More editor stuff

master
Dustin Swan 2 days ago
parent 735db38a2f
commit 63f599b850
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -354,7 +354,9 @@ renderText = config \
gap = c.scale; gap = c.scale;
chars = split "" c.content; chars = split "" c.content;
ui.row { chars == []
| True \ ui.rect { w = 0, h = 12 * c.scale, color = "transparent" }
| False \ ui.row {
children = map (char \ children = map (char \
getField char font.glyphs getField char font.glyphs
| Some g \ glyphView { glyph = g, scale = c.scale, color = c.color } | Some g \ glyphView { glyph = g, scale = c.scale, color = c.color }

@ -14,7 +14,13 @@ textEditor = name \
backspace = state \ backspace = state \
state.cursorCol == 0 state.cursorCol == 0
| True \ { state = state, emit = [] } # todo, join line, if not at row 0 | True \ (
state.cursorRow == 0
| True \ { state = state, emit = [] }
| False \ (
{ state = state, emit = [] } # todo, join with previous line
)
)
| False \ ( | False \ (
newLines = updateAt state.cursorRow (line \ newLines = updateAt state.cursorRow (line \
before = slice line 0 (state.cursorCol - 1); before = slice line 0 (state.cursorCol - 1);
@ -31,6 +37,9 @@ textEditor = name \
newLines = updateAt state.cursorRow (_ \ before) state.lines; newLines = updateAt state.cursorRow (_ \ before) state.lines;
newLines2 = insertAt (state.cursorRow + 1) after newLines; newLines2 = insertAt (state.cursorRow + 1) after newLines;
_ = debug! "enter" { before = before, after = after, newLines2 = newLines2, newRow =
state.cursorRow + 1 };
{ state = state.{ lines = newLines2, cursorCol = 0, cursorRow = state.cursorRow + 1 }, emit = [] }; { state = state.{ lines = newLines2, cursorCol = 0, cursorRow = state.cursorRow + 1 }, emit = [] };
clampCursor = state \ clampCursor = state \
@ -39,8 +48,10 @@ textEditor = name \
newRow = max 0 state.cursorRow; newRow = max 0 state.cursorRow;
newRow2 = min (len state.lines - 1) newRow; newRow2 = min (len state.lines - 1) newRow;
newCol = max 0 (state.cursorCol); maxCol = state.mode
newCol2 = min (len line - 1) newCol; | Insert \ len line
| Normal \ max 0 (len line - 1);
newCol2 = min maxCol (max 0 state.cursorCol);
state.{ cursorRow = newRow2, cursorCol = newCol2 }; state.{ cursorRow = newRow2, cursorCol = newCol2 };

Loading…
Cancel
Save