mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
additional tests on OSC parsing
This commit is contained in:
@ -567,6 +567,31 @@ test "osc: change window title" {
|
||||
|
||||
const cmd = a[0].?.osc_dispatch;
|
||||
try testing.expect(cmd == .change_window_title);
|
||||
try testing.expectEqualStrings("abc", cmd.change_window_title);
|
||||
}
|
||||
}
|
||||
|
||||
test "osc: change window title (end in esc)" {
|
||||
var p = init();
|
||||
_ = p.next(0x1B);
|
||||
_ = p.next(']');
|
||||
_ = p.next('0');
|
||||
_ = p.next(';');
|
||||
_ = p.next('a');
|
||||
_ = p.next('b');
|
||||
_ = p.next('c');
|
||||
|
||||
{
|
||||
const a = p.next(0x1B);
|
||||
_ = p.next('\\');
|
||||
try testing.expect(p.state == .ground);
|
||||
try testing.expect(a[0].? == .osc_dispatch);
|
||||
try testing.expect(a[1] == null);
|
||||
try testing.expect(a[2] == null);
|
||||
|
||||
const cmd = a[0].?.osc_dispatch;
|
||||
try testing.expect(cmd == .change_window_title);
|
||||
try testing.expectEqualStrings("abc", cmd.change_window_title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,11 +326,7 @@ pub const Parser = struct {
|
||||
else => self.state = .invalid,
|
||||
},
|
||||
|
||||
.string => {
|
||||
// Complete once we receive one character since we have
|
||||
// at least SOME value for the expected string value.
|
||||
self.complete = true;
|
||||
},
|
||||
.string => self.complete = true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,6 +348,10 @@ pub const Parser = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn endString(self: *Parser) void {
|
||||
self.temp_state.str.* = self.buf[self.buf_start..self.buf_idx];
|
||||
}
|
||||
|
||||
/// End the sequence and return the command, if any. If the return value
|
||||
/// is null, then no valid command was found.
|
||||
pub fn end(self: *Parser) ?Command {
|
||||
@ -364,7 +364,7 @@ pub const Parser = struct {
|
||||
switch (self.state) {
|
||||
.semantic_exit_code => self.endSemanticExitCode(),
|
||||
.semantic_option_value => self.endSemanticOptionValue(),
|
||||
.string => self.temp_state.str.* = self.buf[self.buf_start..self.buf_idx],
|
||||
.string => self.endString(),
|
||||
else => {},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user