Reverted cursor API to something more compatible with old API. (#1674)

* Reverted cursor API to something more compatible with old API.

* Implemented discord discussion.

* Reduced thiccness of overwrite cursor.
This commit is contained in:
Adam 2023-11-29 15:29:37 -05:00 committed by George Sokianos
parent f43cfc4a94
commit e14af4604a
1 changed files with 15 additions and 9 deletions

View File

@ -460,14 +460,16 @@ function DocView:draw_line_text(line, x, y)
return self:get_line_height()
end
function DocView:draw_caret(x, y, line, col)
function DocView:draw_overwrite_caret(x, y, width)
local lh = self:get_line_height()
renderer.draw_rect(x, y + lh - style.caret_width, width, style.caret_width, style.caret)
end
function DocView:draw_caret(x, y)
local lh = self:get_line_height()
if self.doc.overwrite then
local w = self:get_font():get_width(self.doc:get_char(line, col))
renderer.draw_rect(x, y + lh, w, style.caret_width * 2, style.caret)
else
renderer.draw_rect(x, y, style.caret_width, lh, style.caret)
end
end
function DocView:draw_line_body(line, x, y)
@ -547,7 +549,7 @@ function DocView:draw_ime_decoration(line1, col1, line2, col2)
line_size = style.caret_width
renderer.draw_rect(x + math.min(x1, x2), y + lh - line_size, math.abs(x1 - x2), line_size, style.caret)
end
self:draw_caret(x + x1, y, line1, col)
self:draw_caret(x + x1, y)
end
@ -565,7 +567,11 @@ function DocView:draw_overlay()
if config.disable_blink
or (core.blink_timer - core.blink_start) % T < T / 2 then
local x, y = self:get_line_screen_position(line1, col1)
self:draw_caret(x, y, line1, col1)
if self.doc.overwrite then
self:draw_overwrite_caret(x, y, self:get_font():get_width(self.doc:get_char(line1, col1)))
else
self:draw_caret(x, y)
end
end
end
end