KTextEditor

variable.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "variable.h"
8
9namespace KTextEditor
10{
12 : m_name(name)
13 , m_description(description)
14 , m_function(std::move(func))
15 , m_isPrefixMatch(isPrefixMatch)
16{
17}
18
20{
21 return (!m_name.isEmpty()) && (m_function != nullptr);
22}
23
25{
26 return m_isPrefixMatch;
27}
28
30{
31 return m_name;
32}
33
35{
36 return m_description;
37}
38
40{
41 return isValid() ? m_function(prefix, view) : QString();
42}
43
44}
std::function< QString(const QStringView &text, KTextEditor::View *view)> ExpandFunction
Function that is called to expand a variable in text.
Definition variable.h:41
QString evaluate(const QStringView &prefix, KTextEditor::View *view) const
Expands the Variable to its value.
Definition variable.cpp:39
bool isValid() const
Returns true, if the name is non-empty and the function provided in the constructor is not a nullptr.
Definition variable.cpp:19
Variable()=default
Constructs an invalid Variable, see isValid().
QString description() const
Returns the description that was provided in the constructor.
Definition variable.cpp:34
bool isPrefixMatch() const
Returns whether this Variable represents an exact match (false) or a prefix match (true).
Definition variable.cpp:24
QString name() const
Returns the name that was provided in the constructor.
Definition variable.cpp:29
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:55:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.