Various search improvements

- Do not automatically reset the search start line on search hits
    This was causing the annoying behavior that if you were to pause while typing
    in a search term, and it would actually find a hit, then you would be searching
    for the term a second time once you finish typing.

    This commit introduces two new behaviors:
    1. When you show the search bar, all searching will be done from the first
        visible line in the terminal.
    2. This start position is only reset when you
        advance to the next result, by pressing "next", "previous", or the shortcuts
        RETURN or SHIFT-RETURN

- When the view scrolls to a result, it will appear centered.
- When showing the search bar, do not invoke a search, only apply the highlight filters
- Add "search from beginning/end" button
    This will scroll to the top/bottom before searching
    Ctrl+return is also bound to this action
- Text highlighted by mouse will be set as the current search text when the incremental
    search bar is opened
- Add "Search backwards" to search bar options
    Button text is swapped according to reverse search switch
This commit is contained in:
Harald Hvaal
2013-07-27 09:39:27 +02:00
parent 6f8316eb8e
commit aa42a27ef3
8 changed files with 268 additions and 56 deletions

View File

@@ -32,10 +32,12 @@ ScreenWindow::ScreenWindow(QObject* parent)
, _bufferNeedsUpdate(true)
, _windowLines(1)
, _currentLine(0)
, _currentResultLine(-1)
, _trackOutput(true)
, _scrollCount(0)
{
}
ScreenWindow::~ScreenWindow()
{
delete[] _windowBuffer;
@@ -211,6 +213,21 @@ int ScreenWindow::currentLine() const
return qBound(0, _currentLine, lineCount() - windowLines());
}
int ScreenWindow::currentResultLine() const
{
return _currentResultLine;
}
void ScreenWindow::setCurrentResultLine(int line)
{
if (_currentResultLine == line) {
return;
}
_currentResultLine = line;
emit currentResultLineChanged();
}
void ScreenWindow::scrollBy(RelativeScrollMode mode, int amount, bool fullPage)
{
if (mode == ScrollLines) {