From a5a8f9a11a9ba53eb542500e5defb807892276a1 Mon Sep 17 00:00:00 2001 From: ValekoZ Date: Mon, 13 May 2024 16:38:08 +0200 Subject: [PATCH 1/3] Fix prompt length calculation --- gef.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/gef.py b/gef.py index 93407019e..ed9763e88 100644 --- a/gef.py +++ b/gef.py @@ -503,22 +503,22 @@ def wrapper(*args: Any, **kwargs: Any) -> Callable: class Color: """Used to colorify terminal output.""" 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 From d6316f3867f2ea48a22bab6f348ded113d701763 Mon Sep 17 00:00:00 2001 From: ValekoZ Date: Tue, 14 May 2024 10:56:22 +0200 Subject: [PATCH 2/3] Add a little doc about special chars in Color --- gef.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gef.py b/gef.py index ed9763e88..22b9b5e94 100644 --- a/gef.py +++ b/gef.py @@ -502,6 +502,13 @@ 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" : "\001\033[0m\002", "gray" : "\001\033[1;38;5;240m\002", From e2adb7530107c6f5a903d8f6a6093aa4b3ca6e72 Mon Sep 17 00:00:00 2001 From: ValekoZ Date: Wed, 22 May 2024 09:19:27 +0200 Subject: [PATCH 3/3] Sync colors in utils.py with gef.py --- tests/utils.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 0254ed080..f88d3b304 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -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: