30 #include <QDesktopServices> 32 #include <QApplication> 34 #include <QtCore/QString> 36 #include <QtCore/QSharedData> 44 QMutableListIterator<Filter*> iter(*
this);
46 while ( iter.hasNext() )
68 QListIterator<Filter*> iter(*
this);
69 while (iter.hasNext())
74 QListIterator<Filter*> iter(*
this);
75 while (iter.hasNext())
76 iter.next()->setBuffer(buffer,linePositions);
80 QListIterator<Filter*> iter(*
this);
81 while (iter.hasNext())
82 iter.next()->process();
90 QListIterator<Filter*> iter(*
this);
91 while (iter.hasNext())
95 if ( spot !=
nullptr )
107 QListIterator<Filter*> iter(*
this);
108 while (iter.hasNext())
118 , _linePositions(nullptr)
144 QString* newBuffer =
new QString();
146 setBuffer( newBuffer , newLinePositions );
155 QTextStream lineStream(
_buffer);
156 decoder.
begin(&lineStream);
158 for (
int i=0 ;
i < lines ;
i++)
174 lineStream << QChar(
'\n');
181 _linePositions(nullptr),
189 while (iter.hasNext())
219 nextLine =
_buffer->length() + 1;
256 for (
int line = spot->startLine() ;
line <= spot->endLine() ;
line++)
274 while (spotIter.hasNext())
276 HotSpot* spot = spotIter.next();
290 : _startLine(startLine)
291 , _startColumn(startColumn)
293 , _endColumn(endColumn)
348 _capturedTexts = texts;
352 return _capturedTexts;
376 static const QString emptyString(
"");
399 endLine,endColumn,
_type);
400 spot->setCapturedTexts(
_searchText.capturedTexts());
412 int endLine,
int endColumn,
416 endLine,endColumn,
t);
422 endLine,endColumn,
t);
434 static const QString emptyString(
"");
457 endLine,endColumn,
_type);
458 spot->setCapturedTexts(
_searchText.capturedTexts());
462 connect (spot->get_urlObject (),
464 this, SLOT (request_open_file (
const QString&,
int)));
476 int endLine,
int endColumn,
Type t)
484 QString
url = capturedTexts().first();
486 const UrlType kind = urlType();
488 if ( kind == StandardUrl )
490 else if ( kind == Email )
497 QString
url = capturedTexts().first();
506 return ParseErrorLink;
513 QString
url = capturedTexts().first();
515 const UrlType kind = urlType();
517 const QString& actionName =
object ?
object->objectName() : QString();
519 if ( actionName ==
"copy-action" )
523 QApplication::clipboard()->setText(
url);
527 if ( !
object || actionName ==
"open-action" )
529 if ( kind == StandardUrl )
533 if (!
url.contains(
"://"))
534 url.prepend(
"http://");
535 QDesktopServices::openUrl (QUrl (
url));
537 else if ( kind == Email )
539 url.prepend(
"mailto:");
540 QDesktopServices::openUrl (QUrl (
url));
551 _urlObject->request_open_file (file_name,
line.toInt ());
554 else if (kind == ParseErrorLink)
563 _urlObject->request_open_file (file_name,
line.toInt ());
611 _filter->activate(sender());
617 const UrlType kind = urlType();
619 QAction* openAction =
new QAction(_urlObject);
620 QAction* copyAction =
new QAction(_urlObject);;
622 Q_ASSERT (kind == StandardUrl || kind == Email
624 || kind == ParseErrorLink);
626 if ( kind == StandardUrl )
628 openAction->setText(tr (
"Open Link"));
629 copyAction->setText(tr (
"Copy Link Address"));
631 else if ( kind == Email )
633 openAction->setText(tr (
"Send Email To..."));
634 copyAction->setText(tr (
"Copy Email Address"));
638 QString
url = capturedTexts().first();
644 openAction->setText(tr (
"Edit %1 at line %2")
648 else if ( kind == ParseErrorLink )
650 QString
url = capturedTexts().first();
656 openAction->setText(tr (
"Edit %1 at line %2")
664 openAction->setObjectName(
"open-action");
665 copyAction->setObjectName(
"copy-action");
667 QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
670 if (kind !=
ErrorLink && kind != ParseErrorLink)
672 QObject::connect ( copyAction , SIGNAL(triggered()) ,
673 _urlObject , SLOT(activated()) );
682 QFileInfo file_info = QFileInfo (
file);
688 if (file_info.isAbsolute () && file_info.exists ())
virtual QList< QAction * > actions()
Returns a list of actions associated with the hotspot which can be used in a menu or toolbar...
const QList< int > * _linePositions
OCTAVE_EXPORT octave_value_list column
For example cd octave end example noindent changes the current working directory to file
virtual QString tooltip() const
Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or an empty string i...
void addHotSpot(HotSpot *)
Adds a new hotspot to the list.
void reset()
Resets each filter in the chain.
void clear()
Removes all filters from the chain.
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
QRegExp regExp() const
Returns the regular expression which the filter searches for in blocks of text.
const QString * buffer()
Returns the internal buffer.
static const QRegExp CompleteErrorLinkRegExp
A single character in the terminal which consists of a unicode character value, foreground and backgr...
int endLine() const
Returns the line where the hotspot area ends.
void request_open_file_signal(const QString &, int)
void addFilter(Filter *filter)
Adds a new filter to the chain.
void getLineColumn(int position, int &startLine, int &startColumn)
Converts a character position within buffer() to a line and column.
void request_edit_mfile_signal(const QString &, int)
bool containsFilter(Filter *filter)
Returns true if the chain contains filter.
QList< HotSpot * > hotSpots() const
Returns the list of hotspots identified by the filter.
static const QRegExp ErrorLinkRegExp
A filter which searches for sections of text matching a regular expression and creates a new RegExpFi...
QList< int > * _linePositions
virtual ~TerminalImageFilterChain()
int startColumn() const
Returns the column on startLine() where the hotspot area starts.
Type type() const
Returns the type of the hotspot.
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
virtual void activate(QObject *object=nullptr)
Open a web browser at the current URL.
A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)...
void process()
Processes each filter in the chain.
QStringList capturedTexts() const
Returns the texts found by the filter when matching the filter's regular expression.
HotSpot(int startLine, int startColumn, int endLine, int endColumn)
Constructs a new hotspot which covers the area from (startLine,startColumn) to (endLine,endColumn) in a block of text.
virtual QList< QAction * > actions()
Returns a list of actions associated with the hotspot which can be used in a menu or toolbar...
QList< HotSpot * > _hotspotList
virtual void process()
Reimplemented to search the filter's text buffer for text matching regExp()
static const int LINE_WRAPPED
void setBuffer(const QString *buffer, const QList< int > *linePositions)
Sets the buffer for each filter in the chain to process.
A terminal character decoder which produces plain text, ignoring colours and other appearance-related...
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
virtual void process()
Reimplemented to search the filter's text buffer for text matching regExp()
void reset()
Empties the filters internal buffer and resets the line count back to 0.
QList< HotSpot * > hotSpotsAtLine(int line) const
Returns the list of hotspots identified by the filter which occur on a given line.
RegExpFilter(Type)
Constructs a new regular expression filter.
void setType(Type type)
Sets the type of a hotspot.
Filter()
Constructs a new filter.
virtual QString tooltip() const
Returns the text of a tooltip to be shown when the mouse moves over the hotspot, or an empty string i...
TerminalImageFilterChain()
static const QRegExp EmailAddressRegExp
void setRegExp(const QRegExp &text)
Sets the regular expression which the filter searches for in blocks of text.
static const QRegExp FullUrlRegExp
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
Filter::HotSpot * hotSpotAt(int line, int column) const
Returns the first hotspot which occurs at line, column or 0 if no hotspot was found.
void request_open_file(const QString &, int)
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)
Converts a line of terminal characters with associated properties into a text string and writes the s...
void removeFilter(Filter *filter)
Removes a filter from the chain.
Type of hotspot created by RegExpFilter.
void setTrailingWhitespace(bool enable)
Set whether trailing whitespace at the end of lines should be included in the output.
static const QRegExp CompleteUrlRegExp
void setImage(const Character *const image, int lines, int columns, const QVector< LineProperty > &lineProperties)
Set the current terminal image to image.
HotSpot * hotSpotAt(int line, int column) const
Adds a new line of text to the filter and increments the line count.
Type
Represents an area of text which matched the pattern a particular filter has been looking for...
virtual RegExpFilter::HotSpot * newHotSpot(int startLine, int startColumn, int endLine, int endColumn, Type)
Called when a match for the regular expression is encountered.
HotSpot(int startLine, int startColumn, int endLine, int endColumn, Type t)
static const int LINE_DEFAULT
HotSpot(int startLine, int startColumn, int endLine, int endColumn, Filter::Type)
void setBuffer(const QString *buffer, const QList< int > *linePositions)
TODO: Document me.
static const QRegExp ParseErrorLinkRegExp
int startLine() const
Returns the line when the hotspot area starts.
virtual void end()
End decoding.
int endColumn() const
Returns the column on endLine() where the hotspot area ends.
FilterObject * _urlObject
virtual void activate(QObject *object=nullptr)
Causes the an action associated with a hotspot to be triggered.
void setCapturedTexts(const QStringList &texts)
Sets the captured texts associated with this hotspot.
virtual HotSpot * newHotSpot(int, int, int, int, Type)
Called when a match for the regular expression is encountered.
QMultiHash< int, HotSpot * > _hotspots
virtual void begin(QTextStream *output)
Begin decoding characters.
QList< Filter::HotSpot * > hotSpots() const
Returns a list of all the hotspots in all the chain's filters.
Hotspot type created by UrlFilter instances.