From 373eb497d955b2f66e394dbdc7f5c9a9c1e7bbc5 Mon Sep 17 00:00:00 2001 From: Jakob Friedl <71284620+jakobfriedl@users.noreply.github.com> Date: Fri, 10 Oct 2025 12:55:50 +0200 Subject: [PATCH] Fixed getText() function that caused text highlighting in console to break. --- src/client/views/console.nim | 13 ++++++------- src/common/types.nim | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/client/views/console.nim b/src/client/views/console.nim index 4182243..2209be0 100644 --- a/src/client/views/console.nim +++ b/src/client/views/console.nim @@ -24,10 +24,10 @@ type ]# proc getText(item: ConsoleItem): cstring = if item.timestamp > 0: - let timestamp = item.timestamp.fromUnix().format("dd-MM-yyyy HH:mm:ss") - return fmt"[{timestamp}]{$item.itemType}{item.text}".string + let timestamp = "[" & item.timestamp.fromUnix().format("dd-MM-yyyy HH:mm:ss") & "]" + return timestamp & $item.itemType & item.text else: - return fmt"{$item.itemType}{item.text}".string + return $item.itemType & item.text proc getNumLines(data: pointer): csize_t {.cdecl.} = if data.isNil: @@ -173,14 +173,12 @@ proc callback(data: ptr ImGuiInputTextCallbackData): cint {.cdecl.} = API to add new console item ]# proc addItem*(component: ConsoleComponent, itemType: LogType, data: string, timestamp: int64 = now().toTime().toUnix()) = - for line in data.split("\n"): component.console.items.add(ConsoleItem( timestamp: if itemType == LOG_OUTPUT: 0 else: timestamp, itemType: itemType, text: line )) - #[ Handling console commands ]# @@ -188,6 +186,7 @@ proc displayHelp(component: ConsoleComponent) = for module in getModules(component.agent.modules): for cmd in module.commands: component.addItem(LOG_OUTPUT, fmt" * {cmd.name:<15}{cmd.description}") + component.addItem(LOG_OUTPUT, "") proc displayCommandHelp(component: ConsoleComponent, command: Command) = var usage = command.name & " " & command.arguments.mapIt( @@ -359,12 +358,12 @@ proc draw*(component: ConsoleComponent, connection: WsConnection) = item.print() - component.textSelect.textselect_update() - # Auto-scroll to bottom if igGetScrollY() >= igGetScrollMaxY(): igSetScrollHereY(1.0f) + component.textSelect.textselect_update() + except IndexDefect: # CTRL+A crashes when no items are in the console discard diff --git a/src/common/types.nim b/src/common/types.nim index 60c3267..13e3705 100644 --- a/src/common/types.nim +++ b/src/common/types.nim @@ -256,8 +256,8 @@ type CLIENT_LISTENER_START = 3'u8 # Start a listener on the TS CLIENT_LISTENER_STOP = 4'u8 # Stop a listener CLIENT_LOOT_REMOVE = 5'u8 # Remove loot on the team server - CLIENT_LOOT_SYNC = 6'u8 # Request to download a file/screenshot to the client - + CLIENT_LOOT_SYNC = 6'u8 # Download a file/screenshot to the client + # Sent by team server CLIENT_PROFILE = 100'u8 # Team server profile and configuration CLIENT_LISTENER_ADD = 101'u8 # Add listener to listeners table