From 6676b7d12b3bb381fdfacea816d50e9b86f9333d Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Mon, 3 Feb 2025 20:18:17 +0300 Subject: Fix: load json syscards, replace char and user --- tui.go | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) (limited to 'tui.go') diff --git a/tui.go b/tui.go index fded0e2..7af56d2 100644 --- a/tui.go +++ b/tui.go @@ -68,30 +68,6 @@ Press Enter to go back ` ) -// code block colors get interrupted by " & * -// func codeBlockColor(text string) string { -// fi := strings.Index(text, "```") -// if fi < 0 { -// return text -// } -// li := strings.LastIndex(text, "```") -// if li == fi { // only openning backticks -// return text -// } -// return strings.Replace(text, "```", "```[blue:black:i]", 1) -// } - -// func colorText() { -// // INFO: is there a better way to markdown? -// text := textView.GetText(false) -// text = quotesRE.ReplaceAllString(text, `[orange::-]$1[-:-:-]`) -// text = starRE.ReplaceAllString(text, `[turquoise::i]$1[-:-:-]`) -// text = thinkRE.ReplaceAllString(text, `[turquoise::i]$1[-:-:-]`) -// text = codeBlockRE.ReplaceAllString(text, "[blue::i]```\n$1\n```\n[-:-:-]") -// // text = codeBlockRE.ReplaceAllString(text, "[blue:black:i]```\n$1\n```\n[-:-:-]") -// textView.SetText(text) -// } - func colorText() { text := textView.GetText(false) // Step 1: Extract code blocks and replace them with unique placeholders @@ -101,7 +77,7 @@ func colorText() { // Replace code blocks with placeholders and store their styled versions text = codeBlockRE.ReplaceAllStringFunc(text, func(match string) string { // Style the code block and store it - styled := fmt.Sprintf("[brown:yellow:i]%s[-:-:-]", match) + styled := fmt.Sprintf("[red::i]%s[-:-:-]", match) codeBlocks = append(codeBlocks, styled) // Generate a unique placeholder (e.g., "__CODE_BLOCK_0__") id := fmt.Sprintf(placeholder, counter) @@ -523,9 +499,10 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlL { - fetchModelName() - textArea.SetText("pressed ctrl+l", true) - updateStatusLine() + go func() { + fetchModelName() // blocks + updateStatusLine() + }() return nil } if event.Key() == tcell.KeyCtrlT { -- cgit v1.2.3