termio: changeConfig on reader data

This commit is contained in:
Mitchell Hashimoto
2024-07-13 10:54:04 -07:00
parent 4e6e0f90c7
commit e51180e4a9
3 changed files with 13 additions and 7 deletions

View File

@ -7,6 +7,7 @@ pub const reader = @import("termio/reader.zig");
pub const Options = @import("termio/Options.zig");
pub const Termio = @import("termio/Termio.zig");
pub const Thread = @import("termio/Thread.zig");
pub const DerivedConfig = Termio.DerivedConfig;
pub const Mailbox = Thread.Mailbox;
test {

View File

@ -378,13 +378,7 @@ pub fn changeConfig(self: *Termio, td: *ThreadData, config: *DerivedConfig) !voi
// renderer mutex so this is safe to do despite being executed
// from another thread.
td.ev.terminal_stream.handler.changeConfig(&self.config);
switch (td.reader) {
.manual => {},
.exec => |*exec| {
exec.abnormal_runtime_threshold_ms = config.abnormal_runtime_threshold_ms;
exec.wait_after_command = config.wait_after_command;
},
}
td.reader.changeConfig(&self.config);
// Update the configuration that we know about.
//

View File

@ -1,5 +1,6 @@
const std = @import("std");
const configpkg = @import("../config.zig");
const termio = @import("../termio.zig");
const Command = @import("../Command.zig");
/// The kinds of readers.
@ -45,4 +46,14 @@ pub const ThreadData = union(Kind) {
/// to close the surface.
wait_after_command: bool,
},
pub fn changeConfig(self: *ThreadData, config: *termio.DerivedConfig) void {
switch (self.*) {
.manual => {},
.exec => |*exec| {
exec.abnormal_runtime_threshold_ms = config.abnormal_runtime_threshold_ms;
exec.wait_after_command = config.wait_after_command;
},
}
}
};