diff options
author | Grail Finder <wohilas@gmail.com> | 2024-11-26 21:15:04 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-11-26 21:15:04 +0300 |
commit | ad65c3583a47d09dc1b3b50fd02fb411344bd9ae (patch) | |
tree | afc1d10f8c6a5f6d2dffa9f558e4ba87bbcae4d8 /tui.go | |
parent | 5dfb5584767e56180771ca08c4c27def3b2db536 (diff) |
Feat: add help page
Diffstat (limited to 'tui.go')
-rw-r--r-- | tui.go | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -17,11 +17,26 @@ var ( editArea *tview.TextArea textView *tview.TextView position *tview.TextView + helpView *tview.TextView flex *tview.Flex chatActModal *tview.Modal sysModal *tview.Modal indexPickWindow *tview.InputField renameWindow *tview.InputField + helpText = ` +[yellow]Esc[white]: send msg +[yellow]PgUp/Down[white]: switch focus +[yellow]F1[white]: manage chats +[yellow]F2[white]: regen last +[yellow]F3[white]: delete last msg +[yellow]F4[white]: edit msg +[yellow]F5[white]: toggle system +[yellow]F6[white]: interrupt bot resp +[yellow]F7[white]: copy msg to clipboard (linux xclip) +[yellow]Ctrl+s[white]: choose/replace system prompt + +Press Enter to go back +` ) func init() { @@ -74,7 +89,7 @@ func init() { chatBody.Messages = defaultStarter textView.SetText(chatToText(showSystemMsgs)) newChat := &models.Chat{ - ID: id, + ID: id + 1, Name: fmt.Sprintf("%v_%v", "new", time.Now().Unix()), Msgs: string(defaultStarterBytes), } @@ -209,6 +224,18 @@ func init() { return event }) // + helpView = tview.NewTextView().SetDynamicColors(true).SetText(helpText).SetDoneFunc(func(key tcell.Key) { + pages.RemovePage("helpView") + return + }) + helpView.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + switch event.Key() { + case tcell.KeyEsc, tcell.KeyEnter: + return event + } + return nil + }) + // textArea.SetMovedFunc(updateStatusLine) updateStatusLine() textView.SetText(chatToText(showSystemMsgs)) @@ -271,6 +298,11 @@ func init() { pages.AddPage("getIndex", indexPickWindow, true, true) return nil } + if event.Key() == tcell.KeyF12 { + // help window cheatsheet + pages.AddPage("helpView", helpView, true, true) + return nil + } if event.Key() == tcell.KeyCtrlE { textArea.SetText("pressed ctrl+e", true) return nil |