an experimental irc client

ui: limit completer height

rockorager.dev a51b6646 ec896d27

verified
+17 -2
+17 -2
src/irc.zig
··· 280 280 .completer = Completer.init(gpa), 281 281 }; 282 282 283 + self.text_field.style = .{ .bg = .{ .index = 8 } }; 283 284 self.text_field.userdata = self; 284 285 self.text_field.onSubmit = Channel.onSubmit; 285 286 self.text_field.onChange = Channel.onChange; ··· 735 736 .origin = .{ .col = 0, .row = max.height - 1 }, 736 737 .surface = try self.text_field.draw(text_field_ctx), 737 738 }); 739 + // Write some placeholder text if we don't have anything in the text field 740 + if (self.text_field.buf.realLength() == 0) { 741 + const text = try std.fmt.allocPrint(ctx.arena, "Message {s}", .{self.name}); 742 + var text_style = self.text_field.style; 743 + text_style.italic = true; 744 + text_style.dim = true; 745 + var ghost_text_ctx = text_field_ctx; 746 + ghost_text_ctx.max.width = text_field_ctx.max.width.? -| 2; 747 + const ghost_text: vxfw.Text = .{ .text = text, .style = text_style }; 748 + try children.append(.{ 749 + .origin = .{ .col = 2, .row = max.height - 1 }, 750 + .surface = try ghost_text.draw(ghost_text_ctx), 751 + }); 752 + } 738 753 } 739 754 740 755 if (self.completer_shown) { 741 756 const widest: u16 = @intCast(self.completer.widestMatch(ctx)); 742 - const completer_ctx = ctx.withConstraints(ctx.min, .{ .height = 10, .width = widest + 2 }); 743 - const surface = try self.completer.list_view.draw(completer_ctx); 744 757 const height: u16 = @intCast(@min(10, self.completer.options.items.len)); 758 + const completer_ctx = ctx.withConstraints(ctx.min, .{ .height = height, .width = widest + 2 }); 759 + const surface = try self.completer.list_view.draw(completer_ctx); 745 760 try children.append(.{ 746 761 .origin = .{ .col = 0, .row = max.height -| 1 -| height }, 747 762 .surface = surface,