From 6625a8103bb70833e2399567cbbe7f3b4a8da429 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 23 Nov 2024 18:34:02 +0300 Subject: Feat: add switch between sys prompts --- main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index c7528f5..e8f9f3a 100644 --- a/main.go +++ b/main.go @@ -102,6 +102,27 @@ func main() { return } }) + sysModal := tview.NewModal(). + SetText("Switch sys msg:"). + AddButtons(sysLabels). + SetDoneFunc(func(buttonIndex int, buttonLabel string) { + switch buttonLabel { + case "cancel": + pages.RemovePage("sys") + return + default: + sysMsg, ok := sysMap[buttonLabel] + if !ok { + logger.Warn("no such sys msg", "name", buttonLabel) + pages.RemovePage("sys") + return + } + chatBody.Messages[0].Content = sysMsg + // replace textview + textView.SetText(chatToText(showSystemMsgs)) + pages.RemovePage("sys") + } + }) editArea := tview.NewTextArea(). SetPlaceholder("Replace msg...") editArea.SetBorder(true).SetTitle("input") @@ -218,6 +239,11 @@ func main() { textArea.SetText("pressed ctrl+e", true) return nil } + if event.Key() == tcell.KeyCtrlS { + // switch sys prompt + pages.AddPage("sys", sysModal, true, true) + return nil + } // cannot send msg in editMode or botRespMode if event.Key() == tcell.KeyEscape && !editMode && !botRespMode { fromRow, fromColumn, _, _ := textArea.GetCursor() -- cgit v1.2.3