blob: eeae6a710ff388345d7f1f0d07a19ffd84fed3e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
const std = @import("std");
const Parser = @import("../../osc.zig").Parser;
const Command = @import("../../osc.zig").Command;
/// Parse OSC 1
pub fn parse(parser: *Parser, _: ?u8) ?*Command {
const cap = if (parser.capture) |*c| c else {
parser.state = .invalid;
return null;
};
cap.writer.writeByte(0) catch {
parser.state = .invalid;
return null;
};
const data = cap.trailing();
parser.command = .{
.change_window_icon = data[0 .. data.len - 1 :0],
};
return &parser.command;
}
test "OSC 1: change_window_icon" {
const testing = std.testing;
var p: Parser = .init(null);
p.next('1');
p.next(';');
p.next('a');
p.next('b');
const cmd = p.end(null).?.*;
try testing.expect(cmd == .change_window_icon);
try testing.expectEqualStrings("ab", cmd.change_window_icon);
}
|