MauiKit Terminal
Filter.h
36 * A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)
39 * Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ),
40 * and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact
41 * action will depend on what is displaying the block of text which the filter is processing ), the hotspot's
42 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
44 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
45 * Hotspots may have more than one action, in which case the list of actions can be obtained using the
49 * Subclasses must reimplement the process() method to examine a block of text and identify sections of interest.
50 * When processing the text they should create instances of Filter::HotSpot subclasses for sections of interest
59 * Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ),
60 * and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact
61 * action will depend on what is displaying the block of text which the filter is processing ), the hotspot's
62 * activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.
64 * For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser.
65 * Hotspots may have more than one action, in which case the list of actions can be obtained using the
72 * Constructs a new hotspot which covers the area from (@p startLine,@p startColumn) to (@p endLine,@p endColumn)
174 * A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot
177 * Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression
184 * Type of hotspot created by RegExpFilter. The capturedTexts() method can be used to find the text
225 * Called when a match for the regular expression is encountered. Subclasses should reimplement this
228 virtual std::unique_ptr<HotSpot> newHotSpot(int startLine, int startColumn, int endLine, int endColumn);
326 /** Removes a filter from the chain. The chain will no longer delete the filter when destroyed */
364 void setImage(std::span<const Character> image, int lines, int columns, const QVector<LineProperty> &lineProperties);
A chain which allows a group of filters to be processed as one.
Definition Filter.h:320
bool containsFilter(Filter *filter)
Returns true if the chain contains filter.
Definition Filter.cpp:59
void addFilter(std::unique_ptr< Filter > &&filter)
Adds a new filter to the chain.
Definition Filter.cpp:47
Filter::HotSpot * hotSpotAt(int line, int column) const
Returns the first hotspot which occurs at line, column or 0 if no hotspot was found.
Definition Filter.cpp:90
QList< Filter::HotSpot > hotSpotsAtLine(int line) const
Returns a list of all hotspots at the given line in all the chain's filters.
QList< Filter::HotSpot * > hotSpots() const
Returns a list of all the hotspots in all the chain's filters.
Definition Filter.cpp:102
void setBuffer(const QString *buffer, const QList< int > *linePositions)
Sets the buffer for each filter in the chain to process.
Definition Filter.cpp:76
Represents an area of text which matched the pattern a particular filter has been looking for.
Definition Filter.h:69
virtual void activate(const QString &action=QString())=0
Causes the an action associated with a hotspot to be triggered.
int endColumn() const
Returns the column on endLine() where the hotspot area ends.
Definition Filter.cpp:291
virtual QList< QAction * > actions()
Returns a list of actions associated with the hotspot which can be used in a menu or toolbar.
Definition Filter.cpp:275
HotSpot(int startLine, int startColumn, int endLine, int endColumn)
Constructs a new hotspot which covers the area from (startLine,startColumn) to (endLine,...
Definition Filter.cpp:267
int startColumn() const
Returns the column on startLine() where the hotspot area starts.
Definition Filter.cpp:287
A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)...
Definition Filter.h:54
void setBuffer(const QString *buffer, const QList< int > *linePositions)
TODO: Document me.
Definition Filter.cpp:188
const std::vector< std::unique_ptr< HotSpot > > & hotSpots() const
Returns the list of hotspots identified by the filter.
Definition Filter.cpp:237
QList< HotSpot * > hotSpotsAtLine(int line) const
Returns the list of hotspots identified by the filter which occur on a given line.
Definition Filter.cpp:242
HotSpot * hotSpotAt(int line, int column) const
Adds a new line of text to the filter and increments the line count.
Definition Filter.cpp:251
void addHotSpot(std::unique_ptr< HotSpot > &&)
Adds a new hotspot to the list.
Definition Filter.cpp:228
virtual void process()=0
Causes the filter to process the block of text currently in its internal buffer.
void reset()
Empties the filters internal buffer and resets the line count back to 0.
Definition Filter.cpp:182
void getLineColumn(int position, int &startLine, int &startColumn)
Converts a character position within buffer() to a line and column.
Definition Filter.cpp:194
void activate(const QString &action=QString()) override
Causes the an action associated with a hotspot to be triggered.
Definition Filter.cpp:314
QStringList capturedTexts() const
Returns the texts found by the filter when matching the filter's regular expression.
Definition Filter.cpp:322
void setCapturedTexts(const QStringList &texts)
Sets the captured texts associated with this hotspot.
Definition Filter.cpp:318
A filter which searches for sections of text matching a regular expression and creates a new RegExpFi...
Definition Filter.h:181
void setRegExp(const QRegExp &text)
Sets the regular expression which the filter searches for in blocks of text.
Definition Filter.cpp:327
void process() override
Reimplemented to search the filter's text buffer for text matching regExp()
Definition Filter.cpp:339
virtual std::unique_ptr< HotSpot > newHotSpot(int startLine, int startColumn, int endLine, int endColumn)
Called when a match for the regular expression is encountered.
Definition Filter.cpp:377
QRegExp regExp() const
Returns the regular expression which the filter searches for in blocks of text.
Definition Filter.cpp:331
A filter chain which processes character images from terminal displays.
Definition Filter.h:351
void setImage(std::span< const Character > image, int lines, int columns, const QVector< LineProperty > &lineProperties)
Set the current terminal image to image.
Definition Filter.cpp:126
void activate(const QString &action=QString()) override
Open a web browser at the current URL.
Definition Filter.cpp:408
QList< QAction * > actions() override
Returns a list of actions associated with the hotspot which can be used in a menu or toolbar.
Definition Filter.cpp:475
std::unique_ptr< RegExpFilter::HotSpot > newHotSpot(int, int, int, int) override
Called when a match for the regular expression is encountered.
Definition Filter.cpp:382
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.