From 8fd09cd9ecfad9801217e1b75325656f95117af1 Mon Sep 17 00:00:00 2001 From: Robert Bittle Date: Wed, 7 Sep 2016 15:18:33 -0400 Subject: [PATCH] Add an option to disable client window resizes This goes great with tmux when you are sharing your terminal for presentations and you don't want to give viewers the ability to resize your terminal --- app/app.go | 4 ++++ app/client_context.go | 14 ++++++++++++-- main.go | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index a7f8aa7..9246c4d 100644 --- a/app/app.go +++ b/app/app.go @@ -70,6 +70,8 @@ type Options struct { CloseSignal int `hcl:"close_signal"` Preferences HtermPrefernces `hcl:"preferences"` RawPreferences map[string]interface{} `hcl:"preferences"` + Width int `hcl:"width"` + Height int `hcl:"height"` } var Version = "0.0.13" @@ -95,6 +97,8 @@ var DefaultOptions = Options{ Once: false, CloseSignal: 1, // syscall.SIGHUP Preferences: HtermPrefernces{}, + Width: 0, + Height: 0, } func New(command []string, options *Options) (*App, error) { diff --git a/app/client_context.go b/app/client_context.go index 3a3b27a..3662ac2 100644 --- a/app/client_context.go +++ b/app/client_context.go @@ -197,14 +197,24 @@ func (context *clientContext) processReceive() { return } + rows := uint16(context.app.options.Height) + if rows == 0 { + rows = uint16(args.Rows) + } + + columns := uint16(context.app.options.Width) + if columns == 0 { + columns = uint16(args.Columns) + } + window := struct { row uint16 col uint16 x uint16 y uint16 }{ - uint16(args.Rows), - uint16(args.Columns), + rows, + columns, 0, 0, } diff --git a/main.go b/main.go index 7d14198..e5d43d4 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,8 @@ func main() { flag{"once", "", "Accept only one client and exit on disconnection"}, flag{"permit-arguments", "", "Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB)"}, flag{"close-signal", "", "Signal sent to the command process when gotty close it (default: SIGHUP)"}, + flag{"width", "", "Static width of the screen, 0(default) means dynamically resize"}, + flag{"height", "", "Static height of the screen, 0(default) means dynamically resize"}, } mappingHint := map[string]string{