about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua128
1 files changed, 1 insertions, 127 deletions
diff --git a/text.lua b/text.lua
index ff958f9..f4b466f 100644
--- a/text.lua
+++ b/text.lua
@@ -145,128 +145,11 @@ function Text.compute_fragments(State, line_index)
   end
 end
 
-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(State, 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(State, t)
-  if State.cursor_y > App.screen.height - State.line_height then
-    Text.populate_screen_line_starting_pos(State, State.cursor1.line)
-    Text.snap_cursor_to_bottom_of_screen(State, State.left, State.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(State, {before=before, after=snapshot(State, State.cursor1.line)})
-end
-
-function Text.insert_at_cursor(State, t)
-  local byte_offset = Text.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
-  State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_offset-1)..t..string.sub(State.lines[State.cursor1.line].data, byte_offset)
-  Text.clear_screen_line_cache(State, State.cursor1.line)
-  State.cursor1.pos = State.cursor1.pos+1
-end
-
 -- Don't handle any keys here that would trigger love.textinput above.
 function Text.keychord_pressed(State, chord)
 --?   print('chord', chord, State.selection1.line, State.selection1.pos)
-  --== shortcuts that mutate text
-  if chord == 'return' then
-    local before_line = State.cursor1.line
-    local before = snapshot(State, before_line)
-    Text.insert_return(State)
-    State.selection1 = {}
-    if State.cursor_y > App.screen.height - State.line_height then
-      Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
-    end
-    schedule_save(State)
-    record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
-  elseif chord == 'tab' then
-    local before = snapshot(State, 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(State, '\t')
-    if State.cursor_y > App.screen.height - State.line_height then
-      Text.populate_screen_line_starting_pos(State, State.cursor1.line)
-      Text.snap_cursor_to_bottom_of_screen(State, State.left, State.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
-    schedule_save(State)
-    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
-  elseif chord == 'backspace' then
-    if State.selection1.line then
-      Text.delete_selection(State, State.left, State.right)
-      schedule_save(State)
-      return
-    end
-    local before
-    if State.cursor1.pos > 1 then
-      before = snapshot(State, State.cursor1.line)
-      local byte_start = utf8.offset(State.lines[State.cursor1.line].data, State.cursor1.pos-1)
-      local byte_end = utf8.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
-      if byte_start then
-        if byte_end then
-          State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_start-1)..string.sub(State.lines[State.cursor1.line].data, byte_end)
-        else
-          State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_start-1)
-        end
-        State.cursor1.pos = State.cursor1.pos-1
-      end
-    elseif State.cursor1.line > 1 then
-      before = snapshot(State, State.cursor1.line-1, State.cursor1.line)
-      -- join lines
-      State.cursor1.pos = utf8.len(State.lines[State.cursor1.line-1].data)+1
-      State.lines[State.cursor1.line-1].data = State.lines[State.cursor1.line-1].data..State.lines[State.cursor1.line].data
-      table.remove(State.lines, State.cursor1.line)
-      table.remove(State.line_cache, State.cursor1.line)
-      State.cursor1.line = State.cursor1.line-1
-    end
-    if State.screen_top1.line > #State.lines then
-      Text.populate_screen_line_starting_pos(State, #State.lines)
-      local line_cache = State.line_cache[#State.line_cache]
-      State.screen_top1 = {line=#State.lines, pos=line_cache.screen_line_starting_pos[#line_cache.screen_line_starting_pos]}
-    elseif Text.lt1(State.cursor1, State.screen_top1) then
-      local top2 = Text.to2(State, State.screen_top1)
-      top2 = Text.previous_screen_line(State, top2, State.left, State.right)
-      State.screen_top1 = Text.to1(State, top2)
-      Text.redraw_all(State)  -- if we're scrolling, reclaim all fragments to avoid memory leaks
-    end
-    Text.clear_screen_line_cache(State, State.cursor1.line)
-    assert(Text.le1(State.screen_top1, State.cursor1))
-    schedule_save(State)
-    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
-  elseif chord == 'delete' then
-    if State.selection1.line then
-      Text.delete_selection(State, State.left, State.right)
-      schedule_save(State)
-      return
-    end
-    local before
-    if State.cursor1.pos <= utf8.len(State.lines[State.cursor1.line].data) then
-      before = snapshot(State, State.cursor1.line)
-    else
-      before = snapshot(State, State.cursor1.line, State.cursor1.line+1)
-    end
-    if State.cursor1.pos <= utf8.len(State.lines[State.cursor1.line].data) then
-      local byte_start = utf8.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
-      local byte_end = utf8.offset(State.lines[State.cursor1.line].data, State.cursor1.pos+1)
-      if byte_start then
-        if byte_end then
-          State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_start-1)..string.sub(State.lines[State.cursor1.line].data, byte_end)
-        else
-          State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_start-1)
-        end
-        -- no change to State.cursor1.pos
-      end
-    elseif State.cursor1.line < #State.lines then
-      -- join lines
-      State.lines[State.cursor1.line].data = State.lines[State.cursor1.line].data..State.lines[State.cursor1.line+1].data
-      table.remove(State.lines, State.cursor1.line+1)
-      table.remove(State.line_cache, State.cursor1.line+1)
-    end
-    Text.clear_screen_line_cache(State, State.cursor1.line)
-    schedule_save(State)
-    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
   --== shortcuts that move the cursor
-  elseif chord == 'left' then
+  if chord == 'left' then
     Text.left(State)
     State.selection1 = {}
   elseif chord == 'right' then
@@ -350,15 +233,6 @@ function Text.keychord_pressed(State, chord)
   end
 end
 
-function Text.insert_return(State)
-  local byte_offset = Text.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
-  table.insert(State.lines, State.cursor1.line+1, {data=string.sub(State.lines[State.cursor1.line].data, byte_offset)})
-  table.insert(State.line_cache, State.cursor1.line+1, {})
-  State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_offset-1)
-  Text.clear_screen_line_cache(State, State.cursor1.line)
-  State.cursor1 = {line=State.cursor1.line+1, pos=1}
-end
-
 function Text.pageup(State)
 --?   print('pageup')
   -- duplicate some logic from love.draw
s="ni">&nbsp;useful,<br> #&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br> #&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br> #&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br> #<br> #&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License<br> #&nbsp;along&nbsp;with&nbsp;this&nbsp;program.&nbsp;&nbsp;If&nbsp;not,&nbsp;see&nbsp;&lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom>&nbsp;<br> <font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="test.tc_bookmarks.html">tc_bookmarks</a><br> <a href="test.tc_colorscheme.html">tc_colorscheme</a><br> <a href="test.tc_commandlist.html">tc_commandlist</a><br> </td><td width="25%" valign=top><a href="test.tc_directory.html">tc_directory</a><br> <a href="test.tc_displayable.html">tc_displayable</a><br> <a href="test.tc_ext.html">tc_ext</a><br> </td><td width="25%" valign=top><a href="test.tc_history.html">tc_history</a><br> <a href="test.tc_keyapi.html">tc_keyapi</a><br> <a href="test.tc_signal.html">tc_signal</a><br> </td><td width="25%" valign=top><a href="test.tc_ui.html">tc_ui</a><br> <a href="test.test.html">test</a><br> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom>&nbsp;<br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td> <td width="100%"><strong>__all__</strong> = ['tc_keyapi', 'tc_history', 'tc_colorscheme', 'tc_bookmarks', 'tc_ext', 'tc_directory', 'tc_commandlist', 'tc_colorscheme', 'tc_keyapi', 'tc_history', 'tc_commandlist', 'tc_signal', 'tc_displayable', 'tc_signal', 'tc_directory', 'tc_ui', 'tc_ui', 'tc_bookmarks', 'tc_ext', 'tc_displayable']</td></tr></table> </body></html>