an experimental irc client
1const std = @import("std");
2const app = @import("app.zig");
3const completer = @import("completer.zig");
4const vaxis = @import("vaxis");
5pub const irc = @import("irc.zig");
6pub const lua = @import("lua.zig");
7
8pub const App = app.App;
9pub const Completer = completer.Completer;
10pub const WriteQueue = vaxis.Queue(WriteEvent, 32);
11
12pub const Bind = struct {
13 key: vaxis.Key,
14 command: Command,
15};
16
17pub const Command = union(enum) {
18 /// a raw irc command. Sent verbatim
19 quote,
20 join,
21 me,
22 msg,
23 query,
24 @"next-channel",
25 @"prev-channel",
26 quit,
27 who,
28 names,
29 part,
30 close,
31 redraw,
32 version,
33 lua_function: i32,
34
35 pub var user_commands: std.StringHashMap(i32) = undefined;
36
37 /// only contains void commands
38 const map = std.StaticStringMap(Command).initComptime(.{
39 .{ "quote", .quote },
40 .{ "join", .join },
41 .{ "me", .me },
42 .{ "msg", .msg },
43 .{ "query", .query },
44 .{ "next-channel", .@"next-channel" },
45 .{ "prev-channel", .@"prev-channel" },
46 .{ "quit", .quit },
47 .{ "who", .who },
48 .{ "names", .names },
49 .{ "part", .part },
50 .{ "close", .close },
51 .{ "redraw", .redraw },
52 .{ "version", .version },
53 });
54
55 pub fn fromString(str: []const u8) ?Command {
56 return map.get(str);
57 }
58
59 /// if we should append a space when completing
60 pub fn appendSpace(self: Command) bool {
61 return switch (self) {
62 .quote,
63 .join,
64 .me,
65 .msg,
66 .part,
67 .close,
68 => true,
69 else => false,
70 };
71 }
72};
73
74/// An event our write thread will handle
75pub const WriteEvent = union(enum) {
76 write: struct {
77 client: *irc.Client,
78 msg: []const u8,
79 },
80 join,
81};