Added notes and some minor changes to console view. Auto-scroll to bottom is not supported with the current approach, revisit this later.
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
[Window][Sessions [Table View]]
|
[Window][Sessions [Table View]]
|
||||||
Pos=10,43
|
Pos=10,43
|
||||||
Size=1477,368
|
Size=1477,421
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000003,0
|
DockId=0x00000003,0
|
||||||
|
|
||||||
[Window][Listeners]
|
[Window][Listeners]
|
||||||
Pos=10,413
|
Pos=10,466
|
||||||
Size=1888,576
|
Size=1888,523
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
[Window][Eventlog]
|
[Window][Eventlog]
|
||||||
Pos=1489,43
|
Pos=1489,43
|
||||||
Size=409,368
|
Size=409,421
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=1489,43
|
Pos=1489,43
|
||||||
Size=409,368
|
Size=409,421
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,1
|
||||||
|
|
||||||
@@ -28,16 +28,16 @@ Size=1908,999
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][[FACEDEAD] bob@LAPTOP-02]
|
[Window][[FACEDEAD] bob@LAPTOP-02]
|
||||||
Pos=10,413
|
Pos=10,466
|
||||||
Size=1888,576
|
Size=1888,523
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,3
|
||||||
|
|
||||||
[Window][[C9D8E7F6] charlie@SERVER-03]
|
[Window][[C9D8E7F6] charlie@SERVER-03]
|
||||||
Pos=10,413
|
Pos=10,466
|
||||||
Size=1888,576
|
Size=1888,523
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,2
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
@@ -45,20 +45,20 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][[G1H2I3J5] diana@WORKSTATION-04]
|
[Window][[G1H2I3J5] diana@WORKSTATION-04]
|
||||||
Pos=10,413
|
Pos=10,466
|
||||||
Size=1888,576
|
Size=1888,523
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,1
|
||||||
|
|
||||||
[Window][[DEADBEEF] alice@DESKTOP-01]
|
[Window][[DEADBEEF] alice@DESKTOP-01]
|
||||||
Pos=10,325
|
Pos=10,429
|
||||||
Size=1888,664
|
Size=1888,560
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,1
|
||||||
|
|
||||||
[Window][Example: Console]
|
[Window][Example: Console]
|
||||||
Pos=10,426
|
Pos=10,525
|
||||||
Size=1888,563
|
Size=2848,1160
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000002,1
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ Column 0 Sort=0v
|
|||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x85940918 Window=0x260A4489 Pos=10,43 Size=1888,946 Split=Y
|
DockSpace ID=0x85940918 Window=0x260A4489 Pos=10,43 Size=1888,946 Split=Y
|
||||||
DockNode ID=0x00000001 Parent=0x85940918 SizeRef=1024,368 Split=X
|
DockNode ID=0x00000001 Parent=0x85940918 SizeRef=1024,421 Split=X
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=613,159 CentralNode=1 Selected=0x61E02D75
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=613,159 CentralNode=1 Selected=0x61E02D75
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,159 Selected=0x5E5F7166
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,159 Selected=0x5E5F7166
|
||||||
DockNode ID=0x00000002 Parent=0x85940918 SizeRef=1024,576 Selected=0x65D642C0
|
DockNode ID=0x00000002 Parent=0x85940918 SizeRef=1024,523 Selected=0x4AD091E6
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ proc Console*(agent: Agent): ConsoleComponent =
|
|||||||
result.showConsole = true
|
result.showConsole = true
|
||||||
result.console = TextEditor_TextEditor()
|
result.console = TextEditor_TextEditor()
|
||||||
result.consoleEntries = @[
|
result.consoleEntries = @[
|
||||||
"a",
|
"a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a",
|
||||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -38,11 +38,16 @@ proc draw*(component: ConsoleComponent) =
|
|||||||
igBegin(fmt"[{component.agent.agentId}] {component.agent.username}@{component.agent.hostname}", addr component.showConsole, 0)
|
igBegin(fmt"[{component.agent.agentId}] {component.agent.username}@{component.agent.hostname}", addr component.showConsole, 0)
|
||||||
defer: igEnd()
|
defer: igEnd()
|
||||||
|
|
||||||
# Console text section
|
#[
|
||||||
# A InputTextMultiline component is placed within a Child Frame to enable both proper text selection and a horizontal scrollbar
|
Console entries/text section
|
||||||
# The only thing missing from this implementation is the ability change the text color
|
|
||||||
# https://github.com/ocornut/imgui/issues/383#issuecomment-2080346129
|
Problems:
|
||||||
let footerHeight = igGetStyle().ItemSpacing.y + igGetFrameHeightWithSpacing()
|
# A InputTextMultiline component is placed within a Child Frame to enable both proper text selection and a horizontal scrollbar
|
||||||
|
# The only thing missing from this implementation is the ability change the text color and auto-scrolling
|
||||||
|
# https://github.com/ocornut/imgui/issues/383#issuecomment-2080346129
|
||||||
|
# https://github.com/ocornut/imgui/issues/950
|
||||||
|
]#
|
||||||
|
let footerHeight = igGetStyle().ItemSpacing.y + igGetFrameHeightWithSpacing() # * 2
|
||||||
let buffer = component.consoleEntries.join("\n") & '\0'
|
let buffer = component.consoleEntries.join("\n") & '\0'
|
||||||
|
|
||||||
# Push styles to hide the Child's background and scrollbar background.
|
# Push styles to hide the Child's background and scrollbar background.
|
||||||
@@ -74,17 +79,40 @@ proc draw*(component: ConsoleComponent) =
|
|||||||
# component.console.TextEditor_SetShowLineNumbersEnabled(false)
|
# component.console.TextEditor_SetShowLineNumbersEnabled(false)
|
||||||
# component.console.TextEditor_Render("##ConsoleEntries", false, vec2(-1, -1), true)
|
# component.console.TextEditor_Render("##ConsoleEntries", false, vec2(-1, -1), true)
|
||||||
|
|
||||||
|
# # Scroll to bottom
|
||||||
|
# if igGetScrollY() >= igGetScrollMaxY():
|
||||||
|
# let lineCount = component.console.TextEditor_GetLineCount()
|
||||||
|
# component.console.TextEditor_SetCursorPosition(lineCount, 0)
|
||||||
|
|
||||||
igPopStyleColor(2)
|
igPopStyleColor(2)
|
||||||
|
|
||||||
igPopStyleColor(2)
|
igPopStyleColor(2)
|
||||||
igEndChild()
|
igEndChild()
|
||||||
|
|
||||||
igSeparator()
|
#[
|
||||||
|
Input field with prompt indicator
|
||||||
|
]#
|
||||||
|
let promptIndicator = fmt"[{component.agent.agentId}]"
|
||||||
|
var charWidth: ImVec2
|
||||||
|
igCalcTextSize(addr charWidth, "A", nil, false, -1.0f)
|
||||||
|
let promptWidth = charWidth.x * float(promptIndicator.len())
|
||||||
|
let spacing = igGetStyle().ItemSpacing.x
|
||||||
|
|
||||||
# Input field
|
igTextColored(vec4(1.0f, 1.0f, 1.0f, 1.0f), promptIndicator)
|
||||||
igSetNextItemWidth(-1.0f)
|
igSameLine(0.0f, spacing)
|
||||||
|
|
||||||
|
var availableWidth: ImVec2
|
||||||
|
igGetContentRegionAvail(addr availableWidth)
|
||||||
|
|
||||||
|
igSetNextItemWidth(availableWidth.x)
|
||||||
let inputFlags = ImGuiInputTextFlags_EnterReturnsTrue.int32 or ImGuiInputTextFlags_EscapeClearsAll.int32 or ImGuiInputTextFlags_CallbackCompletion.int32 or ImGuiInputTextFlags_CallbackHistory.int32
|
let inputFlags = ImGuiInputTextFlags_EnterReturnsTrue.int32 or ImGuiInputTextFlags_EscapeClearsAll.int32 or ImGuiInputTextFlags_CallbackCompletion.int32 or ImGuiInputTextFlags_CallbackHistory.int32
|
||||||
if igInputText("##Input", component.inputBuffer, 256, inputFlags, nil, nil):
|
if igInputText("##Input", component.inputBuffer, 256, inputFlags, nil, nil):
|
||||||
discard
|
echo component.inputBuffer
|
||||||
|
|
||||||
|
#[
|
||||||
|
Session information (requires footerHeight to be doubled)
|
||||||
|
]#
|
||||||
|
# igSeparator()
|
||||||
|
# igText(fmt"{component.agent.username}@{component.agent.hostname} [{component.agent.ip}]")
|
||||||
|
|
||||||
igSetItemDefaultFocus()
|
igSetItemDefaultFocus()
|
||||||
|
|||||||
Reference in New Issue
Block a user