change how we handle clicks above top margin

[?]
Jun 3, 2023, 5:36 PM
6RYLD5ONDIQFWU5CNL4NGHJQ2LNAZZFGTPXQJDNJGLNYAUOTUI7QC

Dependencies

  • [2] GNKUD23I get rid of recent_mouse
  • [3] 3TCZ7ADH move
  • [4] ORRSP7FV deduce test names on failures
  • [5] 7RKFA3VA failing test now looks realistic
  • [6] LF7BWEG4 group all editor globals
  • [7] RMKMPFT5 fix a corner case when selecting text
  • [8] 356GY7IQ unify two similar functions
  • [9] VSBSWTE4 bugfix: where cursor is drawn
  • [10] ZLJGZYQG select text with shift + mouseclick
  • [11] WAR3HXHT test both ways of selecting text with mouse
  • [12] LXTTOB33 extract a couple of files
  • [13] T3B4NLV3 include a unit test
  • [*] KOTI3MFG bugfix in previous commit
  • [*] MXA3RZYK deduce left/right from state where possible
  • [*] S2MISTTM add state arg to a few functions
  • [*] 2L5MEZV3 experiment: new edit namespace
  • [*] LNUHQOGH start passing in Editor_state explicitly
  • [*] 3QNOKBFM beginnings of a test harness
  • [*] 4EGQRXDA bugfix: naming points

Change contents

  • edit in text_tests.lua at line 2
    [3.41]
    [15.2]
    -- Arguably this should be called edit_tests.lua,
    -- but that would mess up the git blame at this point.
  • edit in text_tests.lua at line 831
    [3.6899]
    [3.538]
    end
    function test_select_text_using_mouse_starting_above_text()
    App.screen.init{width=50, height=60}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', 'def', 'xyz'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    Editor_state.selection1 = {}
    edit.draw(Editor_state) -- populate line_cache.starty for each line Editor_state.line_cache
    -- press mouse above first line of text
    edit.run_after_mouse_press(Editor_state, Editor_state.left+8,5, 1)
    check(Editor_state.selection1.line ~= nil, 'selection:line-not-nil')
    check_eq(Editor_state.selection1.line, 1, 'selection:line')
    check_eq(Editor_state.selection1.pos, 1, 'selection:pos')
  • edit in text_tests.lua at line 926
    [3.802][2.2:1084](),[2.1084][3.6254:6255](),[3.6254][3.6254:6255]()
    --? 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 77
    [16.4181]
    [17.1483]
    if y < State.line_cache[State.screen_top1.line].starty then
    return State.screen_top1.line, State.screen_top1.pos
    end
  • edit in edit.lua at line 230
    [18.7017]
    [19.4648]
    if y < State.top then
    State.old_cursor1 = State.cursor1
    State.old_selection1 = State.selection1
    State.mousepress_shift = App.shift_down()
    State.selection1 = {
    line=1,
    pos=1,
    }
    return
    end
  • edit in app.lua at line 364
    [21.1994]
    [3.60666]
    --? _G[name]()