about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-24 22:50:25 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-24 23:10:17 +0200
commit7d7f97b6da90bfed93f9dcab4b480e67715d5d5d (patch)
tree5246a230b2138a25828d6ea0b5e7c6d7672c34d2
parent7441f61570a49421c159db48aee3eb3f98b70636 (diff)
downloadchawan-7d7f97b6da90bfed93f9dcab4b480e67715d5d5d.tar.gz
Only set terminal title when it is a tty
Avoid writing the escape sequence when dumping files.
-rw-r--r--src/display/term.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/display/term.nim b/src/display/term.nim
index 1b1f82d7..60be99b0 100644
--- a/src/display/term.nim
+++ b/src/display/term.nim
@@ -12,9 +12,10 @@ import config/config
 import data/charset
 import encoding/encoderstream
 import io/window
+import types/color
 import utils/chamath
+import utils/opt
 import utils/twtstr
-import types/color
 
 #TODO switch from termcap...
 
@@ -57,6 +58,7 @@ type
     smcup: bool
     tc: Termcap
     tname: string
+    set_title: bool
 
 func hascap(term: Terminal, c: TermcapCap): bool = term.tc.caps[c] != nil
 func cap(term: Terminal, c: TermcapCap): string = $term.tc.caps[c]
@@ -327,7 +329,7 @@ proc windowChange*(term: Terminal, attrs: WindowAttributes) =
   term.cleared = false
 
 proc setTitle*(term: Terminal, title: string) =
-  if term.config.display.set_title:
+  if term.set_title:
     term.outfile.write(XTERM_TITLE(title))
 
 proc processOutputString*(term: Terminal, str: string, w: var int): string =
@@ -453,6 +455,7 @@ proc applyConfig(term: Terminal) =
   if term.isatty():
     if term.config.display.alt_screen.isSome:
       term.smcup = term.config.display.alt_screen.get
+    term.set_title = term.config.display.set_title
   term.mincontrast = term.config.display.minimum_contrast
   if term.config.encoding.display_charset.isSome:
     term.cs = term.config.encoding.display_charset.get