diff --git a/TODO.md b/TODO.md index 84d69d76e..65f3535f6 100644 --- a/TODO.md +++ b/TODO.md @@ -7,3 +7,7 @@ Performance: Correctness: * `exit` in the shell should close the window + +Visual: + +* bell diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 77fe678ca..9437844ef 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -4,11 +4,14 @@ const Terminal = @This(); const std = @import("std"); +const builtin = @import("builtin"); const testing = std.testing; const Allocator = std.mem.Allocator; const ansi = @import("ansi.zig"); const Parser = @import("Parser.zig"); +const log = std.log.scoped(.terminal); + /// Screen is the current screen state. screen: Screen, @@ -105,6 +108,7 @@ pub fn append(self: *Terminal, alloc: Allocator, str: []const u8) !void { /// /// This may allocate if necessary to store the character in the grid. pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void { + log.debug("char: {}", .{c}); const actions = self.parser.next(c); for (actions) |action_opt| { switch (action_opt orelse continue) { @@ -127,12 +131,19 @@ fn print(self: *Terminal, alloc: Allocator, c: u8) !void { fn execute(self: *Terminal, c: u8) !void { switch (@intToEnum(ansi.C0, c)) { + .BEL => self.bell(), .BS => self.backspace(), .LF => self.linefeed(), .CR => self.carriage_return(), } } +pub fn bell(self: *Terminal) void { + // TODO: bell + _ = self; + log.info("bell", .{}); +} + /// Backspace moves the cursor back a column (but not less than 0). pub fn backspace(self: *Terminal) void { self.cursor.x -|= 1; diff --git a/src/terminal/ansi.zig b/src/terminal/ansi.zig index a4310b82d..19d5e6b43 100644 --- a/src/terminal/ansi.zig +++ b/src/terminal/ansi.zig @@ -3,6 +3,8 @@ /// This is not complete, control characters are only added to this /// as the terminal emulator handles them. pub const C0 = enum(u7) { + /// Bell + BEL = 0x07, /// Backspace BS = 0x08, /// Line feed