this repo has no description
3
fork

Configure Feed

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

ui: limit scroll to oldest message, draw indicator

+39
+39
src/irc.zig
··· 121 121 history_requested: bool = false, 122 122 who_requested: bool = false, 123 123 at_oldest: bool = false, 124 + can_scroll_up: bool = false, 124 125 // The MARKREAD state of this channel 125 126 last_read: u32 = 0, 126 127 // The location of the last read indicator. This doesn't necessarily match the state of ··· 850 851 851 852 // Scroll up 852 853 if (self.scroll.pending > 0) { 854 + // Check if we can scroll up. If we can't, we are done 855 + if (!self.can_scroll_up) { 856 + self.scroll.pending = 0; 857 + return; 858 + } 853 859 // Consume 1 line, and schedule a tick 854 860 self.scroll.offset += 1; 855 861 self.scroll.pending -= 1; ··· 1198 1204 // We will set the msg offset too to prevent any bumping of the scroll state when we get 1199 1205 // a new message 1200 1206 self.scroll.msg_offset = self.messages.items.len; 1207 + } 1208 + 1209 + // Set the can_scroll_up flag. this is true if we drew past the top of the screen 1210 + self.can_scroll_up = row <= 0; 1211 + if (row > 0) { 1212 + // If we didn't draw past the top of the screen, we must have reached the end of 1213 + // history. Draw an indicator letting the user know this 1214 + const bot = "━"; 1215 + var writer = try std.ArrayList(u8).initCapacity(ctx.arena, bot.len * max.width); 1216 + try writer.writer().writeBytesNTimes(bot, max.width); 1217 + 1218 + const border: vxfw.Text = .{ 1219 + .text = writer.items, 1220 + .style = .{ .fg = .{ .index = 8 } }, 1221 + .softwrap = false, 1222 + }; 1223 + 1224 + const unread: vxfw.SubSurface = .{ 1225 + .origin = .{ .col = 0, .row = row }, 1226 + .surface = try border.draw(ctx), 1227 + }; 1228 + try children.append(unread); 1229 + const no_more_history: vxfw.Text = .{ 1230 + .text = "No more history", 1231 + .style = .{ .fg = .{ .index = 8 } }, 1232 + .softwrap = false, 1233 + }; 1234 + const no_history_surf = try no_more_history.draw(ctx); 1235 + const new_sub: vxfw.SubSurface = .{ 1236 + .origin = .{ .col = (max.width -| no_history_surf.size.width) / 2, .row = row }, 1237 + .surface = no_history_surf, 1238 + }; 1239 + try children.append(new_sub); 1201 1240 } 1202 1241 1203 1242 if (did_scroll_to_last_read) {