mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Add a minor optimisatin: if the character being printed is space, don't worry
about setting the background colour or attributes (except reverse).
This commit is contained in:
		| @@ -257,6 +257,7 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp) | |||||||
| 	if (wp->sx < len * 6 || wp->sy < 5) { | 	if (wp->sx < len * 6 || wp->sy < 5) { | ||||||
| 		tty_cursor(tty, xoff + px - len / 2, yoff + py); | 		tty_cursor(tty, xoff + px - len / 2, yoff + py); | ||||||
| 		memcpy(&gc, &grid_default_cell, sizeof gc); | 		memcpy(&gc, &grid_default_cell, sizeof gc); | ||||||
|  | 		gc.data = '_'; /* not space */ | ||||||
| 		colour_set_fg(&gc, colour); | 		colour_set_fg(&gc, colour); | ||||||
| 		tty_attributes(tty, &gc); | 		tty_attributes(tty, &gc); | ||||||
| 		tty_puts(tty, buf); | 		tty_puts(tty, buf); | ||||||
| @@ -267,6 +268,7 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp) | |||||||
| 	py -= 2; | 	py -= 2; | ||||||
|  |  | ||||||
| 	memcpy(&gc, &grid_default_cell, sizeof gc); | 	memcpy(&gc, &grid_default_cell, sizeof gc); | ||||||
|  | 	gc.data = '_'; /* not space */ | ||||||
| 	colour_set_bg(&gc, colour); | 	colour_set_bg(&gc, colour); | ||||||
| 	tty_attributes(tty, &gc); | 	tty_attributes(tty, &gc); | ||||||
| 	for (ptr = buf; *ptr != '\0'; ptr++) { | 	for (ptr = buf; *ptr != '\0'; ptr++) { | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								tty.c
									
									
									
									
									
								
							| @@ -1119,10 +1119,24 @@ out: | |||||||
| void | void | ||||||
| tty_attributes(struct tty *tty, const struct grid_cell *gc) | tty_attributes(struct tty *tty, const struct grid_cell *gc) | ||||||
| { | { | ||||||
| 	struct grid_cell	*tc = &tty->cell; | 	struct grid_cell	*tc = &tty->cell, gc2; | ||||||
| 	u_char			 changed; | 	u_char			 changed; | ||||||
| 	u_int			 fg = gc->fg, bg = gc->bg, attr = gc->attr; | 	u_int			 fg = gc->fg, bg = gc->bg, attr = gc->attr; | ||||||
|  |  | ||||||
|  | 	/* If the character is space, don't care about foreground. */ | ||||||
|  | 	if (gc->data == ' ' && !(gc->flags & GRID_FLAG_UTF8)) { | ||||||
|  | 		memcpy(&gc2, gc, sizeof gc2); | ||||||
|  |  | ||||||
|  | 		if (gc->attr & GRID_ATTR_REVERSE) | ||||||
|  | 			gc2.bg = tc->bg; | ||||||
|  | 		else | ||||||
|  | 			gc2.fg = tc->fg; | ||||||
|  | 		gc2.attr = tc->attr & ~GRID_ATTR_REVERSE; | ||||||
|  | 		gc2.attr |= gc->attr & GRID_ATTR_REVERSE; | ||||||
|  |  | ||||||
|  | 		gc = &gc2; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/* If any bits are being cleared, reset everything. */ | 	/* If any bits are being cleared, reset everything. */ | ||||||
| 	if (tc->attr & ~attr) | 	if (tc->attr & ~attr) | ||||||
| 		tty_reset(tty); | 		tty_reset(tty); | ||||||
| @@ -1185,7 +1199,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr) | |||||||
| 	/* No changes? Nothing is necessary. */ | 	/* No changes? Nothing is necessary. */ | ||||||
| 	if (fg == tc->fg && bg == tc->bg && | 	if (fg == tc->fg && bg == tc->bg && | ||||||
| 	    ((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0) | 	    ((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0) | ||||||
| 		return;   | 		return; | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Is either the default colour? This is handled specially because the | 	 * Is either the default colour? This is handled specially because the | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott