Option to set the scroll-back buffer size for viewers

This adds default scroll-back buffer size for xterm.js to be set
to 1024 and option to configure different values.
pull/5/head
Faruk Kasumovic 4 years ago
parent 3920a560c5
commit a3683a2341

File diff suppressed because one or more lines are too long

@ -11,7 +11,8 @@
window.ttyInitialData = {
sessionID: {{.SessionID}},
salt: {{.Salt}},
wsPath: {{.WSPath}}
wsPath: {{.WSPath}},
scrollBack: {{.ScrollBack}}
}
console.log("Initial data", window.ttyInitialData)
</script>

@ -25,4 +25,8 @@ let ttyWindow = window as any;
wsAddress += ttyWindow.location.host + ttyWindow.ttyInitialData.wsPath;
const ttyReceiver = new TTYReceiver(wsAddress, document.getElementById('terminal') as HTMLDivElement);
const ttyReceiver = new TTYReceiver(
wsAddress,
document.getElementById('terminal') as HTMLDivElement,
ttyWindow.ttyInitialData.scrollBack
);

@ -11,13 +11,13 @@ class TTYReceiver {
private xterminal: Terminal;
private containerElement: HTMLElement;
constructor(wsAddress: string, container: HTMLDivElement) {
constructor(wsAddress: string, container: HTMLDivElement, scrollback: number) {
const connection = new WebSocket(wsAddress);
this.xterminal = new Terminal({
cursorBlink: true,
macOptionIsMeta: true,
scrollback: 0,
scrollback: scrollback,
fontSize: 12,
letterSpacing: 0,
});

@ -24,9 +24,10 @@ var log = MainLogger
// SessionTemplateModel used for templating
type SessionTemplateModel struct {
SessionID string
Salt string
WSPath string
SessionID string
Salt string
WSPath string
ScrollBack int
}
// TTYServerConfig is used to configure the tty server before it is started
@ -38,6 +39,7 @@ type TTYServerConfig struct {
TLSCertFile string
TLSKeyFile string
FrontendPath string
ScrollBack int
}
// TTYServer represents the instance of a tty server
@ -186,9 +188,10 @@ func (server *TTYServer) handleSession(w http.ResponseWriter, r *http.Request) {
}
templateModel := SessionTemplateModel{
SessionID: sessionID,
Salt: "salt&pepper",
WSPath: getWSPath(sessionID),
SessionID: sessionID,
Salt: "salt&pepper",
WSPath: getWSPath(sessionID),
ScrollBack: server.config.ScrollBack,
}
err = t.Execute(w, templateModel)

@ -16,6 +16,7 @@ func main() {
senderAddress := flag.String("sender_address", ":6543", "The bind address for the tty-share TLS connections. tty-share tool will connect to this address.")
url := flag.String("url", "http://localhost", "The public web URL the server will be accessible at. This will be sent back to the tty-share tool to display it to the user.")
frontendPath := flag.String("frontend_path", "", "The path to the frontend resources. By default, these resources are included in the server binary, so you only need this path if you don't want to use the bundled ones.")
scrollBack := flag.Int("scroll_back", 1024, "Set scrollback buffer size for viewers")
flag.Parse()
log := MainLogger
@ -26,6 +27,7 @@ func main() {
TTYSenderAddress: *senderAddress,
ServerURL: *url,
FrontendPath: *frontendPath,
ScrollBack: *scrollBack,
}
server := NewTTYServer(config)

Loading…
Cancel
Save