Commit ae1a5607 authored by Robert Knight's avatar Robert Knight

Implement Find Next / Find Previous.

svn path=/branches/work/konsole-split-view/; revision=657453
parent bb8c2a6b
......@@ -1243,6 +1243,32 @@ void Screen::clearSelection()
sel_begin = -1;
}
void Screen::getSelectionStart(int& column , int& line)
{
if ( sel_TL != -1 )
{
column = sel_TL % columns;
line = sel_TL / columns;
}
else
{
column = cuX + getHistLines();
line = cuY + getHistLines();
}
}
void Screen::getSelectionEnd(int& column , int& line)
{
if ( sel_BR != -1 )
{
column = sel_BR % columns;
line = sel_BR / columns;
}
else
{
column = cuX + getHistLines();
line = cuY + getHistLines();
}
}
void Screen::setSelectionStart(/*const ScreenCursor& viewCursor ,*/ const int x, const int y, const bool mode)
{
// kDebug(1211) << "setSelBeginXY(" << x << "," << y << ")" << endl;
......
......@@ -233,7 +233,19 @@ public: // these are all `Screen' operations
* @param line The line index of the last character in the selection.
*/
void setSelectionEnd(/*const ScreenCursor& cursor ,*/ const int column, const int line);
/**
* Retrieves the start of the selection or the cursor position if there
* is no selection.
*/
void getSelectionStart(int& column , int& line);
/**
* Retrieves the end of the selection or the cursor position if there
* is no selection.
*/
void getSelectionEnd(int& column , int& line);
/** Clears the current selection */
void clearSelection();
......
......@@ -62,6 +62,16 @@ QString ScreenWindow::selectedText( bool preserveLineBreaks ) const
return _screen->selectedText( preserveLineBreaks );
}
void ScreenWindow::getSelectionStart( int& column , int& line )
{
_screen->getSelectionStart(column,line);
line -= _currentLine;
}
void ScreenWindow::getSelectionEnd( int& column , int& line )
{
_screen->getSelectionEnd(column,line);
line -= _currentLine;
}
void ScreenWindow::setSelectionStart( int column , int line , bool columnMode )
{
/* FIXME - I'm not sure what the columnmode parameter ( the last argument to setSelectionStart )
......
......@@ -111,6 +111,14 @@ public:
* the window.
*/
void setSelectionEnd( int column , int line );
/**
* Retrieves the start of the selection within the window.
*/
void getSelectionStart( int& column , int& line );
/**
* Retrieves the end of the selection within the window.
*/
void getSelectionEnd( int& column , int& line );
/**
* Returns true if the character at @p line , @p column is part of the selection.
*/
......
......@@ -868,13 +868,17 @@ void SearchHistoryTask::execute()
Emulation* emulation = sessions().first()->emulation();
int selectionColumn = 0;
int selectionLine = 0;
_screenWindow->getSelectionEnd(selectionColumn , selectionLine);
if ( !_regExp.isEmpty() )
{
const int startLine = _screenWindow->currentLine();
int pos = -1;
int findPos = -1;
const bool forwards = ( _direction == Forwards );
const int startLine = selectionLine + _screenWindow->currentLine() + ( forwards ? 1 : -1 );
const int lastLine = _screenWindow->lineCount() - 1;
QString string;
......@@ -900,13 +904,13 @@ void SearchHistoryTask::execute()
else
_regExp.setPatternSyntax(QRegExp::FixedString);
int endLine = -1;
int endLine = line;
bool hasWrapped = false; // set to true when we reach the top/bottom
// of the output and continue from the other
// end
//loop through history in blocks of <delta> lines.
while ( endLine != startLine )
do
{
QApplication::processEvents();
......@@ -961,7 +965,8 @@ void SearchHistoryTask::execute()
//update display to show area of history containing selection
_screenWindow->scrollTo(findPos);
_screenWindow->setSelectionStart( 0 , findPos - _screenWindow->currentLine() , false );
_screenWindow->setSelectionEnd( _screenWindow->columnCount() , findPos - _screenWindow->currentLine() );
//qDebug() << "Current line " << _screenWindow->currentLine();
_screenWindow->setTrackOutput(false);
_screenWindow->notifyOutputChanged();
......@@ -973,7 +978,8 @@ void SearchHistoryTask::execute()
//clear the current block of text and move to the next one
string.clear();
line = endLine;
}
} while ( startLine != endLine );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment