aboutsummaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'app.go')
-rw-r--r--app.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/app.go b/app.go
index 10c5db7..89b4438 100644
--- a/app.go
+++ b/app.go
@@ -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