[jhbuild] terminal: Try both terminfo and termcap names when running tput
- From: Ting-Wei Lan <lantw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] terminal: Try both terminfo and termcap names when running tput
- Date: Wed, 9 Nov 2016 13:55:23 +0000 (UTC)
commit 9ea2b62ee9203530b677bc86ab24fdcbe58af9cb
Author: Ting-Wei Lan <lantw src gnome org>
Date: Mon Nov 7 02:51:47 2016 +0800
terminal: Try both terminfo and termcap names when running tput
FreeBSD doesn't have a terminfo database, and its tput command only
support termcap names. To make bold text works on more systems, we try
both terminfo and tercap names before giving up and using normal text.
This commit also adds terminfo 'setaf' as an alternative to 'setf'
because it seems that the latter only works with xterm, not with other
popular terminals such as xterm-256color and screen.
https://bugzilla.gnome.org/show_bug.cgi?id=774070
jhbuild/commands/goalreport.py | 10 +++++++---
jhbuild/frontends/terminal.py | 23 ++++++++++++++++++++---
2 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/jhbuild/commands/goalreport.py b/jhbuild/commands/goalreport.py
index ac3615c..8867a1c 100644
--- a/jhbuild/commands/goalreport.py
+++ b/jhbuild/commands/goalreport.py
@@ -49,10 +49,14 @@ from jhbuild.utils import httpcache
from jhbuild.modtypes import MetaModule
try: t_bold = cmds.get_output(['tput', 'bold'])
-except: t_bold = ''
-try: t_reset = cmds.get_output(['tput', 'sgr0'])
-except: t_reset = ''
+except:
+ try: t_bold = cmds.get_output(['tput', 'md'])
+ except: t_bold = ''
+try: t_reset = cmds.get_output(['tput', 'sgr0'])
+except:
+ try: t_reset = cmds.get_output(['tput', 'me'])
+ except: t_reset = ''
HTML_AT_TOP = '''<html>
<head>
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index 2bb70d6..64b1143 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -36,15 +36,32 @@ is_xterm = term.find('xterm') >= 0 or term == 'rxvt'
del term
try: t_bold = cmds.get_output(['tput', 'bold'])
-except: t_bold = ''
+except:
+ try: t_bold = cmds.get_output(['tput', 'md'])
+ except: t_bold = ''
+
try: t_reset = cmds.get_output(['tput', 'sgr0'])
-except: t_reset = ''
+except:
+ try: t_reset = cmds.get_output(['tput', 'me'])
+ except: t_reset = ''
+
t_colour = [''] * 16
try:
for i in range(8):
t_colour[i] = cmds.get_output(['tput', 'setf', '%d' % i])
t_colour[i+8] = t_bold + t_colour[i]
-except: pass
+except:
+ try:
+ for index, i in enumerate([0, 4, 2, 6, 1, 5, 3, 7]):
+ t_colour[index] = cmds.get_output(['tput', 'setaf', '%d' % i])
+ t_colour[index+8] = t_bold + t_colour[index]
+ except:
+ try:
+ for index, i in enumerate([0, 4, 2, 6, 1, 5, 3, 7]):
+ t_colour[index] = cmds.get_output(['tput', 'AF', '%d' % i])
+ t_colour[index+8] = t_bold + t_colour[index]
+ except:
+ pass
user_shell = os.environ.get('SHELL', '/bin/sh')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]