left/right cursor movement, deleting characters
[?]
May 17, 2022, 3:16 AM
IYW7X3WLOPYLSNO5IQNSULUNO4XFEM24DJ2VB5HPBUKWUYFPRCGQCDependencies
- [2]
OFA3PRBSautosave on keystrokes - [3]
NCRKBTHCposition cursor more precisely - [4]
XX7G2FFJintermingle freehand line drawings with text - [5]
6PUNJS5Bbackspace - [6]
JCSLDGAHbeginnings of support for multiple shapes - [7]
GVOFXXITdelete drawing using backspace - [8]
QW5KQQTDfix a comment - [9]
NL5J7Z5Hnew mode: polygon - [10]
7Q4B6M2Desc to cancel a shape mid-click - [11]
6LJZN727handle chords - [12]
KCIM5UTVrevert: back to freehand - [13]
ZOOY3ME4new mode: circle arc - [14]
2C7CTIQYmake space for multiple kinds of width - [15]
YKRF5V3Zstarting to load/save - [16]
QU7NHFOVshow cursor - [17]
G77XIN7Mselecting a stroke - [18]
WAZVXUV2simplest possible way to straighten strokes - [19]
OTIBCAUJlove2d scaffold - [20]
7RN3AETYbugfix: text sometimes getting colored like drawing borders - [21]
VXORMHMEdelete experimental REPL - [22]
3XD6M3CFrefactor - [23]
MNWHXPBLmore lightweight; select just the stroke at the mouse - [24]
HWPK4SMPnew mode: manhattan - [25]
H7OEU6WPexperimental approach to combining keyboard and mouse while drawing
Change contents
- replacement in main.lua at line 31
lines = {}lines = {''}cursor_line = 1-- this is a line-- ^cursor_pos = 1-- ^cursor_pos = 2-- ...-- ^cursor_pos past end of line is 15cursor_pos = #lines[cursor_line]+1 - replacement in main.lua at line 162
love.graphics.print('_', 25+text:getWidth()*1.5, y+6) -- drop the cursor down a bit to account for the increased font sizelocal line_before_cursor = lines[cursor_line]:sub(1, cursor_pos-1)local text_before_cursor = love.graphics.newText(love.graphics.getFont(), line_before_cursor)love.graphics.print('_', 25+text_before_cursor:getWidth()*1.5, y+6) -- drop the cursor down a bit to account for the increased font size - replacement in main.lua at line 496
lines[#lines] = lines[#lines]..tlocal byteoffsetif cursor_pos > 1 thenbyteoffset = utf8.offset(lines[cursor_line], cursor_pos-1)elsebyteoffset = 0endlines[cursor_line] = string.sub(lines[cursor_line], 1, byteoffset)..t..string.sub(lines[cursor_line], byteoffset+1)cursor_pos = cursor_pos+1 - replacement in main.lua at line 519
local byteoffset = utf8.offset(lines[#lines], -1)if byteoffset thenlines[#lines] = string.sub(lines[#lines], 1, byteoffset-1)if cursor_pos > 1 thenlocal byte_start = utf8.offset(lines[cursor_line], cursor_pos-1)local byte_end = utf8.offset(lines[cursor_line], cursor_pos)if byte_start thenif byte_end thenlines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)elselines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)endcursor_pos = cursor_pos-1endendendelseif chord == 'left' thenif cursor_pos > 1 thencursor_pos = cursor_pos - 1endelseif chord == 'right' thenif cursor_pos <= #lines[cursor_line] thencursor_pos = cursor_pos + 1endelseif chord == 'delete' thenif cursor_pos <= #lines[cursor_line] thenlocal byte_start = utf8.offset(lines[cursor_line], cursor_pos)local byte_end = utf8.offset(lines[cursor_line], cursor_pos+1)if byte_start thenif byte_end thenlines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)elselines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)end-- no change to cursor_pos