mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
termio: inspector forces byte-at-a-time processing
This commit is contained in:
@ -1133,17 +1133,20 @@ const ReadThread = struct {
|
||||
// Schedule a render
|
||||
ev.queueRender() catch unreachable;
|
||||
|
||||
// If we have an inspector, send the data to it too. The inspector
|
||||
// will keep track of the VT sequences that we are processing.
|
||||
// If we have an inspector, we enter SLOW MODE because we need to
|
||||
// process a byte at a time alternating between the inspector handler
|
||||
// and the termio handler. This is very slow compared to our optimizations
|
||||
// below but at least users only pay for it if they're using the inspector.
|
||||
if (ev.renderer_state.inspector) |insp| {
|
||||
// This forces all VT sequences to be parsed twice, meaning our
|
||||
// vt processing always slows down by roughly 50% with the inspector
|
||||
// active. That's fine for now but room for improvement.
|
||||
insp.recordPtyRead(buf) catch |err| {
|
||||
for (buf, 0..) |byte, i| {
|
||||
insp.recordPtyRead(buf[i .. i + 1]) catch |err| {
|
||||
log.err("error recording pty read in inspector err={}", .{err});
|
||||
};
|
||||
}
|
||||
|
||||
ev.terminal_stream.next(byte) catch |err|
|
||||
log.err("error processing terminal data: {}", .{err});
|
||||
}
|
||||
} else {
|
||||
// Process the terminal data. This is an extremely hot part of the
|
||||
// terminal emulator, so we do some abstraction leakage to avoid
|
||||
// function calls and unnecessary logic.
|
||||
@ -1182,6 +1185,7 @@ const ReadThread = struct {
|
||||
ev.terminal_stream.nextSlice(buf[i..end]) catch |err|
|
||||
log.err("error processing terminal data: {}", .{err});
|
||||
}
|
||||
}
|
||||
|
||||
// If our stream handling caused messages to be sent to the writer
|
||||
// thread, then we need to wake it up so that it processes them.
|
||||
|
Reference in New Issue
Block a user