Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement setting custom colours by number #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pyte/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,19 @@ def set_icon_name(self, param: str) -> None:
"""
self.icon_name = param

def set_color_number(self, index: int, color: str) -> None:
"""Set colour number index to be the specified colour (in hex)
"""
# TODO: This has no way to reset colors back to their original.
if index > 15:
g.FG_BG_256[index] = color
elif index > 7: # Bright colors
g.FG_AIXTERM[index + 82] = color
g.BG_AIXTERM[index + 92] = color
else:
g.FG_ANSI[index + 30] = color
g.BG_ANSI[index + 40] = color

def carriage_return(self) -> None:
"""Move the cursor to the beginning of the current line."""
self.cursor.x = 0
Expand Down
3 changes: 3 additions & 0 deletions pyte/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ def create_dispatcher(mapping: Mapping[str, str]) -> Dict[str, Callable[..., Non
listener.set_icon_name(param)
if code in "02":
listener.set_title(param)
if code == "4":
index, color = param.split(";")
listener.set_color_number(int(index), color[4:].replace("/", "").lower())
elif char not in NUL_OR_DEL:
draw(char)

Expand Down
Loading