bugfix: inscript's bug
[?]
Jun 4, 2023, 7:20 PM
6XCJX4DZB6UEAXEXXUGVVPBCF5SNDYOJGU3Q6BPB4ZMI5DZH4MYQCDependencies
- [2]
KYNGDE2Cconsistent names in a few more places - [3]
YFW4MNNPhandle wrapping lines - [4]
3OTESDW6move drawing.starty into line cache - [5]
S2MISTTMadd state arg to a few functions - [6]
UHB4GARJleft/right margin -> left/right coordinates - [7]
FKNXK2OAswitch to line index in a function - [8]
MTJEVRJRadd state arg to a few functions - [9]
WJBZZQE4fold together two largely similar cases - [10]
HIKLULFQextract a function - [11]
52ZZ5TIEswitch to line index in a function - [12]
4CXVIEBSadd args to some functions - [13]
BW2IUB3Kkeep all text cache writes inside text.lua - [14]
6RYLD5ONchange how we handle clicks above top margin - [15]
LXTTOB33extract a couple of files - [16]
OI4FPFINsupport drawings in the source editor - [17]
QCPXQ2E3add state arg to a few functions - [18]
2L5MEZV3experiment: new edit namespace - [19]
PK5U572Cdrop some extra args - [20]
7FPELAZBah, I see the problem - [21]
KTZQ57HVreplace globals with args in a few functions - [22]
LF7BWEG4group all editor globals - [23]
4EGQRXDAbugfix: naming points - [24]
2CK5QI7Wmake love event names consistent - [25]
GNKUD23Iget rid of recent_mouse - [26]
MXA3RZYKdeduce left/right from state where possible - [27]
4GYPLUDYstreamline the interface for Text.draw - [28]
LNUHQOGHstart passing in Editor_state explicitly - [29]
MRA2Y3EEidea: set recent_mouse on mouse events - [30]
QJISOCHJsome temporary logging to catch a bug - [31]
FHSZYAZ2more precise search highlighting - [32]
DLQAEAC7add state arg to Drawing.mouse_pressed - [33]
K6DTOGOQflip return value of button handlers - [34]
GFXWHTE6mouse wheel support - [35]
6D5MOJS4allow buttons to interrupt events - [*]
WAR3HXHTtest both ways of selecting text with mouse - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
SVJZZDC3snapshot - no, that's all wrong - [*]
GNQC72UXgeneralize a function - [*]
HYEAFRZ2split mouse_pressed events between Text and Drawing - [*]
OP643FFGmove
Change contents
- edit in text_tests.lua at line 867
function test_select_text_using_mouse_starting_below_text()-- I'd like to test what happens when a mouse click is below some page of-- text, potentially even in the middle of a line.-- However, it's brittle to set up a text line boundary just right.-- So I'm going to just check things below the bottom of the final line of-- text when it's in the middle of the screen.-- final screen line ends in the middle of screenApp.screen.init{width=50, height=60}Editor_state = edit.initialize_test_state()Editor_state.lines = load_array{'abcde'}Text.redraw_all(Editor_state)Editor_state.cursor1 = {line=1, pos=1}Editor_state.screen_top1 = {line=1, pos=1}Editor_state.screen_bottom1 = {}edit.draw(Editor_state)local y = Editor_state.topApp.screen.check(y, 'ab', 'baseline:screen:1')y = y + Editor_state.line_heightApp.screen.check(y, 'cde', 'baseline:screen:2')-- press mouse above first line of textedit.run_after_mouse_press(Editor_state, 5,App.screen.height-5, 1)-- selection is past bottom-most text in screencheck(Editor_state.selection1.line ~= nil, 'selection:line-not-nil')check_eq(Editor_state.selection1.line, 1, 'selection:line')check_eq(Editor_state.selection1.pos, 6, 'selection:pos')end - edit in text.lua at line 594
-- result: pos, index of screen line - edit in text.lua at line 607
function Text.pos_at_end_of_screen_line(State, loc1)Text.populate_screen_line_starting_pos(State, loc1.line)local line_cache = State.line_cache[loc1.line]local most_recent_final_pos = utf8.len(State.lines[loc1.line].data)+1for i=#line_cache.screen_line_starting_pos,1,-1 dolocal spos = line_cache.screen_line_starting_pos[i]if spos <= loc1.pos thenreturn most_recent_final_posendmost_recent_final_pos = spos-1endassert(false)end - edit in select.lua at line 70
-- inefficient for some reason, so don't do it on every frame - replacement in select.lua at line 71[4.136]→[4.4079:4147](∅→∅),[4.1228]→[4.4079:4147](∅→∅),[4.4147]→[4.1096:1115](∅→∅),[4.1115]→[4.46270:46275](∅→∅),[4.1436]→[4.46270:46275](∅→∅),[4.79554]→[4.46270:46275](∅→∅),[4.46270]→[4.46270:46275](∅→∅),[4.46275]→[4.4148:4181](∅→∅)
local line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y())return line, posendfunction Text.to_pos(State, x,y)local x,y = App.mouse_x(), App.mouse_y() - edit in select.lua at line 82[4.46495][42.5]
return State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1) - edit in edit.lua at line 155
local screen_bottom1 = {line=nil, pos=nil} - replacement in edit.lua at line 161
State.screen_bottom1 = {line=line_index, pos=nil}screen_bottom1.line = line_index - replacement in edit.lua at line 184
y, State.screen_bottom1.pos = Text.draw(State, line_index, y, startpos)y, screen_bottom1.pos = Text.draw(State, line_index, y, startpos) - edit in edit.lua at line 195
State.screen_bottom1 = screen_bottom1 - replacement in edit.lua at line 226
print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))--? print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos)) - replacement in edit.lua at line 263[4.254]→[4.8026:8040](∅→∅),[4.447]→[4.8026:8040](∅→∅),[4.691]→[4.8026:8040](∅→∅),[4.5144]→[4.8026:8040](∅→∅),[4.100956]→[4.8026:8040](∅→∅),[4.8026]→[4.8026:8040](∅→∅)
breakreturn - replacement in edit.lua at line 272[4.77]→[4.8321:8335](∅→∅),[4.261]→[4.8321:8335](∅→∅),[2.788]→[4.8321:8335](∅→∅),[4.8321]→[4.8321:8335](∅→∅)
breakreturn - edit in edit.lua at line 276
-- still here? click is below all screen linesState.old_cursor1 = State.cursor1State.old_selection1 = State.selection1State.mousepress_shift = App.shift_down()State.selection1 = {line=State.screen_bottom1.line,pos=Text.pos_at_end_of_screen_line(State, State.screen_bottom1),} - replacement in edit.lua at line 289
print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))--? print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos)) - replacement in edit.lua at line 298
print_and_log('edit.mouse_release: no current drawing')--? print_and_log('edit.mouse_release: no current drawing') - replacement in edit.lua at line 302
print_and_log(('edit.mouse_release: in line %d'):format(line_index))--? print_and_log(('edit.mouse_release: in line %d'):format(line_index)) - replacement in edit.lua at line 307
print_and_log(('edit.mouse_release: cursor now %d,%d'):format(State.cursor1.line, State.cursor1.pos))--? print_and_log(('edit.mouse_release: cursor now %d,%d'):format(State.cursor1.line, State.cursor1.pos)) - replacement in edit.lua at line 323
print_and_log(('edit.mouse_release: finally selection %s,%s cursor %d,%d'):format(tostring(State.selection1.line), tostring(State.selection1.pos), State.cursor1.line, State.cursor1.pos))--? print_and_log(('edit.mouse_release: finally selection %s,%s cursor %d,%d'):format(tostring(State.selection1.line), tostring(State.selection1.pos), State.cursor1.line, State.cursor1.pos))