about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-03-26 09:49:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-03-26 09:49:03 -0700
commit46e568c4c566b6377b90daad211d16a59c540e4b (patch)
treeb20b073e02418e18c108cc0c2e62b5ff8e42eda4 /edit.lua
parent9fff5b713214263a1565cf933f5db165483a5081 (diff)
parenteae5c9505c665b343af7690d9665431ae17ed5e9 (diff)
downloadtext.love-46e568c4c566b6377b90daad211d16a59c540e4b.tar.gz
Merge lines.love
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/edit.lua b/edit.lua
index 871e48f..36cce6e 100644
--- a/edit.lua
+++ b/edit.lua
@@ -86,8 +86,10 @@ function edit.check_locs(State)
 end
 
 function edit.invalid1(State, loc1)
-  return loc1.line > #State.lines
-      or loc1.pos > #State.lines[loc1.line].data
+  if loc1.line > #State.lines then return true end
+  local l = State.lines[loc1.line]
+  if l.mode ~= 'text' then return false end  -- pos is irrelevant to validity for a drawing line
+  return loc1.pos > #State.lines[loc1.line].data
 end
 
 function edit.draw(State)
@@ -147,7 +149,7 @@ end
 
 function edit.mouse_press(State, x,y, mouse_button)
   if State.search_term then return end
---?   print('press', State.selection1.line, State.selection1.pos)
+--?   print('press', State.cursor1.line)
   for line_index,line in ipairs(State.lines) do
     if Text.in_line(State, line_index, x,y) then
       -- delicate dance between cursor, selection and old cursor/selection
@@ -174,7 +176,7 @@ end
 
 function edit.mouse_release(State, x,y, mouse_button)
   if State.search_term then return end
---?   print('release')
+--?   print('release', State.cursor1.line)
   for line_index,line in ipairs(State.lines) do
     if Text.in_line(State, line_index, x,y) then
 --?       print('reset selection')
@@ -215,6 +217,7 @@ function edit.mouse_wheel_move(State, dx,dy)
 end
 
 function edit.text_input(State, t)
+--?   print('text input', t)
   if State.search_term then
     State.search_term = State.search_term..t
     State.search_text = nil