tangled
alpha
login
or
join now
rockorager.dev
/
comlink
2
fork
atom
an experimental irc client
2
fork
atom
overview
issues
pulls
pipelines
ui: handle /quit properly
rockorager.dev
1 year ago
6c2827f5
07e41c24
+12
-23
2 changed files
expand all
collapse all
unified
split
src
app.zig
ui.zig
+4
-23
src/app.zig
···
59
60
completer: ?Completer,
61
62
-
should_quit: bool,
63
-
64
binds: std.ArrayList(Bind),
65
66
paste_buffer: std.ArrayList(u8),
···
104
.bundle = .{},
105
.deinited = false,
106
.completer = null,
107
-
.should_quit = false,
108
.buffer_list = .{
109
.children = .{
110
.builder = .{
···
207
for (self.binds.items) |bind| {
208
if (key.matches(bind.key.codepoint, bind.key.mods)) {
209
switch (bind.command) {
210
-
.quit => self.should_quit = true,
211
.@"next-channel" => self.nextChannel(),
212
.@"prev-channel" => self.prevChannel(),
213
.redraw => try ctx.queueRefresh(),
···
486
},
487
.@"next-channel" => self.nextChannel(),
488
.@"prev-channel" => self.prevChannel(),
489
-
.quit => self.should_quit = true,
0
0
490
.who => {
491
if (channel == null) return error.InvalidCommand;
492
const msg = try std.fmt.bufPrint(
···
630
}
631
}
632
}
633
-
634
-
/// Returns the number of lines the segments would consume in the given window
635
-
fn lineCountForWindow(win: vaxis.Window, segments: []const vaxis.Segment) usize {
636
-
// Fastpath if we have fewer bytes than the width
637
-
var byte_count: usize = 0;
638
-
for (segments) |segment| {
639
-
byte_count += segment.text.len;
640
-
}
641
-
// One line if we are fewer bytes than the width
642
-
if (byte_count <= win.width) return 1;
643
-
644
-
// Slow path. We have to layout the text
645
-
const result = win.print(segments, .{ .commit = false, .wrap = .word }) catch return 0;
646
-
if (result.col == 0)
647
-
return result.row
648
-
else
649
-
return result.row + 1;
650
-
}
···
59
60
completer: ?Completer,
61
0
0
62
binds: std.ArrayList(Bind),
63
64
paste_buffer: std.ArrayList(u8),
···
102
.bundle = .{},
103
.deinited = false,
104
.completer = null,
0
105
.buffer_list = .{
106
.children = .{
107
.builder = .{
···
204
for (self.binds.items) |bind| {
205
if (key.matches(bind.key.codepoint, bind.key.mods)) {
206
switch (bind.command) {
207
+
.quit => ctx.quit = true,
208
.@"next-channel" => self.nextChannel(),
209
.@"prev-channel" => self.prevChannel(),
210
.redraw => try ctx.queueRefresh(),
···
483
},
484
.@"next-channel" => self.nextChannel(),
485
.@"prev-channel" => self.prevChannel(),
486
+
.quit => {
487
+
if (self.ctx) |ctx| ctx.quit = true;
488
+
},
489
.who => {
490
if (channel == null) return error.InvalidCommand;
491
const msg = try std.fmt.bufPrint(
···
629
}
630
}
631
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
+8
src/ui.zig
···
0
0
0
0
0
0
0
0
···
1
+
const std = @import("std");
2
+
const vaxis = @import("vaxis");
3
+
4
+
const vxfw = vaxis.vxfw;
5
+
6
+
const Allocator = std.mem.Allocator;
7
+
8
+
pub const main = struct {};