diff options
| author | historia <[not public]> | 2026-06-23 17:04:50 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-23 17:04:50 -0400 |
| commit | a1a82c18d5f55b6a809019bd9ab7d3754d126e16 (patch) | |
| tree | 1c50146d9b4d6f5c2660deb985a7ec8920ec6958 /app.go | |
| parent | 3511257cf199c42eddc8784b5babdb6a4120fd54 (diff) | |
| download | tui-ascii-mapper-a1a82c18d5f55b6a809019bd9ab7d3754d126e16.tar.gz | |
fix: text tool made much less janky
Diffstat (limited to 'app.go')
| -rw-r--r-- | app.go | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -418,13 +418,13 @@ func (m *AppModel) mouseRelease(gx, gy int) { m.dirty = true m.undo.Push(m.curMap()) MoveTextLabel(m.curMap(), old, newPos) + m.movingLabel = -1 } else { m.startTextEditText(m.movingLabel) } } else if m.cursor == p && m.curMap().InBounds(p) { m.startTextEdit(p) } - m.movingLabel = -1 m.dragLabelOrigin = Point{X: 0, Y: 0} m.dragMouseOrigin = Point{X: 0, Y: 0} } @@ -918,17 +918,6 @@ func (m *AppModel) labelDragPos() Point { func (m *AppModel) handleTextEditKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { key := msg.String() - toolKeys := map[string]Tool{ - "!": ToolBrush, "@": ToolSelect, "#": ToolErase, "$": ToolFill, - "%": ToolLine, "^": ToolRect, "&": ToolCircle, "*": ToolText, "(": ToolText, - } - if t, ok := toolKeys[key]; ok { - m.commitTextEdit() - m.tool = t - m.drawHeld, m.eraseHeld = false, false - return m, nil - } - switch key { case "esc": m.mode = ModeNormal @@ -957,11 +946,13 @@ func (m *AppModel) commitTextEdit() { if text != "" { m.dirty = true m.undo.Push(m.curMap()) + start := m.cursor if m.textEditing && m.movingLabel >= 0 && m.movingLabel < len(m.curMap().TextLabels) { RemoveTextLabel(m.curMap(), m.curMap().TextLabels[m.movingLabel].Start) + start = m.textCursorStart m.textEditing = false } - PlaceTextLabel(m.curMap(), m.cursor, text, m.textColor) + PlaceTextLabel(m.curMap(), start, text, m.textColor) } m.mode = ModeNormal m.movingLabel = -1 @@ -982,12 +973,12 @@ func (m *AppModel) handleDialogKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.dialog = DialogNone m.filePicker = nil return m, nil - case "up", "k": + case "up": if m.filePicker.Selected > 0 { m.filePicker.Selected-- } return m, nil - case "down", "j": + case "down": if m.filePicker.Selected < len(m.filePicker.Files)-1 { m.filePicker.Selected++ } @@ -1004,7 +995,7 @@ func (m *AppModel) handleDialogKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.filePicker.Selected = len(m.filePicker.Files) - 1 } return m, nil - case "left", "h": + case "left": parent := filepath.Dir(m.filePicker.CurDir) m.filePicker.CurDir = parent m.filePicker.Selected = 0 |
