fold together two largely similar cases
[?]
Jul 17, 2022, 3:05 PM
WJBZZQE4A4KLYGS2KA254I6VN2DVXDY4XKCNAE76GTMLLQGYCUOQCDependencies
- [2]
3ZTODUBQformatting - [3]
3ZSUBI57drop some redundant args from Text.draw - [4]
TGZAJUEFbring back a set of constants - [5]
PTDO2SOTadd state arg to schedule_save - [6]
KTZQ57HVreplace globals with args in a few functions - [7]
UHB4GARJleft/right margin -> left/right coordinates - [8]
MTJEVRJRadd state arg to a few functions - [9]
MXA3RZYKdeduce left/right from state where possible - [10]
LNUHQOGHstart passing in Editor_state explicitly - [11]
2L5MEZV3experiment: new edit namespace - [12]
LF7BWEG4group all editor globals - [13]
X3F7ECSLadd state arg to some functions - [14]
7JH2ZT3Fadd state arg to Drawing.draw
Change contents
- replacement in edit.lua at line 131
if line.mode == 'text' and line.data == '' thenif line.mode == 'text' then--? print('text.draw', y, line_index) - replacement in edit.lua at line 135[4.4442]→[4.4442:4595](∅→∅),[4.4595]→[4.2038:2118](∅→∅),[4.2118]→[4.3139:3391](∅→∅),[4.4668]→[4.3139:3391](∅→∅),[4.3391]→[4.4896:4921](∅→∅),[4.98854]→[4.4896:4921](∅→∅),[4.4896]→[4.4896:4921](∅→∅),[4.4921]→[4.206:248](∅→∅),[4.248]→[4.2119:2241](∅→∅),[4.2241]→[2.15:39](∅→∅),[2.39]→[4.5089:5098](∅→∅),[4.5089]→[4.5089:5098](∅→∅),[4.5098]→[4.3392:3480](∅→∅),[4.3480]→[4.22446:22495](∅→∅),[4.1927]→[4.5217:5229](∅→∅),[4.3529]→[4.5217:5229](∅→∅),[4.22495]→[4.5217:5229](∅→∅),[4.99013]→[4.5217:5229](∅→∅),[4.5217]→[4.5217:5229](∅→∅)
-- insert new drawingbutton('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},icon = icon.insert_drawing,onpress1 = function()Drawing.before = snapshot(State, line_index-1, line_index)table.insert(State.lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})if State.cursor1.line >= line_index thenState.cursor1.line = State.cursor1.line+1endschedule_save(State)record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})end,})if State.search_term == nil thenif line_index == State.cursor1.line thenText.draw_cursor(State, State.left, y)endif line_index == State.screen_top1.line thenline.startpos = State.screen_top1.posendif line.data == '' then-- button to insert new drawingbutton('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},icon = icon.insert_drawing,onpress1 = function()Drawing.before = snapshot(State, line_index-1, line_index)table.insert(State.lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})if State.cursor1.line >= line_index thenState.cursor1.line = State.cursor1.line+1endschedule_save(State)record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})end,}) - replacement in edit.lua at line 153
State.screen_bottom1.pos = State.screen_top1.posy, State.screen_bottom1.pos = Text.draw(State, line_index) - edit in edit.lua at line 155
--? print('=> y', y) - replacement in edit.lua at line 162[4.5492]→[4.5492:5538](∅→∅),[4.5538]→[4.3726:3823](∅→∅),[4.3823]→[4.5623:5677](∅→∅),[4.99356]→[4.5623:5677](∅→∅),[4.5623]→[4.5623:5677](∅→∅),[4.5677]→[3.301:366](∅→∅),[3.366]→[4.3957:3989](∅→∅),[4.2068]→[4.3957:3989](∅→∅),[4.4669]→[4.3957:3989](∅→∅),[4.22605]→[4.3957:3989](∅→∅),[4.3957]→[4.3957:3989](∅→∅),[4.3989]→[4.5818:5845](∅→∅),[4.99550]→[4.5818:5845](∅→∅),[4.5818]→[4.5818:5845](∅→∅)
line.starty = yline.startpos = 1if line_index == State.screen_top1.line thenline.startpos = State.screen_top1.posend--? print('text.draw', y, line_index)y, State.screen_bottom1.pos = Text.draw(State, line_index)y = y + State.line_height--? print('=> y', y)print(line.mode)assert(false)