Clean up trailing whitespaces
This commit is contained in:
+29
-29
@@ -40,7 +40,7 @@ HistorySearch::~HistorySearch() {
|
||||
|
||||
void HistorySearch::search() {
|
||||
bool found = false;
|
||||
|
||||
|
||||
if (! m_regExp.isEmpty())
|
||||
{
|
||||
if (m_forwards) {
|
||||
@@ -48,10 +48,10 @@ void HistorySearch::search() {
|
||||
} else {
|
||||
found = search(0, 0, m_startColumn, m_startLine) || search(m_startColumn, m_startLine, -1, m_emulation->lineCount());
|
||||
}
|
||||
|
||||
|
||||
if (found) {
|
||||
emit matchFound(m_foundStartColumn, m_foundStartLine, m_foundEndColumn, m_foundEndLine);
|
||||
}
|
||||
}
|
||||
else {
|
||||
emit noMatchFound();
|
||||
}
|
||||
@@ -61,43 +61,43 @@ void HistorySearch::search() {
|
||||
}
|
||||
|
||||
bool HistorySearch::search(int startColumn, int startLine, int endColumn, int endLine) {
|
||||
qDebug() << "search from" << startColumn << "," << startLine
|
||||
qDebug() << "search from" << startColumn << "," << startLine
|
||||
<< "to" << endColumn << "," << endLine;
|
||||
|
||||
|
||||
int linesRead = 0;
|
||||
int linesToRead = endLine - startLine + 1;
|
||||
|
||||
|
||||
qDebug() << "linesToRead:" << linesToRead;
|
||||
|
||||
// We read process history from (and including) startLine to (and including) endLine in
|
||||
|
||||
// We read process history from (and including) startLine to (and including) endLine in
|
||||
// blocks of at most 10K lines so that we do not use unhealthy amounts of memory
|
||||
int blockSize;
|
||||
while ((blockSize = qMin(10000, linesToRead - linesRead)) > 0) {
|
||||
|
||||
|
||||
QString string;
|
||||
QTextStream searchStream(&string);
|
||||
PlainTextDecoder decoder;
|
||||
QTextStream searchStream(&string);
|
||||
PlainTextDecoder decoder;
|
||||
decoder.begin(&searchStream);
|
||||
decoder.setRecordLinePositions(true);
|
||||
|
||||
// Calculate lines to read and read them
|
||||
int blockStartLine = m_forwards ? startLine + linesRead : endLine - linesRead - blockSize + 1;
|
||||
// Calculate lines to read and read them
|
||||
int blockStartLine = m_forwards ? startLine + linesRead : endLine - linesRead - blockSize + 1;
|
||||
int chunkEndLine = blockStartLine + blockSize - 1;
|
||||
m_emulation->writeToStream(&decoder, blockStartLine, chunkEndLine);
|
||||
|
||||
// We search between startColumn in the first line of the string and endColumn in the last
|
||||
// line of the string. First we calculate the position (in the string) of endColumn in the
|
||||
|
||||
// We search between startColumn in the first line of the string and endColumn in the last
|
||||
// line of the string. First we calculate the position (in the string) of endColumn in the
|
||||
// last line of the string
|
||||
int endPosition;
|
||||
|
||||
// The String that Emulator.writeToStream produces has a newline at the end, and so ends with an
|
||||
|
||||
// The String that Emulator.writeToStream produces has a newline at the end, and so ends with an
|
||||
// empty line - we ignore that.
|
||||
int numberOfLinesInString = decoder.linePositions().size() - 1;
|
||||
int numberOfLinesInString = decoder.linePositions().size() - 1;
|
||||
if (numberOfLinesInString > 0 && endColumn > -1 )
|
||||
{
|
||||
endPosition = decoder.linePositions().at(numberOfLinesInString - 1) + endColumn;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
endPosition = string.size();
|
||||
}
|
||||
@@ -116,12 +116,12 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
|
||||
if (matchStart < startColumn)
|
||||
matchStart = -1;
|
||||
}
|
||||
|
||||
if (matchStart > -1)
|
||||
|
||||
if (matchStart > -1)
|
||||
{
|
||||
int matchEnd = matchStart + m_regExp.matchedLength() - 1;
|
||||
qDebug() << "Found in string from" << matchStart << "to" << matchEnd;
|
||||
|
||||
|
||||
// Translate startPos and endPos to startColum, startLine, endColumn and endLine in history.
|
||||
int startLineNumberInString = findLineNumberInString(decoder.linePositions(), matchStart);
|
||||
m_foundStartColumn = matchStart - decoder.linePositions().at(startLineNumberInString);
|
||||
@@ -136,17 +136,17 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
|
||||
<< "m_foundEndColumn" << m_foundEndColumn
|
||||
<< "m_foundEndLine" << m_foundEndLine;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
linesRead += blockSize;
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Not found";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int HistorySearch::findLineNumberInString(QList<int> linePositions, int position) {
|
||||
int lineNum = 0;
|
||||
@@ -154,4 +154,4 @@ int HistorySearch::findLineNumberInString(QList<int> linePositions, int position
|
||||
lineNum++;
|
||||
|
||||
return lineNum;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user