From 75c76fec34d56bcfc46f05c1c79900f47ec8c5ab Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 13 Nov 2022 03:09:17 +0100 Subject: [PATCH] Add option to disable buffering (#917) --- gef.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gef.py b/gef.py index a00386ea0..1e497ce59 100644 --- a/gef.py +++ b/gef.py @@ -234,7 +234,7 @@ def highlight_text(text: str) -> str: def gef_print(*args: str, end="\n", sep=" ", **kwargs: Any) -> None: """Wrapper around print(), using string buffering feature.""" parts = [highlight_text(a) for a in args] - if gef.ui.stream_buffer and not is_debug(): + if buffer_output() and gef.ui.stream_buffer and not is_debug(): gef.ui.stream_buffer.write(sep.join(parts) + end) return @@ -1882,6 +1882,11 @@ def is_debug() -> bool: return gef.config["gef.debug"] is True +def buffer_output() -> bool: + """Check if output should be buffered until command completion.""" + return gef.config["gef.buffer"] is True + + def hide_context() -> bool: """Helper function to hide the context pane.""" gef.ui.context_hidden = True @@ -9336,6 +9341,7 @@ def __init__(self) -> None: gef.config["gef.disable_color"] = GefSetting(False, bool, "Disable all colors in GEF") gef.config["gef.tempdir"] = GefSetting(GEF_TEMP_DIR, str, "Directory to use for temporary/cache content") gef.config["gef.show_deprecation_warnings"] = GefSetting(True, bool, "Toggle the display of the `deprecated` warnings") + gef.config["gef.buffer"] = GefSetting(True, bool, "Internally buffer command output until completion") self.commands : Dict[str, GenericCommand] = collections.OrderedDict() self.functions : Dict[str, GenericFunction] = collections.OrderedDict()