diff options
| author | dylan <dylan.araps@gmail.com> | 2020-01-23 10:38:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-23 10:38:33 +0200 |
| commit | c1d90676f9074cf4131f8cb94aeb2344d6fc8ecc (patch) | |
| tree | 63e7fe384b10449fd893b5a2da3e90199df21dae /pywal/sequences.py | |
| parent | 7ecc2ffd39d1c01639da666dd4dbe0aa4789f85c (diff) | |
| parent | 3537e8cc8f2af2051dd695ef1ca7247e76e0f74f (diff) | |
Merge branch 'master' into add-vs-code-support
Diffstat (limited to 'pywal/sequences.py')
| -rw-r--r-- | pywal/sequences.py | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/pywal/sequences.py b/pywal/sequences.py index b713a6e..b5028bc 100644 --- a/pywal/sequences.py +++ b/pywal/sequences.py @@ -11,7 +11,7 @@ from . import util def set_special(index, color, iterm_name="h", alpha=100): """Convert a hex color to a special sequence.""" - if OS == "Darwin": + if OS == "Darwin" and iterm_name: return "\033]P%s%s\033\\" % (iterm_name, color.strip("#")) if index in [11, 708] and alpha != "100": @@ -22,22 +22,20 @@ def set_special(index, color, iterm_name="h", alpha=100): def set_color(index, color): """Convert a hex color to a text color sequence.""" - if OS == "Darwin": - return "\033]P%x%s\033\\" % (index, color.strip("#")) + if OS == "Darwin" and index < 20: + return "\033]P%1x%s\033\\" % (index, color.strip("#")) return "\033]4;%s;%s\033\\" % (index, color) def set_iterm_tab_color(color): """Set iTerm2 tab/window color""" - return """ - \033]6;1;bg;red;brightness;%s\a - \033]6;1;bg;green;brightness;%s\a - \033]6;1;bg;blue;brightness;%s\a - """ % (*util.hex_to_rgb(color),) + return ("\033]6;1;bg;red;brightness;%s\a" + "\033]6;1;bg;green;brightness;%s\a" + "\033]6;1;bg;blue;brightness;%s\a") % (*util.hex_to_rgb(color),) -def create_sequences(colors): +def create_sequences(colors, vte_fix=False): """Create the escape sequences.""" alpha = colors["alpha"] @@ -48,30 +46,22 @@ def create_sequences(colors): # Special colors. # Source: https://goo.gl/KcoQgP # 10 = foreground, 11 = background, 12 = cursor foregound - # 13 = mouse foreground + # 13 = mouse foreground, 708 = background border color. sequences.extend([ set_special(10, colors["special"]["foreground"], "g"), set_special(11, colors["special"]["background"], "h", alpha), set_special(12, colors["special"]["cursor"], "l"), - set_special(13, colors["special"]["foreground"], "l"), - set_special(17, colors["special"]["foreground"], "l"), - set_special(19, colors["special"]["background"], "l"), - set_color(232, colors["special"]["background"]) + set_special(13, colors["special"]["foreground"], "j"), + set_special(17, colors["special"]["foreground"], "k"), + set_special(19, colors["special"]["background"], "m"), + set_color(232, colors["special"]["background"]), + set_color(256, colors["special"]["foreground"]) ]) - # This escape sequence doesn't work in VTE terminals and their parsing of - # unknown sequences is garbage so we need to use some escape sequence - # M A G I C to hide the output. - # \033[s # Save cursor position. - # \033[1000H # Move the cursor off screen. - # \033[8m # Conceal text. - # \033]708;#000000\033\\ # Garbage sequence. - # \033[u # Restore cursor position. - sequences.extend([ - "\033[s\033[1000H\033[8m%s\033[u" % - set_special(708, colors["special"]["background"], "h", alpha), - set_special(13, colors["special"]["cursor"], "l") - ]) + if not vte_fix: + sequences.extend( + set_special(708, colors["special"]["background"], "", alpha) + ) if OS == "Darwin": sequences += set_iterm_tab_color(colors["special"]["background"]) @@ -79,7 +69,7 @@ def create_sequences(colors): return "".join(sequences) -def send(colors, cache_dir=CACHE_DIR, to_send=True): +def send(colors, cache_dir=CACHE_DIR, to_send=True, vte_fix=False): """Send colors to all open terminals.""" if OS == "Darwin": tty_pattern = "/dev/ttys00[0-9]*" @@ -87,7 +77,7 @@ def send(colors, cache_dir=CACHE_DIR, to_send=True): else: tty_pattern = "/dev/pts/[0-9]*" - sequences = create_sequences(colors) + sequences = create_sequences(colors, vte_fix) # Writing to "/dev/pts/[0-9] lets you send data to open terminals. if to_send: |
