srctree

Gregory Mullen parent 4638f3bb 9918b168
half-fix for ctrl-c

src/input.zig added: 11, removed: 5, total 6
@@ -67,7 +67,8 @@ pub const Event = union(enum) {
};
 
stdin: std.posix.fd_t,
hsh: ?*const fn () bool = null,
spin: ?*const fn (?*HSH) bool = null,
hsh: ?*HSH = null,
next: ?Event = null,
 
pub fn init(stdin: std.posix.fd_t) Input {
@@ -219,7 +220,7 @@ pub fn interactive(input: Input) errors!Event {
return error.io;
};
while (nbyte == 0) {
if (input.hsh) |spin| if (spin()) return error.signaled;
if (input.spin) |spin| if (spin(input.hsh)) return error.signaled;
nbyte = input.read(&buffer) catch |err| {
log.err("unable to read {}", .{err});
return error.io;
 
src/line.zig added: 11, removed: 5, total 6
@@ -47,11 +47,16 @@ pub fn init(hsh: *HSH, comp: *Complete.CompSet, options: Options) Line {
.completion = comp,
.options = options,
.history = History.init(hsh.hfs.history, hsh.alloc),
.input = Input.init(hsh.input),
.input = .{ .stdin = hsh.input, .spin = spin, .hsh = hsh },
.mode = if (options.interactive) .{ .interactive = {} } else .{ .scripted = {} },
};
}
 
fn spin(hsh: ?*HSH) bool {
if (hsh) |h| return h.spin();
return false;
}
 
pub fn do(line: *Line) !bool {
while (true) {
const input = switch (line.mode) {