avoid scrolling down if possible
[?]
May 31, 2022, 12:24 AM
QVDQMJXVTM3BBMQDYIAIZMFLBQ56Q27U7H2OYRFE53MEMOCIXIAQCDependencies
- [2]
WY3JD6W6bugfix - [3]
PHFWIFYKscroll on enter - [4]
2RXZ3PGObeginning of a new approach to scroll+wrap - [5]
XNFTJHC4split keyboard handling between Text and Drawing - [6]
2ZYV7D3Whandle tab characters - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
4RUI5X52a few tests for pageup, and a bugfix
Change contents
- edit in text.lua at line 865[9.4097][2.1]
function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()io.write('\ntest_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom')-- display just the bottom line on screenApp.screen.init{width=25+30, height=60}Lines = load_array{'abc', 'def', 'ghi', 'jkl'}Line_width = App.screen.widthCursor1 = {line=4, pos=2}Screen_top1 = {line=4, 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, 'jkl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/baseline/screen:1')-- after hitting the enter key the screen does not scroll downApp.run_after_keychord('return')check_eq(Screen_top1.line, 4, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen_top')check_eq(Cursor1.line, 5, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:line')check_eq(Cursor1.pos, 1, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:pos')y = screen_top_marginApp.screen.check(y, 'j', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen:1')y = y + line_heightApp.screen.check(y, 'kl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen:2')end - edit in text.lua at line 1164
local scroll_down = (Cursor_y + math.floor(15*Zoom)) > App.screen.height - replacement in text.lua at line 1170
if Cursor1.line > Screen_bottom1.line thenif scroll_down then