Polyphase Game Engine
Loading...
Searching...
No Matches
TerminalOutputBuffer.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <deque>
6#include <mutex>
7#include <string>
8
12enum class TerminalEntryKind
13{
14 Stdout, // raw stdout chunk from the child process
15 Stderr, // raw stderr chunk from the child process
16 System, // session/lifecycle notice (e.g. "[CLI] started cmd.exe")
17 UserEcho, // synthetic echo of a command the user typed
18};
19
28struct TerminalOutputEntry
29{
30 TerminalEntryKind mKind;
31 std::string mText;
32 float mTimestamp; // seconds since engine start, or 0 if AppClock unavailable
33};
34
43class TerminalOutputBuffer
44{
45public:
47 void Append(TerminalEntryKind kind, std::string text, float timestamp);
48
50 void Drain();
51
53 void Clear();
54
56 const std::deque<TerminalOutputEntry>& GetEntries() const { return mEntries; }
57
59 bool IsDirty() const;
60
61private:
62 std::deque<TerminalOutputEntry> mEntries;
63 std::deque<TerminalOutputEntry> mPending;
64 mutable std::mutex mMutex;
65 bool mDirty = false;
66
67 static const size_t kMaxEntries = 8192;
68};
69
70#endif