about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua72
1 files changed, 0 insertions, 72 deletions
diff --git a/edit.lua b/edit.lua
index 97860b7..cc3437f 100644
--- a/edit.lua
+++ b/edit.lua
@@ -56,11 +56,6 @@ function edit.initialize_state(top, left, right, font, font_height, line_height)
     width = right-left,
 
     filename = love.filesystem.getSourceBaseDirectory()..'/lines.txt',  -- '/' should work even on Windows
-    next_save = nil,
-
-    -- undo
-    history = {},
-    next_history = 1,
 
     -- search
     search_term = nil,
@@ -124,25 +119,9 @@ function edit.draw(State)
 end
 
 function edit.update(State, dt)
-  if State.next_save and State.next_save < Current_time then
-    save_to_disk(State)
-    State.next_save = nil
-  end
-end
-
-function schedule_save(State)
-  if State.next_save == nil then
-    State.next_save = Current_time + 3  -- short enough that you're likely to still remember what you did
-  end
 end
 
 function edit.quit(State)
-  -- make sure to save before quitting
-  if State.next_save then
-    save_to_disk(State)
-    -- give some time for the OS to flush everything to disk
-    love.timer.sleep(0.1)
-  end
 end
 
 function edit.mouse_press(State, x,y, mouse_button)
@@ -251,10 +230,7 @@ function edit.text_input(State, t)
   if State.search_term then
     State.search_term = State.search_term..t
     Text.search_next(State)
-  else
-    Text.text_input(State, t)
   end
-  schedule_save(State)
 end
 
 function edit.keychord_press(State, chord, key)
@@ -309,29 +285,6 @@ function edit.keychord_press(State, chord, key)
   elseif chord == 'C-0' then
     edit.update_font_settings(State, 20)
     Text.redraw_all(State)
-  -- undo
-  elseif chord == 'C-z' then
-    local event = undo_event(State)
-    if event then
-      local src = event.before
-      State.screen_top1 = deepcopy(src.screen_top)
-      State.cursor1 = deepcopy(src.cursor)
-      State.selection1 = deepcopy(src.selection)
-      patch(State.lines, event.after, event.before)
-      Text.redraw_all(State)  -- if we're scrolling, reclaim all line caches to avoid memory leaks
-      schedule_save(State)
-    end
-  elseif chord == 'C-y' then
-    local event = redo_event(State)
-    if event then
-      local src = event.after
-      State.screen_top1 = deepcopy(src.screen_top)
-      State.cursor1 = deepcopy(src.cursor)
-      State.selection1 = deepcopy(src.selection)
-      patch(State.lines, event.before, event.after)
-      Text.redraw_all(State)  -- if we're scrolling, reclaim all line caches to avoid memory leaks
-      schedule_save(State)
-    end
   -- clipboard
   elseif chord == 'C-a' then
     State.selection1 = {line=1, pos=1}
@@ -341,31 +294,6 @@ function edit.keychord_press(State, chord, key)
     if s then
       App.set_clipboard(s)
     end
-  elseif chord == 'C-x' then
-    local s = Text.cut_selection_and_record_undo_event(State)
-    if s then
-      App.set_clipboard(s)
-    end
-    schedule_save(State)
-  elseif chord == 'C-v' then
-    -- We don't have a good sense of when to scroll, so we'll be conservative
-    -- and sometimes scroll when we didn't quite need to.
-    local before_line = State.cursor1.line
-    local before = snapshot(State, before_line)
-    local clipboard_data = App.get_clipboard()
-    for _,code in utf8.codes(clipboard_data) do
-      local c = utf8.char(code)
-      if c == '\n' then
-        Text.insert_return(State)
-      else
-        Text.insert_at_cursor(State, c)
-      end
-    end
-    if Text.cursor_out_of_screen(State) then
-      Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
-    end
-    record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
-    schedule_save(State)
   else
     Text.keychord_press(State, chord)
   end