Lua: Expose first and last visible block number

Change-Id: I69b6437dad21269e7623db528a5881d036e3dc87
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Krzysztof Chrusciel
2025-03-19 11:00:32 +01:00
parent 774c0214b1
commit 920279d389
2 changed files with 22 additions and 0 deletions

View File

@@ -466,6 +466,20 @@ void setupTextEditorModule()
textEditor && textEditor->editorWidget(),
throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->hasFocus();
},
"firstVisibleBlockNumber",
[](const TextEditorPtr &textEditor) -> int {
QTC_ASSERT(
textEditor && textEditor->editorWidget(),
throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->firstVisibleBlockNumber();
},
"lastVisibleBlockNumber",
[](const TextEditorPtr &textEditor) -> int {
QTC_ASSERT(
textEditor && textEditor->editorWidget(),
throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->lastVisibleBlockNumber();
});
result["Side"] = lua.create_table_with(

View File

@@ -237,6 +237,14 @@ function TextEditor:insertText(text) end
---@return boolean hasFocus True if the editor widget has focus, false otherwise.
function TextEditor:hasFocus() end
---Returns the block number of the first visible line in the text editor.
---@return integer blockNumber The block number of the first visible line.
function TextEditor:firstVisibleBlockNumber() end
---Returns the block number of the last visible line in the text editor.
---@return integer blockNumber The block number of the last visible line.
function TextEditor:lastVisibleBlockNumber() end
---Returns the current editor or nil.
---@return TextEditor|nil editor The currently active editor or nil if there is none.
function textEditor.currentEditor() end