bugfix: UTF-8 in compute_fragments
[?]
Jun 14, 2022, 2:30 PM
DGK5BPVI6PAD3WK2ZB2ITMBE6WYSU3ZR7TV7RTCQ2WJQ4RGJE5RQCDependencies
- [2]
LXTTOB33extract a couple of files - [3]
IMEJA43Lsnapshot - [4]
PFT5Y2ZYmove - [5]
MDXGMZU2disable all debug prints - [6]
R5OKMVVCfix a regression in line wrapping - [7]
QYIFOHW3first test! - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
OTIBCAUJlove2d scaffold - [*]
IRV65LZPfold variables for screen dimensions into the app framework
Change contents
- edit in text_tests.lua at line 110
endfunction test_draw_wrapping_text_containing_non_ascii()-- draw a long line containing non-ASCIIio.write('\ntest_draw_wrapping_text_containing_non_ascii')App.screen.init{width=60, height=60}Lines = load_array{'madam I’m adam', 'xyz'} -- notice the non-ASCII apostropheLine_width = App.screen.widthCursor1 = {line=1, pos=1}Screen_top1 = {line=1, pos=1}Screen_bottom1 = {}App.draw()local y = Margin_topApp.screen.check(y, 'mada', 'F - test_draw_wrapping_text_containing_non_ascii/screen:1')y = y + Line_heightApp.screen.check(y, 'm I’', 'F - test_draw_wrapping_text_containing_non_ascii/screen:2')y = y + Line_heightApp.screen.check(y, 'm ad', 'F - test_draw_wrapping_text_containing_non_ascii/screen:3') - replacement in text.lua at line 113[3.672]→[3.6847:6916](∅→∅),[3.6916]→[3.1529:1603](∅→∅),[3.1603]→[3.738:846](∅→∅),[3.6916]→[3.738:846](∅→∅),[3.738]→[3.738:846](∅→∅)
local b = Text.nearest_pos_less_than(frag, line_width - x)assert(b > 0) -- avoid infinite loop when window is too narrow--? print('space for '..tostring(b)..' graphemes')local frag1 = string.sub(frag, 1, b)local bpos = Text.nearest_pos_less_than(frag, line_width - x)assert(bpos > 0) -- avoid infinite loop when window is too narrowlocal boffset = utf8.offset(frag, bpos+1) -- byte _after_ bposassert(boffset)--? print('space for '..tostring(bpos)..' graphemes, '..tostring(boffset)..' bytes')local frag1 = string.sub(frag, 1, boffset-1) - replacement in text.lua at line 125
frag = string.sub(frag, b+1)frag = string.sub(frag, boffset) - edit in main.lua at line 197[11.337][10.302]
--? love.graphics.setColor(0, 1, 0)--? love.graphics.line(Line_width,0, Line_width,App.screen.height)