Merge text0
This commit is contained in:
commit
aa751541b9
3
edit.lua
3
edit.lua
|
@ -369,9 +369,8 @@ function edit.keychord_press(State, chord, key, readonly)
|
||||||
if Text.cursor_out_of_screen(State) then
|
if Text.cursor_out_of_screen(State) then
|
||||||
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
||||||
end
|
end
|
||||||
schedule_save(State)
|
|
||||||
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
|
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
|
||||||
-- dispatch to text
|
schedule_save(State)
|
||||||
else
|
else
|
||||||
Text.keychord_press(State, chord, readonly)
|
Text.keychord_press(State, chord, readonly)
|
||||||
end
|
end
|
||||||
|
|
13
text.lua
13
text.lua
|
@ -141,7 +141,7 @@ function Text.text_input(State, t)
|
||||||
if App.mouse_down(1) then return end
|
if App.mouse_down(1) then return end
|
||||||
if App.any_modifier_down() then
|
if App.any_modifier_down() then
|
||||||
if App.key_down(t) then
|
if App.key_down(t) then
|
||||||
-- The modifiers didn't change the key. Handle it in keychord_pressed.
|
-- The modifiers didn't change the key. Handle it in keychord_press.
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
-- Key mutated by the keyboard layout. Continue below.
|
-- Key mutated by the keyboard layout. Continue below.
|
||||||
|
@ -168,17 +168,16 @@ end
|
||||||
function Text.keychord_press(State, chord, readonly)
|
function Text.keychord_press(State, chord, readonly)
|
||||||
--? print('chord', chord, State.selection1.line, State.selection1.pos)
|
--? print('chord', chord, State.selection1.line, State.selection1.pos)
|
||||||
if not readonly then
|
if not readonly then
|
||||||
--== shortcuts that mutate text
|
--== shortcuts that mutate text (must schedule_save)
|
||||||
if chord == 'return' then
|
if chord == 'return' then
|
||||||
local before_line = State.cursor1.line
|
local before_line = State.cursor1.line
|
||||||
local before = snapshot(State, before_line)
|
local before = snapshot(State, before_line)
|
||||||
Text.insert_return(State)
|
Text.insert_return(State)
|
||||||
State.selection1 = {}
|
|
||||||
if State.cursor_y > App.screen.height - State.line_height then
|
if State.cursor_y > App.screen.height - State.line_height then
|
||||||
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
||||||
end
|
end
|
||||||
schedule_save(State)
|
|
||||||
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
|
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
|
||||||
|
schedule_save(State)
|
||||||
elseif chord == 'tab' then
|
elseif chord == 'tab' then
|
||||||
local before = snapshot(State, State.cursor1.line)
|
local before = snapshot(State, State.cursor1.line)
|
||||||
--? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)
|
--? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)
|
||||||
|
@ -188,8 +187,8 @@ function Text.keychord_press(State, chord, readonly)
|
||||||
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
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)
|
--? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)
|
||||||
end
|
end
|
||||||
schedule_save(State)
|
|
||||||
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
||||||
|
schedule_save(State)
|
||||||
elseif chord == 'backspace' then
|
elseif chord == 'backspace' then
|
||||||
if State.selection1.line then
|
if State.selection1.line then
|
||||||
Text.delete_selection(State, State.left, State.right)
|
Text.delete_selection(State, State.left, State.right)
|
||||||
|
@ -231,8 +230,8 @@ function Text.keychord_press(State, chord, readonly)
|
||||||
end
|
end
|
||||||
Text.clear_screen_line_cache(State, State.cursor1.line)
|
Text.clear_screen_line_cache(State, State.cursor1.line)
|
||||||
assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos))
|
assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos))
|
||||||
schedule_save(State)
|
|
||||||
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
||||||
|
schedule_save(State)
|
||||||
elseif chord == 'delete' then
|
elseif chord == 'delete' then
|
||||||
if State.selection1.line then
|
if State.selection1.line then
|
||||||
Text.delete_selection(State, State.left, State.right)
|
Text.delete_selection(State, State.left, State.right)
|
||||||
|
@ -263,8 +262,8 @@ function Text.keychord_press(State, chord, readonly)
|
||||||
table.remove(State.line_cache, State.cursor1.line+1)
|
table.remove(State.line_cache, State.cursor1.line+1)
|
||||||
end
|
end
|
||||||
Text.clear_screen_line_cache(State, State.cursor1.line)
|
Text.clear_screen_line_cache(State, State.cursor1.line)
|
||||||
schedule_save(State)
|
|
||||||
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
|
||||||
|
schedule_save(State)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--== shortcuts that move the cursor
|
--== shortcuts that move the cursor
|
||||||
|
|
Loading…
Reference in New Issue