mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 10:41:14 +00:00
Merge pull request #1932 from weaveworks/1481-scroll-lock-terminals
Enable scroll locking on the terminal
This commit is contained in:
@@ -142,7 +142,12 @@ class Terminal extends React.Component {
|
||||
socket.onmessage = (event) => {
|
||||
log('pipe data', event.data.size);
|
||||
const input = ab2str(event.data);
|
||||
const scrolledToBottom = term.ydisp === term.ybase;
|
||||
const savedScrollPosition = term.ydisp;
|
||||
term.write(input);
|
||||
if (!scrolledToBottom) {
|
||||
this.scrollTo(savedScrollPosition);
|
||||
}
|
||||
};
|
||||
|
||||
this.socket = socket;
|
||||
@@ -154,6 +159,19 @@ class Terminal extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
scrollToBottom() {
|
||||
this.scrollTo(this.term.ybase);
|
||||
}
|
||||
|
||||
scrollTo(y) {
|
||||
if (!this.term) {
|
||||
return;
|
||||
}
|
||||
this.term.ydisp = y;
|
||||
this.term.emit('scroll', y);
|
||||
this.term.refresh(0, this.term.rows - 1);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._isMounted = true;
|
||||
if (this.props.connect) {
|
||||
@@ -167,12 +185,14 @@ class Terminal extends React.Component {
|
||||
cols: this.state.cols,
|
||||
rows: this.state.rows,
|
||||
convertEol: !this.props.raw,
|
||||
cursorBlink: true
|
||||
cursorBlink: true,
|
||||
scrollback: 10000,
|
||||
});
|
||||
|
||||
const innerNode = ReactDOM.findDOMNode(component.innerFlex);
|
||||
this.term.open(innerNode);
|
||||
this.term.on('data', (data) => {
|
||||
this.scrollToBottom();
|
||||
if (this.socket) {
|
||||
this.socket.send(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user