get rid of recent_mouse
[?]
Jun 2, 2023, 5:12 AM
GNKUD23IHHTLV6COIR4LBK36GPN2FPBGSXHOSJHRW5KKEA2ENWUACDependencies
- [2]
MRA2Y3EEidea: set recent_mouse on mouse events - [3]
7RKFA3VAfailing test now looks realistic - [4]
MXA3RZYKdeduce left/right from state where possible - [5]
QCPXQ2E3add state arg to a few functions - [6]
LF7BWEG4group all editor globals - [7]
2L5MEZV3experiment: new edit namespace - [8]
QJISOCHJsome temporary logging to catch a bug - [9]
4CXVIEBSadd args to some functions - [10]
VSBSWTE4bugfix: where cursor is drawn - [11]
WAR3HXHTtest both ways of selecting text with mouse - [12]
LAW2O3NWextract variable Margin_left - [13]
S2MISTTMadd state arg to a few functions - [14]
UHB4GARJleft/right margin -> left/right coordinates - [15]
ORRSP7FVdeduce test names on failures - [16]
LXTTOB33extract a couple of files - [17]
DRFE3B3Zmouse buttons are integers, not strings - [18]
ZLJGZYQGselect text with shift + mouseclick - [19]
PK5U572Cdrop some extra args - [20]
FKNXK2OAswitch to line index in a function - [21]
T3B4NLV3include a unit test - [22]
356GY7IQunify two similar functions - [23]
7FPELAZBah, I see the problem - [24]
3TCZ7ADHmove - [25]
JFFUF5ALoverride mouse state lookups in tests - [26]
RMKMPFT5fix a corner case when selecting text - [27]
LNUHQOGHstart passing in Editor_state explicitly
Change contents
- replacement in text_tests.lua at line 907[3.802]→[3.802:1788](∅→∅),[4.323]→[4.6250:6254](∅→∅),[4.842]→[4.6250:6254](∅→∅),[4.842]→[4.6250:6254](∅→∅),[4.1306]→[4.6250:6254](∅→∅),[4.1313]→[4.6250:6254](∅→∅),[4.1581]→[4.6250:6254](∅→∅),[3.1788]→[4.6250:6254](∅→∅),[4.7365]→[4.6250:6254](∅→∅),[4.23358]→[4.6250:6254](∅→∅),[4.6250]→[4.6250:6254](∅→∅)
function test_select_all_text_then_mouse_press_outside_text()-- display a single line of textApp.screen.init{width=75, height=80}Editor_state = edit.initialize_test_state()Editor_state.lines = load_array{'abc def'}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)-- select allApp.fake_key_press('lctrl')edit.run_after_keychord(Editor_state, 'C-a')App.fake_key_release('lctrl')edit.key_release(Editor_state, 'lctrl')-- selectioncheck_eq(Editor_state.selection1.line, 1, 'selection:line')check_eq(Editor_state.selection1.pos, 1, 'selection:pos')check_eq(Editor_state.cursor1.line, 1, 'cursor:line')check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos')-- part of a mouse click outside the selected lineedit.run_after_mouse_press(Editor_state, 45, Margin_top + Editor_state.line_height + 10, --[[mouse button]] 1)end--? function test_select_all_text_then_mouse_press_outside_text()--? -- display a single line of text--? App.screen.init{width=75, height=80}--? Editor_state = edit.initialize_test_state()--? Editor_state.lines = load_array{'abc def'}--? 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)--? -- select all--? App.fake_key_press('lctrl')--? edit.run_after_keychord(Editor_state, 'C-a')--? App.fake_key_release('lctrl')--? edit.key_release(Editor_state, 'lctrl')--? -- selection--? check_eq(Editor_state.selection1.line, 1, 'selection:line')--? check_eq(Editor_state.selection1.pos, 1, 'selection:pos')--? check_eq(Editor_state.cursor1.line, 1, 'cursor:line')--? check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos')--? -- part of a mouse click outside the selected line--? edit.run_after_mouse_press(Editor_state, 45, Margin_top + Editor_state.line_height + 10, --[[mouse button]] 1)--? end - edit in select.lua at line 72[4.4078]→[2.13:94](∅→∅),[2.94]→[4.13:137](∅→∅),[4.1135]→[4.13:137](∅→∅),[4.137]→[4.1135:1194](∅→∅),[4.1135]→[4.1135:1194](∅→∅),[4.1194]→[4.46046:46052](∅→∅),[4.79358]→[4.46046:46052](∅→∅),[4.46046]→[4.46046:46052](∅→∅),[4.46052]→[2.95:136](∅→∅)
if State.recent_mouse.time and State.recent_mouse.time > Current_time-0.1 thenprint_and_log(('text.mouse_pos: returning recent value %d,%d'):format(State.recent_mouse.line, State.recent_mouse.pos))return State.recent_mouse.line, State.recent_mouse.posendState.recent_mouse.time = Current_time - replacement in select.lua at line 73[4.463]→[4.46148:46163](∅→∅),[4.1309]→[4.46148:46163](∅→∅),[4.1343]→[4.46148:46163](∅→∅),[4.4147]→[4.46148:46163](∅→∅),[4.46148]→[4.46148:46163](∅→∅),[4.46163]→[4.1310:1378](∅→∅),[4.1378]→[4.46219:46225](∅→∅),[4.79482]→[4.46219:46225](∅→∅),[4.46219]→[4.46219:46225](∅→∅),[4.46225]→[4.1379:1436](∅→∅)
if line thenState.recent_mouse.line = lineState.recent_mouse.pos = posendreturn State.recent_mouse.line, State.recent_mouse.posreturn line, pos - edit in edit.lua at line 78
-- when selecting text, avoid recomputing some state on every single framerecent_mouse = {}, - edit in edit.lua at line 250
State.recent_mouse = {time=Current_time, line=State.selection1.line, pos=State.selection1.pos} - edit in edit.lua at line 286
State.recent_mouse = {time=Current_time, line=State.cursor1.line, pos=State.cursor1.pos}