mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
bell doesn't crash
This commit is contained in:
4
TODO.md
4
TODO.md
@ -7,3 +7,7 @@ Performance:
|
||||
Correctness:
|
||||
|
||||
* `exit` in the shell should close the window
|
||||
|
||||
Visual:
|
||||
|
||||
* bell
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user