diff options
| author | Paul Buetow <paul@buetow.org> | 2024-06-18 10:11:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-06-18 10:11:36 +0300 |
| commit | 546bf161a2d623f360fea572bf52b62e14e6d3e4 (patch) | |
| tree | 2d5547f81a09c8b76137f8fca6d92188e787773a | |
| parent | 9b12909a5b169000135137a96c37bcd7ea2ff70e (diff) | |
change menu - don't have items selectable but press enter when cursor is there
| -rw-r--r-- | internal/client/tui/tui.go | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/internal/client/tui/tui.go b/internal/client/tui/tui.go index 9851ea9..54bf63c 100644 --- a/internal/client/tui/tui.go +++ b/internal/client/tui/tui.go @@ -25,17 +25,19 @@ func Run(conf config.ClientConfig) error { type model struct { choices []string cursor int - selected map[int]struct{} conf config.ClientConfig altscreenActive bool err error } +const ( + composePostCursorPos = 0 +) + func initModel(conf config.ClientConfig) model { return model{ - choices: []string{"Compose post", "Schedule post"}, - selected: make(map[int]struct{}), - conf: conf, + choices: []string{"Compose post", "Schedule post"}, + conf: conf, } } @@ -55,13 +57,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.cursor < len(m.choices)-1 { m.cursor++ } - case "enter", " ": - _, ok := m.selected[m.cursor] - if ok { - delete(m.selected, m.cursor) - } else { - m.selected[m.cursor] = struct{}{} + case "enter": + switch m.cursor { + case composePostCursorPos: + return m, openEditor(m.conf.Editor) } + case "a": m.altscreenActive = !m.altscreenActive cmd := tea.EnterAltScreen @@ -69,8 +70,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmd = tea.ExitAltScreen } return m, cmd - case "e": - return m, openEditor(m.conf.Editor) case "ctrl+c", "q": return m, tea.Quit } @@ -93,12 +92,7 @@ func (m model) View() string { cursor = "==>" } - checked := " " - if _, ok := m.selected[i]; ok { - checked = "x" - } - - s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice) + s += fmt.Sprintf("%s %s\n", cursor, choice) } s += "\nPress q to quiet.\n" |
