about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-04-01 16:29:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-04-01 18:12:29 -0700
commit876d6298b40fc8b00bf559d4ec2d909ab1e6bc80 (patch)
tree8a949ceac0f9c6010a6de42518683ba9b75a3450 /edit.lua
parent4ab901c92e11f47828bc7f5f16d8d2250812d53f (diff)
downloadlines.love-876d6298b40fc8b00bf559d4ec2d909ab1e6bc80.tar.gz
App.width can no longer take a Text
In the process I discovered the horrible fact that Text.x allocates a new Text.
And it gets called (just once, thank goodness) on every single frame.
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua7
1 files changed, 0 insertions, 7 deletions
diff --git a/edit.lua b/edit.lua
index 3cea87f..407d8fb 100644
--- a/edit.lua
+++ b/edit.lua
@@ -103,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
@@ -324,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)
@@ -355,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)
@@ -382,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)
@@ -514,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