• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. The KDE Frameworks
  3. KTextEditor
  • KDE Home
  • Contact Us

Quick Links

Skip menu "KTextEditor"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules
  • Dependencies
  • Related Pages

Class Picker

About

Advanced embeddable text editor

Maintainer
Christoph Cullmann
Supported platforms
FreeBSD, Linux, MacOSX, Windows
Community
IRC: #kde-devel on Freenode
Mailing list: kde-frameworks-devel
Use with CMake
find_package(KF5TextEditor)
target_link_libraries(yourapp KF5::TextEditor)
Use with QMake
QT += KTextEditor 
Clone
git clone git://anongit.kde.org/ktexteditor.git
Browse source
KTextEditor on cgit.kde.org

KTextEditor

  • View on LXR
  • KTextEditor
  • Variable
Public Types | Public Member Functions | List of all members
KTextEditor::Variable Class Reference

#include <variable.h>

Public Types

using ExpandFunction = std::function< QString(const QStringView &text, KTextEditor::View *view)>
 

Public Member Functions

 Variable ()=default
 
 Variable (const QString &name, const QString &description, ExpandFunction expansionFunc, bool isPrefixMatch)
 
 Variable (const Variable &copy)=default
 
QString description () const
 
QString evaluate (const QStringView &prefix, KTextEditor::View *view) const
 
bool isPrefixMatch () const
 
bool isValid () const
 
QString name () const
 
Variable & operator= (const Variable &copy)=default
 

Detailed Description

Variable for variable expansion.

Introduction

A Variable is used by the KTextEditor::Editor to expand variables, also know as expanding macros. A Variable itself is defined by the variable name() as well as a description() and a function that replaces the variable by its value.

To register a Variable in the Editor use either Editor::registerVariableMatch() or Editor::registerPrefixMatch().

See also
KTextEditor::Editor, KTextEditor::Editor::registerVariableMatch(), KTextEditor::Editor::registerPrefixMatch()
Author
Dominik Haumann <dhaum[email protected][email protected][email protected]kde.o[email protected]rg>

Definition at line 49 of file variable.h.

Member Typedef Documentation

using KTextEditor::Variable::ExpandFunction = std::function<QString(const QStringView &text, KTextEditor::View *view)>

Function that is called to expand a variable in text.

Parameters
text

Definition at line 56 of file variable.h.

Constructor & Destructor Documentation

KTextEditor::Variable::Variable ( )
default

Constructs an invalid Variable, see isValid().

KTextEditor::Variable::Variable ( const QString &  name,
const QString &  description,
Variable::ExpandFunction  func,
bool  isPrefixMatch 
)

Constructor defining a Variable by its name, its description, and its function expansionFunc to expand a variable to its corresponding value.

The parameter isPrefixMatch indicates whether this Variable represents an exact match (false) or a prefix match (true).

Note
The name should not be translated.

Definition at line 25 of file variable.cpp.

KTextEditor::Variable::Variable ( const Variable &  copy)
default

Copy constructor.

Member Function Documentation

QString KTextEditor::Variable::description ( ) const

Returns the description that was provided in the constructor.

Definition at line 48 of file variable.cpp.

QString KTextEditor::Variable::evaluate ( const QStringView &  prefix,
KTextEditor::View *  view 
) const

Expands the Variable to its value.

As example for an exact match, a variable "CurerntDocument:Cursor:Line" uses the view to return the current line of the text cursor. In this case prefix equals the text of the variable itself, i.e. "CurerntDocument:Cursor:Line".

As example of a prefix match, a variable "ENV:value" expands the environment value value, e.g. "ENV:HOME". In this case, the prefix equals the text "ENV:HOME" and view would be unused.

Returns
the expanded variable.

Definition at line 53 of file variable.cpp.

bool KTextEditor::Variable::isPrefixMatch ( ) const

Returns whether this Variable represents an exact match (false) or a prefix match (true).

Definition at line 38 of file variable.cpp.

bool KTextEditor::Variable::isValid ( ) const

Returns true, if the name is non-empty and the function provided in the constructor is not a nullptr.

Definition at line 33 of file variable.cpp.

QString KTextEditor::Variable::name ( ) const

Returns the name that was provided in the constructor.

Depending on where the Variable is registered, this name is used to identify an exact match or a prefix match.

Definition at line 43 of file variable.cpp.

Variable& KTextEditor::Variable::operator= ( const Variable &  copy)
default

Assignment operator.


The documentation for this class was generated from the following files:
  • variable.h
  • variable.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Thu Dec 12 2019 02:25:30 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal