this repo has no description
13
fork

Configure Feed

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

TextInput: add ability to draw widget with a style

authored by

Jeffrey C. Ollie and committed by
Tim Culverhouse
1961712c 2cc1eb77

+18 -3
+18 -3
src/widgets/TextInput.zig
··· 131 131 } 132 132 133 133 pub fn draw(self: *TextInput, win: Window) void { 134 + self.drawWithStyle(win, .{}); 135 + } 136 + 137 + pub fn drawWithStyle(self: *TextInput, win: Window, style: Cell.Style) void { 134 138 const cursor_idx = self.graphemesBeforeCursor(); 135 139 if (cursor_idx < self.draw_offset) self.draw_offset = cursor_idx; 136 140 if (win.width == 0) return; ··· 159 163 const g = grapheme.bytes(first_half); 160 164 const w = win.gwidth(g); 161 165 if (col + w >= win.width) { 162 - win.writeCell(win.width - 1, 0, .{ .char = ellipsis }); 166 + win.writeCell(win.width - 1, 0, .{ 167 + .char = ellipsis, 168 + .style = style, 169 + }); 163 170 break; 164 171 } 165 172 win.writeCell(col, 0, .{ ··· 167 174 .grapheme = g, 168 175 .width = w, 169 176 }, 177 + .style = style, 170 178 }); 171 179 col += w; 172 180 i += 1; ··· 182 190 const g = grapheme.bytes(second_half); 183 191 const w = win.gwidth(g); 184 192 if (col + w > win.width) { 185 - win.writeCell(win.width - 1, 0, .{ .char = ellipsis }); 193 + win.writeCell(win.width - 1, 0, .{ 194 + .char = ellipsis, 195 + .style = style, 196 + }); 186 197 break; 187 198 } 188 199 win.writeCell(col, 0, .{ ··· 190 201 .grapheme = g, 191 202 .width = w, 192 203 }, 204 + .style = style, 193 205 }); 194 206 col += w; 195 207 i += 1; 196 208 if (i == cursor_idx) self.prev_cursor_col = col; 197 209 } 198 210 if (self.draw_offset > 0) { 199 - win.writeCell(0, 0, .{ .char = ellipsis }); 211 + win.writeCell(0, 0, .{ 212 + .char = ellipsis, 213 + .style = style, 214 + }); 200 215 } 201 216 win.showCursor(self.prev_cursor_col, 0); 202 217 }