Split options into a table to allow abbreviations.

pull/1/head
Nicholas Marriott 2008-06-23 07:41:21 +00:00
parent e013970b0b
commit c24d849fa4
11 changed files with 342 additions and 296 deletions

View File

@ -1,3 +1,10 @@
23 June 2008
* Split information about options into a table and use it to parse options
on input (allowing abbreviations) and to print them with show-options
(meaning that bell-action gets a proper string). This turned out a bit ugly
though :-/.
22 June 2008
* Do not translate black and white into default if the terminal supports
@ -550,4 +557,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.136 2008-06-22 16:54:08 nicm Exp $
$Id: CHANGES,v 1.137 2008-06-23 07:41:20 nicm Exp $

2
TODO
View File

@ -70,7 +70,6 @@
session not being watched?
- tidy up window modes
- support \033_string\033\\ for window title too
- fix bell-action in show-options
- list-keys should be sorted
- document buffer stuff
- copy-mode enhancements: next word etc etc
@ -78,6 +77,7 @@
- command history for command-prompt. better tab completion
- options parsing could be much more generic, opening the way for abbreviation
and tab completion of option names
- split status-colour into fg/bg
---
save-buffer -b number filename
load-buffer -b number filename

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-prefix.c,v 1.17 2008-06-20 17:31:48 nicm Exp $ */
/* $Id: cmd-send-prefix.c,v 1.18 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -45,12 +45,13 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_target_data *data = self->data;
struct session *s;
struct winlink *wl;
int key;
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
return;
window_key(
wl->window, ctx->curclient, options_get_key(&s->options, "prefix"));
key = options_get_number(&s->options, "prefix");
window_key(wl->window, ctx->curclient, key);
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.34 2008-06-20 18:45:35 nicm Exp $ */
/* $Id: cmd-set-option.c,v 1.35 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -55,6 +55,39 @@ const struct cmd_entry cmd_set_option_entry = {
cmd_set_option_print
};
const char *set_option_bell_action_choices[] = { "none", "any", "current" };
const struct set_option_entry set_option_table[NSETOPTION] = {
{ "bell-action",
SET_OPTION_CHOICE, NULL, 0, 0, set_option_bell_action_choices },
{ "buffer-limit", SET_OPTION_NUMBER, NULL, 1, INT_MAX, NULL },
{ "default-command", SET_OPTION_STRING, NULL, 0, 0, NULL },
{ "display-time", SET_OPTION_NUMBER, NULL, 1, INT_MAX, NULL },
{ "history-limit", SET_OPTION_NUMBER, NULL, 0, SHRT_MAX, NULL },
{ "prefix", SET_OPTION_KEY, NULL, 0, 0, NULL },
{ "set-titles", SET_OPTION_FLAG, NULL, 0, 0, NULL },
{ "status", SET_OPTION_FLAG, NULL, 0, 0, NULL },
{ "status-bg", SET_OPTION_BG,"status-colour", 0, 0, NULL },
{ "status-fg", SET_OPTION_FG,"status-colour", 0, 0, NULL },
{ "status-interval", SET_OPTION_NUMBER, NULL, 0, INT_MAX, NULL },
{ "status-left", SET_OPTION_STRING, NULL, 0, 0, NULL },
{ "status-right", SET_OPTION_STRING, NULL, 0, 0, NULL },
};
void set_option_string(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_number(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_key(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_fg(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_bg(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_flag(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
void set_option_choice(struct cmd_ctx *, struct options *,
const struct set_option_entry *, const char *, char *);
int
cmd_set_option_parse(struct cmd *self, int argc, char **argv, char **cause)
{
@ -97,16 +130,15 @@ usage:
}
void
cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_set_option_data *data = self->data;
struct client *c;
struct session *s;
struct client *c;
struct options *oo;
const char *errstr;
const struct set_option_entry *entry;
const char *option;
u_int i;
int number, flag, key;
u_char colour;
if (data == NULL)
return;
@ -122,205 +154,220 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
return;
}
number = -1;
if (data->value != NULL) {
number = strtonum(data->value, 0, INT_MAX, &errstr);
if (errstr != NULL)
number = 0;
entry = NULL;
for (i = 0; i < NSETOPTION; i++) {
if (strncmp(set_option_table[i].name,
data->option, strlen(data->option)) != 0)
continue;
if (entry != NULL) {
ctx->error(ctx, "ambiguous option: %s", data->option);
return;
}
entry = &set_option_table[i];
flag = -1;
if (number == 1 || strcasecmp(data->value, "on") == 0 ||
strcasecmp(data->value, "yes") == 0)
flag = 1;
else if (number == 0 || strcasecmp(data->value, "off") == 0 ||
strcasecmp(data->value, "no") == 0)
flag = 0;
} else
flag = -2;
if (strcmp(data->option, "prefix") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
key = key_string_lookup_string(data->value);
if (key == KEYC_NONE) {
ctx->error(ctx, "unknown key: %s", data->value);
return;
}
options_set_key(oo, "prefix", key);
} else if (strcmp(data->option, "status") == 0) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (flag == -2)
flag = !options_get_number(oo, "status");
options_set_number(oo, "status", flag);
recalculate_sizes();
} else if (strcmp(data->option, "status-fg") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
number = screen_stringcolour(data->value);
if (number > 8) {
ctx->error(ctx, "bad colour: %s", data->value);
return;
}
colour = options_get_colours(oo, "status-colour");
colour &= 0x0f;
colour |= number << 4;
options_set_colours(oo, "status-colour", colour);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
} else if (strcmp(data->option, "status-bg") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
number = screen_stringcolour(data->value);
if (number > 8) {
ctx->error(ctx, "bad colour: %s", data->value);
return;
}
colour = options_get_colours(oo, "status-colour");
colour &= 0xf0;
colour |= number;
options_set_colours(oo, "status-colour", colour);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
} else if (strcmp(data->option, "bell-action") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
if (strcmp(data->value, "any") == 0)
number = BELL_ANY;
else if (strcmp(data->value, "none") == 0)
number = BELL_NONE;
else if (strcmp(data->value, "current") == 0)
number = BELL_CURRENT;
else {
ctx->error(ctx, "unknown bell-action: %s", data->value);
return;
}
options_set_number(oo, "bell-action", number);
} else if (strcmp(data->option, "default-command") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
options_set_string(oo, "default-command", "%s", data->value);
} else if (strcmp(data->option, "history-limit") == 0) {
if (data->value == NULL || number == -1) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL) {
ctx->error(ctx, "history-limit %s", errstr);
return;
}
if (number > SHRT_MAX) {
ctx->error(ctx, "history-limit too big: %u", number);
return;
}
options_set_number(oo, "history-limit", number);
} else if (strcmp(data->option, "display-time") == 0) {
if (data->value == NULL || number == -1) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL) {
ctx->error(ctx, "display-time %s", errstr);
return;
}
if (number > INT_MAX) {
ctx->error(ctx, "display-time too big: %u", number);
return;
}
options_set_number(oo, "display-time", number);
} else if (strcmp(data->option, "buffer-limit") == 0) {
if (data->value == NULL || number == -1) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL) {
ctx->error(ctx, "buffer-limit %s", errstr);
return;
}
if (number == 0) {
ctx->error(ctx, "zero buffer-limit");
return;
}
if (number > INT_MAX) {
ctx->error(ctx, "buffer-limit too big: %u", number);
return;
}
options_set_number(oo, "buffer-limit", number);
} else if (strcmp(data->option, "status-left") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
options_set_string(oo, "status-left", "%s", data->value);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
} else if (strcmp(data->option, "status-right") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
options_set_string(oo, "status-right", "%s", data->value);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
} else if (strcmp(data->option, "status-interval") == 0) {
if (data->value == NULL || number == -1) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL) {
ctx->error(ctx, "status-interval %s", errstr);
return;
}
options_set_number(oo, "status-interval", number);
} else if (strcmp(data->option, "set-titles") == 0) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (flag == -2)
flag = !options_get_number(oo, "set-titles");
options_set_number(oo, "set-titles", flag);
} else {
}
if (entry == NULL) {
ctx->error(ctx, "unknown option: %s", data->option);
return;
}
option = entry->name;
if (entry->option != NULL)
option = entry->option;
switch (entry->type) {
case SET_OPTION_STRING:
set_option_string(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_NUMBER:
set_option_number(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_KEY:
set_option_key(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_FG:
set_option_fg(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_BG:
set_option_bg(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_FLAG:
set_option_flag(ctx, oo, entry, option, data->value);
break;
case SET_OPTION_CHOICE:
set_option_choice(ctx, oo, entry, option, data->value);
break;
}
recalculate_sizes();
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
void
set_option_string(struct cmd_ctx *ctx, struct options *oo,
unused const struct set_option_entry *entry,
const char *option, char *value)
{
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
options_set_string(oo, option, "%s", value);
}
void
set_option_number(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, const char *option, char *value)
{
long long number;
const char *errstr;
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
number = strtonum(value, entry->minimum, entry->maximum, &errstr);
if (errstr != NULL) {
ctx->error(ctx, "value is %s: %s", errstr, value);
return;
}
options_set_number(oo, option, number);
}
void
set_option_key(struct cmd_ctx *ctx, struct options *oo,
unused const struct set_option_entry *entry,
const char *option, char *value)
{
int key;
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
ctx->error(ctx, "unknown key: %s", value);
return;
}
options_set_number(oo, option, key);
}
void
set_option_fg(struct cmd_ctx *ctx, struct options *oo,
unused const struct set_option_entry *entry,
const char *option, char *value)
{
u_char number, colour;
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
if ((number = screen_stringcolour(value)) > 8) {
ctx->error(ctx, "bad colour: %s", value);
return;
}
colour = options_get_number(oo, option);
colour &= 0x0f;
colour |= number << 4;
options_set_number(oo, option, colour);
}
void
set_option_bg(struct cmd_ctx *ctx, struct options *oo,
unused const struct set_option_entry *entry,
const char *option, char *value)
{
u_char number, colour;
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
if ((number = screen_stringcolour(value)) > 8) {
ctx->error(ctx, "bad colour: %s", value);
return;
}
colour = options_get_number(oo, option);
colour &= 0xf0;
colour |= number;
options_set_number(oo, option, colour);
}
void
set_option_flag(struct cmd_ctx *ctx, struct options *oo,
unused const struct set_option_entry *entry,
const char *option, char *value)
{
int flag;
if (value == NULL || *value == '\0')
flag = !options_get_number(oo, option);
else {
if ((value[0] == '1' && value[1] == '\0') ||
strcasecmp(value, "on") == 0 ||
strcasecmp(value, "yes") == 0)
flag = 1;
else if ((value[0] == '0' && value[1] == '\0') ||
strcasecmp(value, "off") == 0 ||
strcasecmp(value, "no") == 0)
flag = 0;
else {
ctx->error(ctx, "bad value: %s", value);
return;
}
}
options_set_number(oo, option, flag);
}
void
set_option_choice(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, const char *option, char *value)
{
const char **choicep;
int n, choice = -1;
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
n = 0;
for (choicep = entry->choices; *choicep != NULL; choicep++) {
n++;
if (strncmp(*choicep, value, strlen(value)) != 0)
continue;
if (choice != -1) {
ctx->error(ctx, "ambiguous option: %s", value);
return;
}
choice = n - 1;
}
if (choice == -1) {
ctx->error(ctx, "unknown option: %s", value);
return;
}
options_set_number(oo, option, choice);
}
void
cmd_set_option_send(struct cmd *self, struct buffer *b)
{

View File

@ -1,4 +1,4 @@
/* $Id: cmd-show-options.c,v 1.3 2008-06-18 22:21:51 nicm Exp $ */
/* $Id: cmd-show-options.c,v 1.4 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -98,7 +98,11 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_show_options_data *data = self->data;
struct session *s;
struct options *oo;
struct options_entry *o;
const struct set_option_entry *entry;
const char *option;
u_int i;
char *vs;
long long vn;
if (data == NULL)
return;
@ -109,23 +113,51 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
else
oo = &s->options;
SPLAY_FOREACH(o, options_tree, &oo->tree) {
switch (o->type) {
case OPTIONS_STRING:
ctx->print(
ctx, "%s \"%s\"", o->name, o->value.string);
for (i = 0; i < NSETOPTION; i++) {
entry = &set_option_table[i];
option = entry->name;
if (entry->option != NULL)
option = entry->option;
if (options_find1(oo, option) == NULL)
continue;
switch (entry->type) {
case SET_OPTION_STRING:
vs = options_get_string(oo, option);
ctx->print(ctx, "%s \"%s\"", entry->name, vs);
break;
case OPTIONS_NUMBER:
ctx->print(ctx, "%s %lld", o->name, o->value.number);
case SET_OPTION_NUMBER:
vn = options_get_number(oo, option);
ctx->print(ctx, "%s %lld", entry->name, vn);
break;
case OPTIONS_KEY:
ctx->print(ctx, "%s %s", o->name,
key_string_lookup_key(o->value.key));
case SET_OPTION_KEY:
vn = options_get_number(oo, option);
ctx->print(ctx, "%s %s",
entry->name, key_string_lookup_key(vn));
break;
case OPTIONS_COLOURS:
ctx->print(ctx, "%s fg=%s, bg=%s", o->name,
screen_colourstring(o->value.colours >> 4),
screen_colourstring(o->value.colours & 0x0f));
case SET_OPTION_FG:
vn = options_get_number(oo, option);
ctx->print(ctx, "%s %s",
entry->name, screen_colourstring(vn >> 4));
break;
case SET_OPTION_BG:
vn = options_get_number(oo, option);
ctx->print(ctx, "%s %s",
entry->name, screen_colourstring(vn & 0x0f));
break;
case SET_OPTION_FLAG:
vn = options_get_number(oo, option);
if (vn)
ctx->print(ctx, "%s on", option);
else
ctx->print(ctx, "%s off", option);
break;
case SET_OPTION_CHOICE:
vn = options_get_number(oo, option);
ctx->print(ctx, "%s %s",
entry->name, entry->choices[vn]);
break;
}
}

8
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.54 2008-06-21 14:16:30 nicm Exp $ */
/* $Id: cmd.c,v 1.55 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -75,7 +75,7 @@ cmd_complete(const char *s)
{
const struct cmd_entry **entryp;
ARRAY_DECL(, const char *) list;
char *prefix;
char *prefix, *s2;
u_int i;
size_t j;
@ -98,9 +98,9 @@ cmd_complete(const char *s)
/* If an exact match, return it, with a trailing space. */
if (ARRAY_LENGTH(&list) == 1) {
xasprintf(&s, "%s ", ARRAY_FIRST(&list));
xasprintf(&s2, "%s ", ARRAY_FIRST(&list));
ARRAY_FREE(&list);
return (s);
return (s2);
}
/* Now loop through the list and find the longest common prefix. */

