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, left, right)
Text.draw_highlight(line, x,y, pos, lo,hi)
local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len, left, right)
Text.draw_highlight(State, line, x,y, pos, lo,hi)
function Text.clip_selection(line_index, apos, bpos, left, right)
if Editor_state.selection1.line == nil then return nil,nil end
-- min,max = sorted(Editor_state.selection1,Editor_state.cursor1)
local minl,minp = Editor_state.selection1.line,Editor_state.selection1.pos
function Text.clip_selection(State, line_index, apos, bpos, left, right)
if State.selection1.line == nil then return nil,nil end
-- min,max = sorted(State.selection1,State.cursor1)
local minl,minp = State.selection1.line,State.selection1.pos
if Editor_state.recent_mouse.time and Editor_state.recent_mouse.time > time-0.1 then
return Editor_state.recent_mouse.line, Editor_state.recent_mouse.pos
if State.recent_mouse.time and State.recent_mouse.time > time-0.1 then
return State.recent_mouse.line, State.recent_mouse.pos
Editor_state.recent_mouse.time = time
local line,pos = Text.to_pos(App.mouse_x(), App.mouse_y(), left, right)
State.recent_mouse.time = time
local line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y(), left, right)
function Text.cut_selection(left, right)
if Editor_state.selection1.line == nil then return end
local result = Text.selection()
Text.delete_selection(left, right)
function Text.cut_selection(State, left, right)
if State.selection1.line == nil then return end
local result = Text.selection(State)
Text.delete_selection(State, left, right)
function Text.delete_selection(left, right)
if Editor_state.selection1.line == nil then return end
local minl,maxl = minmax(Editor_state.selection1.line, Editor_state.cursor1.line)
function Text.delete_selection(State, left, right)
if State.selection1.line == nil then return end
local minl,maxl = minmax(State.selection1.line, State.cursor1.line)
Text.delete_selection_without_undo(left, right)
record_undo_event({before=before, after=snapshot(Editor_state.cursor1.line)})
Text.delete_selection_without_undo(State, left, right)
record_undo_event({before=before, after=snapshot(State.cursor1.line)})
function Text.delete_selection_without_undo(left, right)
if Editor_state.selection1.line == nil then return end
-- min,max = sorted(Editor_state.selection1,Editor_state.cursor1)
local minl,minp = Editor_state.selection1.line,Editor_state.selection1.pos
local maxl,maxp = Editor_state.cursor1.line,Editor_state.cursor1.pos
function Text.delete_selection_without_undo(State, left, right)
if State.selection1.line == nil then return end
-- min,max = sorted(State.selection1,State.cursor1)
local minl,minp = State.selection1.line,State.selection1.pos
local maxl,maxp = State.cursor1.line,State.cursor1.pos
-- update Editor_state.cursor1 and Editor_state.selection1
Editor_state.cursor1.line = minl
Editor_state.cursor1.pos = minp
if Text.lt1(Editor_state.cursor1, Editor_state.screen_top1) then
Editor_state.screen_top1.line = Editor_state.cursor1.line
_,Editor_state.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(left, right)
-- update State.cursor1 and State.selection1
State.cursor1.line = minl
State.cursor1.pos = minp
if Text.lt1(State.cursor1, State.screen_top1) then
State.screen_top1.line = State.cursor1.line
_,State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(left, right)
Text.clear_cache(Editor_state.lines[minl])
local min_offset = Text.offset(Editor_state.lines[minl].data, minp)
local max_offset = Text.offset(Editor_state.lines[maxl].data, maxp)
Text.clear_cache(State.lines[minl])
local min_offset = Text.offset(State.lines[minl].data, minp)
local max_offset = Text.offset(State.lines[maxl].data, maxp)
function Text.selection()
if Editor_state.selection1.line == nil then return end
-- min,max = sorted(Editor_state.selection1,Editor_state.cursor1)
local minl,minp = Editor_state.selection1.line,Editor_state.selection1.pos
local maxl,maxp = Editor_state.cursor1.line,Editor_state.cursor1.pos
function Text.selection(State)
if State.selection1.line == nil then return end
-- min,max = sorted(State.selection1,State.cursor1)
local minl,minp = State.selection1.line,State.selection1.pos
local maxl,maxp = State.cursor1.line,State.cursor1.pos
local min_offset = Text.offset(Editor_state.lines[minl].data, minp)
local max_offset = Text.offset(Editor_state.lines[maxl].data, maxp)
local min_offset = Text.offset(State.lines[minl].data, minp)
local max_offset = Text.offset(State.lines[maxl].data, maxp)