Changeset aa2f33b3 for variable.c


Ignore:
Timestamp:
Jul 16, 2002, 9:55:47 PM (18 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f2e36b5
Parents:
e50cd56
Message:
	Variables now have a summary and a long description.
	        Only the summary is shown with help.
		The long description is shown with "show variable foo".
        Fix the scrolling bug where we would sometimes fail to scroll
             the screen down, leaving the current message off
             the bottom of the screen.
        Added a 'scrollmode' variable which determines how the screen
	     will scroll as the cursor moves.  The default behaves
	     identically to previous versions of owl.
             The following modes are supported:
	     normal      - This is the owl default.  Scrolling happens
	                   when it needs to, and an attempt is made to
	                   keep the current message roughly near
	                   the middle of the screen.  (default)
	     top         - The current message will always be the
	                   the top message displayed.
	     neartop     - The current message will be one down
	                   from the top message displayed,
	                   where possible.
	     center      - An attempt is made to keep the current
	                   message near the center of the screen.
	     paged       - The top message displayed only changes
	                   when user moves the cursor to the top
	                   or bottom of the screen.  When it moves,
	                   the screen will be paged up or down and
	                   the cursor will be near the top or
	                   the bottom.
	     pagedcenter - The top message displayed only changes
	                   when user moves the cursor to the top
	                   or bottom of the screen.  When it moves,
	                   the screen will be paged up or down and
	                   the cursor will be near the center.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    rae9e6be raa2f33b3  
    1010static int in_regtest = 0;
    1111
    12 #define OWLVAR_BOOL(name,default,docstring) \
    13         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", docstring, NULL, \
     12#define OWLVAR_BOOL(name,default,summary,description) \
     13        { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
    1414        NULL, NULL, NULL, NULL, NULL }
    1515
    16 #define OWLVAR_BOOL_FULL(name,default,docstring,validate,set,get) \
    17         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", docstring, NULL, \
     16#define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \
     17        { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
    1818        validate, set, NULL, get, NULL }
    1919
    20 #define OWLVAR_INT(name,default,docstring) \
    21         { name, OWL_VARIABLE_INT, NULL, default, "<int>", docstring, NULL, \
     20#define OWLVAR_INT(name,default,summary,description) \
     21        { name, OWL_VARIABLE_INT, NULL, default, "<int>", summary,description, NULL, \
    2222        NULL, NULL, NULL, NULL, NULL, NULL }
    2323
    24 #define OWLVAR_INT_FULL(name,default,docstring,validset,validate,set,get) \
    25         { name, OWL_VARIABLE_INT, NULL, default, validset, docstring, NULL, \
     24#define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \
     25        { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
    2626        validate, set, NULL, get, NULL, NULL }
    2727
    28 #define OWLVAR_PATH(name,default,docstring) \
    29         { name, OWL_VARIABLE_STRING, default, 0, "<path>", docstring,  NULL, \
     28#define OWLVAR_PATH(name,default,summary,description) \
     29        { name, OWL_VARIABLE_STRING, default, 0, "<path>", summary,description,  NULL, \
    3030        NULL, NULL, NULL, NULL, NULL, NULL }
    3131
    32 #define OWLVAR_STRING(name,default,docstring) \
    33         { name, OWL_VARIABLE_STRING, default, 0, "<string>", docstring, NULL, \
     32#define OWLVAR_STRING(name,default,summary,description) \
     33        { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
    3434        NULL, NULL, NULL, NULL, NULL, NULL }
    3535
     
    3737 * list of strings which can be specified.  The tokens, starting at 0,
    3838 * correspond to the values that may be specified. */
    39 #define OWLVAR_ENUM(name,default,docstring,validset) \
    40         { name, OWL_VARIABLE_INT, NULL, default, validset, docstring, NULL, \
     39#define OWLVAR_ENUM(name,default,summary,description,validset) \
     40        { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
    4141        owl_variable_enum_validate, \
    4242        NULL, owl_variable_enum_set_fromstring, \
     
    4444        NULL }
    4545
    46 #define OWLVAR_ENUM_FULL(name,default,docstring,validset,validate, set, get) \
    47         { name, OWL_VARIABLE_INT, NULL, default, validset, docstring, NULL, \
     46#define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \
     47        { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
    4848        validate, \
    4949        set, owl_variable_enum_set_fromstring, \
     
    5454
    5555  OWLVAR_BOOL( "personalbell" /* %OwlVarStub */, 0,
    56                "ring the terminal bell when personal messages are received" ),
     56               "ring the terminal bell when personal messages are received",
     57               "" ),
    5758
    5859  OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1,
    59                "enable / disable the terminal bell" ),
     60               "enable / disable the terminal bell", "" ),
    6061
    6162  OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG,
    6263                    "whether debugging is enabled",
     64                    "If set to 'on', debugging messages are logged to the\n"
     65                    "file specified by the debugfile variable.\n",
    6366                    NULL, owl_variable_debug_set, NULL),
    6467
    6568  OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1,
    66                "send a login message when owl starts" ),
     69               "send a login message when owl starts", "" ),
    6770
    6871  OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1,
    69                "send a logout message when owl exits" ),
     72               "send a logout message when owl exits", "" ),
    7073
    7174  OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0,
    72                "display received pings" ),
     75               "display received pings", "" ),
    7376
    7477  OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1,
    75                "send pings" ),
     78               "send pings", "" ),
    7679
    7780  OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1,
    78                "display outgoing messages" ),
     81               "display outgoing messages", "" ),
    7982
    8083  OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1,
    81                "load logins from .anyone on startup" ),
     84               "load logins from .anyone on startup", "" ),
    8285
    8386  OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0,
    84                "turn personal logging on or off" ),
     87               "turn personal logging on or off",
     88               "If this is set to on, personal messages are\n"
     89               "logged in the directory specified\n"
     90               "by the 'logpath' variable.  The filename in that\n"
     91               "directory is derived from the sender of the message.\n" ),
    8592
    8693  OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0,
    87                "turn class logging on or off" ),
     94               "turn class logging on or off",
     95               "If this is set to on, class messages are\n"
     96               "logged in the directory specified\n"
     97               "by the 'classlogpath' variable.\n"
     98               "The filename in that directory is derived from\n"
     99               "the name of the class to which the message was sent.\n" ),
    88100
    89101  OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1,
    90                "allow @color() in zephyrs to change color" ),
     102               "allow @color() in zephyrs to change color",
     103               "Note that only messages received after this variable\n"
     104               "is set will be affected." ),
    91105
    92106  OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1,
    93                     "don't send zephyrs on C-d (or disable if in the middle of the message if set to 'middle')", "off,middle,on",
     107                    "don't send zephyrs on C-d",
     108                    "If set to 'off', C-d won't send a zephyr from the edit\n"
     109                    "window.  If set to 'on', C-d will always send a zephyr\n"
     110                    "being composed in the edit window.  If set to 'middle',\n"
     111                    "C-d will only ever send a zephyr if the cursor is at\n"
     112                    "the end of the message being composed.\n\n"
     113                    "Note that this works by changing the C-d keybinding\n"
     114                    "in the editmulti keymap.\n",
     115                    "off,middle,on",
    94116                    NULL, owl_variable_disable_ctrl_d_set, NULL),
    95117
    96118  OWLVAR_BOOL( "_burningears" /* %OwlVarStub:burningears */, 0,
    97                "[NOT YET IMPLEMENTED] beep on messages matching patterns" ),
     119               "[NOT YET IMPLEMENTED] beep on messages matching patterns", "" ),
    98120
    99121  OWLVAR_BOOL( "_summarymode" /* %OwlVarStub:summarymode */, 0,
    100                "[NOT YET IMPLEMENTED]" ),
     122               "[NOT YET IMPLEMENTED]", "" ),
    101123
    102124  OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people",
    103                "path for logging personal zephyrs" ),
     125               "path for logging personal zephyrs",
     126               "Specifies a directory which must exist.\n"
     127               "Files will be created in the directory for each sender.\n"),
    104128
    105129  OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class",
    106                "path for logging class zephyrs" ),
     130               "path for logging class zephyrs",
     131               "Specifies a directory which must exist.\n"
     132               "Files will be created in the directory for each class.\n"),
    107133
    108134  OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE,
    109                "path for logging debug messages when debugging is enabled" ),
     135               "path for logging debug messages when debugging is enabled",
     136               "This file will be logged to if 'debug' is set to 'on'.\n"),
    110137 
    111138  OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsig_exec */, NULL,
    112                "name of a program to run that will generate zsigs" ),
     139               "name of a program to run that will generate zsigs",
     140               "This program should produce a zsig on stdout when run.\n"
     141               "Note that it is important that this program not block.\n" ),
    113142
    114143  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
    115                  "zephyr signature" ),
     144                 "zephyr signature",
     145                 "If 'zsigproc' is not set, this string will be used\n"
     146                 "as a zsig.  If this is also unset, the 'zwrite-signature'\n"
     147                 "zephyr variable will be used instead.\n"),
    116148
    117149  OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "",
    118                  "string to append to the end of the sepbar" ),
     150                 "string to append to the end of the sepbar",
     151                 "The sepbar is the bar separating the top and bottom\n"
     152                 "of the owl screen.  Any string specified here will\n"
     153                 "be displayed on the right of the sepbar\n"),
    119154
    120155  OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0,
    121                "turn zaway on or off" ),
     156               "turn zaway on or off", "" ),
    122157
    123158  OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */,
    124159                 OWL_DEFAULT_ZAWAYMSG,
    125                  "zaway msg for responding to zephyrs when away" ),
     160                 "zaway msg for responding to zephyrs when away", "" ),
    126161
    127162  OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */,
    128163                 OWL_DEFAULT_ZAWAYMSG,
    129                  "default zaway message" ),
     164                 "default zaway message", "" ),
    130165
    131166  OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all",
    132                  "home view to switch to after 'X'" ),
     167                 "home view to switch to after 'X' and 'V'",
     168                 "SEE ALSO: view, filter\n" ),
    133169
    134170  OWLVAR_INT(    "edit:maxfillcols" /* %OwlVarStub:edit_maxfillcols */, 70,
    135                  "maximum number of columns for M-q to fill text to (or unlimited if 0)" ),
     171                 "maximum number of columns for M-q to fill text to",
     172                 "This specifies the maximum number of columns for M-q\n"
     173                 "to fill text to.  If set to 0, ther will be no maximum\n"
     174                 "limit.  In all cases, the current width of the screen\n"
     175                 "will also be taken into account.  It will be used instead\n"
     176                 "if it is narrower than the maximum, or if this\n"
     177                 "is set to 0.\n" ),
    136178
    137179  OWLVAR_INT(    "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 0,
    138                  "maximum number of columns for line-wrapping (or unlimited if 0)" ),
     180                 "maximum number of columns for line-wrapping",
     181                 "This specifies the maximum number of columns for\n"
     182                 "auto-line-wrapping.  If set to 0, ther will be no maximum\n"
     183                 "limit.  In all cases, the current width of the screen\n"
     184                 "will also be taken into account.  It will be used instead\n"
     185                 "if it is narrower than the maximum, or if this\n"
     186                 "is set to 0.\n\n"
     187                 "It is recommended that outgoing messages be no wider\n"
     188                 "than 60 columns, as a courtesy to recipients.\n"),
    139189
    140190  OWLVAR_INT_FULL( "typewinsize" /* %OwlVarStub:typwin_lines */,
    141191                   OWL_TYPWIN_SIZE,
    142                   "number of lines in the typing window", "int > 0",
     192                  "number of lines in the typing window",
     193                   "This specifies the height of the window at the\n"
     194                   "bottom of the screen where commands are entered\n"
     195                   "and where messages are composed.\n",
     196                   "int > 0",
    143197                   owl_variable_int_validate_gt0,
    144198                   owl_variable_typewinsize_set,
     
    146200                   ),
    147201
     202  OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL,
     203               "how to scroll up and down",
     204               "This controls how the screen is scrolled as the\n"
     205               "cursor moves between messages being displayed.\n"
     206               "The following modes are supported:\n\n"
     207               "   normal      - This is the owl default.  Scrolling happens\n"
     208               "                 when it needs to, and an attempt is made to\n"
     209               "                 keep the current message roughly near\n"
     210               "                 the middle of the screen.\n"
     211               "   top         - The current message will always be the\n"
     212               "                 the top message displayed.\n"
     213               "   neartop     - The current message will be one down\n"
     214               "                 from the top message displayed,\n"
     215               "                 where possible.\n"
     216               "   center      - An attempt is made to keep the current\n"
     217               "                 message near the center of the screen.\n"
     218               "   paged       - The top message displayed only changes\n"
     219               "                 when user moves the cursor to the top\n"
     220               "                 or bottom of the screen.  When it moves,\n"
     221               "                 the screen will be paged up or down and\n"
     222               "                 the cursor will be near the top or\n"
     223               "                 the bottom.\n"
     224               "   pagedcenter - The top message displayed only changes\n"
     225               "                 when user moves the cursor to the top\n"
     226               "                 or bottom of the screen.  When it moves,\n"
     227               "                 the screen will be paged up or down and\n"
     228               "                 the cursor will be near the center.\n",
     229               "normal,top,neartop,center,paged,pagedcenter" ),
     230
    148231  OWLVAR_ENUM( "webbrowser" /* %OwlVarStub */, OWL_WEBBROWSER_NETSCAPE,
    149232               "web browser to use to launch URLs",
     233               "When the 'w' key is pressed, this browser is used\n"
     234               "to display the requested URL.\n",
    150235               "none,netscape,galeon,opera" ),
    151236
    152237  OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0,
    153                "enable automatic following of the last zephyr" ),
     238               "enable automatic following of the last zephyr",
     239               "If the cursor is at the last message, it will\n"
     240               "continue to follow the last message if this is set.\n"
     241               "Note that this is currently risky as you might accidentally\n"
     242               "delete a message right as it came in.\n" ),
    154243
    155244  /* This MUST be last... */
    156   { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
     245  { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
     246    NULL, NULL, NULL, NULL, NULL, NULL }
    157247
    158248};
     
    300390
    301391
    302 char *owl_variable_get_docstring(owl_variable *v) {
    303   return v->docstring;
     392char *owl_variable_get_description(owl_variable *v) {
     393  return v->description;
     394}
     395
     396char *owl_variable_get_summary(owl_variable *v) {
     397  return v->summary;
    304398}
    305399
     
    420514}
    421515
    422 #define OWL_VARIABLE_HELP_FMT "     %-15s %-9s %-9s %s\n"
    423 
    424 /* appends to the end of the fmtext */
    425 void owl_variable_get_summaryheader(owl_fmtext *fm) {
    426   char tmpbuff[512];
    427   snprintf(tmpbuff, 512, 
    428            OWL_VARIABLE_HELP_FMT OWL_VARIABLE_HELP_FMT,
    429            "name",            "settings", "default", "meaning",
    430            "---------------", "--------", "-------", "-------");
    431   owl_fmtext_append_bold(fm, tmpbuff);
    432 }
    433 
    434 void owl_variable_get_summary(owl_vardict *d, char *name, owl_fmtext *fm) {
    435   char defaultbuf[10];
     516void owl_variable_describe(owl_vardict *d, char *name, owl_fmtext *fm) {
     517  char defaultbuf[50];
    436518  char buf[1024];
    437519  int buflen = 1023;
     
    446528  }
    447529  if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
    448     v->get_tostring_fn(v, defaultbuf, 10, &(v->ival_default));
     530    v->get_tostring_fn(v, defaultbuf, 50, &(v->ival_default));
    449531  } else {
    450     v->get_tostring_fn(v, defaultbuf, 10, v->pval_default);
    451   }
    452   snprintf(buf, buflen, OWL_VARIABLE_HELP_FMT,
     532    v->get_tostring_fn(v, defaultbuf, 50, v->pval_default);
     533  }
     534  snprintf(buf, buflen, OWL_TABSTR "%-20s - %s (default: '%s')\n",
    453535                  v->name,
    454                   owl_variable_get_validsettings(v),
    455                   defaultbuf,
    456                   owl_variable_get_docstring(v));
     536                  owl_variable_get_summary(v), defaultbuf);
    457537  owl_fmtext_append_normal(fm, buf);
    458538}
     
    474554  owl_fmtext_append_normal(fm, name);
    475555  owl_fmtext_append_normal(fm, " - ");
    476   owl_fmtext_append_normal(fm, v->docstring);
     556  owl_fmtext_append_normal(fm, v->summary);
    477557  owl_fmtext_append_normal(fm, "\n\n");
    478558
     
    495575  owl_fmtext_append_normal(fm, owl_variable_get_validsettings(v));
    496576  owl_fmtext_append_normal(fm, "\n\n");
     577
     578  if (v->description && *v->description) {
     579    owl_fmtext_append_normal(fm, "Description:\n");
     580    owl_fmtext_append_normal(fm, owl_variable_get_description(v));
     581    owl_fmtext_append_normal(fm, "\n\n");
     582  }
    497583}
    498584
Note: See TracChangeset for help on using the changeset viewer.