bugfix: naming points

[?]
Mar 26, 2023, 4:36 PM
4EGQRXDANFLUYXADP3MNHZWP2LBH2P5VBVKNN5RT6ERGMBVSRI2AC

Dependencies

  • [2] K6DTOGOQ flip return value of button handlers
  • [3] ORRSP7FV deduce test names on failures
  • [4] 5Y24ZDZI bugfix
  • [5] LNUHQOGH start passing in Editor_state explicitly
  • [6] MTJEVRJR add state arg to a few functions
  • [7] 2CK5QI7W make love event names consistent
  • [8] 3QQZ7W4E bring couple more globals back to the app level
  • [9] 6D5MOJS4 allow buttons to interrupt events
  • [10] AVTNUQYR basic test-enabled framework
  • [11] PP2IIHL6 stop putting button state in a global
  • [12] LF7BWEG4 group all editor globals
  • [13] KYNGDE2C consistent names in a few more places
  • [14] 5ZA3BRNY add state arg to a few functions
  • [15] 2L5MEZV3 experiment: new edit namespace
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] Z5HLXU4P add state arg to a few functions
  • [*] K2X6G75Z start writing some tests for drawings
  • [*] L6XA5EY2 test: moving a point
  • [*] 3QNOKBFM beginnings of a test harness
  • [*] FCFJVYKY redundant check

Change contents

  • edit in text.lua at line 164
    [18.79]
    [18.79]
    assert(State.lines[State.cursor1.line].mode == 'text')
  • replacement in edit.lua at line 229
    [5.4581][5.4581:4647]()
    --? print('press', State.selection1.line, State.selection1.pos)
    [5.4581]
    [2.15]
    --? print('press', State.cursor1.line)
  • replacement in edit.lua at line 272
    [5.5338][5.8445:8468](),[5.101116][5.8445:8468](),[5.8445][5.8445:8468]()
    --? print('release')
    [5.5338]
    [5.5339]
    --? print('release', State.cursor1.line)
  • edit in edit.lua at line 324
    [5.5593]
    [5.6394]
    --? print('text input', t)
  • replacement in edit.lua at line 329
    [5.2117][5.6496:6547](),[5.9975][5.6496:6547]()
    elseif State.current_drawing_mode == 'name' then
    [5.2117]
    [5.2411]
    elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
  • replacement in edit.lua at line 482
    [5.15043][5.9045:9096]()
    elseif State.current_drawing_mode == 'name' then
    [5.15043]
    [5.15088]
    elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
  • edit in drawing_tests.lua at line 460
    [4.1729]
    [20.19]
    function test_name_point_then_exit_drawing()
    -- create a drawing with a line
    App.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
    Editor_state = edit.initialize_test_state()
    Editor_state.filename = 'foo'
    Editor_state.lines = load_array{'```lines', '```', ''}
    Text.redraw_all(Editor_state)
    edit.check_locs(Editor_state)
    Editor_state.current_drawing_mode = 'line'
    edit.draw(Editor_state)
    -- draw a line
    edit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)
    edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)
    local drawing = Editor_state.lines[1]
    check_eq(#drawing.shapes, 1, 'baseline/#shapes')
    check_eq(#drawing.points, 2, 'baseline/#points')
    check_eq(drawing.shapes[1].mode, 'line', 'baseline/shape:1')
    local p1 = drawing.points[drawing.shapes[1].p1]
    local p2 = drawing.points[drawing.shapes[1].p2]
    check_eq(p1.x, 5, 'baseline/p1:x')
    check_eq(p1.y, 6, 'baseline/p1:y')
    check_eq(p2.x, 35, 'baseline/p2:x')
    check_eq(p2.y, 36, 'baseline/p2:y')
    check_nil(p2.name, 'baseline/p2:name')
    -- enter 'name' mode without moving the mouse
    edit.run_after_keychord(Editor_state, 'C-n')
    check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')
    -- click outside the drawing
    edit.run_after_mouse_click(Editor_state, App.screen.width-5, App.screen.height-5, 1)
    -- press a key
    edit.run_after_text_input(Editor_state, 'a')
    -- key goes to text
    check_eq(Editor_state.lines[2].data, 'a')
    end
  • edit in app.lua at line 372
    [22.47]
    [3.60666]
    --? print('=== '..name)
  • replacement in app.lua at line 384
    [3.60904][3.60904:60966]()
    local stack_trace = debug.traceback('', --[[stack frame]]5)
    [3.60904]
    [3.60966]
    local stack_trace = debug.traceback('', --[[stack frame]]4)
  • edit in app.lua at line 387
    [3.61148]
    [3.61148]
    --? local full_error = file_and_line_number..':'..test_name..' -- '..err_without_line_number..'\t\t'..stack_trace:gsub('\n', '\n\t\t')