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.lua80
1 files changed, 0 insertions, 80 deletions
diff --git a/edit.lua b/edit.lua
index 446d76d..a0145a0 100644
--- a/edit.lua
+++ b/edit.lua
@@ -56,11 +56,6 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
     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,
@@ -134,25 +129,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)
@@ -249,11 +228,7 @@ function edit.text_input(State, t)
   if State.search_term then
     State.search_term = State.search_term..t
     Text.search_next(State)
-  else
-    for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    Text.text_input(State, t)
   end
-  schedule_save(State)
 end
 
 function edit.keychord_press(State, chord, key)
@@ -304,34 +279,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
-    for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    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)
-      patch_placeholders(State.line_cache, event.after, event.before)
-      -- if we're scrolling, reclaim all fragments to avoid memory leaks
-      Text.redraw_all(State)
-      schedule_save(State)
-    end
-  elseif chord == 'C-y' then
-    for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    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)
-      -- if we're scrolling, reclaim all fragments to avoid memory leaks
-      Text.redraw_all(State)
-      schedule_save(State)
-    end
   -- clipboard
   elseif chord == 'C-a' then
     State.selection1 = {line=1, pos=1}
@@ -341,33 +288,6 @@ function edit.keychord_press(State, chord, key)
     if s then
       App.set_clipboard(s)
     end
-  elseif chord == 'C-x' then
-    for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    local s = Text.cut_selection(State, State.left, State.right)
-    if s then
-      App.set_clipboard(s)
-    end
-    schedule_save(State)
-  elseif chord == 'C-v' then
-    for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll
-    -- 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
-    schedule_save(State)
-    record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
   -- dispatch to text
   else
     for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end  -- just in case we scroll