scrollToEnd() method provided to trigger 'snapping' the terminal to cursor tracked position (typically the extreme value of the scrollbar, or the 'end')
Some signal-fu particular to keyPressEvent(QKeyEvent *) done to make the above usable, no existing dependent implementations should be disturbed by this.
This commit is contained in:
@@ -1684,6 +1684,16 @@ void TerminalDisplay::setScroll(int cursor, int slines)
|
||||
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
|
||||
}
|
||||
|
||||
void TerminalDisplay::scrollToEnd()
|
||||
{
|
||||
disconnect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
|
||||
_scrollBar->setValue( _scrollBar->maximum() );
|
||||
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
|
||||
|
||||
_screenWindow->scrollTo( _scrollBar->value() + 1 );
|
||||
_screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() );
|
||||
}
|
||||
|
||||
void TerminalDisplay::setScrollBarPosition(ScrollBarPosition position)
|
||||
{
|
||||
if (_scrollbarLocation == position)
|
||||
|
||||
@@ -117,6 +117,11 @@ public:
|
||||
*/
|
||||
void setScroll(int cursor, int lines);
|
||||
|
||||
/**
|
||||
* Scroll to the bottom of the terminal (reset scrolling).
|
||||
*/
|
||||
void scrollToEnd();
|
||||
|
||||
/**
|
||||
* Returns the display's filter chain. When the image for the display is updated,
|
||||
* the text is passed through each filter in the chain. Each filter can define
|
||||
|
||||
@@ -120,6 +120,8 @@ QTermWidget::QTermWidget(int startnow, QWidget *parent)
|
||||
this, SIGNAL(termGetFocus()));
|
||||
connect(m_impl->m_terminalDisplay, SIGNAL(termLostFocus()),
|
||||
this, SIGNAL(termLostFocus()));
|
||||
connect(m_impl->m_terminalDisplay, SIGNAL(keyPressedSignal(QKeyEvent *)),
|
||||
this, SIGNAL(termKeyPressed(QKeyEvent *)));
|
||||
}
|
||||
|
||||
void QTermWidget::selectionChanged(bool textSelected)
|
||||
@@ -284,6 +286,13 @@ void QTermWidget::setScrollBarPosition(ScrollBarPosition pos)
|
||||
m_impl->m_terminalDisplay->setScrollBarPosition((TerminalDisplay::ScrollBarPosition)pos);
|
||||
}
|
||||
|
||||
void QTermWidget::scrollToEnd()
|
||||
{
|
||||
if (!m_impl->m_terminalDisplay)
|
||||
return;
|
||||
m_impl->m_terminalDisplay->scrollToEnd();
|
||||
}
|
||||
|
||||
void QTermWidget::sendText(QString &text)
|
||||
{
|
||||
m_impl->m_session->sendText(text);
|
||||
|
||||
@@ -92,6 +92,9 @@ public:
|
||||
// Presence of scrollbar
|
||||
void setScrollBarPosition(ScrollBarPosition);
|
||||
|
||||
// Wrapped, scroll to end.
|
||||
void scrollToEnd();
|
||||
|
||||
// Send some text to terminal
|
||||
void sendText(QString & text);
|
||||
|
||||
@@ -121,6 +124,8 @@ signals:
|
||||
void termGetFocus();
|
||||
void termLostFocus();
|
||||
|
||||
void termKeyPressed(QKeyEvent *);
|
||||
|
||||
public slots:
|
||||
// Paste clipboard content to terminal
|
||||
void copyClipboard();
|
||||
|
||||
Reference in New Issue
Block a user