Drop having a separate type for style options and make them all strings, which

allows formats to be expanded. Any styles without a '#{' are still validated
when they are set but any with a '#{' are not. Formats are not expanded
usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the fg and
  bg are stored in the pane struct and act as the defaults that can be
  overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep them in
  sync.
This commit is contained in:
Nicholas Marriott
2020-04-28 13:50:07 +01:00
parent a43a156846
commit 1f8256fc50
14 changed files with 226 additions and 174 deletions

28
tmux.h
View File

@ -898,6 +898,9 @@ struct window_pane {
u_int xoff;
u_int yoff;
int fg;
int bg;
int flags;
#define PANE_REDRAW 0x1
#define PANE_DROP 0x2
@ -1664,7 +1667,6 @@ enum options_table_type {
OPTIONS_TABLE_COLOUR,
OPTIONS_TABLE_FLAG,
OPTIONS_TABLE_CHOICE,
OPTIONS_TABLE_STYLE,
OPTIONS_TABLE_COMMAND
};
@ -1676,12 +1678,13 @@ enum options_table_type {
#define OPTIONS_TABLE_IS_ARRAY 0x1
#define OPTIONS_TABLE_IS_HOOK 0x2
#define OPTIONS_TABLE_IS_STYLE 0x4
struct options_table_entry {
const char *name;
enum options_table_type type;
int scope;
int flags;
int flags;
u_int minimum;
u_int maximum;
@ -1720,7 +1723,7 @@ struct spawn_context {
const char *name;
char **argv;
int argc;
struct environ *environ;
struct environ *environ;
int idx;
const char *cwd;
@ -1900,18 +1903,17 @@ struct options_entry *options_match_get(struct options *, const char *, int *,
int, int *);
const char *options_get_string(struct options *, const char *);
long long options_get_number(struct options *, const char *);
struct style *options_get_style(struct options *, const char *);
struct options_entry * printflike(4, 5) options_set_string(struct options *,
const char *, int, const char *, ...);
struct options_entry *options_set_number(struct options *, const char *,
long long);
struct options_entry *options_set_style(struct options *, const char *, int,
const char *);
int options_scope_from_name(struct args *, int,
const char *, struct cmd_find_state *, struct options **,
char **);
int options_scope_from_flags(struct args *, int,
struct cmd_find_state *, struct options **, char **);
struct style *options_string_to_style(struct options *, const char *,
struct format_tree *);
/* options-table.c */
extern const struct options_table_entry options_table[];
@ -2138,7 +2140,7 @@ enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int,
int, const char *, int);
/* cmd-parse.c */
void cmd_parse_empty(struct cmd_parse_input *);
void cmd_parse_empty(struct cmd_parse_input *);
struct cmd_parse_result *cmd_parse_from_file(FILE *, struct cmd_parse_input *);
struct cmd_parse_result *cmd_parse_from_string(const char *,
struct cmd_parse_input *);
@ -2229,8 +2231,8 @@ void file_fire_done(struct client_file *);
void file_fire_read(struct client_file *);
int file_can_print(struct client *);
void printflike(2, 3) file_print(struct client *, const char *, ...);
void file_vprint(struct client *, const char *, va_list);
void file_print_buffer(struct client *, void *, size_t);
void file_vprint(struct client *, const char *, va_list);
void file_print_buffer(struct client *, void *, size_t);
void printflike(2, 3) file_error(struct client *, const char *, ...);
void file_write(struct client *, const char *, int, const void *, size_t,
client_file_cb, void *);
@ -2728,7 +2730,7 @@ struct session *session_find_by_id_str(const char *);
struct session *session_find_by_id(u_int);
struct session *session_create(const char *, const char *, const char *,
struct environ *, struct options *, struct termios *);
void session_destroy(struct session *, int, const char *);
void session_destroy(struct session *, int, const char *);
void session_add_ref(struct session *, const char *);
void session_remove_ref(struct session *, const char *);
char *session_check_name(const char *);
@ -2798,7 +2800,7 @@ struct menu *menu_create(const char *);
void menu_add_items(struct menu *, const struct menu_item *,
struct cmdq_item *, struct client *,
struct cmd_find_state *);
void menu_add_item(struct menu *, const struct menu_item *,
void menu_add_item(struct menu *, const struct menu_item *,
struct cmdq_item *, struct client *,
struct cmd_find_state *);
void menu_free(struct menu *);
@ -2821,8 +2823,10 @@ int popup_display(int, struct cmdq_item *, u_int, u_int, u_int,
int style_parse(struct style *,const struct grid_cell *,
const char *);
const char *style_tostring(struct style *);
void style_add(struct grid_cell *, struct options *,
const char *, struct format_tree *);
void style_apply(struct grid_cell *, struct options *,
const char *);
const char *, struct format_tree *);
void style_set(struct style *, const struct grid_cell *);
void style_copy(struct style *, struct style *);