Lua: Add font getter method to TextDocument lua type

Change-Id: I60da4f51f2ddc7b930b827f721818210610ea115
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Artur Twardy
2024-10-31 12:38:37 +01:00
parent cc8d9c2655
commit 0e5145730d
2 changed files with 9 additions and 0 deletions

View File

@@ -353,6 +353,11 @@ void setupTextEditorModule()
QTC_ASSERT(document, throw sol::error("TextDocument is not valid")); QTC_ASSERT(document, throw sol::error("TextDocument is not valid"));
return document->filePath(); return document->filePath();
}, },
"font",
[](const TextDocumentPtr &document) {
QTC_ASSERT(document, throw sol::error("TextDocument is not valid"));
return document->fontSettings().font();
},
"blockAndColumn", "blockAndColumn",
[](const TextDocumentPtr &document, int position) -> std::optional<std::pair<int, int>> { [](const TextDocumentPtr &document, int position) -> std::optional<std::pair<int, int>> {
QTC_ASSERT(document, throw sol::error("TextDocument is not valid")); QTC_ASSERT(document, throw sol::error("TextDocument is not valid"));

View File

@@ -78,6 +78,10 @@ local TextDocument = {}
---@return FilePath filePath The file path of the document. ---@return FilePath filePath The file path of the document.
function TextDocument:file() end function TextDocument:file() end
---Returns the font of the document.
---@return QFont
function TextDocument:font() end
---Returns the block (line) and column for the given position. ---Returns the block (line) and column for the given position.
---@param position integer The position to convert. ---@param position integer The position to convert.
---@return integer block The block (line) of the position. ---@return integer block The block (line) of the position.