fix: remove thespian from win32 renderer module
This commit is contained in:
parent
9047439315
commit
7bfb9a2216
3 changed files with 34 additions and 32 deletions
|
@ -150,7 +150,7 @@ pub fn process_renderer_event(self: *Self, msg: []const u8) !void {
|
||||||
var input_: []const u8 = undefined;
|
var input_: []const u8 = undefined;
|
||||||
var text_: []const u8 = undefined;
|
var text_: []const u8 = undefined;
|
||||||
if (!try cbor.match(msg, .{ "RDR", cbor.extract(&input_), cbor.extract(&text_) }))
|
if (!try cbor.match(msg, .{ "RDR", cbor.extract(&input_), cbor.extract(&text_) }))
|
||||||
return error.InvalidRendererEvent;
|
return error.UnexpectedRendererEvent;
|
||||||
const text = if (text_.len > 0) text_ else null;
|
const text = if (text_.len > 0) text_ else null;
|
||||||
const event = std.mem.bytesAsValue(vaxis.Event, input_);
|
const event = std.mem.bytesAsValue(vaxis.Event, input_);
|
||||||
switch (event.*) {
|
switch (event.*) {
|
||||||
|
|
|
@ -3,7 +3,6 @@ pub const log_name = "renderer";
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const cbor = @import("cbor");
|
const cbor = @import("cbor");
|
||||||
const thespian = @import("thespian");
|
|
||||||
const vaxis = @import("vaxis");
|
const vaxis = @import("vaxis");
|
||||||
const Style = @import("theme").Style;
|
const Style = @import("theme").Style;
|
||||||
const Color = @import("theme").Color;
|
const Color = @import("theme").Color;
|
||||||
|
@ -149,7 +148,7 @@ pub fn leave_alternate_screen(self: *Self) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
@panic("todo");
|
@panic("todo");
|
||||||
}
|
}
|
||||||
pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
pub fn process_renderer_event(self: *Self, msg: []const u8) !void {
|
||||||
const Input = struct {
|
const Input = struct {
|
||||||
kind: u8,
|
kind: u8,
|
||||||
codepoint: u21,
|
codepoint: u21,
|
||||||
|
@ -172,14 +171,14 @@ pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
||||||
|
|
||||||
{
|
{
|
||||||
var args: Input = undefined;
|
var args: Input = undefined;
|
||||||
if (try m.match(.{
|
if (try cbor.match(msg, .{
|
||||||
thespian.any,
|
cbor.any,
|
||||||
"I",
|
"I",
|
||||||
thespian.extract(&args.kind),
|
cbor.extract(&args.kind),
|
||||||
thespian.extract(&args.codepoint),
|
cbor.extract(&args.codepoint),
|
||||||
thespian.extract(&args.shifted_codepoint),
|
cbor.extract(&args.shifted_codepoint),
|
||||||
thespian.extract(&args.text),
|
cbor.extract(&args.text),
|
||||||
thespian.extract(&args.mods),
|
cbor.extract(&args.mods),
|
||||||
})) {
|
})) {
|
||||||
var buf: [300]u8 = undefined;
|
var buf: [300]u8 = undefined;
|
||||||
const cbor_msg = fmtmsg(&buf, .{
|
const cbor_msg = fmtmsg(&buf, .{
|
||||||
|
@ -197,13 +196,13 @@ pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
||||||
|
|
||||||
{
|
{
|
||||||
var args: Winsize = undefined;
|
var args: Winsize = undefined;
|
||||||
if (try m.match(.{
|
if (try cbor.match(msg, .{
|
||||||
thespian.any,
|
cbor.any,
|
||||||
"Resize",
|
"Resize",
|
||||||
thespian.extract(&args.cell_width),
|
cbor.extract(&args.cell_width),
|
||||||
thespian.extract(&args.cell_height),
|
cbor.extract(&args.cell_height),
|
||||||
thespian.extract(&args.pixel_width),
|
cbor.extract(&args.pixel_width),
|
||||||
thespian.extract(&args.pixel_height),
|
cbor.extract(&args.pixel_height),
|
||||||
})) {
|
})) {
|
||||||
var drop_writer = DropWriter{};
|
var drop_writer = DropWriter{};
|
||||||
self.vx.resize(self.allocator, drop_writer.writer().any(), .{
|
self.vx.resize(self.allocator, drop_writer.writer().any(), .{
|
||||||
|
@ -222,13 +221,13 @@ pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var args: MousePos = undefined;
|
var args: MousePos = undefined;
|
||||||
if (try m.match(.{
|
if (try cbor.match(msg, .{
|
||||||
thespian.any,
|
cbor.any,
|
||||||
"M",
|
"M",
|
||||||
thespian.extract(&args.col),
|
cbor.extract(&args.col),
|
||||||
thespian.extract(&args.row),
|
cbor.extract(&args.row),
|
||||||
thespian.extract(&args.xoffset),
|
cbor.extract(&args.xoffset),
|
||||||
thespian.extract(&args.yoffset),
|
cbor.extract(&args.yoffset),
|
||||||
})) {
|
})) {
|
||||||
var buf: [200]u8 = undefined;
|
var buf: [200]u8 = undefined;
|
||||||
if (self.dispatch_mouse) |f| f(
|
if (self.dispatch_mouse) |f| f(
|
||||||
|
@ -254,15 +253,15 @@ pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
||||||
id: u8,
|
id: u8,
|
||||||
},
|
},
|
||||||
} = undefined;
|
} = undefined;
|
||||||
if (try m.match(.{
|
if (try cbor.match(msg, .{
|
||||||
thespian.any,
|
cbor.any,
|
||||||
"B",
|
"B",
|
||||||
thespian.extract(&args.button.press),
|
cbor.extract(&args.button.press),
|
||||||
thespian.extract(&args.button.id),
|
cbor.extract(&args.button.id),
|
||||||
thespian.extract(&args.pos.col),
|
cbor.extract(&args.pos.col),
|
||||||
thespian.extract(&args.pos.row),
|
cbor.extract(&args.pos.row),
|
||||||
thespian.extract(&args.pos.xoffset),
|
cbor.extract(&args.pos.xoffset),
|
||||||
thespian.extract(&args.pos.yoffset),
|
cbor.extract(&args.pos.yoffset),
|
||||||
})) {
|
})) {
|
||||||
var buf: [200]u8 = undefined;
|
var buf: [200]u8 = undefined;
|
||||||
if (self.dispatch_mouse) |f| f(
|
if (self.dispatch_mouse) |f| f(
|
||||||
|
@ -283,7 +282,7 @@ pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return thespian.unexpected(m);
|
return error.UnexpectedRendererEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_input_event(self: *Self, input_: []const u8, text: ?[]const u8) !void {
|
pub fn process_input_event(self: *Self, input_: []const u8, text: ?[]const u8) !void {
|
||||||
|
|
|
@ -249,7 +249,10 @@ fn receive(self: *Self, from: tp.pid_ref, m: tp.message) tp.result {
|
||||||
|
|
||||||
fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
if (try m.match(.{ "RDR", tp.more })) {
|
if (try m.match(.{ "RDR", tp.more })) {
|
||||||
try self.rdr.process_renderer_event(m.buf);
|
self.rdr.process_renderer_event(m.buf) catch |e| switch (e) {
|
||||||
|
error.UnexpectedRendererEvent => return tp.unexpected(m),
|
||||||
|
else => return e,
|
||||||
|
};
|
||||||
try self.dispatch_flush_input_event();
|
try self.dispatch_flush_input_event();
|
||||||
if (self.unrendered_input_events_count > 0 and !self.frame_clock_running)
|
if (self.unrendered_input_events_count > 0 and !self.frame_clock_running)
|
||||||
need_render();
|
need_render();
|
||||||
|
|
Loading…
Add table
Reference in a new issue