GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Filter.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007, 2013 by Robert Knight <robertknight@gmail.com>
3 
4  Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
5  Adoption to octave by Torsten <mttl@mailbox.org>, Copyright (c) 2017
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301 USA.
21 */
22 
23 // Own
24 #include "unix/Filter.h"
25 
26 // System
27 #include <iostream>
28 
29 // Qt
30 #include <QDesktopServices>
31 #include <QAction>
32 #include <QApplication>
33 #include <QClipboard>
34 #include <QtCore/QString>
35 
36 #include <QtCore/QSharedData>
37 #include <QtCore>
38 
39 // Konsole
41 
43 {
44  QMutableListIterator<Filter*> iter(*this);
45 
46  while ( iter.hasNext() )
47  {
48  Filter* filter = iter.next();
49  iter.remove();
50  delete filter;
51  }
52 }
53 
55 {
56  append(filter);
57 }
59 {
60  removeAll(filter);
61 }
63 {
64  return contains(filter);
65 }
67 {
68  QListIterator<Filter*> iter(*this);
69  while (iter.hasNext())
70  iter.next()->reset();
71 }
72 void FilterChain::setBuffer(const QString* buffer , const QList<int>* linePositions)
73 {
74  QListIterator<Filter*> iter(*this);
75  while (iter.hasNext())
76  iter.next()->setBuffer(buffer,linePositions);
77 }
79 {
80  QListIterator<Filter*> iter(*this);
81  while (iter.hasNext())
82  iter.next()->process();
83 }
85 {
87 }
89 {
90  QListIterator<Filter*> iter(*this);
91  while (iter.hasNext())
92  {
93  Filter* filter = iter.next();
94  Filter::HotSpot* spot = filter->hotSpotAt(line,column);
95  if ( spot != nullptr )
96  {
97  return spot;
98  }
99  }
100 
101  return nullptr;
102 }
103 
105 {
107  QListIterator<Filter*> iter(*this);
108  while (iter.hasNext())
109  {
110  Filter* filter = iter.next();
111  list << filter->hotSpots();
112  }
113  return list;
114 }
115 
117 : _buffer(nullptr)
118 , _linePositions(nullptr)
119 {
120 }
121 
123 {
124  delete _buffer;
125  delete _linePositions;
126 }
127 
128 void TerminalImageFilterChain::setImage(const Character* const image , int lines , int columns, const QVector<LineProperty>& lineProperties)
129 {
130 //qDebug("%s %d", __FILE__, __LINE__);
131  if (empty())
132  return;
133 //qDebug("%s %d", __FILE__, __LINE__);
134 
135  // reset all filters and hotspots
136  reset();
137 //qDebug("%s %d", __FILE__, __LINE__);
138 
139  PlainTextDecoder decoder;
140  decoder.setTrailingWhitespace(false);
141 
142 //qDebug("%s %d", __FILE__, __LINE__);
143  // setup new shared buffers for the filters to process on
144  QString* newBuffer = new QString();
145  QList<int>* newLinePositions = new QList<int>();
146  setBuffer( newBuffer , newLinePositions );
147 
148  // free the old buffers
149  delete _buffer;
150  delete _linePositions;
151 
152  _buffer = newBuffer;
153  _linePositions = newLinePositions;
154 
155  QTextStream lineStream(_buffer);
156  decoder.begin(&lineStream);
157 
158  for (int i=0 ; i < lines ; i++)
159  {
160  _linePositions->append(_buffer->length());
161  decoder.decodeLine(image + i*columns,columns,LINE_DEFAULT);
162 
163  // pretend that each line ends with a newline character.
164  // this prevents a link that occurs at the end of one line
165  // being treated as part of a link that occurs at the start of the next line
166  //
167  // the downside is that links which are spread over more than one line are not
168  // highlighted.
169  //
170  // TODO - Use the "line wrapped" attribute associated with lines in a
171  // terminal image to avoid adding this imaginary character for wrapped
172  // lines
173  if ( !(lineProperties.value(i,LINE_DEFAULT) & LINE_WRAPPED) )
174  lineStream << QChar('\n');
175  }
176  decoder.end();
177 // qDebug("%s %d", __FILE__, __LINE__);
178 }
179 
181 _linePositions(nullptr),
182 _buffer(nullptr)
183 {
184 }
185 
187 {
188  QListIterator<HotSpot*> iter(_hotspotList);
189  while (iter.hasNext())
190  {
191  delete iter.next();
192  }
193 }
195 {
196  _hotspots.clear();
197  _hotspotList.clear();
198 }
199 
200 void Filter::setBuffer(const QString* buffer , const QList<int>* linePositions)
201 {
202  _buffer = buffer;
203  _linePositions = linePositions;
204 }
205 
206 void Filter::getLineColumn(int position , int& startLine , int& startColumn)
207 {
208  Q_ASSERT( _linePositions );
209  Q_ASSERT( _buffer );
210 
211 
212  for (int i = 0 ; i < _linePositions->count() ; i++)
213  {
214  //kDebug() << "line position at " << i << " = " << _linePositions[i];
215  int nextLine = 0;
216 
217  if ( i == _linePositions->count()-1 )
218  {
219  nextLine = _buffer->length() + 1;
220  }
221  else
222  {
223  nextLine = _linePositions->value(i+1);
224  }
225 
226  // kDebug() << "pos - " << position << " line pos(" << i<< ") " << _linePositions->value(i) <<
227  // " next = " << nextLine << " buffer len = " << _buffer->length();
228 
229  if ( _linePositions->value(i) <= position && position < nextLine )
230  {
231  startLine = i;
232  startColumn = position - _linePositions->value(i);
233  return;
234  }
235  }
236 }
237 
238 
239 /*void Filter::addLine(const QString& text)
240 {
241  _linePositions << _buffer.length();
242  _buffer.append(text);
243 }*/
244 
245 const QString* Filter::buffer()
246 {
247  return _buffer;
248 }
250 {
251 }
253 {
254  _hotspotList << spot;
255 
256  for (int line = spot->startLine() ; line <= spot->endLine() ; line++)
257  {
258  _hotspots.insert(line,spot);
259  }
260 }
262 {
263  return _hotspotList;
264 }
266 {
267  return _hotspots.values(line);
268 }
269 
271 {
272  QListIterator<HotSpot*> spotIter(_hotspots.values(line));
273 
274  while (spotIter.hasNext())
275  {
276  HotSpot* spot = spotIter.next();
277 
278  if ( spot->startLine() == line && spot->startColumn() > column )
279  continue;
280  if ( spot->endLine() == line && spot->endColumn() < column )
281  continue;
282 
283  return spot;
284  }
285 
286  return nullptr;
287 }
288 
289 Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int endColumn)
290  : _startLine(startLine)
291  , _startColumn(startColumn)
292  , _endLine(endLine)
293  , _endColumn(endColumn)
294  , _type(NotSpecified)
295 {
296 }
298 {
299  return QString();
300 }
302 {
303  return QList<QAction*>();
304 }
306 {
307  return _startLine;
308 }
310 {
311  return _endLine;
312 }
314 {
315  return _startColumn;
316 }
318 {
319  return _endColumn;
320 }
322 {
323  return _type;
324 }
326 {
327  _type = type;
328 }
329 
331  : _type (t)
332 {
333 }
334 
335 RegExpFilter::HotSpot::HotSpot(int startLine,int startColumn,
336  int endLine,int endColumn, Filter::Type t)
337  : Filter::HotSpot(startLine,startColumn,endLine,endColumn)
338 {
339  setType(t);
340 }
341 
343 {
344 }
345 
346 void RegExpFilter::HotSpot::setCapturedTexts(const QStringList& texts)
347 {
348  _capturedTexts = texts;
349 }
351 {
352  return _capturedTexts;
353 }
354 
355 void RegExpFilter::setRegExp(const QRegExp& regExp)
356 {
358 }
359 QRegExp RegExpFilter::regExp() const
360 {
361  return _searchText;
362 }
363 /*void RegExpFilter::reset(int)
364 {
365  _buffer = QString();
366 }*/
368 {
369  int pos = 0;
370  const QString* text = buffer();
371 
372  Q_ASSERT( text );
373 
374  // ignore any regular expressions which match an empty string.
375  // otherwise the while loop below will run indefinitely
376  static const QString emptyString("");
377  if ( _searchText.exactMatch(emptyString) )
378  return;
379 
380  while(pos >= 0)
381  {
382  pos = _searchText.indexIn(*text,pos);
383 
384  if ( pos >= 0 )
385  {
386 
387  int startLine = 0;
388  int endLine = 0;
389  int startColumn = 0;
390  int endColumn = 0;
391 
392 
393  //kDebug() << "pos from " << pos << " to " << pos + _searchText.matchedLength();
394 
395  getLineColumn(pos,startLine,startColumn);
396  getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn);
397 
398  RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn,
399  endLine,endColumn,_type);
400  spot->setCapturedTexts(_searchText.capturedTexts());
401 
402  addHotSpot( spot );
403  pos += _searchText.matchedLength();
404 
405  // if matchedLength == 0, the program will get stuck in an infinite loop
406  Q_ASSERT( _searchText.matchedLength() > 0 );
407  }
408  }
409 }
410 
411 RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn,
412  int endLine,int endColumn,
413  Filter::Type t)
414 {
415  return new RegExpFilter::HotSpot(startLine,startColumn,
416  endLine,endColumn, t);
417 }
418 UrlFilter::HotSpot* UrlFilter::newHotSpot(int startLine,int startColumn,int endLine,
419  int endColumn, Filter::Type t)
420 {
421  return new UrlFilter::HotSpot(startLine,startColumn,
422  endLine,endColumn,t);
423 }
424 
426 {
427  int pos = 0;
428  const QString* text = buffer();
429 
430  Q_ASSERT( text );
431 
432  // ignore any regular expressions which match an empty string.
433  // otherwise the while loop below will run indefinitely
434  static const QString emptyString("");
435  if ( _searchText.exactMatch(emptyString) )
436  return;
437 
438  while(pos >= 0)
439  {
440  pos = _searchText.indexIn(*text,pos);
441 
442  if ( pos >= 0 )
443  {
444 
445  int startLine = 0;
446  int endLine = 0;
447  int startColumn = 0;
448  int endColumn = 0;
449 
450 
451  //kDebug() << "pos from " << pos << " to " << pos + _searchText.matchedLength();
452 
453  getLineColumn(pos,startLine,startColumn);
454  getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn);
455 
456  UrlFilter::HotSpot* spot = newHotSpot(startLine,startColumn,
457  endLine,endColumn,_type);
458  spot->setCapturedTexts(_searchText.capturedTexts());
459 
460  // Connect the signal of the urlobject to the slot of the filter;
461  // the filter is then signaling to the main window
462  connect (spot->get_urlObject (),
463  SIGNAL (request_open_file_signal (const QString&, int)),
464  this, SLOT (request_open_file (const QString&, int)));
465 
466  addHotSpot( spot );
467  pos += _searchText.matchedLength();
468 
469  // if matchedLength == 0, the program will get stuck in an infinite loop
470  Q_ASSERT( _searchText.matchedLength() > 0 );
471  }
472  }
473 }
474 
475 UrlFilter::HotSpot::HotSpot(int startLine,int startColumn,
476  int endLine,int endColumn,Type t)
477 : RegExpFilter::HotSpot(startLine,startColumn,endLine,endColumn,t)
478 , _urlObject(new FilterObject(this))
479 {
480 }
481 
483 {
484  QString url = capturedTexts().first();
485 
486  const UrlType kind = urlType();
487 
488  if ( kind == StandardUrl )
489  return QString();
490  else if ( kind == Email )
491  return QString();
492  else
493  return QString();
494 }
496 {
497  QString url = capturedTexts().first();
498 
499  if ( FullUrlRegExp.exactMatch(url) )
500  return StandardUrl;
501  else if ( EmailAddressRegExp.exactMatch(url) )
502  return Email;
503  else if ( ErrorLinkRegExp.exactMatch(url) )
504  return ErrorLink;
505  else if ( ParseErrorLinkRegExp.exactMatch(url) )
506  return ParseErrorLink;
507  else
508  return Unknown;
509 }
510 
512 {
513  QString url = capturedTexts().first();
514 
515  const UrlType kind = urlType();
516 
517  const QString& actionName = object ? object->objectName() : QString();
518 
519  if ( actionName == "copy-action" )
520  {
521  //kDebug() << "Copying url to clipboard:" << url;
522 
523  QApplication::clipboard()->setText(url);
524  return;
525  }
526 
527  if ( !object || actionName == "open-action" )
528  {
529  if ( kind == StandardUrl )
530  {
531  // if the URL path does not include the protocol ( eg. "www.kde.org" ) then
532  // prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" )
533  if (!url.contains("://"))
534  url.prepend("http://");
535  QDesktopServices::openUrl (QUrl (url));
536  }
537  else if ( kind == Email )
538  {
539  url.prepend("mailto:");
540  QDesktopServices::openUrl (QUrl (url));
541  }
542  else if (kind == ErrorLink)
543  {
544  int pos = ErrorLinkRegExp.indexIn (url);
545  if (pos > -1)
546  {
547  QString file_name = ErrorLinkRegExp.cap (1);
548  QString line = ErrorLinkRegExp.cap (2);
549  // call the urlobject's method for opening a file; this
550  // method then signals to the filter
551  _urlObject->request_open_file (file_name, line.toInt ());
552  }
553  }
554  else if (kind == ParseErrorLink)
555  {
556  int pos = ParseErrorLinkRegExp.indexIn (url);
557  if (pos > -1)
558  {
559  QString line = ParseErrorLinkRegExp.cap (1);
560  QString file_name = ParseErrorLinkRegExp.cap (2);
561  // call the urlobject's method for opening a file; this
562  // method then signals to the filter
563  _urlObject->request_open_file (file_name, line.toInt ());
564  }
565  }
566 
567 
568  }
569 
570 }
571 
572 // Note: Altering these regular expressions can have a major effect on the performance of the filters
573 // used for finding URLs in the text, especially if they are very general and could match very long
574 // pieces of text.
575 // Please be careful when altering them.
576 
577 //regexp matches:
578 // full url:
579 // protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot
580 const QRegExp UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]");
581 // email address:
582 // [word chars, dots or dashes]@[word chars, dots or dashes].[word chars]
583 const QRegExp UrlFilter::EmailAddressRegExp("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b");
584 // matches full url or email address
585 const QRegExp UrlFilter::CompleteUrlRegExp('('+FullUrlRegExp.pattern()+'|'+
586  EmailAddressRegExp.pattern()+')');
587 // error link:
588 // normal error
589 const QRegExp UrlFilter::ErrorLinkRegExp ("(\\S+) at line (\\d+) column (?:\\d+)");
590 // parse error
591 const QRegExp UrlFilter::ParseErrorLinkRegExp ("parse error near line (\\d+) of file (\\S+)");
592 // complete regexp
593 const QRegExp UrlFilter::CompleteErrorLinkRegExp ('('+ErrorLinkRegExp.pattern ()+'|'+
594  ParseErrorLinkRegExp.pattern ()+')');
595 
596 
598  : RegExpFilter (t)
599 {
600  if (_type == ErrorLink)
602  else
604 }
606 {
607  delete _urlObject;
608 }
610 {
611  _filter->activate(sender());
612 }
614 {
616 
617  const UrlType kind = urlType();
618 
619  QAction* openAction = new QAction(_urlObject);
620  QAction* copyAction = new QAction(_urlObject);;
621 
622  Q_ASSERT (kind == StandardUrl || kind == Email
623  || kind == ErrorLink
624  || kind == ParseErrorLink);
625 
626  if ( kind == StandardUrl )
627  {
628  openAction->setText(tr ("Open Link"));
629  copyAction->setText(tr ("Copy Link Address"));
630  }
631  else if ( kind == Email )
632  {
633  openAction->setText(tr ("Send Email To..."));
634  copyAction->setText(tr ("Copy Email Address"));
635  }
636  else if ( kind == ErrorLink )
637  {
638  QString url = capturedTexts().first();
639  int pos = ErrorLinkRegExp.indexIn (url);
640  if (pos >= 0)
641  {
642  QString file_name = ErrorLinkRegExp.cap (1);
643  QString line = ErrorLinkRegExp.cap (2);
644  openAction->setText(tr ("Edit %1 at line %2")
645  .arg (file_name).arg (line));
646  }
647  }
648  else if ( kind == ParseErrorLink )
649  {
650  QString url = capturedTexts().first();
651  int pos = ParseErrorLinkRegExp.indexIn (url);
652  if (pos >= 0)
653  {
654  QString line = ParseErrorLinkRegExp.cap (1);
655  QString file_name = ParseErrorLinkRegExp.cap (2);
656  openAction->setText(tr ("Edit %1 at line %2")
657  .arg (file_name).arg (line));
658  }
659  }
660 
661  // object names are set here so that the hotspot performs the
662  // correct action when activated() is called with the triggered
663  // action passed as a parameter.
664  openAction->setObjectName("open-action");
665  copyAction->setObjectName("copy-action");
666 
667  QObject::connect( openAction , SIGNAL(triggered()) , _urlObject , SLOT(activated()) );
668  list << openAction;
669 
670  if (kind != ErrorLink && kind != ParseErrorLink)
671  {
672  QObject::connect ( copyAction , SIGNAL(triggered()) ,
673  _urlObject , SLOT(activated()) );
674  list << copyAction;
675  }
676  return list;
677 }
678 
679 void
681 {
682  QFileInfo file_info = QFileInfo (file);
683 
684  // We have to distinguish between a parse error, where we get the full
685  // path of the file or a general error in a script, where we only get
686  // the function name. depending on this we have to invoke different
687  // slots in main_window
688  if (file_info.isAbsolute () && file_info.exists ())
690  else
692 }
693 
694 //#include "moc_Filter.cpp"
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:301
const QList< int > * _linePositions
Definition: Filter.h:188
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
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...
Definition: Filter.cpp:297
void addHotSpot(HotSpot *)
Adds a new hotspot to the list.
Definition: Filter.cpp:252
virtual ~Filter()
Definition: Filter.cpp:186
void reset()
Resets each filter in the chain.
Definition: Filter.cpp:66
void clear()
Removes all filters from the chain.
Definition: Filter.cpp:84
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
Definition: oct-hist.cc:734
QRegExp regExp() const
Returns the regular expression which the filter searches for in blocks of text.
Definition: Filter.cpp:359
const QString * buffer()
Returns the internal buffer.
Definition: Filter.cpp:245
static const QRegExp CompleteErrorLinkRegExp
Definition: Filter.h:323
virtual ~HotSpot()
Definition: Filter.cpp:605
Type _type
Definition: Filter.h:257
A single character in the terminal which consists of a unicode character value, foreground and backgr...
Definition: Character.h:55
int endLine() const
Returns the line where the hotspot area ends.
Definition: Filter.cpp:309
void request_open_file_signal(const QString &, int)
void addFilter(Filter *filter)
Adds a new filter to the chain.
Definition: Filter.cpp:54
void getLineColumn(int position, int &startLine, int &startColumn)
Converts a character position within buffer() to a line and column.
Definition: Filter.cpp:206
void request_edit_mfile_signal(const QString &, int)
bool containsFilter(Filter *filter)
Returns true if the chain contains filter.
Definition: Filter.cpp:62
QList< HotSpot * > hotSpots() const
Returns the list of hotspots identified by the filter.
Definition: Filter.cpp:261
static const QRegExp ErrorLinkRegExp
Definition: Filter.h:321
A filter which searches for sections of text matching a regular expression and creates a new RegExpFi...
Definition: Filter.h:199
QList< int > * _linePositions
Definition: Filter.h:413
virtual ~TerminalImageFilterChain()
Definition: Filter.cpp:122
int startColumn() const
Returns the column on startLine() where the hotspot area starts.
Definition: Filter.cpp:313
Type type() const
Returns the type of the hotspot.
Definition: Filter.cpp:321
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
virtual void activate(QObject *object=nullptr)
Open a web browser at the current URL.
Definition: Filter.cpp:511
A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list)...
Definition: Filter.h:55
void process()
Processes each filter in the chain.
Definition: Filter.cpp:78
QStringList capturedTexts() const
Returns the texts found by the filter when matching the filter&#39;s regular expression.
Definition: Filter.cpp:350
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.
Definition: Filter.cpp:289
octave_value arg
Definition: pr-output.cc:3244
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:613
const QString * _buffer
Definition: Filter.h:189
QList< HotSpot * > _hotspotList
Definition: Filter.h:186
virtual void process()
Reimplemented to search the filter&#39;s text buffer for text matching regExp()
Definition: Filter.cpp:367
static const int LINE_WRAPPED
Definition: Character.h:37
void setBuffer(const QString *buffer, const QList< int > *linePositions)
Sets the buffer for each filter in the chain to process.
Definition: Filter.cpp:72
A terminal character decoder which produces plain text, ignoring colours and other appearance-related...
virtual ~FilterChain()
Definition: Filter.cpp:42
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
Definition: ov-struct.cc:1736
virtual void process()
Reimplemented to search the filter&#39;s text buffer for text matching regExp()
Definition: Filter.cpp:425
void reset()
Empties the filters internal buffer and resets the line count back to 0.
Definition: Filter.cpp:194
QList< HotSpot * > hotSpotsAtLine(int line) const
Returns the list of hotspots identified by the filter which occur on a given line.
Definition: Filter.cpp:265
RegExpFilter(Type)
Constructs a new regular expression filter.
Definition: Filter.cpp:330
void setType(Type type)
Sets the type of a hotspot.
Definition: Filter.cpp:325
Filter()
Constructs a new filter.
Definition: Filter.cpp:180
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...
Definition: Filter.cpp:482
static const QRegExp EmailAddressRegExp
Definition: Filter.h:320
void setRegExp(const QRegExp &text)
Sets the regular expression which the filter searches for in blocks of text.
Definition: Filter.cpp:355
QRegExp _searchText
Definition: Filter.h:259
static const QRegExp FullUrlRegExp
Definition: Filter.h:319
bool append
Definition: load-save.cc:1618
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
Definition: matrix_type.cc:120
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:88
void request_open_file(const QString &, int)
Definition: Filter.cpp:680
virtual ~HotSpot()
Definition: Filter.cpp:249
idx type
Definition: ov.cc:3114
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
Definition: filter.cc:43
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...
std::string url
Definition: urlwrite.cc:118
void removeFilter(Filter *filter)
Removes a filter from the chain.
Definition: Filter.cpp:58
UrlType urlType() const
Definition: Filter.cpp:495
Type of hotspot created by RegExpFilter.
Definition: Filter.h:209
UrlFilter(Type t=Link)
Definition: Filter.cpp:597
void setTrailingWhitespace(bool enable)
Set whether trailing whitespace at the end of lines should be included in the output.
static const QRegExp CompleteUrlRegExp
Definition: Filter.h:326
void setImage(const Character *const image, int lines, int columns, const QVector< LineProperty > &lineProperties)
Set the current terminal image to image.
Definition: Filter.cpp:128
HotSpot * hotSpotAt(int line, int column) const
Adds a new line of text to the filter and increments the line count.
Definition: Filter.cpp:270
Type
Represents an area of text which matched the pattern a particular filter has been looking for...
Definition: Filter.h:74
virtual RegExpFilter::HotSpot * newHotSpot(int startLine, int startColumn, int endLine, int endColumn, Type)
Called when a match for the regular expression is encountered.
Definition: Filter.cpp:411
HotSpot(int startLine, int startColumn, int endLine, int endColumn, Type t)
Definition: Filter.cpp:475
void activated()
Definition: Filter.cpp:609
static const int LINE_DEFAULT
Definition: Character.h:36
HotSpot(int startLine, int startColumn, int endLine, int endColumn, Filter::Type)
Definition: Filter.cpp:335
for i
Definition: data.cc:5264
void setBuffer(const QString *buffer, const QList< int > *linePositions)
TODO: Document me.
Definition: Filter.cpp:200
static const QRegExp ParseErrorLinkRegExp
Definition: Filter.h:322
int startLine() const
Returns the line when the hotspot area starts.
Definition: Filter.cpp:305
virtual void end()
End decoding.
int endColumn() const
Returns the column on endLine() where the hotspot area ends.
Definition: Filter.cpp:317
FilterObject * _urlObject
Definition: Filter.h:304
virtual void activate(QObject *object=nullptr)
Causes the an action associated with a hotspot to be triggered.
Definition: Filter.cpp:342
void setCapturedTexts(const QStringList &texts)
Sets the captured texts associated with this hotspot.
Definition: Filter.cpp:346
virtual HotSpot * newHotSpot(int, int, int, int, Type)
Called when a match for the regular expression is encountered.
Definition: Filter.cpp:418
QMultiHash< int, HotSpot * > _hotspots
Definition: Filter.h:185
virtual void begin(QTextStream *output)
Begin decoding characters.
QList< Filter::HotSpot * > hotSpots() const
Returns a list of all the hotspots in all the chain&#39;s filters.
Definition: Filter.cpp:104
Hotspot type created by UrlFilter instances.
Definition: Filter.h:275