fix: fixes for shell/Terminal issues and CPU burn
This commit is contained in:
@@ -20,6 +20,7 @@ struct TermCell {
|
||||
};
|
||||
|
||||
static constexpr int TERM_MAX_SCROLLBACK = 500;
|
||||
static constexpr int TERM_MAX_READS_PER_POLL = 8;
|
||||
|
||||
struct TerminalState {
|
||||
TermCell* cells;
|
||||
@@ -716,8 +717,8 @@ static inline void terminal_handle_key(TerminalState* t, const Montauk::KeyEvent
|
||||
static inline bool terminal_poll(TerminalState* t) {
|
||||
if (t->child_pid <= 0) return false;
|
||||
char buf[4096];
|
||||
// Drain all available data so large output renders in one frame
|
||||
for (;;) {
|
||||
// Drain a bounded amount per frame so window close/input events stay responsive.
|
||||
for (int reads = 0; reads < TERM_MAX_READS_PER_POLL; reads++) {
|
||||
int n = montauk::childio_read(t->child_pid, buf, sizeof(buf));
|
||||
if (n > 0) {
|
||||
terminal_feed(t, buf, n);
|
||||
|
||||
Reference in New Issue
Block a user