bugfix: manage screen_top and cursor when resizing
[?]
Jul 1, 2022, 5:30 PM
WOXIYUTL4NU7ACHQYXEXJDSXCRDLQ2X457KO6C7GEXFQZ43F3L7QCDependencies
- [2]
PX7DDEMOautosave slightly less aggressively - [3]
DBNRULIJrecord one more case I can't automatically detect - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
HOSPP2ANcrisp font rendering - [*]
OTIBCAUJlove2d scaffold - [*]
2RXZ3PGObeginning of a new approach to scroll+wrap - [*]
K464QQR4more defensive resize handling - [*]
Z4XRNDTRfind text - [*]
OAHNWDYG. - [*]
2ENZW7TVselect text using mouse drag - [*]
BJ5X5O4Alet's prevent the text cursor from ever getting on a drawing
Change contents
- edit in text.lua at line 918
function Text.tweak_screen_top_and_cursor()--? print('a', Selection1.line)if Screen_top1.pos == 1 then return endText.populate_screen_line_starting_pos(Screen_top1.line)local line = Lines[Screen_top1.line]for i=2,#line.screen_line_starting_pos dolocal pos = line.screen_line_starting_pos[i]if pos == Screen_top1.pos thenbreakendif pos > Screen_top1.pos then-- make sure screen top is at start of a screen linelocal prev = line.screen_line_starting_pos[i-1]if Screen_top1.pos - prev < pos - Screen_top1.pos thenScreen_top1.pos = prevelseScreen_top1.pos = posendbreakendend-- make sure cursor is on screenif Text.lt1(Cursor1, Screen_top1) thenCursor1 = {line=Screen_top1.line, pos=Screen_top1.pos}elseif Cursor1.line >= Screen_bottom1.line then--? print('too low')App.draw()if Text.lt1(Screen_bottom1, Cursor1) then--? print('tweak')local line = Lines[Screen_bottom1.line]Cursor1 = {line=Screen_bottom1.line, pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5)}endendend - edit in main.lua at line 55
---- Make sure these coordinates are never aliased, so that changing one causes-- action at a distance. - edit in main.lua at line 193
Selection1 = {} -- no support for shift drag while we're resizingText.tweak_screen_top_and_cursor() - edit in main.lua at line 329
--? print('press') - edit in main.lua at line 363
--? print('release') - edit in Manual_tests.md at line 23[3.301]
* Like any high-level language, it's easy to accidentally alias two non-scalarvariables. I wish there was a way to require copy when assigning.