From 0e5145730d092b357801e3554e685d16ca660c0a Mon Sep 17 00:00:00 2001 From: Artur Twardy Date: Thu, 31 Oct 2024 12:38:37 +0100 Subject: [PATCH] Lua: Add font getter method to TextDocument lua type Change-Id: I60da4f51f2ddc7b930b827f721818210610ea115 Reviewed-by: Marcus Tillmanns --- src/plugins/lua/bindings/texteditor.cpp | 5 +++++ src/plugins/lua/meta/texteditor.lua | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/plugins/lua/bindings/texteditor.cpp b/src/plugins/lua/bindings/texteditor.cpp index 0a28984a199..a774f1d6cbf 100644 --- a/src/plugins/lua/bindings/texteditor.cpp +++ b/src/plugins/lua/bindings/texteditor.cpp @@ -353,6 +353,11 @@ void setupTextEditorModule() QTC_ASSERT(document, throw sol::error("TextDocument is not valid")); return document->filePath(); }, + "font", + [](const TextDocumentPtr &document) { + QTC_ASSERT(document, throw sol::error("TextDocument is not valid")); + return document->fontSettings().font(); + }, "blockAndColumn", [](const TextDocumentPtr &document, int position) -> std::optional> { QTC_ASSERT(document, throw sol::error("TextDocument is not valid")); diff --git a/src/plugins/lua/meta/texteditor.lua b/src/plugins/lua/meta/texteditor.lua index fa63c0880cd..cb62a6e473d 100644 --- a/src/plugins/lua/meta/texteditor.lua +++ b/src/plugins/lua/meta/texteditor.lua @@ -78,6 +78,10 @@ local TextDocument = {} ---@return FilePath filePath The file path of the document. 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. ---@param position integer The position to convert. ---@return integer block The block (line) of the position.