texteditor. 'o' key
This commit is contained in:
parent
295a8a5e24
commit
7a97ec3f90
2 changed files with 30 additions and 0 deletions
|
|
@ -77,6 +77,16 @@ join = s list \ list
|
||||||
| [x] \ x
|
| [x] \ x
|
||||||
| [x, ...xs] \ (x & s & (join s xs));
|
| [x, ...xs] \ (x & s & (join s xs));
|
||||||
|
|
||||||
|
# repeatStr : Int \ String \ String
|
||||||
|
repeatStr = n str \ n
|
||||||
|
| 0 \ ""
|
||||||
|
| m \ str & (repeatStr (m - 1) str);
|
||||||
|
|
||||||
|
# repeat : Int \ a \ List a
|
||||||
|
repeat = n a \ n
|
||||||
|
| 0 \ []
|
||||||
|
| m \ [a, ...repeat (m - 1) a];
|
||||||
|
|
||||||
# zipWith : (a \ b \ c) \ List a \ List b \ List c
|
# zipWith : (a \ b \ c) \ List a \ List b \ List c
|
||||||
zipWith = f l1 l2 \ l1
|
zipWith = f l1 l2 \ l1
|
||||||
| [] \ []
|
| [] \ []
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,22 @@ textEditor = name \
|
||||||
emit = []
|
emit = []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# 'o' key
|
||||||
|
openLine = state \
|
||||||
|
stateSnapshot = { lines = state.lines, cursorRow = state.cursorRow, cursorCol = state.cursorCol };
|
||||||
|
newUndoStack = [stateSnapshot, ...state.undoStack];
|
||||||
|
cursorRow = state.cursorRow + 1;
|
||||||
|
newLines = insertAt cursorRow "" state.lines;
|
||||||
|
{
|
||||||
|
state = state.{
|
||||||
|
lines = newLines,
|
||||||
|
cursorRow = cursorRow,
|
||||||
|
undoStack = newUndoStack,
|
||||||
|
mode = Insert
|
||||||
|
},
|
||||||
|
emit = []
|
||||||
|
};
|
||||||
|
|
||||||
escape = state \ { state = state.{ mode = Normal }, emit = [] };
|
escape = state \ { state = state.{ mode = Normal }, emit = [] };
|
||||||
|
|
||||||
undo = state \ state.undoStack
|
undo = state \ state.undoStack
|
||||||
|
|
@ -206,6 +222,10 @@ textEditor = name \
|
||||||
| Insert \ insertChar "i" state
|
| Insert \ insertChar "i" state
|
||||||
| Normal \ insertMode state)
|
| Normal \ insertMode state)
|
||||||
|
|
||||||
|
| Key { key = "o" } \ (state.mode
|
||||||
|
| Insert \ insertChar "o" state
|
||||||
|
| Normal \ openLine state)
|
||||||
|
|
||||||
| Key { key = "d", ctrl = True } \ scrollHalfDown state ctx
|
| Key { key = "d", ctrl = True } \ scrollHalfDown state ctx
|
||||||
| Key { key = "u", ctrl = True } \ scrollHalfUp state ctx
|
| Key { key = "u", ctrl = True } \ scrollHalfUp state ctx
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue