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, Editor_state.selection1.pos)
function Text.keychord_pressed(State, chord)
--? print('chord', chord, State.selection1.line, State.selection1.pos)
Editor_state.selection1 = {}
if (Editor_state.cursor_y + Editor_state.line_height) > App.screen.height then
Text.snap_cursor_to_bottom_of_screen(Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
State.selection1 = {}
if (State.cursor_y + State.line_height) > App.screen.height then
Text.snap_cursor_to_bottom_of_screen(State.margin_left, App.screen.width-State.margin_right)
local before = snapshot(Editor_state.cursor1.line)
--? print(Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
local before = snapshot(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)
if Editor_state.cursor_y >= App.screen.height - Editor_state.line_height then
Text.populate_screen_line_starting_pos(Editor_state.lines[Editor_state.cursor1.line], Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
Text.snap_cursor_to_bottom_of_screen(Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
--? print('=>', Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
if State.cursor_y >= App.screen.height - State.line_height then
Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], State.margin_left, App.screen.width-State.margin_right)
Text.snap_cursor_to_bottom_of_screen(State.margin_left, App.screen.width-State.margin_right)
--? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
if Editor_state.cursor1.pos > 1 then
before = snapshot(Editor_state.cursor1.line)
local byte_start = utf8.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos-1)
local byte_end = utf8.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos)
if State.cursor1.pos > 1 then
before = snapshot(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)
Editor_state.lines[Editor_state.cursor1.line].data = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, 1, byte_start-1)..string.sub(Editor_state.lines[Editor_state.cursor1.line].data, byte_end)
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)
elseif Editor_state.cursor1.line > 1 then
before = snapshot(Editor_state.cursor1.line-1, Editor_state.cursor1.line)
if Editor_state.lines[Editor_state.cursor1.line-1].mode == 'drawing' then
table.remove(Editor_state.lines, Editor_state.cursor1.line-1)
elseif State.cursor1.line > 1 then
before = snapshot(State.cursor1.line-1, State.cursor1.line)
if State.lines[State.cursor1.line-1].mode == 'drawing' then
table.remove(State.lines, State.cursor1.line-1)
Editor_state.cursor1.pos = utf8.len(Editor_state.lines[Editor_state.cursor1.line-1].data)+1
Editor_state.lines[Editor_state.cursor1.line-1].data = Editor_state.lines[Editor_state.cursor1.line-1].data..Editor_state.lines[Editor_state.cursor1.line].data
table.remove(Editor_state.lines, Editor_state.cursor1.line)
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)
if Text.lt1(Editor_state.cursor1, Editor_state.screen_top1) then
local top2 = Text.to2(Editor_state.screen_top1, Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
top2 = Text.previous_screen_line(top2, Editor_state.margin_left, App.screen.width-Editor_state.margin_right)
Editor_state.screen_top1 = Text.to1(top2)
if Text.lt1(State.cursor1, State.screen_top1) then
local top2 = Text.to2(State.screen_top1, State.margin_left, App.screen.width-State.margin_right)
top2 = Text.previous_screen_line(top2, State.margin_left, App.screen.width-State.margin_right)
State.screen_top1 = Text.to1(top2)
if Editor_state.cursor1.pos <= utf8.len(Editor_state.lines[Editor_state.cursor1.line].data) then
before = snapshot(Editor_state.cursor1.line)
if State.cursor1.pos <= utf8.len(State.lines[State.cursor1.line].data) then
before = snapshot(State.cursor1.line)
if Editor_state.cursor1.pos <= utf8.len(Editor_state.lines[Editor_state.cursor1.line].data) then
local byte_start = utf8.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos)
local byte_end = utf8.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos+1)
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)
Editor_state.lines[Editor_state.cursor1.line].data = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, 1, byte_start-1)..string.sub(Editor_state.lines[Editor_state.cursor1.line].data, byte_end)
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)
elseif Editor_state.cursor1.line < #Editor_state.lines then
if Editor_state.lines[Editor_state.cursor1.line+1].mode == 'drawing' then
table.remove(Editor_state.lines, Editor_state.cursor1.line+1)
elseif State.cursor1.line < #State.lines then
if State.lines[State.cursor1.line+1].mode == 'drawing' then
table.remove(State.lines, State.cursor1.line+1)
Editor_state.lines[Editor_state.cursor1.line].data = Editor_state.lines[Editor_state.cursor1.line].data..Editor_state.lines[Editor_state.cursor1.line+1].data
table.remove(Editor_state.lines, Editor_state.cursor1.line+1)
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)