this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

app: set title

+43 -6
+2 -2
build.zig.zon
··· 7 7 .hash = "1220affeb3fe37ef09411b5a213b5fdf9bb6568e9913bade204694648983a8b2776d", 8 8 }, 9 9 .vaxis = .{ 10 - .url = "git+https://github.com/rockorager/libvaxis#4e07fb905ef40e3bd544a563914c769c1cf285d3", 11 - .hash = "1220c42eb95ef849c0d4c131ed2042bfffd392cb61db2f30dbb41148e866b5756610", 10 + .url = "git+https://github.com/rockorager/libvaxis#dbf7e0bf09118a80f7e6184cde1d8f096f82a7da", 11 + .hash = "12207fb15ef5b259a95b581e663713883b172a98855e536a4487ae224b730290b564", 12 12 }, 13 13 .zeit = .{ 14 14 .url = "git+https://github.com/rockorager/zeit?ref=main#d943bc4bfe9e18490460dfdd64f48e997065eba8",
+8 -1
src/app.zig
··· 87 87 buffer_list: vxfw.ListView, 88 88 unicode: *const vaxis.Unicode, 89 89 90 + title_buf: [128]u8, 91 + 90 92 const default_rhs: vxfw.Text = .{ .text = "TODO: update this text" }; 91 93 92 94 /// initialize vaxis, lua state ··· 122 124 .draw_cursor = false, 123 125 }, 124 126 .unicode = unicode, 127 + .title_buf = undefined, 125 128 }; 126 129 127 130 self.lua = try Lua.init(&self.alloc); ··· 212 215 fn typeErasedEventHandler(ptr: *anyopaque, ctx: *vxfw.EventContext, event: vxfw.Event) anyerror!void { 213 216 const self: *App = @ptrCast(@alignCast(ptr)); 214 217 switch (event) { 215 - .init => try ctx.tick(8, self.widget()), 218 + .init => { 219 + const title = try std.fmt.bufPrint(&self.title_buf, "comlink", .{}); 220 + try ctx.setTitle(title); 221 + try ctx.tick(8, self.widget()); 222 + }, 216 223 .key_press => |key| { 217 224 if (key.matches('c', .{ .ctrl = true })) { 218 225 ctx.quit = true;
+33 -3
src/irc.zig
··· 252 252 if (mouse.type == .press and mouse.button == .left) { 253 253 self.client.app.selectBuffer(.{ .channel = self }); 254 254 try ctx.requestFocus(self.text_field.widget()); 255 + const buf = &self.client.app.title_buf; 256 + const suffix = " - comlink"; 257 + if (self.name.len + suffix.len <= buf.len) { 258 + const title = try std.fmt.bufPrint(buf, "{s}{s}", .{ self.name, suffix }); 259 + try ctx.setTitle(title); 260 + } else { 261 + const title = try std.fmt.bufPrint( 262 + buf, 263 + "{s}{s}", 264 + .{ self.name[0 .. buf.len - suffix.len], suffix }, 265 + ); 266 + try ctx.setTitle(title); 267 + } 255 268 return ctx.consumeAndRedraw(); 256 269 } 257 270 }, ··· 302 315 pub fn addMember(self: *Channel, user: *User, args: struct { 303 316 prefix: ?u8 = null, 304 317 sort: bool = true, 305 - }) !void { 318 + }) Allocator.Error!void { 306 319 if (args.prefix) |p| { 307 320 log.debug("adding member: nick={s}, prefix={c}", .{ user.nick, p }); 308 321 } ··· 358 371 359 372 fn typeErasedViewDraw(ptr: *anyopaque, ctx: vxfw.DrawContext) Allocator.Error!vxfw.Surface { 360 373 const self: *Channel = @ptrCast(@alignCast(ptr)); 374 + if (!self.who_requested) { 375 + try self.client.whox(self); 376 + } 361 377 362 378 const max = ctx.max.size(); 363 379 var children = std.ArrayList(vxfw.SubSurface).init(ctx.arena); ··· 822 838 try ctx.setMouseShape(.pointer); 823 839 if (mouse.type == .press and mouse.button == .left) { 824 840 self.app.selectBuffer(.{ .client = self }); 841 + const buf = &self.app.title_buf; 842 + const suffix = " - comlink"; 843 + const name = self.config.name orelse self.config.server; 844 + if (name.len + suffix.len <= buf.len) { 845 + const title = try std.fmt.bufPrint(buf, "{s}{s}", .{ name, suffix }); 846 + try ctx.setTitle(title); 847 + } else { 848 + const title = try std.fmt.bufPrint( 849 + buf, 850 + "{s}{s}", 851 + .{ name[0 .. buf.len - suffix.len], suffix }, 852 + ); 853 + try ctx.setTitle(title); 854 + } 825 855 return ctx.consumeAndRedraw(); 826 856 } 827 857 }, ··· 1488 1518 ); 1489 1519 } 1490 1520 1491 - pub fn getOrCreateChannel(self: *Client, name: []const u8) !*Channel { 1521 + pub fn getOrCreateChannel(self: *Client, name: []const u8) Allocator.Error!*Channel { 1492 1522 for (self.channels.items) |channel| { 1493 1523 if (caseFold(name, channel.name)) return channel; 1494 1524 } ··· 1502 1532 1503 1533 var color_indices = [_]u8{ 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14 }; 1504 1534 1505 - pub fn getOrCreateUser(self: *Client, nick: []const u8) !*User { 1535 + pub fn getOrCreateUser(self: *Client, nick: []const u8) Allocator.Error!*User { 1506 1536 return self.users.get(nick) orelse { 1507 1537 const color_u32 = std.hash.Fnv1a_32.hash(nick); 1508 1538 const index = color_u32 % color_indices.len;