about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-08-17 09:17:00 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-17 09:17:00 -0700
commitf11c3f2a9baca97665240f4197a66e387be7bfea (patch)
tree3bf9656795aca1d64bb439ed8fa557fc2f130e78
parent68052e807b999c2b3c53f438741a9111b094e325 (diff)
parent1d710912cc6f4b9649e4cc2c4749c6a852a3ff5a (diff)
downloadtext.love-f11c3f2a9baca97665240f4197a66e387be7bfea.tar.gz
Merge lines.love
-rw-r--r--search.lua4
-rw-r--r--select.lua2
-rw-r--r--text.lua10
3 files changed, 8 insertions, 8 deletions
diff --git a/search.lua b/search.lua
index 1872b9e..e613ed7 100644
--- a/search.lua
+++ b/search.lua
@@ -62,7 +62,7 @@ function Text.search_next(State)
   end
   if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(State.screen_bottom1, State.cursor1) then
     State.screen_top1.line = State.cursor1.line
-    local _, pos = Text.pos_at_start_of_cursor_screen_line(State, State.left, State.right)
+    local pos = Text.pos_at_start_of_cursor_screen_line(State, State.left, State.right)
     State.screen_top1.pos = pos
   end
 end
@@ -110,7 +110,7 @@ function Text.search_previous(State)
   end
   if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(State.screen_bottom1, State.cursor1) then
     State.screen_top1.line = State.cursor1.line
-    local _, pos = Text.pos_at_start_of_cursor_screen_line(State, State.left, State.right)
+    local pos = Text.pos_at_start_of_cursor_screen_line(State, State.left, State.right)
     State.screen_top1.pos = pos
   end
 end
diff --git a/select.lua b/select.lua
index 147d60a..91f7890 100644
--- a/select.lua
+++ b/select.lua
@@ -131,7 +131,7 @@ function Text.delete_selection_without_undo(State)
   State.cursor1.pos = minp
   if Text.lt1(State.cursor1, State.screen_top1) then
     State.screen_top1.line = State.cursor1.line
-    _,State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(State)
+    State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(State)
   end
   State.selection1 = {}
   -- delete everything between min (inclusive) and max (exclusive)
diff --git a/text.lua b/text.lua
index b33547c..27b0def 100644
--- a/text.lua
+++ b/text.lua
@@ -411,7 +411,7 @@ end
 
 function Text.up(State)
 --?   print('up', State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos)
-  local screen_line_index,screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State)
+  local screen_line_starting_pos, screen_line_index = Text.pos_at_start_of_cursor_screen_line(State)
   if screen_line_starting_pos == 1 then
 --?     print('cursor is at first screen line of its line')
     -- line is done; skip to previous text line
@@ -479,7 +479,7 @@ function Text.down(State)
       scroll_down = true
     end
 --?     print('cursor is NOT at final screen line of its line')
-    local screen_line_index, screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State)
+    local screen_line_starting_pos, screen_line_index = Text.pos_at_start_of_cursor_screen_line(State)
     new_screen_line_starting_pos = State.line_cache[State.cursor1.line].screen_line_starting_pos[screen_line_index+1]
 --?     print('switching pos of screen line at cursor from '..tostring(screen_line_starting_pos)..' to '..tostring(new_screen_line_starting_pos))
     local new_screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, new_screen_line_starting_pos)
@@ -504,7 +504,7 @@ end
 
 function Text.end_of_line(State)
   State.cursor1.pos = utf8.len(State.lines[State.cursor1.line].data) + 1
-  local _,botpos = Text.pos_at_start_of_cursor_screen_line(State)
+  local botpos = Text.pos_at_start_of_cursor_screen_line(State)
   local botline1 = {line=State.cursor1.line, pos=botpos}
   if Text.cursor_past_screen_bottom(State) then
     Text.snap_cursor_to_bottom_of_screen(State)
@@ -604,7 +604,7 @@ function Text.pos_at_start_of_cursor_screen_line(State)
   for i=#State.line_cache[State.cursor1.line].screen_line_starting_pos,1,-1 do
     local spos = State.line_cache[State.cursor1.line].screen_line_starting_pos[i]
     if spos <= State.cursor1.pos then
-      return i,spos
+      return spos,i
     end
   end
   assert(false)
@@ -912,7 +912,7 @@ function Text.cursor_past_screen_bottom(State)
   return State.cursor_y >= App.screen.height - State.line_height
   -- this approach is cheaper and almost works, except on the final screen
   -- where file ends above bottom of screen
---?   local _,botpos = Text.pos_at_start_of_cursor_screen_line(State)
+--?   local botpos = Text.pos_at_start_of_cursor_screen_line(State)
 --?   local botline1 = {line=State.cursor1.line, pos=botpos}
 --?   return Text.lt1(State.screen_bottom1, botline1)
 end