diff --git a/src/plugins/lua/bindings/texteditor.cpp b/src/plugins/lua/bindings/texteditor.cpp index d1601969e5e..bd42fb59cd2 100644 --- a/src/plugins/lua/bindings/texteditor.cpp +++ b/src/plugins/lua/bindings/texteditor.cpp @@ -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( diff --git a/src/plugins/lua/meta/texteditor.lua b/src/plugins/lua/meta/texteditor.lua index b832fe5c497..71346f34ffe 100644 --- a/src/plugins/lua/meta/texteditor.lua +++ b/src/plugins/lua/meta/texteditor.lua @@ -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