mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	If the terminfo entry has colors#256, assume that setaf and setab work
and use them for the 256 colour set. If the terminfo entry doesn't have colors#256 and the user gives -2 to the client, use a \033[38;5;Xm sequence as before. Should allow fbterm to work with it's weird setaf and setab.
This commit is contained in:
		
							
								
								
									
										28
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								tty.c
									
									
									
									
									
								
							@@ -1581,13 +1581,29 @@ tty_try_256(struct tty *tty, u_char colour, const char *type)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	char	s[32];
 | 
						char	s[32];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!(tty->term->flags & TERM_256COLOURS) &&
 | 
						/*
 | 
				
			||||||
	    !(tty->term_flags & TERM_256COLOURS))
 | 
						 * If the terminfo entry has 256 colours, assume that setaf and setab
 | 
				
			||||||
		return (-1);
 | 
						 * work correctly.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (tty->term->flags & TERM_256COLOURS) {
 | 
				
			||||||
 | 
							if (*type == '3')
 | 
				
			||||||
 | 
								tty_putcode1(tty, TTYC_SETAF, colour);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								tty_putcode1(tty, TTYC_SETAB, colour);
 | 
				
			||||||
 | 
							return (0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
 | 
						/*
 | 
				
			||||||
	tty_puts(tty, s);
 | 
						 * If the user has specified -2 to the client, setaf and setab may not
 | 
				
			||||||
	return (0);
 | 
						 * work, so send the usual sequence.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (tty->term_flags & TERM_256COLOURS) {
 | 
				
			||||||
 | 
							xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
 | 
				
			||||||
 | 
							tty_puts(tty, s);
 | 
				
			||||||
 | 
							return (0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (-1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user