add state arg to some functions

[?]
Jul 12, 2022, 11:08 PM
X3F7ECSLGXCH6NBSDIH7LY47I4EG2RR5VFPEMM6ZVDYQIGFID4HQC

Dependencies

  • [2] LNUHQOGH start passing in Editor_state explicitly
  • [3] 4VKEE43Z bugfix
  • [4] Y36LOGR5 bugfix: show cursor when past end of line
  • [5] 537TQ2QN some more logging
  • [6] M6TH7VSZ rip out notion of Line_width
  • [7] 4CXVIEBS add args to some functions
  • [8] 3TFEAQSW start using some globals
  • [9] JY4VK7L2 rename
  • [10] B3IWYWSR delete another arg that can be deduced
  • [11] BULPIBEG beginnings of a module for the text editor
  • [12] 5DOC2CBM extract a function
  • [13] A2NV3WVO scrolling with up arrow
  • [14] JRGTJ2IW quite the frustrating bugfix
  • [15] OIB2QPRC start remembering where the cursor is drawn in px
  • [16] CVGE3SIG I feel confident now that page-down is working.
  • [17] QYIFOHW3 first test!
  • [18] GK47BBCY start passing left/right margins everywhere
  • [19] 2L5MEZV3 experiment: new edit namespace
  • [20] EWMPYCDO bugfix
  • [21] J2SVGR2E experiment: blinking cursor
  • [22] OYXDYPGS get rid of debug variables
  • [23] LXTTOB33 extract a couple of files
  • [24] LF7BWEG4 group all editor globals
  • [25] KWOJ6XHE cut/copy selected text to clipboard
  • [26] HIKLULFQ extract a function
  • [27] FYQQTPRP the problem is that the cursor can occlude text
  • [28] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [29] FHSZYAZ2 more precise search highlighting
  • [30] WLHI7KD3 new globals: draw partial screen line up top
  • [31] 2ZRC7FUL .
  • [32] 4KC7I3E2 make colors easier to edit
  • [33] 5DOTWNVM right margin
  • [34] AYE2VEGJ extract a couple of methods
  • [35] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [36] Z4XRNDTR find text
  • [37] XNFTJHC4 split keyboard handling between Text and Drawing
  • [38] DHI6IJCN selecting text and deleting selections
  • [39] LERERVPH keep one screen line of overlap on pagedown
  • [40] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [41] HOSPP2AN crisp font rendering
  • [42] LAW2O3NW extract variable Margin_left

Change contents

  • replacement in text.lua at line 12
    [3.103][3.3:58]()
    function Text.draw(line, line_index, top, left, right)
    [3.103]
    [3.1129]
    function Text.draw(State, line, line_index, top, left, right)
  • replacement in text.lua at line 31
    [3.26][3.54100:54396]()
    --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(right)..') '..s(line_index)..' vs '..s(Editor_state.screen_top1.line)..'; '..s(pos)..' vs '..s(Editor_state.screen_top1.pos)..'; bottom: '..s(Editor_state.screen_bottom1.line)..'/'..s(Editor_state.screen_bottom1.pos))
    [3.26]
    [3.337]
    --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(right)..') '..s(line_index)..' vs '..s(State.screen_top1.line)..'; '..s(pos)..' vs '..s(State.screen_top1.pos)..'; bottom: '..s(State.screen_bottom1.line)..'/'..s(State.screen_bottom1.pos))
  • replacement in text.lua at line 35
    [3.74][3.54397:54580]()
    if Text.lt1(Editor_state.screen_top1, {line=line_index, pos=pos}) then
    y = y + Editor_state.line_height
    if y + Editor_state.line_height > App.screen.height then
    [3.74]
    [3.420]
    if Text.lt1(State.screen_top1, {line=line_index, pos=pos}) then
    y = y + State.line_height
    if y + State.line_height > App.screen.height then
  • replacement in text.lua at line 46
    [3.2206][3.54581:54650]()
    --? print('checking to draw', pos, Editor_state.screen_top1.pos)
    [3.2206]
    [3.387]
    --? print('checking to draw', pos, State.screen_top1.pos)
  • replacement in text.lua at line 48
    [3.427][3.54651:54769]()
    if Text.le1(Editor_state.screen_top1, {line=line_index, pos=pos}) then
    if Editor_state.selection1.line then
    [3.427]
    [3.3]
    if Text.le1(State.screen_top1, {line=line_index, pos=pos}) then
    if State.selection1.line then
  • replacement in text.lua at line 57
    [3.2288][3.54770:55294]()
    if line_index == Editor_state.cursor1.line then
    if pos <= Editor_state.cursor1.pos and pos + frag_len > Editor_state.cursor1.pos then
    if Editor_state.search_term then
    if Editor_state.lines[Editor_state.cursor1.line].data:sub(Editor_state.cursor1.pos, Editor_state.cursor1.pos+utf8.len(Editor_state.search_term)-1) == Editor_state.search_term then
    local lo_px = Text.draw_highlight(line, x,y, pos, Editor_state.cursor1.pos, Editor_state.cursor1.pos+utf8.len(Editor_state.search_term))
    [3.2288]
    [3.28]
    if line_index == State.cursor1.line then
    if pos <= State.cursor1.pos and pos + frag_len > State.cursor1.pos then
    if State.search_term then
    if State.lines[State.cursor1.line].data:sub(State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)-1) == State.search_term then
    local lo_px = Text.draw_highlight(line, x,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term))
  • replacement in text.lua at line 63
    [3.62][3.55295:55364]()
    love.graphics.print(Editor_state.search_term, x+lo_px,y)
    [3.62]
    [3.530]
    love.graphics.print(State.search_term, x+lo_px,y)
  • replacement in text.lua at line 66
    [3.557][3.55365:55443]()
    Text.draw_cursor(x+Text.x(frag, Editor_state.cursor1.pos-pos+1), y)
    [3.557]
    [3.622]
    Text.draw_cursor(State, x+Text.x(frag, State.cursor1.pos-pos+1), y)
  • replacement in text.lua at line 73
    [3.37][3.55444:55574](),[3.55574][3.726:755](),[3.726][3.726:755]()
    if Editor_state.search_term == nil then
    if line_index == Editor_state.cursor1.line and Editor_state.cursor1.pos == pos then
    Text.draw_cursor(x, y)
    [3.37]
    [3.755]
    if State.search_term == nil then
    if line_index == State.cursor1.line and State.cursor1.pos == pos then
    Text.draw_cursor(State, x, y)
  • replacement in text.lua at line 83
    [3.962][3.101:133](),[3.101][3.101:133]()
    function Text.draw_cursor(x, y)
    [3.851]
    [3.3]
    function Text.draw_cursor(State, x, y)
  • replacement in text.lua at line 87
    [3.91][3.55575:55644]()
    love.graphics.rectangle('fill', x,y, 3,Editor_state.line_height)
    [3.91]
    [3.92]
    love.graphics.rectangle('fill', x,y, 3,State.line_height)
  • replacement in text.lua at line 90
    [3.198][3.55645:55726]()
    Editor_state.cursor_x = x
    Editor_state.cursor_y = y+Editor_state.line_height
    [3.198]
    [3.256]
    State.cursor_x = x
    State.cursor_y = y+State.line_height
  • replacement in search.lua at line 3
    [3.48884][3.48884:48916](),[3.48916][3.81797:81836]()
    function Text.draw_search_bar()
    local h = Editor_state.line_height+2
    [3.48884]
    [3.48942]
    function Text.draw_search_bar(State)
    local h = State.line_height+2
  • replacement in search.lua at line 15
    [3.205][3.81837:81890]()
    App.screen.print(Editor_state.search_term, 25,y-5)
    [3.205]
    [3.206]
    App.screen.print(State.search_term, 25,y-5)
  • replacement in search.lua at line 17
    [3.232][3.81891:82027]()
    if Editor_state.search_text == nil then
    Editor_state.search_text = App.newText(love.graphics.getFont(), Editor_state.search_term)
    [3.232]
    [3.49593]
    if State.search_text == nil then
    State.search_text = App.newText(love.graphics.getFont(), State.search_term)
  • replacement in search.lua at line 20
    [3.49599][3.82028:82108]()
    love.graphics.circle('fill', 25+App.width(Editor_state.search_text),y-5+h, 2)
    [3.49599]
    [3.233]
    love.graphics.circle('fill', 25+App.width(State.search_text),y-5+h, 2)
  • replacement in edit.lua at line 147
    [2.3480][2.3480:3529]()
    Text.draw_cursor(State.margin_left, y)
    [2.3480]
    [3.5217]
    Text.draw_cursor(State, State.margin_left, y)
  • replacement in edit.lua at line 164
    [3.5677][2.3824:3957]()
    y, State.screen_bottom1.pos = Text.draw(line, line_index, line.starty, State.margin_left, App.screen.width-State.margin_right)
    [3.5677]
    [2.3957]
    y, State.screen_bottom1.pos = Text.draw(State, line, line_index, line.starty, State.margin_left, App.screen.width-State.margin_right)
  • replacement in edit.lua at line 174
    [2.4219][3.6057:6084](),[3.99822][3.6057:6084](),[3.6057][3.6057:6084]()
    Text.draw_search_bar()
    [2.4219]
    [3.6084]
    Text.draw_search_bar(State)