forked from qt-creator/qt-creator
LUA: Add hasSuggestionLocked() method to TextEditor and clenaup
Change-Id: Iff0c1af586b69c930c55327f70a513ef94a5f879 Reviewed-by: Artur Twardy Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -149,16 +149,6 @@ void setupTextEditorModule()
|
|||||||
return TextEditor::BaseTextEditor::currentTextEditor();
|
return TextEditor::BaseTextEditor::currentTextEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
result["currentSuggestion"] = []() -> TextEditor::CyclicSuggestion * {
|
|
||||||
if (const auto *textEditor = TextEditor::BaseTextEditor::currentTextEditor()) {
|
|
||||||
if (const TextEditor::TextEditorWidget *widget = textEditor->editorWidget())
|
|
||||||
return dynamic_cast<TextEditor::CyclicSuggestion *>(widget->currentSuggestion());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
result.new_usertype<TextEditor::CyclicSuggestion>("CyclicSuggestion", sol::no_constructor);
|
|
||||||
|
|
||||||
result.new_usertype<MultiTextCursor>(
|
result.new_usertype<MultiTextCursor>(
|
||||||
"MultiTextCursor",
|
"MultiTextCursor",
|
||||||
sol::no_constructor,
|
sol::no_constructor,
|
||||||
@@ -249,6 +239,11 @@ void setupTextEditorModule()
|
|||||||
[](const TextEditorPtr &textEditor) {
|
[](const TextEditorPtr &textEditor) {
|
||||||
QTC_ASSERT(textEditor, throw sol::error("TextEditor is not valid"));
|
QTC_ASSERT(textEditor, throw sol::error("TextEditor is not valid"));
|
||||||
return textEditor->editorWidget()->multiTextCursor();
|
return textEditor->editorWidget()->multiTextCursor();
|
||||||
|
},
|
||||||
|
"hasLockedSuggestion",
|
||||||
|
[](const TextEditorPtr &textEditor) {
|
||||||
|
QTC_ASSERT(textEditor, throw sol::error("TextEditor is not valid"));
|
||||||
|
return textEditor->editorWidget()->suggestionVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
result.new_usertype<TextEditor::TextSuggestion::Data>(
|
result.new_usertype<TextEditor::TextSuggestion::Data>(
|
||||||
|
@@ -60,13 +60,6 @@ local Suggestion = {}
|
|||||||
---@return Suggestion suggestion The created suggestion.
|
---@return Suggestion suggestion The created suggestion.
|
||||||
function Suggestion:create(startLine, startCharacter, endLine, endCharacter, text) end
|
function Suggestion:create(startLine, startCharacter, endLine, endCharacter, text) end
|
||||||
|
|
||||||
---@class CyclicSuggestion
|
|
||||||
local CyclicSuggestion = {}
|
|
||||||
|
|
||||||
---@return boolean True if the suggestion is locked, false otherwise.
|
|
||||||
---Suggestion is locked when the user selects it and already started applying it partially.
|
|
||||||
function CyclicSuggestion:isLocked() end
|
|
||||||
|
|
||||||
---@class TextDocument
|
---@class TextDocument
|
||||||
local TextDocument = {}
|
local TextDocument = {}
|
||||||
|
|
||||||
@@ -106,12 +99,13 @@ function TextEditor:cursor() end
|
|||||||
---@param position integer The position in the document where the widget should appear.
|
---@param position integer The position in the document where the widget should appear.
|
||||||
function TextEditor:addFloatingWidget(widget, position) end
|
function TextEditor:addFloatingWidget(widget, position) end
|
||||||
|
|
||||||
|
---Checks if the current suggestion is locked. The suggestion is locked when the user can use it.
|
||||||
|
---@return boolean True if the suggestion is locked, false otherwise.
|
||||||
|
function TextEditor:hasLockedSuggestion() end
|
||||||
|
|
||||||
---Returns the current editor or nil.
|
---Returns the current editor or nil.
|
||||||
---@return TextEditor|nil editor The currently active editor or nil if there is none.
|
---@return TextEditor|nil editor The currently active editor or nil if there is none.
|
||||||
function textEditor.currentEditor() end
|
function textEditor.currentEditor() end
|
||||||
|
|
||||||
---Returns the current suggestion of the current editor if available.
|
|
||||||
---@return CyclicSuggestion|nil suggestion The current suggestion if available. Otherwise nil.
|
|
||||||
function textEditor.currentSuggestion() end
|
|
||||||
|
|
||||||
return textEditor
|
return textEditor
|
||||||
|
Reference in New Issue
Block a user