xonecas.io
62159
Sy

symb / commit 9f2018b

fix: readonly editor for now, I don't want to add file save yet

xonecas2026-02-11 9f2018b4e8238b133653303c2351815376ea10ae parent 4015876

3 files changed

docs/DESIGN.md+15−14
@@ -14,11 +14,11 @@ A TUI from the future. We want feature parity with a GUI editor: mouse selection
1414 - Auto Context, LLM is aware of file/project in question probably via tree-sitter?
1515 - AGENTS.md support
1616
17-- Code/Diff viewer UI:
17+- Code/Diff viewer (currently editor in read-only) UI:
1818 - Line numbers, syntax highlighting
1919 - LSP support
2020 - Git integration (show file git status)
21- - Simple editting support, no advanced usages or keybinds. ** DONE **
21+ - Simple editting support, no advanced usages or keybinds. ** DONE BUT UNUSED FOR NOW, KEEP!! **
2222 - Code browsing mouse features: click to go to definition/references. Search for word under cursor.
2323
2424 - LLM Tools:
@@ -91,6 +91,12 @@ XXs 00:00 ───────────────────────
9191
9292 ```
9393
94+### Post mvp:
95+
96+- Send input text to editor and send editor text to input/llm via keybinds
97+- Send cursor position/filename to llm via keybind
98+- Send selected text to llm via keybind
99+
94100 ## Tech:
95101
96102 - True ELM architecture (no exceptions ever).
@@ -154,21 +160,16 @@ Confidence Level: High for a prototype. The ecosystem is ready.
154160
155161 # TODO:
156162
157-Potential Mouse Improvements:
163+- file and filesystem combined search with fuzzy matching in the current directory tree.
164+- respects gitignore if it exists.
165+- will be used by both tool for llm (Grep()) and for user later. So make a internal/filesearch separate from the Grep tool definition. Keep it decoupled.
158166
159-1. Click to focus between editor and input panes
160-2. Click in conversation log to select/copy text
161-3. Scroll conversation with mouse wheel (currently auto-scrolls to bottom only)
162-4. Click to position cursor in editor and input areas
163-5. Text selection with mouse drag
164-6. Resize panes by dragging the divider
167+- Enter on editor area send empty message.
165168
166-- Copy text selection to clipboard (ctrl c)
169+- Copy text selection to clipboard (shift + arrows) then (ctrl c)
167170
168-- Scroll the coversation log with mouse.
169-- `stub.go` is bleeding into prod runs, the llm sees those tools.
170-- Credentials tools need to be deleted
171-- OpenForUser(file, start, end) tool for llm -> sends file contents to editor in a new buffer with correct filetype syntax
172171 - file searching and opening, buffer switching.
172+
173173 - sendUserEditor(content) tool to add a "buffer"
174+
174175 - streamed assistant response
internal/tui/textarea/textarea.go+46−2
@@ -225,6 +225,10 @@ type Model struct {
225225 // EndOfBufferCharacter is displayed at the end of the input.
226226 EndOfBufferCharacter rune
227227
228+ // ReadOnly, if enabled, prevents all text modifications
229+ // while still allowing navigation and scrolling.
230+ ReadOnly bool
231+
228232 // KeyMap encodes the keybindings recognized by the widget.
229233 KeyMap KeyMap
230234
@@ -997,6 +1001,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
9971001 case tea.KeyMsg:
9981002 switch {
9991003 case key.Matches(msg, m.KeyMap.DeleteAfterCursor):
1004+ if m.ReadOnly {
1005+ break
1006+ }
10001007 m.col = clamp(m.col, 0, len(m.value[m.row]))
10011008 if m.col >= len(m.value[m.row]) {
10021009 m.mergeLineBelow(m.row)
@@ -1004,6 +1011,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10041011 }
10051012 m.deleteAfterCursor()
10061013 case key.Matches(msg, m.KeyMap.DeleteBeforeCursor):
1014+ if m.ReadOnly {
1015+ break
1016+ }
10071017 m.col = clamp(m.col, 0, len(m.value[m.row]))
10081018 if m.col <= 0 {
10091019 m.mergeLineAbove(m.row)
@@ -1011,6 +1021,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10111021 }
10121022 m.deleteBeforeCursor()
10131023 case key.Matches(msg, m.KeyMap.DeleteCharacterBackward):
1024+ if m.ReadOnly {
1025+ break
1026+ }
10141027 m.col = clamp(m.col, 0, len(m.value[m.row]))
10151028 if m.col <= 0 {
10161029 m.mergeLineAbove(m.row)
@@ -1023,6 +1036,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10231036 }
10241037 }
10251038 case key.Matches(msg, m.KeyMap.DeleteCharacterForward):
1039+ if m.ReadOnly {
1040+ break
1041+ }
10261042 if len(m.value[m.row]) > 0 && m.col < len(m.value[m.row]) {
10271043 m.value[m.row] = append(m.value[m.row][:m.col], m.value[m.row][m.col+1:]...)
10281044 }
@@ -1031,12 +1047,18 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10311047 break
10321048 }
10331049 case key.Matches(msg, m.KeyMap.DeleteWordBackward):
1050+ if m.ReadOnly {
1051+ break
1052+ }
10341053 if m.col <= 0 {
10351054 m.mergeLineAbove(m.row)
10361055 break
10371056 }
10381057 m.deleteWordLeft()
10391058 case key.Matches(msg, m.KeyMap.DeleteWordForward):
1059+ if m.ReadOnly {
1060+ break
1061+ }
10401062 m.col = clamp(m.col, 0, len(m.value[m.row]))
10411063 if m.col >= len(m.value[m.row]) {
10421064 m.mergeLineBelow(m.row)
@@ -1044,6 +1066,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10441066 }
10451067 m.deleteWordRight()
10461068 case key.Matches(msg, m.KeyMap.InsertNewline):
1069+ if m.ReadOnly {
1070+ break
1071+ }
10471072 if m.MaxHeight > 0 && len(m.value) >= m.MaxHeight {
10481073 return m, nil
10491074 }
@@ -1060,6 +1085,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10601085 case key.Matches(msg, m.KeyMap.WordForward):
10611086 m.wordRight()
10621087 case key.Matches(msg, m.KeyMap.Paste):
1088+ if m.ReadOnly {
1089+ break
1090+ }
10631091 return m, Paste
10641092 case key.Matches(msg, m.KeyMap.CharacterBackward):
10651093 m.characterLeft(false /* insideLine */)
@@ -1072,20 +1100,36 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
10721100 case key.Matches(msg, m.KeyMap.InputEnd):
10731101 m.moveToEnd()
10741102 case key.Matches(msg, m.KeyMap.LowercaseWordForward):
1103+ if m.ReadOnly {
1104+ break
1105+ }
10751106 m.lowercaseRight()
10761107 case key.Matches(msg, m.KeyMap.UppercaseWordForward):
1108+ if m.ReadOnly {
1109+ break
1110+ }
10771111 m.uppercaseRight()
10781112 case key.Matches(msg, m.KeyMap.CapitalizeWordForward):
1113+ if m.ReadOnly {
1114+ break
1115+ }
10791116 m.capitalizeRight()
10801117 case key.Matches(msg, m.KeyMap.TransposeCharacterBackward):
1118+ if m.ReadOnly {
1119+ break
1120+ }
10811121 m.transposeLeft()
10821122
10831123 default:
1084- m.insertRunesFromUserInput(msg.Runes)
1124+ if !m.ReadOnly {
1125+ m.insertRunesFromUserInput(msg.Runes)
1126+ }
10851127 }
10861128
10871129 case pasteMsg:
1088- m.insertRunesFromUserInput([]rune(msg))
1130+ if !m.ReadOnly {
1131+ m.insertRunesFromUserInput([]rune(msg))
1132+ }
10891133
10901134 case pasteErrMsg:
10911135 m.Err = msg
internal/tui/tui.go+1−0
@@ -61,6 +61,7 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool) Model {
6161 editor := editorarea.New()
6262 editor.ShowLineNumbers = true
6363 editor.Prompt = ""
64+ editor.ReadOnly = true
6465 editor.FocusedStyle.CursorLine = lipgloss.NewStyle().Background(lipgloss.NoColor{})
6566 editor.FocusedStyle.LineNumber = lipgloss.NewStyle().Foreground(ColorBorder)
6667 editor.Cursor.Style = cursorStyle