Skip to content

Commit

Permalink
Add bold option to color functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fidgetingbits committed May 24, 2024
1 parent 2b9beef commit b913546
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
40 changes: 21 additions & 19 deletions pwndbg/color/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,75 +45,75 @@
none = str


def normal(x: str) -> str:
def normal(x: str, bold=False) -> str:
return colorize(x, NORMAL)


def black(x: str) -> str:
def black(x: str, bold=False) -> str:
return colorize(x, BLACK)


def red(x: str) -> str:
def red(x: str, bold=False) -> str:
return colorize(x, RED)


def green(x: str) -> str:
def green(x: str, bold=False) -> str:
return colorize(x, GREEN)


def yellow(x: str) -> str:
def yellow(x: str, bold=False) -> str:
return colorize(x, YELLOW)


def blue(x: str) -> str:
def blue(x: str, bold=False) -> str:
return colorize(x, BLUE)


def purple(x: str) -> str:
def purple(x: str, bold=False) -> str:
return colorize(x, PURPLE)


def cyan(x: str) -> str:
def cyan(x: str, bold=False) -> str:
return colorize(x, CYAN)


def light_gray(x: str) -> str:
def light_gray(x: str, bold=False) -> str:
return colorize(x, LIGHT_GRAY)


def foreground(x: str) -> str:
def foreground(x: str, bold=False) -> str:
return colorize(x, FOREGROUND)


def gray(x: str) -> str:
def gray(x: str, bold=False) -> str:
return colorize(x, GRAY)


def light_red(x: str) -> str:
def light_red(x: str, bold=False) -> str:
return colorize(x, LIGHT_RED)


def light_green(x: str) -> str:
def light_green(x: str, bold=False) -> str:
return colorize(x, LIGHT_GREEN)


def light_yellow(x: str) -> str:
def light_yellow(x: str, bold=False) -> str:
return colorize(x, LIGHT_YELLOW)


def light_blue(x: str) -> str:
def light_blue(x: str, bold=False) -> str:
return colorize(x, LIGHT_BLUE)


def light_purple(x: str) -> str:
def light_purple(x: str, bold=False) -> str:
return colorize(x, LIGHT_PURPLE)


def light_cyan(x: str) -> str:
def light_cyan(x: str, bold=False) -> str:
return colorize(x, LIGHT_CYAN)


def white(x: str) -> str:
def white(x: str, bold=False) -> str:
return colorize(x, WHITE)


Expand All @@ -125,7 +125,9 @@ def underline(x: str) -> str:
return colorize(x, UNDERLINE)


def colorize(x: str, color: str) -> str:
def colorize(x: str, color: str, bold: bool = False) -> str:
if bold:
color = BOLD + color
return color + terminateWith(str(x), color) + NORMAL


Expand Down
2 changes: 1 addition & 1 deletion pwndbg/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def context_threads(with_banner=True, target=sys.stdout, width=None):

line += f"{pc_colored}"
if symbol:
line += f" <{pwndbg.color.bold(pwndbg.color.green(symbol))}> "
line += f" <{pwndbg.color.green(symbol, bold=True)}> "

out.append(line)

Expand Down
6 changes: 3 additions & 3 deletions pwndbg/commands/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def errno_(err) -> None:
def pwndbg_(filter_pattern, shell, all_, category_, list_categories) -> None:
if list_categories:
for category in CommandCategory:
print(C.bold(C.green(f"{category.value}")))
print(C.green(f"{category.value}", bold=True))
return

if all_:
Expand Down Expand Up @@ -126,8 +126,8 @@ def pwndbg_(filter_pattern, shell, all_, category_, list_categories) -> None:
continue
data = table_data[category]

category_header = C.bold(C.green(category + " Commands"))
alias_header = C.bold(C.blue("Aliases"))
category_header = C.green(category + " Commands", bold=True)
alias_header = C.blue("Aliases", bold=True)
print(
tabulate(
data, headers=[f"{category_header} [{alias_header}]", f"{C.bold('Description')}"]
Expand Down
2 changes: 1 addition & 1 deletion pwndbg/commands/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def tls(pthread_self=False) -> None:
def threads(num_threads, respect_config) -> None:
table = []
headers = ["global_num", "name", "status", "pc", "symbol"]
bold_green = lambda text: pwndbg.color.bold(pwndbg.color.green(text))
bold_green = lambda text: pwndbg.color.green(text, bold=True)

try:
original_thread = gdb.selected_thread()
Expand Down

0 comments on commit b913546

Please sign in to comment.