about summary refs log tree commit diff stats
path: root/source_edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-04-02 09:22:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-04-02 09:22:32 -0700
commit3547c18db6b9d508fb5c2399c124e33f4cc8c488 (patch)
treeefec742d0c0a10017b1af35ae1a586077ee0cb05 /source_edit.lua
parent3bdaf97baab7fd03c53a91ebd11bf359ab97a5d3 (diff)
parent29f1687f3c6a494eb67029acbeefbf11571bbe2c (diff)
downloadtext.love-3547c18db6b9d508fb5c2399c124e33f4cc8c488.tar.gz
Merge lines.love
Diffstat (limited to 'source_edit.lua')
-rw-r--r--source_edit.lua10
1 files changed, 1 insertions, 9 deletions
diff --git a/source_edit.lua b/source_edit.lua
index 2fc7e1b..5dabee9 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -54,7 +54,7 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
     -- rendering wrapped text lines needs some additional short-lived data per line:
     --   startpos, the index of data the line starts rendering from, can only be >1 for topmost line on screen
     --   starty, the y coord in pixels the line starts rendering from
-    --   fragments: snippets of rendered love.graphics.Text, guaranteed to not straddle screen lines
+    --   fragments: snippets of the line guaranteed to not straddle screen lines
     --   screen_line_starting_pos: optional array of grapheme indices if it wraps over more than one screen line
     line_cache = {},
 
@@ -88,7 +88,6 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
 
     font_height = font_height,
     line_height = line_height,
-    em = App.newText(love.graphics.getFont(), 'm'),  -- widest possible character width
 
     top = top,
     left = math.floor(left),
@@ -104,7 +103,6 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
 
     -- search
     search_term = nil,
-    search_text = nil,
     search_backup = nil,  -- stuff to restore when cancelling search
   }
   return result
@@ -325,7 +323,6 @@ 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
     Text.search_next(State)
   elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
     local before = snapshot(State, State.lines.current_drawing_index)
@@ -356,20 +353,17 @@ function edit.keychord_press(State, chord, key)
     for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
     if chord == 'escape' then
       State.search_term = nil
-      State.search_text = nil
       State.cursor1 = State.search_backup.cursor
       State.screen_top1 = State.search_backup.screen_top
       State.search_backup = nil
       Text.redraw_all(State)  -- if we're scrolling, reclaim all fragments to avoid memory leaks
     elseif chord == 'return' then
       State.search_term = nil
-      State.search_text = nil
       State.search_backup = nil
     elseif chord == 'backspace' then
       local len = utf8.len(State.search_term)
       local byte_offset = Text.offset(State.search_term, len)
       State.search_term = string.sub(State.search_term, 1, byte_offset-1)
-      State.search_text = nil
     elseif chord == 'down' then
       State.cursor1.pos = State.cursor1.pos+1
       Text.search_next(State)
@@ -383,7 +377,6 @@ function edit.keychord_press(State, chord, key)
       cursor={line=State.cursor1.line, pos=State.cursor1.pos},
       screen_top={line=State.screen_top1.line, pos=State.screen_top1.pos},
     }
-    assert(State.search_text == nil)
   -- zoom
   elseif chord == 'C-=' then
     edit.update_font_settings(State, State.font_height+2)
@@ -515,7 +508,6 @@ function edit.update_font_settings(State, font_height)
   State.font_height = font_height
   love.graphics.setFont(love.graphics.newFont(State.font_height))
   State.line_height = math.floor(font_height*1.3)
-  State.em = App.newText(love.graphics.getFont(), 'm')
   Text_cache = {}
 end