mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-19 08:06:38 +02:00
sequences: Update docs.
This commit is contained in:
parent
11d20ef055
commit
0757c9ef05
@ -9,12 +9,12 @@ from pywal import util
|
|||||||
|
|
||||||
|
|
||||||
def set_special(index, color):
|
def set_special(index, color):
|
||||||
"""Build the escape sequence for special colors."""
|
"""Convert a hex color to a special sequence."""
|
||||||
return f"\033]{index};{color}\007"
|
return f"\033]{index};{color}\007"
|
||||||
|
|
||||||
|
|
||||||
def set_color(index, color):
|
def set_color(index, color):
|
||||||
"""Build the escape sequence we need for each color."""
|
"""Convert a hex color to a text color sequence."""
|
||||||
return f"\033]4;{index};{color}\007"
|
return f"\033]4;{index};{color}\007"
|
||||||
|
|
||||||
|
|
||||||
@ -34,13 +34,14 @@ def send_sequences(colors, vte):
|
|||||||
sequences.append(set_special(13, colors["special"]["cursor"]))
|
sequences.append(set_special(13, colors["special"]["cursor"]))
|
||||||
|
|
||||||
# Set a blank color that isn"t affected by bold highlighting.
|
# Set a blank color that isn"t affected by bold highlighting.
|
||||||
|
# Used in wal.vim's airline theme.
|
||||||
sequences.append(set_color(66, colors["special"]["background"]))
|
sequences.append(set_color(66, colors["special"]["background"]))
|
||||||
|
|
||||||
# This escape sequence doesn"t work in VTE terminals.
|
# This escape sequence doesn"t work in VTE terminals.
|
||||||
if not vte:
|
if not vte:
|
||||||
sequences.append(set_special(708, colors["special"]["background"]))
|
sequences.append(set_special(708, colors["special"]["background"]))
|
||||||
|
|
||||||
# Get a list of terminals.
|
# Get the list of terminals.
|
||||||
terminals = [f"/dev/pts/{term}" for term in os.listdir("/dev/pts/")
|
terminals = [f"/dev/pts/{term}" for term in os.listdir("/dev/pts/")
|
||||||
if len(term) < 4]
|
if len(term) < 4]
|
||||||
terminals.append(CACHE_DIR / "sequences")
|
terminals.append(CACHE_DIR / "sequences")
|
||||||
@ -53,17 +54,16 @@ def send_sequences(colors, vte):
|
|||||||
|
|
||||||
|
|
||||||
def reload_colors(vte):
|
def reload_colors(vte):
|
||||||
"""Reload colors."""
|
"""Reload the current scheme."""
|
||||||
sequence_file = CACHE_DIR / "sequences"
|
sequence_file = CACHE_DIR / "sequences"
|
||||||
|
|
||||||
if sequence_file.is_file():
|
if sequence_file.is_file():
|
||||||
sequences = "".join(util.read_file(sequence_file))
|
sequences = "".join(util.read_file(sequence_file))
|
||||||
|
|
||||||
# If vte mode was used, remove the problem sequence.
|
# If vte mode was used, remove the unsupported sequence.
|
||||||
if vte:
|
if vte:
|
||||||
sequences = re.sub(r"\]708;\#.{6}", "", sequences)
|
sequences = re.sub(r"\]708;\#.{6}", "", sequences)
|
||||||
|
|
||||||
# Make the terminal interpret escape sequences.
|
|
||||||
print(sequences, end="")
|
print(sequences, end="")
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user