beginning of a new approach to scroll+wrap
[?]
May 21, 2022, 11:24 PM
2RXZ3PGOTTZ6M4R372JXIKPLBQKPVBMAXNPIEO2HZDN4EMYW4GNACDependencies
- [2]
O6T3TPXDbugfix: position cursor up top when loading file - [3]
2ZYV7D3Whandle tab characters - [4]
GE56XURAbugfix: cursor past end of screen line - [5]
3TFEAQSWstart using some globals - [6]
PYGMASTVdisable some debug prints - [7]
242L3OQXbugfix: ensure Cursor_line is always on a text line - [8]
WLHI7KD3new globals: draw partial screen line up top - [9]
7IKRRESBlonger names for indices in long loops - [10]
SVJZZDC3snapshot - no, that's all wrong - [11]
OTIBCAUJlove2d scaffold - [12]
AVQ5MC5Dfinish uppercasing all globals - [13]
BULPIBEGbeginnings of a module for the text editor - [14]
A2QPFRFJmove - [15]
3CSIZJ33clearer comments - [16]
2POFQQLWkeep cursor on screen when pressing 'down' - [17]
DLQMM265scroll past first page - [18]
Y6FTGOHJsimpler - [19]
537TQ2QNsome more logging - [20]
252M2QMDforgot to move this special case out - [21]
UWNHC4AAredo y computations - [22]
HYEAFRZ2split mouse_pressed events between Text and Drawing - [23]
B3IWYWSRdelete another arg that can be deduced - [24]
C42QQZSFanother piece of support for line wrapping in cursor up - [25]
FJ4L6N74draw lines by default - [26]
5T2E3PDVcouple of bugfixes to file-handling - [27]
5L7K4GBDclicking to the right of a wrapped line - [28]
MGT5FTJ3first stab at supporting wrapping in cursor up - [29]
PR4KIAZDfirst stab at equally hacky cursor down support - [30]
HIH47LNBdrop unused arg - [31]
H2DPLWMVsnapshot: wrapping long lines at word boundaries - [32]
W4UVZETR2 regressions: - [33]
DXT4QTAHa few more integer coordinates - [34]
DAENUOGVeliminate assumptions that line length == size in bytes - [35]
IZZVOCLBconfirm that we have access to all of the love API - [36]
HBZ2UCUFstop recomputing Cursor_x now that we're saving it - [37]
TRNWIQN6more precise height calculation when scrolling up as much as possible while keeping cursor on screen - [38]
RCDVDFJQcomment - [39]
JY4VK7L2rename - [40]
KJKKASHZreduce ambitions a bit: page up/down need not start screen from the middle of a line - [41]
WKTPVZKLensure integer coordinates - [42]
XVR2O5PIchange text cursor shape - [43]
PHQPLJUQrename - [44]
5DOC2CBMextract a function - [45]
XX7G2FFJintermingle freehand line drawings with text - [46]
BOFNXP5Gclicking now moves the cursor even on long, wrapped lines - [47]
2C7CTIQYmake space for multiple kinds of width - [48]
EWMPYCDObugfix - [49]
JCSLDGAHbeginnings of support for multiple shapes - [50]
MGOQ5XAVstart uppercasing globals - [51]
OIB2QPRCstart remembering where the cursor is drawn in px - [52]
BJ5X5O4Alet's prevent the text cursor from ever getting on a drawing - [53]
Y36LOGR5bugfix: show cursor when past end of line - [54]
XNFTJHC4split keyboard handling between Text and Drawing - [55]
VXORMHMEdelete experimental REPL - [56]
IYW7X3WLleft/right cursor movement, deleting characters - [57]
VHQCNMARseveral more modules - [58]
BYG5CEMVsupport for naming points - [59]
JVRL5TWLstore device-independent coordinates inside drawings - [60]
5ED3YGHWplanning out cursor up/down over wrapped lines
Change contents
- replacement in text.lua at line 25
if line_index > Screen_top_line or pos > Top_screen_line_starting_pos thenif line_index > Screen_top1.line or pos > Screen_top1.pos then - replacement in text.lua at line 36[7.2206]→[7.128:222](∅→∅),[7.199]→[7.130:210](∅→∅),[7.222]→[7.130:210](∅→∅),[7.2206]→[7.130:210](∅→∅)
if Debug_new_render then print('checking to draw', pos, Top_screen_line_starting_pos) endif line_index > Screen_top_line or pos >= Top_screen_line_starting_pos thenif Debug_new_render then print('checking to draw', pos, Screen_top1.pos) endif line_index > Screen_top1.line or pos >= Screen_top1.pos then - replacement in text.lua at line 43
if line_index == Cursor_line thenif pos <= Cursor_pos and pos + frag_len > Cursor_pos thenText.draw_cursor(x+Text.cursor_x2(frag, Cursor_pos-pos+1), y)if line_index == Cursor1.line thenif pos <= Cursor1.pos and pos + frag_len > Cursor1.pos thenText.draw_cursor(x+Text.cursor_x2(frag, Cursor1.pos-pos+1), y) - replacement in text.lua at line 51
if line_index == Cursor_line and Cursor_pos == pos thenif line_index == Cursor1.line and Cursor1.pos == pos then - replacement in text.lua at line 112
if Cursor_pos > 1 thenbyte_offset = utf8.offset(Lines[Cursor_line].data, Cursor_pos-1)if Cursor1.pos > 1 thenbyte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos-1) - replacement in text.lua at line 117[7.318]→[7.318:453](∅→∅),[7.453]→[7.2797:2834](∅→∅),[7.2834]→[7.453:481](∅→∅),[7.453]→[7.453:481](∅→∅)
Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_offset)..t..string.sub(Lines[Cursor_line].data, byte_offset+1)Lines[Cursor_line].fragments = nilCursor_pos = Cursor_pos+1Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_offset)..t..string.sub(Lines[Cursor1.line].data, byte_offset+1)Lines[Cursor1.line].fragments = nilCursor1.pos = Cursor1.pos+1 - replacement in text.lua at line 126[7.655]→[7.655:921](∅→∅),[7.921]→[7.2835:2874](∅→∅),[7.2874]→[7.921:972](∅→∅),[7.921]→[7.921:972](∅→∅)
local byte_offset = utf8.offset(Lines[Cursor_line].data, Cursor_pos)table.insert(Lines, Cursor_line+1, {mode='text', data=string.sub(Lines[Cursor_line].data, byte_offset)})Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_offset-1)Lines[Cursor_line].fragments = nilCursor_line = Cursor_line+1Cursor_pos = 1local byte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)table.insert(Lines, Cursor1.line+1, {mode='text', data=string.sub(Lines[Cursor1.line].data, byte_offset)})Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_offset-1)Lines[Cursor1.line].fragments = nilCursor1.line = Cursor1.line+1Cursor1.pos = 1 - replacement in text.lua at line 137
assert(Lines[Cursor_line].mode == 'text')if Cursor_pos > 1 thenCursor_pos = Cursor_pos-1assert(Lines[Cursor1.line].mode == 'text')if Cursor1.pos > 1 thenCursor1.pos = Cursor1.pos-1 - replacement in text.lua at line 141
local new_cursor_line = Cursor_linelocal new_cursor_line = Cursor1.line - replacement in text.lua at line 145
Cursor_line = new_cursor_lineCursor_pos = utf8.len(Lines[Cursor_line].data) + 1Cursor1.line = new_cursor_lineCursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1 - replacement in text.lua at line 150
if Cursor_line < Screen_top_line thenScreen_top_line = Cursor_lineif Cursor1.line < Screen_top1.line thenScreen_top1.line = Cursor1.line - replacement in text.lua at line 155[7.1492]→[7.1492:1538](∅→∅),[7.1538]→[7.176:236](∅→∅),[7.236]→[7.1589:1621](∅→∅),[7.1589]→[7.1589:1621](∅→∅)
assert(Lines[Cursor_line].mode == 'text')if Cursor_pos <= utf8.len(Lines[Cursor_line].data) thenCursor_pos = Cursor_pos+1assert(Lines[Cursor1.line].mode == 'text')if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) thenCursor1.pos = Cursor1.pos+1 - replacement in text.lua at line 159
local new_cursor_line = Cursor_linelocal new_cursor_line = Cursor1.line - replacement in text.lua at line 163
Cursor_line = new_cursor_lineCursor_pos = 1Cursor1.line = new_cursor_lineCursor1.pos = 1 - replacement in text.lua at line 168
if Cursor_line > Screen_bottom_line thenScreen_top_line = Cursor_lineif Cursor1.line > Screen_bottom1.line thenScreen_top1.line = Cursor1.line - replacement in text.lua at line 173
Cursor_pos = 1Cursor1.pos = 1 - replacement in text.lua at line 175
Cursor_pos = utf8.len(Lines[Cursor_line].data) + 1Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1 - replacement in text.lua at line 177
if Cursor_pos > 1 thenlocal byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos-1)local byte_end = utf8.offset(Lines[Cursor_line].data, Cursor_pos)if Cursor1.pos > 1 thenlocal byte_start = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos-1)local byte_end = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos) - replacement in text.lua at line 182
Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)..string.sub(Lines[Cursor_line].data, byte_end)Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)..string.sub(Lines[Cursor1.line].data, byte_end) - replacement in text.lua at line 184
Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1) - replacement in text.lua at line 186
Lines[Cursor_line].fragments = nilCursor_pos = Cursor_pos-1Lines[Cursor1.line].fragments = nilCursor1.pos = Cursor1.pos-1 - replacement in text.lua at line 189
elseif Cursor_line > 1 thenif Lines[Cursor_line-1].mode == 'drawing' thentable.remove(Lines, Cursor_line-1)elseif Cursor1.line > 1 thenif Lines[Cursor1.line-1].mode == 'drawing' thentable.remove(Lines, Cursor1.line-1) - replacement in text.lua at line 194[7.2761]→[7.2761:2907](∅→∅),[7.2907]→[7.2919:2964](∅→∅),[7.2964]→[7.2907:2948](∅→∅),[7.2907]→[7.2907:2948](∅→∅)
Cursor_pos = utf8.len(Lines[Cursor_line-1].data)+1Lines[Cursor_line-1].data = Lines[Cursor_line-1].data..Lines[Cursor_line].dataLines[Cursor_line-1].fragments = niltable.remove(Lines, Cursor_line)Cursor1.pos = utf8.len(Lines[Cursor1.line-1].data)+1Lines[Cursor1.line-1].data = Lines[Cursor1.line-1].data..Lines[Cursor1.line].dataLines[Cursor1.line-1].fragments = niltable.remove(Lines, Cursor1.line) - replacement in text.lua at line 199
Cursor_line = Cursor_line-1Cursor1.line = Cursor1.line-1 - replacement in text.lua at line 203
if Cursor_pos <= utf8.len(Lines[Cursor_line].data) thenlocal byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos)local byte_end = utf8.offset(Lines[Cursor_line].data, Cursor_pos+1)if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) thenlocal byte_start = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)local byte_end = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos+1) - replacement in text.lua at line 208
Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)..string.sub(Lines[Cursor_line].data, byte_end)Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)..string.sub(Lines[Cursor1.line].data, byte_end) - replacement in text.lua at line 210
Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1) - replacement in text.lua at line 212
Lines[Cursor_line].fragments = nil-- no change to Cursor_posLines[Cursor1.line].fragments = nil-- no change to Cursor1.pos - replacement in text.lua at line 215
elseif Cursor_line < #Lines thenif Lines[Cursor_line+1].mode == 'drawing' thentable.remove(Lines, Cursor_line+1)elseif Cursor1.line < #Lines thenif Lines[Cursor1.line+1].mode == 'drawing' thentable.remove(Lines, Cursor1.line+1) - replacement in text.lua at line 220[7.3776]→[7.3776:3861](∅→∅),[7.3861]→[7.3009:3052](∅→∅),[7.3052]→[7.3861:3904](∅→∅),[7.3861]→[7.3861:3904](∅→∅)
Lines[Cursor_line].data = Lines[Cursor_line].data..Lines[Cursor_line+1].dataLines[Cursor_line].fragments = niltable.remove(Lines, Cursor_line+1)Lines[Cursor1.line].data = Lines[Cursor1.line].data..Lines[Cursor1.line+1].dataLines[Cursor1.line].fragments = niltable.remove(Lines, Cursor1.line+1) - replacement in text.lua at line 227
assert(Lines[Cursor_line].mode == 'text')--? print('up', Cursor_pos, Top_screen_line_starting_pos)assert(Lines[Cursor1.line].mode == 'text')--? print('up', Cursor1.pos, Screen_top1.pos) - replacement in text.lua at line 233
local new_cursor_line = Cursor_linelocal new_cursor_line = Cursor1.line - replacement in text.lua at line 237
Cursor_line = new_cursor_lineif Lines[Cursor_line].screen_line_starting_pos == nil thenCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)Cursor1.line = new_cursor_lineif Lines[Cursor1.line].screen_line_starting_pos == nil thenCursor1.pos = Text.nearest_cursor_pos(Lines[Cursor1.line].data, Cursor_x) - replacement in text.lua at line 243
local screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_poslocal screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos - replacement in text.lua at line 246
if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos thenTop_screen_line_starting_pos = screen_line_starting_pos--? print('pos of top of screen is also '..tostring(Top_screen_line_starting_pos)..' of the same line')if Screen_top1.line == Cursor1.line and Screen_top1.pos == screen_line_starting_pos thenScreen_top1.pos = screen_line_starting_pos--? print('pos of top of screen is also '..tostring(Screen_top1.pos)..' of the same line') - replacement in text.lua at line 250
local s = string.sub(Lines[Cursor_line].data, screen_line_starting_pos)Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_pos)Cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1 - replacement in text.lua at line 255
if Cursor_line < Screen_top_line thenScreen_top_line = Cursor_lineif Cursor1.line < Screen_top1.line thenScreen_top1.line = Cursor1.line - replacement in text.lua at line 262
new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index-1]new_screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos[screen_line_index-1] - replacement in text.lua at line 264
if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos thenTop_screen_line_starting_pos = new_screen_line_starting_pos--? print('also setting pos of top of screen to '..tostring(Top_screen_line_starting_pos))if Screen_top1.line == Cursor1.line and Screen_top1.pos == screen_line_starting_pos thenScreen_top1.pos = new_screen_line_starting_pos--? print('also setting pos of top of screen to '..tostring(Screen_top1.pos)) - replacement in text.lua at line 268
local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1--? print('cursor pos is now '..tostring(Cursor_pos))local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)Cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1--? print('cursor pos is now '..tostring(Cursor1.pos)) - replacement in text.lua at line 273
assert(Lines[Cursor_line].mode == 'text')assert(Lines[Cursor1.line].mode == 'text') - replacement in text.lua at line 277
local new_cursor_line = Cursor_linelocal new_cursor_line = Cursor1.line - replacement in text.lua at line 281
Cursor_line = new_cursor_lineCursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)--? print(Cursor_pos)Cursor1.line = new_cursor_lineCursor1.pos = Text.nearest_cursor_pos(Lines[Cursor1.line].data, Cursor_x)--? print(Cursor1.pos) - replacement in text.lua at line 287[7.789]→[6.832:893](∅→∅),[7.121]→[7.789:836](∅→∅),[6.893]→[7.789:836](∅→∅),[7.789]→[7.789:836](∅→∅),[7.836]→[6.894:981](∅→∅),[7.84]→[7.836:874](∅→∅),[6.981]→[7.836:874](∅→∅),[7.836]→[7.836:874](∅→∅)
--? print(Cursor_line, Cursor_pos, Screen_bottom_line)if Cursor_line > Screen_bottom_line then--? print('screen top before:', Screen_top_line, Top_screen_line_starting_pos)Screen_top_line = Cursor_line--? print(Cursor1.line, Cursor1.pos, Screen_bottom1.line)if Cursor1.line > Screen_bottom1.line then--? print('screen top before:', Screen_top1.line, Screen_top1.pos)Screen_top1.line = Cursor1.line - replacement in text.lua at line 293
--? print('screen top after:', Screen_top_line, Top_screen_line_starting_pos)--? print('screen top after:', Screen_top1.line, Screen_top1.pos) - replacement in text.lua at line 295
--? print('=>', Cursor_line, Cursor_pos, Screen_bottom_line)--? print('=>', Cursor1.line, Cursor1.pos, Screen_bottom1.line) - replacement in text.lua at line 300
new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index+1]new_screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos[screen_line_index+1] - replacement in text.lua at line 302[6.1402]→[7.1391:1564](∅→∅),[7.1391]→[7.1391:1564](∅→∅),[7.1564]→[6.1403:1463](∅→∅),[6.1463]→[7.122:158](∅→∅),[7.1620]→[7.122:158](∅→∅)
local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1--? print('cursor pos is now '..tostring(Cursor_pos))Screen_top_line = Cursor_linelocal s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)Cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1--? print('cursor pos is now '..tostring(Cursor1.pos))Screen_top1.line = Cursor1.line - replacement in text.lua at line 308
--? print('screen top after:', Screen_top_line, Top_screen_line_starting_pos)--? print('screen top after:', Screen_top1.line, Screen_top1.pos) - replacement in text.lua at line 314
if Lines[Cursor_line].screen_line_starting_pos == nil thenif Lines[Cursor1.line].screen_line_starting_pos == nil then - replacement in text.lua at line 317
for i=#Lines[Cursor_line].screen_line_starting_pos,1,-1 dolocal spos = Lines[Cursor_line].screen_line_starting_pos[i]if spos <= Cursor_pos thenfor i=#Lines[Cursor1.line].screen_line_starting_pos,1,-1 dolocal spos = Lines[Cursor1.line].screen_line_starting_pos[i]if spos <= Cursor1.pos then - replacement in text.lua at line 327
if Lines[Cursor_line].screen_line_starting_pos == nil thenif Lines[Cursor1.line].screen_line_starting_pos == nil then - replacement in text.lua at line 330
i=#Lines[Cursor_line].screen_line_starting_poslocal spos = Lines[Cursor_line].screen_line_starting_pos[i]return spos <= Cursor_posi=#Lines[Cursor1.line].screen_line_starting_poslocal spos = Lines[Cursor1.line].screen_line_starting_pos[i]return spos <= Cursor1.pos - replacement in text.lua at line 336
while Cursor_line <= #Lines doif Lines[Cursor_line].mode == 'text' thenwhile Cursor1.line <= #Lines doif Lines[Cursor1.line].mode == 'text' then - replacement in text.lua at line 340
Cursor_line = Cursor_line + 1Cursor1.line = Cursor1.line + 1 - replacement in text.lua at line 343
if Cursor_line > #Lines thenassert(Cursor_line == #Lines+1)if Cursor1.line > #Lines thenassert(Cursor1.line == #Lines+1) - replacement in text.lua at line 347
if Cursor_line > Screen_bottom_line thenScreen_top_line = Cursor_lineif Cursor1.line > Screen_bottom1.line thenScreen_top1.line = Cursor1.line - replacement in text.lua at line 355
--? print('cursor pos '..tostring(Cursor_pos)..' is on the #'..tostring(cursor_pos_screen_lines)..' screen line down')--? print('cursor pos '..tostring(Cursor1.pos)..' is on the #'..tostring(cursor_pos_screen_lines)..' screen line down') - replacement in text.lua at line 359
if Screen_top_line == 1 then break endif Screen_top1.line == 1 then break end - replacement in text.lua at line 362
if Lines[Screen_top_line-1].mode == 'drawing' thenh = 20 + Drawing.pixels(Lines[Screen_top_line-1].h)elseif Lines[Screen_top_line-1].screen_line_starting_pos == nil thenif Lines[Screen_top1.line-1].mode == 'drawing' thenh = 20 + Drawing.pixels(Lines[Screen_top1.line-1].h)elseif Lines[Screen_top1.line-1].screen_line_starting_pos == nil then - replacement in text.lua at line 367
local n = #Lines[Screen_top_line-1].screen_line_starting_poslocal n = #Lines[Screen_top1.line-1].screen_line_starting_pos - replacement in text.lua at line 378
Screen_top_line = Screen_top_line - 1Screen_top1.line = Screen_top1.line - 1 - replacement in text.lua at line 391
Cursor_line = line_indexCursor1.line = line_index - replacement in text.lua at line 393
Cursor_pos = Text.nearest_cursor_pos(line.data, mx)Cursor1.pos = Text.nearest_cursor_pos(line.data, mx) - replacement in text.lua at line 407
Cursor_pos = line.screen_line_starting_pos[screen_line_index+1]Cursor1.pos = line.screen_line_starting_pos[screen_line_index+1] - replacement in text.lua at line 411
Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1Cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1 - replacement in text.lua at line 426
-- Cursor_pos = 4 + 2 - 1 = 5-- Cursor1.pos = 4 + 2 - 1 = 5 - replacement in text.lua at line 431
-- Cursor_pos = 7 + 2 - 1 = 8-- Cursor1.pos = 7 + 2 - 1 = 8 - edit in text.lua at line 476
function Text.to2(pos1)local result = {line=pos1.line, screen_line=1}if Line[pos1.line].screen_line_starting_pos == nil thenresult.screen_pos = pos1.poselsefor i=#Lines[pos1.line].screen_line_starting_pos,1,-1 dolocal spos = Lines[pos1.line].screen_line_starting_pos[i]if spos <= Cursor1.pos thenresult.screen_line = iresult.screen_pos = sposbreakendendendassert(result.screen_pos)return resultendfunction Text.to1(pos2)local result = {line=pos2.line, pos=pos2.screen_pos}if pos2.screen_line > 1 thenresult.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_posendreturn resultend - replacement in main.lua at line 40
Cursor_line = 1Cursor_pos = 1 -- in Unicode codepoints, from 1 to utf8.len(line) + 1-- Lines can be too long to fit on screen, in which case they _wrap_ into-- multiple _screen lines_.---- Therefore, any potential location for the cursor can be described in two ways:-- * schema 1: As a combination of line index and position within a line (in utf8 codepoint units)-- * schema 2: As a combination of line index, screen line index within the line, and a position within the screen line.---- Most of the time we'll only persist positions in schema 1, translating to-- schema 2 when that's convenient.Cursor1 = {line=1, pos=1} -- position of cursorScreen_top1 = {line=1, pos=1} -- position of start of screen line at top of screenScreen_bottom1 = {line=1, pos=1} -- position of start of screen line at bottom of screen - edit in main.lua at line 58[7.4]→[7.4:68](∅→∅),[7.68]→[7.288:377](∅→∅),[7.68]→[7.1240:1241](∅→∅),[7.95]→[7.1240:1241](∅→∅),[7.114]→[7.1240:1241](∅→∅),[7.377]→[7.1240:1241](∅→∅),[7.455]→[7.1240:1241](∅→∅),[7.45]→[7.1240:1241](∅→∅)
-- scrolling supportScreen_top_line = 1Screen_bottom_line = 1Top_screen_line_starting_pos = 1 -- when top of screen starts in between a wrapped line - replacement in main.lua at line 89
Cursor_line = iCursor1.line = i - replacement in main.lua at line 103
Cursor_line = iCursor1.line = i - replacement in main.lua at line 121
if line_index >= Screen_top_line thenScreen_bottom_line = line_indexif line_index >= Screen_top1.line thenScreen_bottom1.line = line_index - replacement in main.lua at line 129
if Cursor_line >= line_index thenCursor_line = Cursor_line+1if Cursor1.line >= line_index thenCursor1.line = Cursor1.line+1 - replacement in main.lua at line 133
if line_index == Cursor_line thenif line_index == Cursor1.line then - replacement in main.lua at line 218
Screen_top_line = Screen_bottom_lineCursor_line = Screen_top_lineTop_screen_line_starting_pos = 1Cursor_pos = Top_screen_line_starting_posScreen_top1.line = Screen_bottom1.lineScreen_top1.pos = 1Cursor1.line = Screen_top1.lineCursor1.pos = Screen_top1.pos - replacement in main.lua at line 227
if Screen_top_line == 1 then break endif Screen_top1.line == 1 then break end - replacement in main.lua at line 229[7.308]→[7.1043:1098](∅→∅),[7.1043]→[7.1043:1098](∅→∅),[7.1098]→[7.1976:2033](∅→∅),[7.1976]→[7.1976:2033](∅→∅)
if Lines[Screen_top_line].mode == 'drawing' theny = y - Drawing.pixels(Lines[Screen_top_line].h)if Lines[Screen_top1.line].mode == 'drawing' theny = y - Drawing.pixels(Lines[Screen_top1.line].h) - replacement in main.lua at line 232
Screen_top_line = Screen_top_line - 1Screen_top1.line = Screen_top1.line - 1 - replacement in main.lua at line 234
if Cursor_line ~= Screen_top_line thenCursor_pos = 1if Cursor1.line ~= Screen_top1.line thenCursor1.pos = 1 - replacement in main.lua at line 237
Cursor_line = Screen_top_lineCursor1.line = Screen_top1.line