an experimental irc client

rename: s/zircon/comlink

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+24 -24
+5 -5
README.md
··· 1 - #zircon 1 + # comlink 2 2 3 3 An experimental IRC client written in zig 4 4 5 5 ## Configuration 6 6 7 - Configuration is loaded from `$HOME/.config/zircon/init.lua` 7 + Configuration is loaded from `$HOME/.config/comlink/init.lua` 8 8 9 - Works best (maybe only?) with `soju` 9 + Works best with `soju` 10 10 11 11 ```zig 12 - local zirc = require("zircon") 12 + local comlink = require("comlink") 13 13 14 14 local config = { 15 15 server = "chat.sr.ht", ··· 19 19 real_name = "Tim Culverhouse", 20 20 } 21 21 22 - zirc.connect(config) 22 + comlink.connect(config) 23 23 ```
+1 -1
build.zig
··· 21 21 }); 22 22 23 23 const exe = b.addExecutable(.{ 24 - .name = "zircon", 24 + .name = "comlink", 25 25 .root_source_file = b.path("src/main.zig"), 26 26 .target = target, 27 27 .optimize = optimize,
+1 -1
build.zig.zon
··· 1 1 .{ 2 - .name = "zircon", 2 + .name = "comlink", 3 3 .version = "0.0.0", 4 4 .dependencies = .{ 5 5 .ziglua = .{
+9 -9
docs/zircon.lua docs/comlink.lua
··· 1 1 ---@meta 2 2 3 - --- The primary zircon module 3 + --- The primary comlink module 4 4 -- 5 - ---@class zircon 6 - local zircon = {} 5 + ---@class comlink 6 + local comlink = {} 7 7 8 8 ---@class ConnectionConfiguration 9 9 -- ··· 16 16 ---Set connection configuration 17 17 -- 18 18 ---@param cfg ConnectionConfiguration 19 - function zircon.connect(cfg) end 19 + function comlink.connect(cfg) end 20 20 21 - ---Log a msg to the zircon logs 21 + ---Log a msg to the comlink logs 22 22 -- 23 23 ---@param msg string The message to log 24 - function zircon.log(msg) end 24 + function comlink.log(msg) end 25 25 26 - --- A command for zircon to execute 26 + --- A command for comlink to execute 27 27 -- 28 28 ---@enum action 29 29 local Action = { ··· 40 40 -- 41 41 ---@param key string The key to bind, eg "alt+n", "shift+left" 42 42 ---@param action action The action to perform, eg "quit" 43 - function zircon.bind(key, action) end 43 + function comlink.bind(key, action) end 44 44 45 - return zircon 45 + return comlink
+3 -3
src/App.zig
··· 248 248 _ = try self.lua.getGlobal("package"); // [package] 249 249 _ = self.lua.getField(-1, "preload"); // [package, preload] 250 250 self.lua.pushFunction(ziglua.wrap(lua.preloader)); // [package, preload, function] 251 - self.lua.setField(-2, "zircon"); // [package, preload] 251 + self.lua.setField(-2, "comlink"); // [package, preload] 252 252 // empty the stack 253 253 self.lua.pop(2); // [] 254 254 ··· 259 259 // load config 260 260 const home = std.posix.getenv("HOME") orelse return error.EnvironmentVariableNotFound; 261 261 var buf: [std.posix.PATH_MAX]u8 = undefined; 262 - const path = try std.fmt.bufPrintZ(&buf, "{s}/.config/zircon/init.lua", .{home}); 262 + const path = try std.fmt.bufPrintZ(&buf, "{s}/.config/comlink/init.lua", .{home}); 263 263 switch (ziglua.lang) { 264 264 .luajit, .lua51 => self.lua.loadFile(path) catch return error.LuaError, 265 265 else => self.lua.loadFile(path, .binary_text) catch return error.LuaError, ··· 757 757 try channel.messages.append(msg); 758 758 const content = iter.next() orelse continue; 759 759 if (std.mem.indexOf(u8, content, msg.client.config.nick)) |_| { 760 - try self.vx.notify(writer, "zircon", content); 760 + try self.vx.notify(writer, "comlink", content); 761 761 } 762 762 const time = msg.time orelse continue; 763 763 if (time.instant().unixTimestamp() > channel.last_read)
+2 -2
src/irc.zig
··· 7 7 const zeit = @import("zeit"); 8 8 9 9 const App = @import("App.zig"); 10 - const zircon = @import("main.zig"); 10 + const comlink = @import("main.zig"); 11 11 12 12 const log = std.log.scoped(.irc); 13 13 ··· 282 282 if (!std.mem.eql(u8, tag.key, "time")) continue; 283 283 const instant = try zeit.instant(.{ 284 284 .source = .{ .iso8601 = tag.value }, 285 - .timezone = &zircon.local, 285 + .timezone = &comlink.local, 286 286 }); 287 287 288 288 break :blk instant.time();
+3 -3
src/lua.zig
··· 12 12 pub const registry_index = ziglua.registry_index; 13 13 14 14 /// global key for the app userdata pointer in the registry 15 - pub const app_key = "zircon.app"; 15 + pub const app_key = "comlink.app"; 16 16 17 - /// loads our "zircon" library 17 + /// loads our "comlink" library 18 18 pub fn preloader(lua: *Lua) i32 { 19 19 const fns = [_]ziglua.FnReg{ 20 20 .{ .name = "bind", .func = ziglua.wrap(bind) }, ··· 139 139 /// retrieves the *App lightuserdata from the registry index 140 140 fn getApp(lua: *Lua) *App { 141 141 const lua_type = lua.getField(ziglua.registry_index, app_key); // [userdata] 142 - assert(lua_type == .light_userdata); // set by zircon as a lightuserdata 142 + assert(lua_type == .light_userdata); // set by comlink as a lightuserdata 143 143 const app = lua.toUserdata(App, -1) catch unreachable; // already asserted 144 144 // as lightuserdata 145 145 return app;