add state arg to a few functions
[?]
Jul 12, 2022, 11:43 PM
S2MISTTMPEULTO6WRO4Q4NRUO7XC2PTZW3UBR7K7SO6JPZO6HBHACDependencies
- [2]
X3F7ECSLadd state arg to some functions - [3]
PTDO2SOTadd state arg to schedule_save - [4]
JFFUF5ALoverride mouse state lookups in tests - [5]
MP2TBKU6bugfix: crash in Text.up() after return - [6]
PLKNHYZ4extract a function - [7]
LXTTOB33extract a couple of files - [8]
FHSZYAZ2more precise search highlighting - [9]
XNFTJHC4split keyboard handling between Text and Drawing - [10]
O7QH4N4Wspeeding up copy, attempt 1 - [11]
4CXVIEBSadd args to some functions - [12]
DHI6IJCNselecting text and deleting selections - [13]
OP643FFGmove - [14]
YW5324Q3bugfix: cut (C-x) without first selecting anything - [15]
HIKLULFQextract a function - [16]
2TQR4PSYadd args to some functions - [17]
4J2L6JMRbugfix: deleting a selection spanning pages - [18]
4KC7I3E2make colors easier to edit - [19]
PX7DDEMOautosave slightly less aggressively - [20]
AYE2VEGJextract a couple of methods - [21]
LF7BWEG4group all editor globals - [22]
DRFE3B3Zmouse buttons are integers, not strings - [23]
LNUHQOGHstart passing in Editor_state explicitly - [24]
SPSW74Y5add state arg to Text.keychord_pressed - [25]
JRGTJ2IWquite the frustrating bugfix - [26]
2L5MEZV3experiment: new edit namespace - [*]
BULPIBEGbeginnings of a module for the text editor
Change contents
- replacement in text.lua at line 50[2.665]→[4.3:90](∅→∅),[4.54769]→[4.3:90](∅→∅),[4.68]→[4.3:90](∅→∅),[4.90]→[4.3:54](∅→∅),[4.142]→[4.3:54](∅→∅)
local lo, hi = Text.clip_selection(line_index, pos, pos+frag_len, 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) - replacement in text.lua at line 185
Text.delete_selection(State.margin_left, App.screen.width-State.margin_right)Text.delete_selection(State, State.margin_left, App.screen.width-State.margin_right) - replacement in text.lua at line 226
Text.delete_selection(State.margin_left, App.screen.width-State.margin_right)Text.delete_selection(State, State.margin_left, App.screen.width-State.margin_right) - replacement in select.lua at line 3
-- Return any intersection of the region from Editor_state.selection1 to Editor_state.cursor1 (or-- Return any intersection of the region from State.selection1 to State.cursor1 (or - replacement in select.lua at line 7
-- apos must be less than bpos. However Editor_state.selection1 and Editor_state.cursor1 can be in any order.-- apos must be less than bpos. However State.selection1 and State.cursor1 can be in any order. - replacement in select.lua at line 9
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.posfunction 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 - replacement in select.lua at line 15
maxl,maxp = Text.mouse_pos(left, right)maxl,maxp = Text.mouse_pos(State, left, right) - replacement in select.lua at line 17
maxl,maxp = Editor_state.cursor1.line,Editor_state.cursor1.posmaxl,maxp = State.cursor1.line,State.cursor1.pos - replacement in select.lua at line 54
function Text.draw_highlight(line, x,y, pos, lo,hi)function Text.draw_highlight(State, line, x,y, pos, lo,hi) - replacement in select.lua at line 72
love.graphics.rectangle('fill', x+lo_px,y, text_width,Editor_state.line_height)love.graphics.rectangle('fill', x+lo_px,y, text_width,State.line_height) - replacement in select.lua at line 79
function Text.mouse_pos(left, right)function Text.mouse_pos(State, left, right) - replacement in select.lua at line 81
if Editor_state.recent_mouse.time and Editor_state.recent_mouse.time > time-0.1 thenreturn Editor_state.recent_mouse.line, Editor_state.recent_mouse.posif State.recent_mouse.time and State.recent_mouse.time > time-0.1 thenreturn State.recent_mouse.line, State.recent_mouse.pos - replacement in select.lua at line 84
Editor_state.recent_mouse.time = timelocal line,pos = Text.to_pos(App.mouse_x(), App.mouse_y(), left, right)State.recent_mouse.time = timelocal line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y(), left, right) - replacement in select.lua at line 87
Editor_state.recent_mouse.line = lineEditor_state.recent_mouse.pos = posState.recent_mouse.line = lineState.recent_mouse.pos = pos - replacement in select.lua at line 90
return Editor_state.recent_mouse.line, Editor_state.recent_mouse.posreturn State.recent_mouse.line, State.recent_mouse.pos - replacement in select.lua at line 93
function Text.to_pos(x,y, left, right)for line_index,line in ipairs(Editor_state.lines) dofunction Text.to_pos(State, x,y, left, right)for line_index,line in ipairs(State.lines) do - replacement in select.lua at line 103[4.10]→[4.504:545](∅→∅),[4.545]→[4.79611:79668](∅→∅),[4.49]→[4.40:74](∅→∅),[4.79668]→[4.40:74](∅→∅),[4.40]→[4.40:74](∅→∅),[4.74]→[4.546:583](∅→∅)
function Text.cut_selection(left, right)if Editor_state.selection1.line == nil then return endlocal result = Text.selection()Text.delete_selection(left, right)function Text.cut_selection(State, left, right)if State.selection1.line == nil then return endlocal result = Text.selection(State)Text.delete_selection(State, left, right) - replacement in select.lua at line 110
function Text.delete_selection(left, right)if Editor_state.selection1.line == nil then return endlocal 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 endlocal minl,maxl = minmax(State.selection1.line, State.cursor1.line) - replacement in select.lua at line 114
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)}) - replacement in select.lua at line 118
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.poslocal maxl,maxp = Editor_state.cursor1.line,Editor_state.cursor1.posfunction 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.poslocal maxl,maxp = State.cursor1.line,State.cursor1.pos - replacement in select.lua at line 131
-- update Editor_state.cursor1 and Editor_state.selection1Editor_state.cursor1.line = minlEditor_state.cursor1.pos = minpif Text.lt1(Editor_state.cursor1, Editor_state.screen_top1) thenEditor_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.selection1State.cursor1.line = minlState.cursor1.pos = minpif Text.lt1(State.cursor1, State.screen_top1) thenState.screen_top1.line = State.cursor1.line_,State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(left, right) - replacement in select.lua at line 138
Editor_state.selection1 = {}State.selection1 = {} - replacement in select.lua at line 140
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) - replacement in select.lua at line 145
Editor_state.lines[minl].data = Editor_state.lines[minl].data:sub(1, min_offset-1)..Editor_state.lines[minl].data:sub(max_offset)State.lines[minl].data = State.lines[minl].data:sub(1, min_offset-1)..State.lines[minl].data:sub(max_offset) - replacement in select.lua at line 149
local rhs = Editor_state.lines[maxl].data:sub(max_offset)local rhs = State.lines[maxl].data:sub(max_offset) - replacement in select.lua at line 151
table.remove(Editor_state.lines, i)table.remove(State.lines, i) - replacement in select.lua at line 153
Editor_state.lines[minl].data = Editor_state.lines[minl].data:sub(1, min_offset-1)..rhsState.lines[minl].data = State.lines[minl].data:sub(1, min_offset-1)..rhs - replacement in select.lua at line 156
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.poslocal maxl,maxp = Editor_state.cursor1.line,Editor_state.cursor1.posfunction 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.poslocal maxl,maxp = State.cursor1.line,State.cursor1.pos - replacement in select.lua at line 169
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) - replacement in select.lua at line 172
return Editor_state.lines[minl].data:sub(min_offset, max_offset-1)return State.lines[minl].data:sub(min_offset, max_offset-1) - replacement in select.lua at line 175
local result = {Editor_state.lines[minl].data:sub(min_offset)}local result = {State.lines[minl].data:sub(min_offset)} - replacement in select.lua at line 177
if Editor_state.lines[i].mode == 'text' thentable.insert(result, Editor_state.lines[i].data)if State.lines[i].mode == 'text' thentable.insert(result, State.lines[i].data) - replacement in select.lua at line 181
table.insert(result, Editor_state.lines[maxl].data:sub(1, max_offset-1))table.insert(result, State.lines[maxl].data:sub(1, max_offset-1)) - replacement in edit.lua at line 302
Text.delete_selection(State.margin_left, App.screen.width-State.margin_right)Text.delete_selection(State, State.margin_left, App.screen.width-State.margin_right) - replacement in edit.lua at line 368
local s = Text.selection()local s = Text.selection(State) - replacement in edit.lua at line 374
local s = Text.cut_selection(State.margin_left, App.screen.width-State.margin_right)local s = Text.cut_selection(State, State.margin_left, App.screen.width-State.margin_right)