summaryrefslogtreecommitdiffstats
path: root/powerline/renderers/shell/tcsh.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:40:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:40:16 +0000
commit3f25952c13d5847d510c0cae22a8ba876638d570 (patch)
tree02f505f016ed5a1029277dcae520d5e2a75906fb /powerline/renderers/shell/tcsh.py
parentInitial commit. (diff)
downloadpowerline-3f25952c13d5847d510c0cae22a8ba876638d570.tar.xz
powerline-3f25952c13d5847d510c0cae22a8ba876638d570.zip
Adding upstream version 2.8.3.upstream/2.8.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'powerline/renderers/shell/tcsh.py')
-rw-r--r--powerline/renderers/shell/tcsh.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/powerline/renderers/shell/tcsh.py b/powerline/renderers/shell/tcsh.py
new file mode 100644
index 0000000..bf0697d
--- /dev/null
+++ b/powerline/renderers/shell/tcsh.py
@@ -0,0 +1,31 @@
+# vim:fileencoding=utf-8:noet
+from __future__ import (unicode_literals, division, absolute_import, print_function)
+
+from powerline.renderers.shell.zsh import ZshPromptRenderer
+
+
+class TcshPromptRenderer(ZshPromptRenderer):
+ '''Powerline tcsh prompt segment renderer.'''
+ character_translations = ZshPromptRenderer.character_translations.copy()
+ character_translations[ord('%')] = '%%'
+ character_translations[ord('\\')] = '\\\\'
+ character_translations[ord('^')] = '\\^'
+ character_translations[ord('!')] = '\\!'
+
+ def do_render(self, **kwargs):
+ ret = super(TcshPromptRenderer, self).do_render(**kwargs)
+ nbsp = self.character_translations.get(ord(' '), ' ')
+ end = self.hlstyle()
+ assert not ret or ret.endswith(end)
+ if ret.endswith(nbsp + end):
+ # Exchange nbsp and highlight end because tcsh removes trailing
+ # %{%} part of the prompt for whatever reason
+ ret = ret[:-(len(nbsp) + len(end))] + end + nbsp
+ else:
+ # We *must* end prompt with non-%{%} sequence for the reasons
+ # explained above. So add nbsp if it is not already there.
+ ret += nbsp
+ return ret
+
+
+renderer = TcshPromptRenderer