@@ -127,7 +127,7 @@ pub const Terminal = struct {
127127 try self .writer .writeAll (if (enable ) "\x1b [?7h" else "\x1b [?7l" );
128128 }
129129
130- fn resetAttributes (self : * Terminal ) ! void {
130+ fn resetAttribute (self : * Terminal ) ! void {
131131 try self .writer .writeAll ("\x1b [0m" );
132132 }
133133
@@ -140,8 +140,8 @@ pub const Terminal = struct {
140140 }
141141
142142 fn drawNumberLine (self : * Terminal , buffer : * buf.Buffer , area : Area ) ! void {
143- try co .Attributes . write (co .Attributes .number_line , self .writer );
144- defer self .resetAttributes () catch {};
143+ try co .Attribute . writeSlice (co .Attribute .number_line , self .writer );
144+ defer self .resetAttribute () catch {};
145145 const cursor_row = buffer .cursor .row ;
146146 for (@intCast (area .pos .row ).. @as (usize , @intCast (area .pos .row )) + area .dims .height ) | term_row | {
147147 const buffer_row = @as (i32 , @intCast (term_row )) + buffer .offset .row ;
@@ -194,15 +194,15 @@ pub const Terminal = struct {
194194 try self .moveCursor (.{ .row = @intCast (term_row ), .col = area .pos .col });
195195 switch (hunk .type ) {
196196 .add = > {
197- try co .Attributes . write (co .Attributes .git_added , self .writer );
197+ try co .Attribute . writeSlice (co .Attribute .git_added , self .writer );
198198 try self .writer .writeAll ("┃" );
199199 },
200200 .delete = > {
201- try co .Attributes . write (co .Attributes .git_deleted , self .writer );
201+ try co .Attribute . writeSlice (co .Attribute .git_deleted , self .writer );
202202 try self .writer .writeAll ("▁" );
203203 },
204204 .modify = > {
205- try co .Attributes . write (co .Attributes .git_modified , self .writer );
205+ try co .Attribute . writeSlice (co .Attribute .git_modified , self .writer );
206206 try self .writer .writeAll ("┃" );
207207 },
208208 }
@@ -252,30 +252,30 @@ pub const Terminal = struct {
252252 if (buffer .ts_state ) | ts_state | {
253253 if (ts_state .highlight ) | hi | {
254254 const highlight_spans = hi .spans .items ;
255- const ch_attrs : []const co.Attr = b : while (span_index < highlight_spans .len ) {
255+ const ch_attrs : []const co.Attribute = b : while (span_index < highlight_spans .len ) {
256256 const span = highlight_spans [span_index ];
257- if (span .span .start > byte ) break :b co .Attributes .text ;
257+ if (span .span .start > byte ) break :b co .Attribute .text ;
258258 if (byte >= span .span .start and byte < span .span .end ) {
259259 break :b span .attrs ;
260260 }
261261 span_index += 1 ;
262262 } else {
263- break :b co .Attributes .text ;
263+ break :b co .Attribute .text ;
264264 };
265- try co .Attributes . write (ch_attrs , & attrs_writer );
265+ try co .Attribute . writeSlice (ch_attrs , & attrs_writer );
266266 }
267267 }
268268
269269 if (buffer .selection ) | selection | {
270270 if (selection .inRange (.{ .row = buffer_row , .col = buffer_col })) {
271- const attr = if (buffer .mode .isSelect ()) co .Attributes .selection else co .Attributes .selection_normal ;
272- try co .Attributes . write (attr , & attrs_writer );
271+ const attr = if (buffer .mode .isSelect ()) co .Attribute .selection else co .Attribute .selection_normal ;
272+ try co .Attribute . writeSlice (attr , & attrs_writer );
273273 }
274274 } else {
275275 if (buffer .mode == .normal ) {
276276 for (buffer .highlights .items ) | hi | {
277277 if (hi .inRange (.{ .row = buffer_row , .col = buffer_col })) {
278- try co .Attributes . write (co .Attributes .highlight , & attrs_writer );
278+ try co .Attribute . writeSlice (co .Attribute .highlight , & attrs_writer );
279279 }
280280 }
281281 }
@@ -286,15 +286,15 @@ pub const Terminal = struct {
286286 const span = diagnostic .span ;
287287
288288 if (span .inRange (.{ .row = buffer_row , .col = buffer_col })) {
289- try co .Attributes . write (co .Attributes . diagnostic_error , & attrs_writer );
289+ try co .Attribute . writeSlice (co .Attribute . diagnosticSeverity ( diagnostic . severity ) , & attrs_writer );
290290 break ;
291291 }
292292 }
293293 }
294294
295295 attrs = attrs_writer .buffered ();
296296 if (last_attrs == null or ! std .mem .eql (u8 , attrs , last_attrs .? )) {
297- self .resetAttributes () catch {};
297+ self .resetAttribute () catch {};
298298 try self .writer .writeAll (attrs );
299299 @memcpy (& last_attrs_buf , & attrs_buf );
300300 last_attrs = last_attrs_buf [0.. attrs .len ];
@@ -308,7 +308,7 @@ pub const Terminal = struct {
308308 if (col_width > 1 ) try self .moveCursor (.{ .row = @intCast (term_row ), .col = area .pos .col + area_col });
309309 }
310310 // reached line end
311- try self .resetAttributes ();
311+ try self .resetAttribute ();
312312 last_attrs = null ;
313313 }
314314 }
@@ -337,7 +337,7 @@ pub const Terminal = struct {
337337 const menu_width = @min (max_width , longest_item + 1 );
338338
339339 {
340- try self .resetAttributes ();
340+ try self .resetAttribute ();
341341
342342 for (0.. cmp_menu .display_items .items .len ) | menu_row | {
343343 const idx = cmp_menu .display_items .items [menu_row ];
@@ -347,9 +347,9 @@ pub const Terminal = struct {
347347 .col = menu_pos .col ,
348348 });
349349 if (menu_row == cmp_menu .active_item ) {
350- try co .Attributes . write (co .Attributes .completion_menu_active , self .writer );
350+ try co .Attribute . writeSlice (co .Attribute .completion_menu_active , self .writer );
351351 } else {
352- try co .Attributes . write (co .Attributes .completion_menu , self .writer );
352+ try co .Attribute . writeSlice (co .Attribute .completion_menu , self .writer );
353353 }
354354 try self .writer .writeAll (cmp_item .label [0.. @min (cmp_item .label .len , menu_width )]);
355355
@@ -360,7 +360,7 @@ pub const Terminal = struct {
360360 }
361361 }
362362 }
363- try self .resetAttributes ();
363+ try self .resetAttribute ();
364364 }
365365
366366 {
@@ -436,8 +436,8 @@ pub const Terminal = struct {
436436 /// Draw a box on top of the editor's content, containing `lines`
437437 /// Box width is min(longest line, available area)
438438 fn drawOverlay (self : * Terminal , lines : []const []const u8 , pos : Cursor ) ! void {
439- try co .Attributes . write (co .Attributes .overlay , self .writer );
440- defer self .resetAttributes () catch {};
439+ try co .Attribute . writeSlice (co .Attribute .overlay , self .writer );
440+ defer self .resetAttribute () catch {};
441441
442442 const max_doc_width = 90 ;
443443 var longest_line : usize = 0 ;
@@ -466,21 +466,21 @@ pub const Terminal = struct {
466466 const message = main .editor .messages .items [main .editor .message_read_idx ];
467467 const message_height = std .mem .count (u8 , message , "\n " ) + 1 ;
468468 try self .moveCursor (.{ .row = @intCast (self .dimensions .height - message_height ) });
469- try co .Attributes . write (co .Attributes .message , self .writer );
469+ try co .Attribute . writeSlice (co .Attribute .message , self .writer );
470470 try self .writer .writeAll (message );
471- try self .resetAttributes ();
471+ try self .resetAttribute ();
472472 }
473473
474474 fn drawCmd (self : * Terminal , command_line : * const cmd.CommandLine ) ! void {
475475 const last_row = self .dimensions .height - 1 ;
476476 const prefix = command_line .command .? .prefix ();
477477 try self .moveCursor (.{ .row = @intCast (last_row ) });
478- try co .Attributes . write (co .Attributes .command_line , self .writer );
478+ try co .Attribute . writeSlice (co .Attribute .command_line , self .writer );
479479 try self .writer .writeAll (prefix );
480480 for (command_line .content .items ) | ch | {
481481 try uni .unicodeToBytesWrite (self .writer , &.{ch });
482482 }
483- try self .resetAttributes ();
483+ try self .resetAttribute ();
484484 try self .moveCursor (.{ .row = @intCast (last_row ), .col = @intCast (prefix .len + command_line .cursor ) });
485485 }
486486};
0 commit comments