fold together two largely similar cases

[?]
Jul 17, 2022, 3:05 PM
WJBZZQE4A4KLYGS2KA254I6VN2DVXDY4XKCNAE76GTMLLQGYCUOQC

Dependencies

  • [2] 3ZTODUBQ formatting
  • [3] 3ZSUBI57 drop some redundant args from Text.draw
  • [4] TGZAJUEF bring back a set of constants
  • [5] PTDO2SOT add state arg to schedule_save
  • [6] KTZQ57HV replace globals with args in a few functions
  • [7] UHB4GARJ left/right margin -> left/right coordinates
  • [8] MTJEVRJR add state arg to a few functions
  • [9] MXA3RZYK deduce left/right from state where possible
  • [10] LNUHQOGH start passing in Editor_state explicitly
  • [11] 2L5MEZV3 experiment: new edit namespace
  • [12] LF7BWEG4 group all editor globals
  • [13] X3F7ECSL add state arg to some functions
  • [14] 7JH2ZT3F add state arg to Drawing.draw

Change contents

  • replacement in edit.lua at line 131
    [4.3138][4.4344:4396](),[4.98573][4.4344:4396](),[4.4344][4.4344:4396]()
    if line.mode == 'text' and line.data == '' then
    [4.3138]
    [4.4396]
    if 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 drawing
    button('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 then
    State.cursor1.line = State.cursor1.line+1
    end
    schedule_save(State)
    record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})
    end,
    })
    if State.search_term == nil then
    if line_index == State.cursor1.line then
    Text.draw_cursor(State, State.left, y)
    end
    [4.4442]
    [4.5229]
    if line_index == State.screen_top1.line then
    line.startpos = State.screen_top1.pos
    end
    if line.data == '' then
    -- button to insert new drawing
    button('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 then
    State.cursor1.line = State.cursor1.line+1
    end
    schedule_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
    [4.5239][4.3530:3585]()
    State.screen_bottom1.pos = State.screen_top1.pos
    [4.5239]
    [4.3585]
    y, State.screen_bottom1.pos = Text.draw(State, line_index)
  • edit in edit.lua at line 155
    [4.3617]
    [4.5308]
    --? 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 = y
    line.startpos = 1
    if line_index == State.screen_top1.line then
    line.startpos = State.screen_top1.pos
    end
    --? print('text.draw', y, line_index)
    y, State.screen_bottom1.pos = Text.draw(State, line_index)
    y = y + State.line_height
    --? print('=> y', y)
    [4.5492]
    [4.5845]
    print(line.mode)
    assert(false)