diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-07-23 23:36:04 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-07-23 23:36:04 -0700 |
commit | 6f74f95a46b173f7b4f8c04e5821dc348191192e (patch) | |
tree | 3d6c7d91185fc47779a536f1871ffae89690d630 /edit.lua | |
parent | b7a67ab1e962ebc03b297f0ca220a0a97b8c5c3a (diff) | |
download | text.love-6f74f95a46b173f7b4f8c04e5821dc348191192e.tar.gz |
extract method
Diffstat (limited to 'edit.lua')
-rw-r--r-- | edit.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/edit.lua b/edit.lua index b1a315d..1b39dbb 100644 --- a/edit.lua +++ b/edit.lua @@ -118,6 +118,17 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c return result end -- App.initialize_state +function edit.fixup_cursor(State) + if State.cursor1.line > #State.lines or State.lines[State.cursor1.line].mode ~= 'text' then + for i,line in ipairs(State.lines) do + if line.mode == 'text' then + State.cursor1.line = i + break + end + end + end +end + function edit.draw(State) App.color(Text_color) --? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos) |