Skip to content

Commit

Permalink
feat: Support transparency (use default colors)
Browse files Browse the repository at this point in the history
PR #84: #84
Co-authored-by: Timothée Mazzucotelli <[email protected]>
  • Loading branch information
blackCauldron7 authored Apr 5, 2021
1 parent a603961 commit ff35d2b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ loguru = "*"
requests = ">2.19.1"
toml = "^0.10.2"
websocket_client = "*"
asciimatics = {version = "^1.11.0", optional = true}
asciimatics = {version = "^1.13.0", optional = true}
pyperclip = {version = "^1.8.0", optional = true}

[tool.poetry.extras]
tui = ["asciimatics", "pyperclip"]

[tool.poetry.dev-dependencies]
asciimatics = "^1.11.0"
asciimatics = "^1.13.0"
autoflake = "^1.4"
black = "^20.8b1"
duty = "^0.5.0"
Expand All @@ -58,7 +58,7 @@ pyinstaller = "^3.6"
pyperclip = "^1.8.0"
pytest = "^6.0.1"
pytest-cov = "^2.10.1"
pytest-randomly = "<3.6.0"
pytest-randomly = "<3.6"
pytest-rerunfailures = "^9.1.1"
pytest-sugar = "^0.9.4"
pytest-xdist = "^2.1.0"
Expand Down
18 changes: 10 additions & 8 deletions src/aria2p/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def color_palette_parser(palette: str) -> Tuple[int, int, int]:
"YELLOW": Screen.COLOUR_YELLOW,
"BLUE": Screen.COLOUR_BLUE,
"GREEN": Screen.COLOUR_GREEN,
"DEFAULT": Screen.COLOUR_DEFAULT,
}
mode_map = {
"NORMAL": Screen.A_NORMAL,
Expand Down Expand Up @@ -353,9 +354,10 @@ class State:
follow = None
bounds = []

palettes = defaultdict(lambda: (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLACK))
palettes = defaultdict(lambda: color_palette_parser("UI"))
palettes.update(
{
"ui": color_palette_parser("UI"),
"header": color_palette_parser("HEADER"),
"focused_header": color_palette_parser("FOCUSED_HEADER"),
"focused_row": color_palette_parser("FOCUSED_ROW"),
Expand Down Expand Up @@ -951,7 +953,7 @@ def print_add_downloads(self):
self.screen.print_at(header_string, 0, y, *self.palettes["side_column_header"])
self.screen.print_at(" ", len_header, y, *self.palettes["default"])
y += 1
self.screen.print_at(" " * self.width, 0, y)
self.screen.print_at(" " * self.width, 0, y, *self.palettes["ui"])
separator = "..."

for i, uri in enumerate(self.downloads_uris):
Expand All @@ -970,7 +972,7 @@ def print_add_downloads(self):
self.screen.print_at(" ", len(uri), y, *self.palettes["default"])

for i in range(1, self.height - y):
self.screen.print_at(" " * (padding + 1), 0, y + i)
self.screen.print_at(" " * (padding + 1), 0, y + i, *self.palettes["ui"])

def print_help(self):
version = get_version()
Expand Down Expand Up @@ -1018,13 +1020,13 @@ def print_help(self):
self.print_keys(keys, text, y)
y += 1

self.screen.print_at(" " * self.width, 0, y)
self.screen.print_at(" " * self.width, 0, y, *self.palettes["ui"])
y += 1
self.screen.print_at(f"{'Press any key to return.':<{self.width}}", 0, y, *self.palettes["bright_help"])
y += 1

for i in range(self.height - y):
self.screen.print_at(" " * self.width, 0, y + i)
self.screen.print_at(" " * self.width, 0, y + i, *self.palettes["ui"])

def print_keys(self, keys, text, y):
self.print_keys_text(" ".join(Keys.names(keys)) + ":", text, y)
Expand Down Expand Up @@ -1053,7 +1055,7 @@ def print_remove_ask_column(self):
self.screen.print_at(" ", len_row, y, *self.palettes["default"])

for i in range(1, self.height - y):
self.screen.print_at(" " * (padding + 1), 0, y + i)
self.screen.print_at(" " * (padding + 1), 0, y + i, *self.palettes["ui"])

def print_select_sort_column(self):
y = self.y_offset
Expand All @@ -1073,7 +1075,7 @@ def print_select_sort_column(self):
self.screen.print_at(" ", len_row, y, *self.palettes["default"])

for i in range(1, self.height - y):
self.screen.print_at(" " * (padding + 1), 0, y + i)
self.screen.print_at(" " * (padding + 1), 0, y + i, *self.palettes["ui"])

def print_table(self):
self.print_headers()
Expand Down Expand Up @@ -1127,7 +1129,7 @@ def print_rows(self):
y += 1

for i in range(self.height - y):
self.screen.print_at(" " * self.width, self.x_offset, y + i)
self.screen.print_at(" " * self.width, self.x_offset, y + i, *self.palettes["ui"])

def get_column_at_x(self, x):
"""For an horizontal position X, return the column index."""
Expand Down
19 changes: 10 additions & 9 deletions src/aria2p/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,20 @@ def load_configuration() -> Dict[str, Any]:
ADD_DOWNLOADS = "a"
[colors]
BRIGHT_HELP = "CYAN BOLD BLACK"
UI = "WHITE BOLD DEFAULT"
BRIGHT_HELP = "CYAN BOLD DEFAULT"
FOCUSED_HEADER = "BLACK NORMAL CYAN"
FOCUSED_ROW = "BLACK NORMAL CYAN"
HEADER = "BLACK NORMAL GREEN"
METADATA = "WHITE UNDERLINE BLACK"
SIDE_COLUMN_FOCUSED_ROW = "BLACK NORMAL CYAN"
METADATA = "WHITE UNDERLINE DEFAULT"
SIDE_COLUMN_FOCUSED_ROW = "DEFAULT NORMAL CYAN"
SIDE_COLUMN_HEADER = "BLACK NORMAL GREEN"
SIDE_COLUMN_ROW = "WHITE NORMAL BLACK"
STATUS_ACTIVE = "CYAN NORMAL BLACK"
STATUS_COMPLETE = "GREEN NORMAL BLACK"
STATUS_ERROR = "RED BOLD BLACK"
STATUS_PAUSED = "YELLOW NORMAL BLACK"
STATUS_WAITING = "WHITE BOLD BLACK"
SIDE_COLUMN_ROW = "DEFAULT NORMAL DEFAULT"
STATUS_ACTIVE = "CYAN NORMAL DEFAULT"
STATUS_COMPLETE = "GREEN NORMAL DEFAULT"
STATUS_ERROR = "RED BOLD DEFAULT"
STATUS_PAUSED = "YELLOW NORMAL DEFAULT"
STATUS_WAITING = "WHITE BOLD DEFAULT"
"""

config_dict = {}
Expand Down

0 comments on commit ff35d2b

Please sign in to comment.