Warning, file /utilities/konsole/src/filterHotSpots/TerminalImageFilterChain.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0003 SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #include "TerminalImageFilterChain.h" 0008 #include "profile/Profile.h" 0009 0010 #include <QTextStream> 0011 0012 #include "../decoders/PlainTextDecoder.h" 0013 0014 #include "terminalDisplay/TerminalDisplay.h" 0015 0016 using namespace Konsole; 0017 0018 TerminalImageFilterChain::TerminalImageFilterChain(TerminalDisplay *terminalDisplay) 0019 : FilterChain(terminalDisplay) 0020 , _buffer(nullptr) 0021 , _linePositions(nullptr) 0022 { 0023 } 0024 0025 TerminalImageFilterChain::~TerminalImageFilterChain() = default; 0026 0027 void TerminalImageFilterChain::setImage(const Character *const image, int lines, int columns, const QVector<LineProperty> &lineProperties) 0028 { 0029 if (_filters.empty()) { 0030 return; 0031 } 0032 0033 // reset all filters and hotspots 0034 reset(); 0035 0036 PlainTextDecoder decoder; 0037 decoder.setLeadingWhitespace(true); 0038 decoder.setTrailingWhitespace(true); 0039 0040 // setup new shared buffers for the filters to process on 0041 _buffer.reset(new QString()); 0042 _linePositions.reset(new QList<int>()); 0043 0044 setBuffer(_buffer.get(), _linePositions.get()); 0045 0046 QTextStream lineStream(_buffer.get()); 0047 decoder.begin(&lineStream); 0048 0049 for (int i = 0; i < lines; i++) { 0050 _linePositions->append(_buffer->length()); 0051 decoder.decodeLine(image + i * columns, columns, LineProperty()); 0052 0053 // pretend that each non-wrapped line ends with a newline character. 0054 // this prevents a link that occurs at the end of one line 0055 // being treated as part of a link that occurs at the start of the next line 0056 if ((lineProperties.value(i, LineProperty()).flags.f.wrapped) == 0) { 0057 lineStream << QLatin1Char('\n'); 0058 } 0059 } 0060 decoder.end(); 0061 }