From aeee577e24963f844e6382c2ab2460b81426d84e Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 15 Dec 2019 11:00:39 -0800 Subject: [PATCH 1/3] Adds title change escapes to cui --- cui/cui.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cui/cui.go b/cui/cui.go index b6ca90b..666f76d 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -49,14 +49,17 @@ func Exit(exitCode int, msg string) { if msg != "" { fmt.Print(msg, "\n") } + fmt.Print("\033[23;0t") os.Exit(exitCode) } // InitTerm sets the terminal modes appropriate for Bombadillo func InitTerm() { SetCharMode() + fmt.Print("\033[22;0t") Tput("rmam") // turn off line wrapping Tput("smcup") // use alternate screen + fmt.Print("\033]0;Bombadillo\007") } // CleanupTerm reverts changs to terminal mode made by InitTerm From 4182619a7858e0778c259b487ab2ea78c6b4190a Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 16 Dec 2019 19:40:52 -0800 Subject: [PATCH 2/3] Adds flag for displaying title and adds documentation --- bombadillo.1 | 13 +++++++++---- bombadillo.desktop | 2 +- cui/cui.go | 4 +--- main.go | 9 +++++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 04d186c..9576233 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -6,6 +6,7 @@ .fam C \fBbombadillo\fP [\fIurl\fP] \fBbombadillo\fP [\fBOPTION\fP] +\fBbombadillo\fP [\fBOPTION\fP] [\fIurl\fP] .fam T .fi .SH DESCRIPTION @@ -15,12 +16,16 @@ .SH OPTIONS .TP .B -\fB-v\fP -Display version information and exit. +\fB-h\fP +Usage help. Displays all command line options with a short description and exits. .TP .B -\fB-h\fP -Usage help. Displays all command line options with a short description. +\fB-t\fP +Set the window title to Bomabdillo and run Bombadillo. +.TP +.B +\fB-v\fP +Display version information and exit. .SH PROTOCOL SUPPORT All of the below protocols are supported. With the exception of gopher, the protocol name must be present as the scheme component of a url in the form of \fI[protocol]://[the rest of the url]\fP. .TP diff --git a/bombadillo.desktop b/bombadillo.desktop index 3ca2531..4510dcd 100644 --- a/bombadillo.desktop +++ b/bombadillo.desktop @@ -5,6 +5,6 @@ GenericName=Non-Web Browser Comment=View gopher, gemini, finger, telnet, http(s) sites over the internet Terminal=true Categories=Network;WebBrowser;ConsoleOnly; -Exec=bombadillo %U +Exec=bombadillo -t %u Icon=bombadillo-icon MimeType=x-scheme-handler/gopher;x-scheme-handler/gemini;x-scheme-handler/finger; diff --git a/cui/cui.go b/cui/cui.go index 666f76d..90a6001 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -49,17 +49,15 @@ func Exit(exitCode int, msg string) { if msg != "" { fmt.Print(msg, "\n") } - fmt.Print("\033[23;0t") + fmt.Print("\033[23;0t") // Restore window title from terminal stack os.Exit(exitCode) } // InitTerm sets the terminal modes appropriate for Bombadillo func InitTerm() { SetCharMode() - fmt.Print("\033[22;0t") Tput("rmam") // turn off line wrapping Tput("smcup") // use alternate screen - fmt.Print("\033]0;Bombadillo\007") } // CleanupTerm reverts changs to terminal mode made by InitTerm diff --git a/main.go b/main.go index 88a70b0..8ab5979 100644 --- a/main.go +++ b/main.go @@ -168,8 +168,10 @@ func printHelp() { Syntax: bombadillo [url] bombadillo [options...] + bombadillo -t [url] Examples: bombadillo gopher://bombadillo.colorfield.space + bombadillo -t bombadillo -v Options: @@ -180,6 +182,7 @@ Options: func main() { getVersion := flag.Bool("v", false, "Display version information and exit") + addTitleToXWindow := flag.Bool("t", false, "Change the window title to Bomabdillo while running") flag.Usage = printHelp flag.Parse() if *getVersion { @@ -189,6 +192,12 @@ func main() { args := flag.Args() cui.InitTerm() + + if *addTitleToXWindow { + fmt.Print("\033[22;0t") // Store window title on terminal stack + fmt.Print("\033]0;Bombadillo\007") // Update window title + } + defer cui.Exit(0, "") initClient() From 4bb0c84c5644fe848047e8c2a2e7c1b3254477e2 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 19 Dec 2019 14:57:40 +1100 Subject: [PATCH 3/3] Amended man page and usage details synopsis --- bombadillo.1 | 8 +++----- main.go | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 9576233..a8b9e07 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -4,9 +4,7 @@ .SH SYNOPSIS .nf .fam C -\fBbombadillo\fP [\fIurl\fP] -\fBbombadillo\fP [\fBOPTION\fP] -\fBbombadillo\fP [\fBOPTION\fP] [\fIurl\fP] +\fBbombadillo\fP [\fIoptions\fP] [\fIurl\fP] .fam T .fi .SH DESCRIPTION @@ -17,11 +15,11 @@ .TP .B \fB-h\fP -Usage help. Displays all command line options with a short description and exits. +Display usage help and exit. Provides a list of all command line options with a short description and exits. .TP .B \fB-t\fP -Set the window title to Bomabdillo and run Bombadillo. +Set the window title to 'Bombadillo'. Can be used in a GUI environment, however not all terminals support this feature. .TP .B \fB-v\fP diff --git a/main.go b/main.go index 8ab5979..1362e78 100644 --- a/main.go +++ b/main.go @@ -166,12 +166,10 @@ func handleSignals(c <-chan os.Signal) { func printHelp() { art := `Bombadillo - a non-web browser -Syntax: bombadillo [url] - bombadillo [options...] - bombadillo -t [url] +Syntax: bombadillo [options] [url] Examples: bombadillo gopher://bombadillo.colorfield.space - bombadillo -t + bombadillo -t bombadillo -v Options: @@ -182,7 +180,7 @@ Options: func main() { getVersion := flag.Bool("v", false, "Display version information and exit") - addTitleToXWindow := flag.Bool("t", false, "Change the window title to Bomabdillo while running") + addTitleToXWindow := flag.Bool("t", false, "Set the window title to 'Bombadillo'. Can be used in a GUI environment, however not all terminals support this feature.") flag.Usage = printHelp flag.Parse() if *getVersion {