View File

@ -1,4 +1,4 @@
/* $Id: options.c,v 1.2 2008-06-15 08:01:54 nicm Exp $ */
/* $Id: options.c,v 1.3 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -30,9 +30,6 @@
SPLAY_GENERATE(options_tree, options_entry, entry, options_cmp);
struct options_entry *options_find1(struct options *, const char *);
struct options_entry *options_find(struct options *, const char *);
int
options_cmp(struct options_entry *o1, struct options_entry *o2)
{
@ -145,61 +142,3 @@ options_get_number(struct options *oo, const char *name)
fatalx("option not a number");
return (o->value.number);
}
void
options_set_key(struct options *oo, const char *name, int value)
{
struct options_entry *o;
if ((o = options_find1(oo, name)) == NULL) {
o = xmalloc(sizeof *o);
o->name = xstrdup(name);
SPLAY_INSERT(options_tree, &oo->tree, o);
} else if (o->type == OPTIONS_STRING)
xfree(o->value.string);
o->type = OPTIONS_KEY;
o->value.key = value;
}
int
options_get_key(struct options *oo, const char *name)
{
struct options_entry *o;
if ((o = options_find(oo, name)) == NULL)
fatalx("missing option");
if (o->type != OPTIONS_KEY)
fatalx("option not a key");
return (o->value.key);
}
void
options_set_colours(struct options *oo, const char *name, u_char value)
{
struct options_entry *o;
if ((o = options_find1(oo, name)) == NULL) {
o = xmalloc(sizeof *o);
o->name = xstrdup(name);
SPLAY_INSERT(options_tree, &oo->tree, o);
} else if (o->type == OPTIONS_STRING)
xfree(o->value.string);
o->type = OPTIONS_COLOURS;
o->value.colours = value;
}
u_char
options_get_colours(struct options *oo, const char *name)
{
struct options_entry *o;
if ((o = options_find(oo, name)) == NULL)
fatalx("missing option");
if (o->type != OPTIONS_COLOURS)
fatalx("option not a colours");
return (o->value.colours);
}

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.75 2008-06-22 16:56:47 nicm Exp $ */
/* $Id: server.c,v 1.76 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -527,7 +527,7 @@ server_handle_client(struct client *c)
struct window *w = c->session->curw->window;
int key, prefix;
prefix = options_get_key(&c->session->options, "prefix");
prefix = options_get_number(&c->session->options, "prefix");
while (tty_keys_next(&c->tty, &key) == 0) {
server_clear_client_message(c);
if (c->prompt_string != NULL) {

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.37 2008-06-21 14:11:39 nicm Exp $ */
/* $Id: status.c,v 1.38 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,7 +48,7 @@ status_redraw(struct client *c)
if (clock_gettime(CLOCK_REALTIME, &c->status_timer) != 0)
fatal("clock_gettime failed");
colr = options_get_colours(&s->options, "status-colour");
colr = options_get_number(&s->options, "status-colour");
yy = c->sy - 1;
if (yy == 0)

6
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.66 2008-06-20 18:45:35 nicm Exp $ */
/* $Id: tmux.c,v 1.67 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -210,11 +210,11 @@ main(int argc, char **argv)
options_init(&global_options, NULL);
options_set_number(&global_options, "status", 1);
options_set_colours(&global_options, "status-colour", 0x02);
options_set_number(&global_options, "status-colour", 0x02);
options_set_number(&global_options, "bell-action", BELL_ANY);
options_set_number(&global_options, "history-limit", 2000);
options_set_number(&global_options, "display-time", 750);
options_set_key(&global_options, "prefix", META);
options_set_number(&global_options, "prefix", META);
options_set_string(&global_options, "status-left", "%s", ""); /* ugh */
options_set_string(
&global_options, "status-right", "%%H:%%M %%d-%%b-%%y");

