about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-12 16:33:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-12 16:33:26 -0700
commitadeb5416c61c7a5face4f082fee32e70a0e69203 (patch)
tree763b9189f9143523b5d512fffa3a19bdfeea50ec
parentb7000215d8921490cb08ed64439a02e9f69770b5 (diff)
downloadtext.love-adeb5416c61c7a5face4f082fee32e70a0e69203.tar.gz
add state arg to Text.textinput
-rw-r--r--edit.lua2
-rw-r--r--text.lua16
2 files changed, 9 insertions, 9 deletions
diff --git a/edit.lua b/edit.lua
index d1cc2aa..9e5aabb 100644
--- a/edit.lua
+++ b/edit.lua
@@ -287,7 +287,7 @@ function edit.textinput(State, t)
     p.name = p.name..t
     record_undo_event({before=before, after=snapshot(State.lines.current_drawing_index)})
   else
-    Text.textinput(t)
+    Text.textinput(State, t)
   end
   schedule_save(State)
 end
diff --git a/text.lua b/text.lua
index 33ea0f1..1296254 100644
--- a/text.lua
+++ b/text.lua
@@ -134,18 +134,18 @@ function Text.compute_fragments(line, left, right)
   end
 end
 
-function Text.textinput(t)
+function Text.textinput(State, t)
   if App.mouse_down(1) then return end
   if App.ctrl_down() or App.alt_down() or App.cmd_down() then return end
-  local before = snapshot(Editor_state.cursor1.line)
---?   print(Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
+  local before = snapshot(State.cursor1.line)
+--?   print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
   Text.insert_at_cursor(t)
-  if Editor_state.cursor_y >= App.screen.height - Editor_state.line_height then
-    Text.populate_screen_line_starting_pos(Editor_state.lines[Editor_state.cursor1.line], Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
-    Text.snap_cursor_to_bottom_of_screen(Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
---?     print('=>', Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
+  if State.cursor_y >= App.screen.height - State.line_height then
+    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], State.margin_left, App.screen.width-State.margin_right)
+    Text.snap_cursor_to_bottom_of_screen(State.margin_left, App.screen.width-State.margin_right)
+--?     print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
   end
-  record_undo_event({before=before, after=snapshot(Editor_state.cursor1.line)})
+  record_undo_event({before=before, after=snapshot(State.cursor1.line)})
 end
 
 function Text.insert_at_cursor(t)