termio: configure OSC parser with an allocator

This commit is contained in:
Mitchell Hashimoto
2023-10-15 08:41:38 -07:00
parent cfac6c4001
commit de1ed071ad
3 changed files with 17 additions and 0 deletions

View File

@ -218,6 +218,10 @@ pub fn init() Parser {
return .{};
}
pub fn deinit(self: *Parser) void {
self.osc_parser.deinit();
}
/// Next consumes the next character c and returns the actions to execute.
/// Up to 3 actions may need to be executed -- in order -- representing
/// the state exit, transition, and entry actions.

View File

@ -38,6 +38,10 @@ pub fn Stream(comptime Handler: type) type {
handler: Handler,
parser: Parser = .{},
pub fn deinit(self: *Self) void {
self.parser.deinit();
}
/// Process a string of characters.
pub fn nextSlice(self: *Self, c: []const u8) !void {
const tracy = trace(@src());

View File

@ -229,6 +229,14 @@ pub fn threadEnter(self: *Exec, thread: *termio.Thread) !ThreadData {
.default_background_color = self.default_background_color,
.osc_color_report_format = self.osc_color_report_format,
},
.parser = .{
.osc_parser = .{
// Populate the OSC parser allocator (optional) because
// we want to support large OSC payloads such as OSC 52.
.alloc = self.alloc,
},
},
},
};
errdefer ev_data_ptr.deinit(self.alloc);
@ -565,6 +573,7 @@ const EventData = struct {
// Clear any StreamHandler state
self.terminal_stream.handler.deinit();
self.terminal_stream.deinit();
}
/// This queues a render operation with the renderer thread. The render