+66
-1
@@ -16,7 +16,11 @@
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <QLayout>
|
||||
#include <QtGui/qboxlayout.h>
|
||||
#include <QtGui/qlayoutitem.h>
|
||||
#include <QtGui/qsizepolicy.h>
|
||||
#include "SearchBar.h"
|
||||
#include "qtermwidget.h"
|
||||
#include "ColorTables.h"
|
||||
|
||||
@@ -27,6 +31,7 @@
|
||||
#include "TerminalDisplay.h"
|
||||
#include "KeyboardTranslator.h"
|
||||
#include "ColorScheme.h"
|
||||
#include "SearchBar.h"
|
||||
|
||||
#define STEP_ZOOM 3
|
||||
|
||||
@@ -121,6 +126,47 @@ void QTermWidget::selectionChanged(bool textSelected)
|
||||
emit copyAvailable(textSelected);
|
||||
}
|
||||
|
||||
void QTermWidget::search(QRegExp regexp, bool forwards, bool next)
|
||||
{
|
||||
int startColumn, startLine;
|
||||
|
||||
if (next) // search from end of current selection
|
||||
{
|
||||
m_impl->m_terminalDisplay->screenWindow()->screen()->getSelectionEnd(startColumn, startLine);
|
||||
}
|
||||
else // search from start of current selection
|
||||
{
|
||||
m_impl->m_terminalDisplay->screenWindow()->screen()->getSelectionStart(startColumn, startLine);
|
||||
}
|
||||
|
||||
qDebug() << "current selection starts at: " << startColumn << startLine;
|
||||
qDebug() << "current cursor position: " << m_impl->m_terminalDisplay->screenWindow()->cursorPosition();
|
||||
|
||||
|
||||
HistorySearch *historySearch =
|
||||
new HistorySearch(m_impl->m_session->emulation(), regexp, forwards, startColumn, startLine, this);
|
||||
connect(historySearch, SIGNAL(matchFound(int, int, int, int)), this, SLOT(matchFound(int, int, int, int)));
|
||||
connect(historySearch, SIGNAL(noMatchFound()), this, SLOT(noMatchFound()));
|
||||
historySearch->search();
|
||||
}
|
||||
|
||||
|
||||
void QTermWidget::matchFound(int startColumn, int startLine, int endColumn, int endLine)
|
||||
{
|
||||
ScreenWindow* sw = m_impl->m_terminalDisplay->screenWindow();
|
||||
qDebug() << "Scroll to" << startLine;
|
||||
sw->scrollTo(startLine);
|
||||
sw->setTrackOutput(false);
|
||||
sw->notifyOutputChanged();
|
||||
sw->setSelectionStart(startColumn, startLine - sw->currentLine(), false);
|
||||
sw->setSelectionEnd(endColumn, endLine - sw->currentLine());
|
||||
}
|
||||
|
||||
void QTermWidget::noMatchFound()
|
||||
{
|
||||
m_impl->m_terminalDisplay->screenWindow()->clearSelection();
|
||||
}
|
||||
|
||||
int QTermWidget::getShellPID()
|
||||
{
|
||||
return m_impl->m_session->processId();
|
||||
@@ -163,7 +209,19 @@ void QTermWidget::startShellProgram()
|
||||
|
||||
void QTermWidget::init(int startnow)
|
||||
{
|
||||
m_layout = new QVBoxLayout();
|
||||
m_layout->setMargin(0);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_impl = new TermWidgetImpl(this);
|
||||
m_impl->m_terminalDisplay->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
m_layout->addWidget(m_impl->m_terminalDisplay);
|
||||
|
||||
m_searchBar = new SearchBar(this);
|
||||
m_searchBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
|
||||
connect(m_searchBar, SIGNAL(search(QRegExp, bool, bool)), this, SLOT(search(QRegExp, bool, bool)));
|
||||
m_layout->addWidget(m_searchBar);
|
||||
m_searchBar->hide();
|
||||
|
||||
if (startnow && m_impl->m_session) {
|
||||
m_impl->m_session->run();
|
||||
@@ -188,6 +246,8 @@ void QTermWidget::init(int startnow)
|
||||
font.setPointSize(10);
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
setTerminalFont(font);
|
||||
m_searchBar->setFont(font);
|
||||
|
||||
setScrollBarPosition(NoScrollBar);
|
||||
|
||||
m_impl->m_session->addView(m_impl->m_terminalDisplay);
|
||||
@@ -386,6 +446,11 @@ QString QTermWidget::keyBindings()
|
||||
return m_impl->m_session->keyBindings();
|
||||
}
|
||||
|
||||
void QTermWidget::toggleShowSearchBar()
|
||||
{
|
||||
m_searchBar->toggleShown();
|
||||
}
|
||||
|
||||
bool QTermWidget::flowControlEnabled(void)
|
||||
{
|
||||
return m_impl->m_session->flowControlEnabled();
|
||||
|
||||
Reference in New Issue
Block a user