mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Accept colours as strings.
This commit is contained in:
		
							
								
								
									
										5
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								CHANGES
									
									
									
									
									
								
							@@ -2,7 +2,8 @@
 | 
			
		||||
 | 
			
		||||
* (nicm) send-prefix command. Bound to C-b by default.
 | 
			
		||||
* (nicm) set status, status-fg, status-bg commands. fg and bg are as a number
 | 
			
		||||
  from 0 to 7. status may be 0/1/on/off/yes/no.
 | 
			
		||||
  from 0 to 8 or a string ("red", "blue", etc). status may be 1/0, on/off,
 | 
			
		||||
  yes/no.
 | 
			
		||||
* (nicm) Make status line mark window in yellow on bell.
 | 
			
		||||
 | 
			
		||||
04 October 2007
 | 
			
		||||
@@ -125,5 +126,5 @@
 | 
			
		||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
			
		||||
  customisation.
 | 
			
		||||
 | 
			
		||||
$Id: CHANGES,v 1.39 2007-10-12 13:03:58 nicm Exp $
 | 
			
		||||
$Id: CHANGES,v 1.40 2007-10-12 13:51:44 nicm Exp $
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								TODO
									
									
									
									
									
								
							@@ -42,8 +42,7 @@
 | 
			
		||||
- Nested sessions over the network, plug-in another tmux as a window/subsession
 | 
			
		||||
- it would be nice to have multichar commands so you could have C-b K K for
 | 
			
		||||
  kill-window to limit accidental presses
 | 
			
		||||
- status-fg/status-bg should be able to a) use strings for colours "red" etc
 | 
			
		||||
  b) set attributes too ("bold-red"?)
 | 
			
		||||
- status-fg/status-bg should be to set attributes: bold, etc
 | 
			
		||||
 | 
			
		||||
-- For 0.1 --------------------------------------------------------------------
 | 
			
		||||
- man page
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.6 2007-10-12 12:11:40 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.7 2007-10-12 13:51:44 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -139,7 +139,8 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
			ctx->error(ctx, "invalid value");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (errstr != NULL || number > 7) {
 | 
			
		||||
		number = screen_stringcolour(data->value);
 | 
			
		||||
		if (number > 8) {
 | 
			
		||||
			ctx->error(ctx, "bad colour: %s", data->value);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
@@ -157,7 +158,8 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
			ctx->error(ctx, "invalid value");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (errstr != NULL || number > 7) {
 | 
			
		||||
		number = screen_stringcolour(data->value);
 | 
			
		||||
		if (number > 8) {
 | 
			
		||||
			ctx->error(ctx, "bad colour: %s", data->value);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								cmd.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd.c,v 1.15 2007-10-12 13:03:58 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd.c,v 1.16 2007-10-12 13:51:44 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -56,7 +56,8 @@ cmd_parse(int argc, char **argv, char **cause)
 | 
			
		||||
 | 
			
		||||
	entry = NULL;
 | 
			
		||||
	for (entryp = cmd_table; *entryp != NULL; entryp++) {
 | 
			
		||||
		if (strcmp((*entryp)->alias, argv[0]) == 0) {
 | 
			
		||||
		if ((*entryp)->alias != NULL && 
 | 
			
		||||
		    strcmp((*entryp)->alias, argv[0]) == 0) {
 | 
			
		||||
			entry = *entryp;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										54
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								screen.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: screen.c,v 1.22 2007-10-05 17:51:56 nicm Exp $ */
 | 
			
		||||
/* $Id: screen.c,v 1.23 2007-10-12 13:51:44 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -43,6 +43,58 @@ void	 screen_fill_lines(
 | 
			
		||||
#define screen_offset_y(py, ny) ((py) + (ny) - 1)
 | 
			
		||||
#define screen_offset_x(px, nx) ((px) + (nx) - 1)
 | 
			
		||||
 | 
			
		||||
/* Colour to string. */
 | 
			
		||||
const char *
 | 
			
		||||
screen_colourstring(u_char c)
 | 
			
		||||
{
 | 
			
		||||
	switch (c) {
 | 
			
		||||
	case 0:
 | 
			
		||||
		return ("black");
 | 
			
		||||
	case 1:
 | 
			
		||||
		return ("red");
 | 
			
		||||
	case 2:
 | 
			
		||||
		return ("green");
 | 
			
		||||
	case 3:
 | 
			
		||||
		return ("yellow");
 | 
			
		||||
	case 4:
 | 
			
		||||
		return ("blue");
 | 
			
		||||
	case 5:
 | 
			
		||||
		return ("magenta");
 | 
			
		||||
	case 6:
 | 
			
		||||
		return ("cyan");
 | 
			
		||||
	case 7:
 | 
			
		||||
		return ("white");
 | 
			
		||||
	case 8:
 | 
			
		||||
		return ("default");
 | 
			
		||||
	}
 | 
			
		||||
	return (NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* String to colour. */
 | 
			
		||||
u_char
 | 
			
		||||
screen_stringcolour(const char *s)
 | 
			
		||||
{
 | 
			
		||||
	if (strcasecmp(s, "black") == 0 || (s[0] == '0' && s[1] == '\0'))
 | 
			
		||||
		return (0);
 | 
			
		||||
	if (strcasecmp(s, "red") == 0 || (s[0] == '1' && s[1] == '\0'))
 | 
			
		||||
		return (1);
 | 
			
		||||
	if (strcasecmp(s, "green") == 0 || (s[0] == '2' && s[1] == '\0'))
 | 
			
		||||
		return (2);
 | 
			
		||||
	if (strcasecmp(s, "yellow") == 0 || (s[0] == '3' && s[1] == '\0'))
 | 
			
		||||
		return (3);
 | 
			
		||||
	if (strcasecmp(s, "blue") == 0 || (s[0] == '4' && s[1] == '\0'))
 | 
			
		||||
		return (4);
 | 
			
		||||
	if (strcasecmp(s, "magenta") == 0 || (s[0] == '5' && s[1] == '\0'))
 | 
			
		||||
		return (5);
 | 
			
		||||
	if (strcasecmp(s, "cyan") == 0 || (s[0] == '6' && s[1] == '\0'))
 | 
			
		||||
		return (6);
 | 
			
		||||
	if (strcasecmp(s, "white") == 0 || (s[0] == '7' && s[1] == '\0'))
 | 
			
		||||
		return (7);
 | 
			
		||||
	if (strcasecmp(s, "default") == 0 || (s[0] == '8' && s[1] == '\0'))
 | 
			
		||||
		return (8);
 | 
			
		||||
	return (255);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Create a new screen. */
 | 
			
		||||
void
 | 
			
		||||
screen_create(struct screen *s, u_int sx, u_int sy)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: tmux.h,v 1.56 2007-10-12 13:03:58 nicm Exp $ */
 | 
			
		||||
/* $Id: tmux.h,v 1.57 2007-10-12 13:51:44 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -603,6 +603,8 @@ void	 input_store_two(struct buffer *, u_char, uint16_t, uint16_t);
 | 
			
		||||
void	 input_translate_key(struct buffer *, int);
 | 
			
		||||
 | 
			
		||||
/* screen.c */
 | 
			
		||||
const char *screen_colourstring(u_char);
 | 
			
		||||
u_char	 screen_stringcolour(const char *);
 | 
			
		||||
void	 screen_create(struct screen *, u_int, u_int);
 | 
			
		||||
void	 screen_destroy(struct screen *);
 | 
			
		||||
void	 screen_resize(struct screen *, u_int, u_int);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user