a few tests for pageup, and a bugfix
[?]
May 24, 2022, 3:57 AM
4RUI5X52CSQODLT3WI4VBMXWZLACBYV5QANGDKRWS3VONZPVSEEQCDependencies
- [2]
R53OF3ONone bug I've repeatedly run into while testing with Moby Dick - [3]
VCMS2CWTbugfix: escape key to hide online help - [4]
IRV65LZPfold variables for screen dimensions into the app framework - [5]
252M2QMDforgot to move this special case out - [6]
DLQMM265scroll past first page - [7]
MDXGMZU2disable all debug prints - [8]
XNFTJHC4split keyboard handling between Text and Drawing - [9]
2RXZ3PGObeginning of a new approach to scroll+wrap - [10]
DXT4QTAHa few more integer coordinates - [11]
U7M4M2F7bugfix: don't rely on Screen_bottom1 while scrolling - [12]
242L3OQXbugfix: ensure Cursor_line is always on a text line - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
PFT5Y2ZYmove - [*]
OTIBCAUJlove2d scaffold - [*]
OIB2QPRCstart remembering where the cursor is drawn in px - [*]
V5TP27FPctrl-+ and ctrl-- to adjust font size
Change contents
- edit in text.lua at line 421
function test_pageup()io.write('\ntest_pageup')App.screen.init{width=120, height=45}Lines = load_array{'abc', 'def', 'ghi'}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) -- pixels-- initially the last two lines are displayedApp.draw()local y = screen_top_marginApp.screen.check(y, 'def', 'F - test_pageup/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_pageup/baseline/screen:2')-- after pageup the cursor goes to first lineApp.run_after_keychord('pageup')check_eq(Screen_top1.line, 1, 'F - test_pageup/screen_top')check_eq(Cursor1.line, 1, 'F - test_pageup/cursor')y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_pageup/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_pageup/screen:2')endfunction test_pageup_scrolls_up_by_screen_line()io.write('\ntest_pageup_scrolls_up_by_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=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, 'ghi', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace-- after hitting the page-up key the screen scrolls up to topApp.run_after_keychord('pageup')check_eq(Screen_top1.line, 1, 'F - test_pageup_scrolls_up_by_screen_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_pageup_scrolls_up_by_screen_line/cursor:line')check_eq(Cursor1.pos, 1, 'F - test_pageup_scrolls_up_by_screen_line/cursor:pos')y = screen_top_marginApp.screen.check(y, 'abc ', 'F - test_pageup_scrolls_up_by_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_pageup_scrolls_up_by_screen_line/screen:2')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_pageup_scrolls_up_by_screen_line/screen:3')endfunction test_pageup_scrolls_up_from_middle_screen_line()io.write('\ntest_pageup_scrolls_up_from_middle_screen_line')-- display a few lines starting from the middle of a line (Cursor1.pos > 1)App.screen.init{width=25+30, height=60}Lines = load_array{'abc def', 'ghi jkl', 'mno'}Line_width = App.screen.widthCursor1 = {line=2, pos=5}Screen_top1 = {line=2, pos=5}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, 'jkl', 'F - test_pageup_scrolls_up_from_middle_screen_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_pageup_scrolls_up_from_middle_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace-- after hitting the page-up key the screen scrolls up to topApp.run_after_keychord('pageup')check_eq(Screen_top1.line, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/cursor:line')check_eq(Cursor1.pos, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/cursor:pos')y = screen_top_marginApp.screen.check(y, 'abc ', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:2')y = y + line_heightApp.screen.check(y, 'ghi ', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:3')end - edit in main.lua at line 71
--? App.screen.width = 120--? App.screen.height = 200--? love.window.setMode(App.screen.width, App.screen.height) - edit in main.lua at line 82[3.255][18.1]
--? Line_width = 100 - replacement in main.lua at line 245[3.1796]→[3.405:437](∅→∅),[3.437]→[3.1824:1844](∅→∅),[3.1824]→[3.1824:1844](∅→∅),[3.1844]→[3.9628:9674](∅→∅),[3.9674]→[3.274:308](∅→∅),[3.1889]→[3.274:308](∅→∅),[3.308]→[3.9675:9789](∅→∅)
local y = App.screen.heightwhile y >= 0 doif Screen_top1.line == 1 then break endy = y - math.floor(15*Zoom)if Lines[Screen_top1.line].mode == 'drawing' theny = y - Drawing.pixels(Lines[Screen_top1.line].h)local top2 = Text.to2(Screen_top1)--? print(App.screen.height)local y = App.screen.height - math.floor(15*Zoom)while y >= 15 do--? print(y, top2.line)if Screen_top1.line == 1 and Screen_top1.pos == 1 then break endif Lines[Screen_top1.line].mode == 'text' theny = y - math.floor(15*Zoom)elseif Lines[Screen_top1.line].mode == 'drawing' theny = y - 20 - Drawing.pixels(Lines[Screen_top1.line].h) - replacement in main.lua at line 256
Screen_top1.line = Screen_top1.line - 1top2 = Text.previous_screen_line(top2) - replacement in main.lua at line 258[3.2095]→[3.9837:9904](∅→∅),[3.2159]→[3.155:163](∅→∅),[3.9904]→[3.155:163](∅→∅),[3.155]→[3.155:163](∅→∅)
if Cursor1.line ~= Screen_top1.line thenCursor1.pos = 1endScreen_top1 = Text.to1(top2) - edit in main.lua at line 260
Cursor1.pos = Screen_top1.pos - edit in main.lua at line 262
--? print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos)