go through and fix similar issues

[?]
Jun 14, 2022, 3:15 PM
CPZGQT72EBP3SEDBPDWQRK5IUGA664PHXNP2GOHJLP43PKPWF25AC

Dependencies

  • [2] 4VKEE43Z bugfix
  • [3] CUIV2LE5 some typos
  • [4] 5FW7YOFT highlight selection while dragging
  • [5] AYE2VEGJ extract a couple of methods
  • [6] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [7] PR4KIAZD first stab at equally hacky cursor down support
  • [8] V5MJRFOZ bugfix: down arrow doesn't scroll up unnecessarily
  • [9] ZPUQSPQP extract a few methods
  • [10] 5L7K4GBD clicking to the right of a wrapped line
  • [11] HOSPP2AN crisp font rendering
  • [12] XNFTJHC4 split keyboard handling between Text and Drawing
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing

Change contents

  • replacement in text.lua at line 467
    [3.1520][3.1520:1601]()
    local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_pos)
    [3.1520]
    [3.1601]
    local screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, screen_line_starting_pos)
    assert(screen_line_starting_byte_offset)
    local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_byte_offset)
  • replacement in text.lua at line 487
    [3.2441][3.2441:2522]()
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    [3.2441]
    [3.2522]
    local new_screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    assert(new_screen_line_starting_byte_offset)
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_byte_offset)
  • replacement in text.lua at line 527
    [3.4338][3.4338:4419]()
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    [3.4338]
    [3.4419]
    local new_screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    assert(new_screen_line_starting_byte_offset)
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_byte_offset)
  • replacement in text.lua at line 698
    [3.133][2.1359:1478]()
    --? print('iter', y, screen_line_index, screen_line_starting_pos, string.sub(line.data, screen_line_starting_pos))
    [3.133]
    [3.3874]
    local screen_line_starting_byte_offset = utf8.offset(line.data, screen_line_starting_pos)
    assert(screen_line_starting_byte_offset)
    --? print('iter', y, screen_line_index, screen_line_starting_pos, string.sub(line.data, screen_line_starting_byte_offset))
  • edit in text.lua at line 710
    [3.538][2.1536:1679]()
    local screen_line_starting_byte_offset = utf8.offset(line.data, screen_line_starting_pos)
    assert(screen_line_starting_byte_offset)
  • edit in manual_tests at line 1
    [15.1]
    [15.2]
    -- static properties of the code
    All strings are UTF-8. Bytes within them are not characters.
    I try to label byte offsets as _offset, and character positions as _pos.
    For example, string.sub should never use a _pos to substring, only an _offset.
    Wish I had some static typing here. We're not going to try to write tests to catch issues like this.
    -- manual tests