TextViewer: add Find (#9507)

This commit is contained in:
hius07
2022-09-14 00:09:49 +03:00
committed by GitHub
parent c3cd88e019
commit 56388aa491
8 changed files with 261 additions and 130 deletions

View File

@@ -144,6 +144,15 @@ function ScrollTextWidget:getCharPos()
return self.text_widget:getCharPos()
end
function ScrollTextWidget:getCharPosAtXY(x, y)
return self.text_widget:getCharPosAtXY(x, y)
end
function ScrollTextWidget:getCharPosLineNum(charpos)
local _, _, line_num = self.text_widget:_getXYForCharPos(charpos)
return line_num -- screen line number
end
function ScrollTextWidget:updateScrollBar(is_partial)
local low, high = self.text_widget:getVisibleHeightRatios()
if low ~= self.prev_low or high ~= self.prev_high then
@@ -187,8 +196,12 @@ function ScrollTextWidget:resetScroll()
self.v_scroll_bar.enable = visible_line_count < total_line_count
end
function ScrollTextWidget:moveCursorToCharPos(charpos)
self.text_widget:moveCursorToCharPos(charpos)
function ScrollTextWidget:moveCursorToCharPos(charpos, centered_lines_count)
if centered_lines_count then
self.text_widget:moveCursorToCharPosKeepingViewCentered(charpos, centered_lines_count)
else
self.text_widget:moveCursorToCharPos(charpos)
end
self:updateScrollBar()
end