mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
bell doesn't crash
This commit is contained in:
4
TODO.md
4
TODO.md
@ -7,3 +7,7 @@ Performance:
|
|||||||
Correctness:
|
Correctness:
|
||||||
|
|
||||||
* `exit` in the shell should close the window
|
* `exit` in the shell should close the window
|
||||||
|
|
||||||
|
Visual:
|
||||||
|
|
||||||
|
* bell
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
const Terminal = @This();
|
const Terminal = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ansi = @import("ansi.zig");
|
const ansi = @import("ansi.zig");
|
||||||
const Parser = @import("Parser.zig");
|
const Parser = @import("Parser.zig");
|
||||||
|
|
||||||
|
const log = std.log.scoped(.terminal);
|
||||||
|
|
||||||
/// Screen is the current screen state.
|
/// Screen is the current screen state.
|
||||||
screen: Screen,
|
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.
|
/// This may allocate if necessary to store the character in the grid.
|
||||||
pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void {
|
pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void {
|
||||||
|
log.debug("char: {}", .{c});
|
||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
switch (action_opt orelse continue) {
|
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 {
|
fn execute(self: *Terminal, c: u8) !void {
|
||||||
switch (@intToEnum(ansi.C0, c)) {
|
switch (@intToEnum(ansi.C0, c)) {
|
||||||
|
.BEL => self.bell(),
|
||||||
.BS => self.backspace(),
|
.BS => self.backspace(),
|
||||||
.LF => self.linefeed(),
|
.LF => self.linefeed(),
|
||||||
.CR => self.carriage_return(),
|
.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).
|
/// Backspace moves the cursor back a column (but not less than 0).
|
||||||
pub fn backspace(self: *Terminal) void {
|
pub fn backspace(self: *Terminal) void {
|
||||||
self.cursor.x -|= 1;
|
self.cursor.x -|= 1;
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
/// This is not complete, control characters are only added to this
|
/// This is not complete, control characters are only added to this
|
||||||
/// as the terminal emulator handles them.
|
/// as the terminal emulator handles them.
|
||||||
pub const C0 = enum(u7) {
|
pub const C0 = enum(u7) {
|
||||||
|
/// Bell
|
||||||
|
BEL = 0x07,
|
||||||
/// Backspace
|
/// Backspace
|
||||||
BS = 0x08,
|
BS = 0x08,
|
||||||
/// Line feed
|
/// Line feed
|
||||||
|
Reference in New Issue
Block a user