snapshot
[?]
May 23, 2022, 10:22 PM
IMEJA43L3OX7S5KIYLZJ4F3ITACLAA5SZBHSCIJMULCPRSW7LXBACDependencies
- [2]
XOAHJ6M3similar tests for cursor up - [3]
PFT5Y2ZYmove - [4]
BOFNXP5Gclicking now moves the cursor even on long, wrapped lines - [5]
AVTNUQYRbasic test-enabled framework - [6]
YTSPVDZHfirst successful pagedown test, first bug found by test - [7]
76AIXR7Hbugfix - [8]
U7M4M2F7bugfix: don't rely on Screen_bottom1 while scrolling - [9]
QYIFOHW3first test! - [10]
BULPIBEGbeginnings of a module for the text editor - [11]
S5VCAFKYcouple of tests for cursor down - [12]
2RXZ3PGObeginning of a new approach to scroll+wrap - [*]
H2DPLWMVsnapshot: wrapping long lines at word boundaries - [*]
ESETRNLBbugfix: printing the first part of a line at the bottom made it seem non-wrapping - [*]
3QNOKBFMbeginnings of a test harness
Change contents
- edit in text.lua at line 28
print(x, frag, frag_width, line_width) - edit in text.lua at line 31
-- I no longer remember why the fuck I added this - edit in text.lua at line 44
print(line_index, Screen_top1.line, pos, Screen_top1.pos) - edit in text.lua at line 46
print('a') - edit in text.lua at line 48
print('b', y, App.screen.height) - replacement in text.lua at line 91
Line_width = 120Line_width = App.screen.width - replacement in text.lua at line 111
Line_width = 120Line_width = App.screen.width - edit in text.lua at line 126
check_eq(Screen_top1.line, 2, 'F - test_pagedown/screen_top')check_eq(Cursor1.line, 2, 'F - test_pagedown/cursor') - replacement in text.lua at line 156
-- after pagedown the screen draws the screen up top-- after pagedown the screen draws the drawing up top - replacement in text.lua at line 159
--? print('test: top:', Screen_top1.line)check_eq(Screen_top1.line, 2, 'F - test_pagedown_skips_drawings/screen_top')check_eq(Cursor1.line, 3, 'F - test_pagedown_skips_drawings/cursor') - replacement in text.lua at line 169
Line_width = 120Line_width = App.screen.width - replacement in text.lua at line 184
-- after hitting the down arrow the screen is unchanged-- after hitting the down arrow, the cursor moves down by 1 line - edit in text.lua at line 186
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')check_eq(Cursor1.line, 2, 'F - test_down_arrow_moves_cursor/cursor')-- the screen is unchanged - edit in text.lua at line 195[3.1523]→[3.1523:1564](∅→∅),[3.1564]→[2.27:104](∅→∅),[2.104]→[3.1564:1635](∅→∅),[3.1564]→[3.1564:1635](∅→∅)
-- but the cursor moves down by 1 linecheck_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')check_eq(Cursor1.line, 2, 'F - test_down_arrow_moves_cursor/cursor') - replacement in text.lua at line 202
Line_width = 120Line_width = App.screen.width - edit in text.lua at line 218
check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_line/screen_top')check_eq(Cursor1.line, 4, 'F - test_down_arrow_scrolls_down_by_one_line/cursor') - replacement in text.lua at line 226
check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_line/screen_top')check_eq(Cursor1.line, 4, 'F - test_down_arrow_scrolls_down_by_one_line/cursor')endfunction test_down_arrow_scrolls_down_by_one_screen_line()print('test_down_arrow_scrolls_down_by_one_screen_line')-- display the first three lines with the cursor on the bottom lineApp.screen.init{width=25+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthCursor1 = {line=3, pos=1}Screen_top1 = {line=1, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'ghi ', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace-- after hitting the down arrow the screen scrolls down by one lineApp.run_after_keychord('down')check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:line')check_eq(Cursor1.pos, 5, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:pos')y = screen_top_marginApp.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'ghi ', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:2')y = y + line_height-- HEREApp.screen.check(y, 'jkl', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:3')endfunction test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word()print('test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word')-- display the first three lines with the cursor on the bottom lineApp.screen.init{width=25+30, height=60}Lines = load_array{'abc', 'def', 'ghijkl', 'mno'}Line_width = App.screen.widthCursor1 = {line=3, pos=1}Screen_top1 = {line=1, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'ghijk', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:3')-- after hitting the down arrow the screen scrolls down by one lineApp.run_after_keychord('down')check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen_top')check_eq(Cursor1.line, 3, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/cursor:line')check_eq(Cursor1.pos, 6, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/cursor:pos')y = screen_top_marginApp.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:1')y = y + line_heightApp.screen.check(y, 'ghijk', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:2')y = y + line_heightApp.screen.check(y, 'l', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:3') - replacement in text.lua at line 312
-- after hitting the up arrow the screen is unchanged-- after hitting the up arrow the cursor moves up by 1 line - edit in text.lua at line 314
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')check_eq(Cursor1.line, 2, 'F - test_up_arrow_moves_cursor/cursor')-- the screen is unchanged - edit in text.lua at line 323
-- but the cursor moves up by 1 linecheck_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')check_eq(Cursor1.line, 2, 'F - test_up_arrow_moves_cursor/cursor') - edit in text.lua at line 346
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/cursor') - replacement in text.lua at line 354
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/cursor')endfunction test_up_arrow_scrolls_up_by_one_screen_line()print('test_up_arrow_scrolls_up_by_one_screen_line')-- display the lines 2/3/4 with the cursor on line 2App.screen.init{width=120, height=60}Lines = load_array{'abc', 'def', 'ghi', 'jkl'}Line_width = App.screen.widthCursor1 = {line=2, pos=1}Screen_top1 = {line=2, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:3')-- after hitting the up arrow the screen scrolls up by one lineApp.run_after_keychord('up')y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:2')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:3')check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_screen_line/cursor') - edit in text.lua at line 388
--? print('compute_fragments') - edit in text.lua at line 398
assert(25 + frag_width > line_width) -- avoid infinite loop when window is too narrow - edit in text.lua at line 401
print(frag, x, frag_width, line_width) - replacement in text.lua at line 404
local b = Text.nearest_cursor_pos(frag, line_width - x)local b = Text.nearest_pos_less_than(frag, line_width - x) - replacement in text.lua at line 408
local frag1_width = math.floor(frag1App.width(_text)*Zoom)local frag1_width = math.floor(App.width(frag1_text)*Zoom)print(frag, x, frag1_width, line_width)assert(x + frag1_width <= line_width) - replacement in text.lua at line 766
function Text.nearest_cursor_pos(line, x)function Text.nearest_cursor_pos(line, x) -- x includes left margin - edit in text.lua at line 797
function Text.nearest_pos_less_than(line, x) -- x DOES NOT include left marginif x == 0 thenreturn 1endlocal len = utf8.len(line)local max_x = Text.cursor_x2(line, len+1)if x > max_x thenreturn len+1endlocal left, right = 1, len+1--? print('--')while true dolocal curr = math.floor((left+right)/2)local currxmin = Text.cursor_x2(line, curr+1)local currxmax = Text.cursor_x2(line, curr+2)--? print(x, left, right, curr, currxmin, currxmax)if currxmin <= x and x < currxmax thenreturn currendif left >= right-1 thenreturn leftendif currxmin > x thenright = currelseleft = currendendassert(false)end - edit in app.lua at line 202
local sorted_names = {} - edit in app.lua at line 205
table.insert(sorted_names, name)endendtable.sort(sorted_names)for _,name in ipairs(sorted_names) doif name:find('test_') == 1 then - replacement in app.lua at line 212
binding()_G[name]()