Skip to content

Commit

Permalink
Fix prompt length calculation (#1103)
Browse files Browse the repository at this point in the history
## Description

Fix bug described in #1102
  • Loading branch information
ValekoZ authored May 26, 2024
1 parent 2c26e33 commit bdf8219
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
39 changes: 23 additions & 16 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,23 +502,30 @@ def wrapper(*args: Any, **kwargs: Any) -> Callable:

class Color:
"""Used to colorify terminal output."""

### Special chars:
# \001 -> Tell the readline library that we start a special sequence
# which won't be displayed (takes no column in the output)
# \002 -> Tell the readline library that we end a special sequence
# started with \001
# \033 -> Start an ANSI escape code for displaying colors
colors = {
"normal" : "\033[0m",
"gray" : "\033[1;38;5;240m",
"light_gray" : "\033[0;37m",
"red" : "\033[31m",
"green" : "\033[32m",
"yellow" : "\033[33m",
"blue" : "\033[34m",
"pink" : "\033[35m",
"cyan" : "\033[36m",
"bold" : "\033[1m",
"underline" : "\033[4m",
"underline_off" : "\033[24m",
"highlight" : "\033[3m",
"highlight_off" : "\033[23m",
"blink" : "\033[5m",
"blink_off" : "\033[25m",
"normal" : "\001\033[0m\002",
"gray" : "\001\033[1;38;5;240m\002",
"light_gray" : "\001\033[0;37m\002",
"red" : "\001\033[31m\002",
"green" : "\001\033[32m\002",
"yellow" : "\001\033[33m\002",
"blue" : "\001\033[34m\002",
"pink" : "\001\033[35m\002",
"cyan" : "\001\033[36m\002",
"bold" : "\001\033[1m\002",
"underline" : "\001\033[4m\002",
"underline_off" : "\001\033[24m\002",
"highlight" : "\001\033[3m\002",
"highlight_off" : "\001\033[23m\002",
"blink" : "\001\033[5m\002",
"blink_off" : "\001\033[25m\002",
}

@staticmethod
Expand Down
32 changes: 16 additions & 16 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ def which(program: str) -> pathlib.Path:
class Color(enum.Enum):
"""Used to colorify terminal output."""

NORMAL = "\x1b[0m"
GRAY = "\x1b[1;38;5;240m"
LIGHT_GRAY = "\x1b[0;37m"
RED = "\x1b[31m"
GREEN = "\x1b[32m"
YELLOW = "\x1b[33m"
BLUE = "\x1b[34m"
PINK = "\x1b[35m"
CYAN = "\x1b[36m"
BOLD = "\x1b[1m"
UNDERLINE = "\x1b[4m"
UNDERLINE_OFF = "\x1b[24m"
HIGHLIGHT = "\x1b[3m"
HIGHLIGHT_OFF = "\x1b[23m"
BLINK = "\x1b[5m"
BLINK_OFF = "\x1b[25m"
NORMAL = "\001\033[0m\002"
GRAY = "\001\033[1;38;5;240m\002"
LIGHT_GRAY = "\001\033[0;37m\002"
RED = "\001\033[31m\002"
GREEN = "\001\033[32m\002"
YELLOW = "\001\033[33m\002"
BLUE = "\001\033[34m\002"
PINK = "\001\033[35m\002"
CYAN = "\001\033[36m\002"
BOLD = "\001\033[1m\002"
UNDERLINE = "\001\033[4m\002"
UNDERLINE_OFF = "\001\033[24m\002"
HIGHLIGHT = "\001\033[3m\002"
HIGHLIGHT_OFF = "\001\033[23m\002"
BLINK = "\001\033[5m\002"
BLINK_OFF = "\001\033[25m\002"


def is_64b() -> bool:
Expand Down

0 comments on commit bdf8219

Please sign in to comment.