30
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.164 2008-06-22 22:20:07 nicm Exp $ */
/* $Id: tmux.h,v 1.165 2008-06-23 07:41:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -793,6 +793,28 @@ struct binding {
};
ARRAY_DECL(bindings, struct binding *);
/* Set/display option data. */
struct set_option_entry {
const char *name;
enum {
SET_OPTION_STRING,
SET_OPTION_NUMBER,
SET_OPTION_KEY,
SET_OPTION_FG,
SET_OPTION_BG,
SET_OPTION_FLAG,
SET_OPTION_CHOICE
} type;
const char *option;
u_int minimum;
u_int maximum;
const char **choices;
};
extern const struct set_option_entry set_option_table[];
#define NSETOPTION 13
#ifdef NO_STRTONUM
/* strtonum.c */
long long strtonum(const char *, long long, long long, const char **);
@ -848,15 +870,13 @@ int options_cmp(struct options_entry *, struct options_entry *);
SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
void options_init(struct options *, struct options *);
void options_free(struct options *);
struct options_entry *options_find1(struct options *, const char *);
struct options_entry *options_find(struct options *, const char *);
void printflike3 options_set_string(
struct options *, const char *, const char *, ...);
char *options_get_string(struct options *, const char *);
void options_set_number(struct options *, const char *, long long);
long long options_get_number(struct options *, const char *);
void options_set_key(struct options *, const char *, int);
int options_get_key(struct options *, const char *);
void options_set_colours(struct options *, const char *, u_char);
u_char options_get_colours(struct options *, const char *);
/* tty.c */
void tty_init(struct tty *, char *, char *);