support 2 cursors yet again
This time we assume that while a position may map to multiple rects, only one of them will actually show the character.
This commit is contained in:
parent
9d8a518085
commit
208cc02ed8
2
edit.lua
2
edit.lua
|
@ -157,7 +157,7 @@ function edit.draw(editor)
|
|||
love.graphics.print(c.data, editor.left+c.x, y+c.y)
|
||||
end
|
||||
if line_index == editor.cursor.line then
|
||||
if c.pos == editor.cursor.pos and c.show_cursor then
|
||||
if c.pos == editor.cursor.pos then
|
||||
Text.draw_cursor(editor, editor.left+c.x, y+c.y)
|
||||
end
|
||||
end
|
||||
|
|
10
move.lua
10
move.lua
|
@ -282,7 +282,7 @@ function edit.to_coord(editor, loc) -- scans
|
|||
-- text
|
||||
for _,s in ipairs(rect.screen_line_rects) do
|
||||
for _,c in ipairs(s.char_rects) do
|
||||
if c.pos == loc.pos and c.show_cursor then
|
||||
if c.pos == loc.pos and c.data then
|
||||
return editor.left + c.x, y + c.y
|
||||
end
|
||||
end
|
||||
|
@ -557,7 +557,7 @@ function Text.get_rect(editor, loc)
|
|||
if char:match('%s') then
|
||||
if Text.line_wrap_at_word_boundary(editor, editor.left + x, line.data, pos) then
|
||||
table.insert(curr_screen_line,
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char, show_cursor=true}) -- char
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char}) -- char
|
||||
table.insert(curr_screen_line,
|
||||
{x=x+w, y=y, dx=editor.width-x-w, dy=editor.line_height, pos=pos+1}) -- filler
|
||||
table.insert(screen_lines,
|
||||
|
@ -572,7 +572,7 @@ function Text.get_rect(editor, loc)
|
|||
end
|
||||
else
|
||||
table.insert(curr_screen_line,
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char, show_cursor=true})
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char})
|
||||
x = x + w
|
||||
end
|
||||
else
|
||||
|
@ -594,12 +594,12 @@ function Text.get_rect(editor, loc)
|
|||
-- nothing
|
||||
end
|
||||
table.insert(curr_screen_line,
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char, show_cursor=true})
|
||||
{x=x, y=y, dx=w, dy=editor.line_height, pos=pos, data=char})
|
||||
x = x + w
|
||||
end
|
||||
end
|
||||
table.insert(curr_screen_line,
|
||||
{x=x, y=y, dx=editor.width-x, dy=editor.line_height, pos=utf8.len(line.data)+1, show_cursor=true}) -- filler
|
||||
{x=x, y=y, dx=editor.width-x, dy=editor.line_height, pos=utf8.len(line.data)+1}) -- filler
|
||||
table.insert(screen_lines,
|
||||
{x=0, y=y, dx=editor.width, dy=editor.line_height,
|
||||
pos=spos, dpos=utf8.len(line.data)+1-spos+1, char_rects=curr_screen_line})
|
||||
|
|
Loading…
Reference in New Issue