home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume18
/
mush6.4
/
part06
/
viewopts.c
< prev
Wrap
C/C++ Source or Header
|
1989-03-12
|
13KB
|
349 lines
/* @(#)viewopts.c (c) copyright 10/18/86 (Dan Heller) */
#include "mush.h"
struct viewopts {
char *v_opt;
char *v_prompt;
int v_usage;
#define TOOL 01
#define TEXT 02
char *v_description;
};
/*
* struct contains the option, a prompt if it has a string value, whether
* or not it applies to non suntools, line mode, or both, and a
* string describing what the option does. If the prompt string starts
* with a minus sign, then the value can be set without a value. This
* is there to indicate to option_line to print a toggle (cycle) pixrect
* and to print TRUE/FALSE telling whether the value is on or off regardless
* of it's "string" value.
*/
struct viewopts viewopts[] = {
{ "alwaysignore", NULL, TOOL | TEXT,
"Always ignore the message headers on the 'ignored' list." },
{ "ask", NULL, TOOL | TEXT,
"Prompts for a subject on outgoing mail." },
{ "askcc", NULL, TOOL | TEXT,
"Ask for list of Carbon Copy recipients whenever sending mail." },
{ "autodelete", NULL, TOOL | TEXT,
"Automatically delete ALL READ messages whenever you update mail." },
{ "autoedit", NULL, TOOL | TEXT,
"Automatically enter editor whenever you REPLY to mail." },
{ "autoinclude", NULL, TOOL | TEXT,
"Include a copy of author's message each time you reply to mail." },
{ "autoprint", NULL, TOOL | TEXT,
"Display the next message on the list when you delete a message." },
{ "auto_route", NULL, TOOL | TEXT,
"Remove redundant uucp addresses when replying to messages." },
{ "autosign", "-Filename", TOOL | TEXT,
"Add file (~/.signature if set but no value) at end of all letters." },
{ "autosign2", "Address : Filename", TOOL | TEXT,
"Signature to use for specific addresses. \"addr, ... : <signature>\""},
{ "cdpath", "Path", TEXT,
"Path to search for directories when the \"cd\" command is issued." },
{ "crt", "Lines", TEXT,
"The number of lines a message must have for 'pager' to be invoked." },
{ "date_received", NULL, TOOL | TEXT,
"Time displayed for message headers shows date received (or sent)." },
{ "dead", "Filename", TOOL | TEXT,
"The name of the file to store dead mail (default = ~/dead.letter)." },
{ "dot", NULL, TOOL | TEXT,
"Allow \".\" on a line by itself to send letter." },
{ "editor", "Editor name/path", TOOL | TEXT,
"Editor for message editing (default = env EDITOR or \"vi\")." },
{ "escape", "Character", TOOL | TEXT,
"Escape character for extended editing commands (default = ~)." },
{ "folder", "Pathname", TOOL | TEXT,
"Full pathname to the directory where personal folders are kept." },
{ "fortune", "-Flag", TOOL | TEXT,
"Add fortune to end of letters. Flag to \"fortune\" is optional." },
{ "fortunates", "Users", TOOL | TEXT,
"Those who will receive fortunes if fortune is set (default: All)." },
{ "hdr_format", "Format", TOOL | TEXT,
"Formatting string for headers. \"headers -?\" or help hdr_format." },
{ "history", "Number", TEXT,
"How many commands to remember (like csh)." },
{ "hold", NULL, TOOL | TEXT,
"Read but not deleted messages are saved in spool -- not mbox." },
{ "home", "Directory", TOOL | TEXT,
"The user's home directory." },
{ "hostname", "Hostname", TOOL | TEXT,
"User-definable name for the name of your machine." },
{ "ignore_bang", NULL, TEXT,
"Ignore '!' as a history reference. Otherwise, escape by: \\!" },
{ "ignoreeof", "-Command", TEXT,
"Ignores ^D as exit, or (if set), execute \"command\"." },
{ "indent_str", "String", TOOL | TEXT,
"String to offset included messages within your letters." },
{ "in_reply_to", NULL, TOOL | TEXT,
"When responding to mail, add In-Reply-To: to message headers." },
{ "keepsave", NULL, TOOL | TEXT,
"Prevents messages from being marked as `deleted' when you `save'." },
{ "known_hosts", "Host list", TOOL | TEXT,
"List of hosts that your site is known to uucp mail to." },
{ "lister", "Arguments", TOOL | TEXT,
"Arguments passed to the 'ls' command." },
{ "logfile", "Filename", TOOL | TEXT,
"Log outgoing mail headers only. Message text not logged." },
{ "mbox", "Filename", TOOL | TEXT,
"Filename to use instead of ~/mbox for default mailbox." },
{ "metoo", NULL, TOOL | TEXT,
"When replying to mail, metoo preserves your name on mailing list." },
{ "mil_time", NULL, TOOL | TEXT,
"24-hour military time format is used whenever a time is printed. " },
{ "newline", "-Command", TEXT,
"Ignore RETURN. If set to a command, execute that command." },
{ "no_expand", NULL, TEXT | TOOL,
"Prevents expansion of Mush aliases in outgoing mail headers." },
{ "no_hdrs", NULL, TOOL | TEXT,
"If set, personalized headers are NOT inserted to outgoing mail." },
{ "no_reverse", NULL, TOOL | TEXT,
"Disables reverse video in curses mode -- uses \"bold\" in tool mode."},
{ "nonobang", NULL, TEXT,
"Suppresses errors from unsuccessful history references." },
{ "nosave", NULL, TOOL | TEXT,
"Prevents aborted mail from being saved in $dead." },
{ "pager", "Program", TEXT,
"Program name to be used as a pager for messages longer than crt." },
{ "pre_indent_str", "String", TEXT | TOOL,
"String to precede message text interpolated into message body." },
{ "post_indent_str", "String", TEXT | TOOL,
"String to succeed message text interpolated into message body." },
{ "print_cmd", "Program", TOOL | TEXT,
"Alternate program to use to send messages to the printer." },
{ "printer", "Printer", TOOL | TEXT,
"Printer to send messages to (default = environment PRINTER)." },
{ "prompt", "String", TEXT,
"Your prompt. \"help prompt\" for more information." },
{ "quiet", NULL, TEXT,
"Don't print the version number of Mush on startup." },
{ "realname", "Name:", TOOL | TEXT,
"Your real name." },
{ "record", "Filename", TOOL | TEXT,
"Save all outgoing mail in specified filename." },
{ "reply_to_hdr", "Headers", TOOL | TEXT,
"List of headers use to construct reply addresses from a message." },
{ "save_empty", NULL, TOOL | TEXT,
"Folders which have all messages deleted are NOT removed on updates." },
{ "screen", "Number of Headers", TEXT,
"Number of headers to print in non-suntools (text) mode." },
{ "screen_win", "Number of Headers", TOOL,
"Set the size of the header window for the tool mode only." },
{ "show_deleted", NULL, TOOL | TEXT,
"Show deleted messages in headers listings (unused in curses mode)." },
{ "show_hdrs", "Headers", TOOL | TEXT,
"When displaying a message, show list of \"headers\" only." },
{ "sendmail", "Program", TOOL | TEXT,
"Program to use to deliver mail instead of using the default."},
{ "sort", "-Option", TOOL | TEXT,
"Pre-sorting of messages on mush startup (set to valid sort option)." },
{ "squeeze", NULL, TOOL | TEXT,
"When reading messages, squeeze all blank lines into one." },
{ "thisfolder", NULL, TEXT,
"This read-only variable gives the current folder name." },
{ "toplines", "Lines", TOOL | TEXT,
"Number of lines to print of a message for the 'top' command." },
{ "tmpdir", "Directory", TOOL | TEXT,
"Directory to use for temporary files used by Mush." },
{ "unix", NULL, TEXT,
"Non-mush commands are considered to be UNIX commands." },
{ "verify", NULL, TEXT,
"Verify to send, re-edit, or abort letter after editing." },
{ "visual", "Visual editor", TOOL | TEXT,
"Visual editor for messages (default = $editor or env VISUAL)."},
{ "warning", NULL, TOOL | TEXT,
"Print warning messages for non-fatal errors." },
{ "wrap", NULL, TOOL | TEXT,
"After referencing last message, message pointer wraps to start." },
{ "wrapcolumn", "-Column to wrap [78]", TEXT,
"Column at which to wrap lines when composing messages." },
};
#define total_opts (sizeof viewopts / sizeof (struct viewopts))
#ifdef SUNTOOL
static int start_cnt;
#define twenty 5 + 20*l_width(DEFAULT)
#define forty 5 + 40*l_width(DEFAULT)
#define image_at(x,y,image) pw_rop(msg_win, x, y, 16, 16, PIX_SRC, image, 0,0)
/* print in default text, but increment in large text segments */
view_options()
{
if (msg_rect.r_height < 80) {
print("Window not big enough to display options.");
return;
}
do_clear();
getting_opts = 1, start_cnt = 0;
win_setcursor(msg_sw->ts_windowfd, &checkmark);
highlight(msg_win, txt.x, txt.y, LARGE,
" : Toggle Value : Description : Menu (Help)");
image_at(txt.x + 2 * l_width(DEFAULT), txt.y - 12, &mouse_left);
image_at(txt.x + 25 * l_width(DEFAULT), txt.y - 12, &mouse_middle);
image_at(txt.x + 48 * l_width(DEFAULT), txt.y - 12, &mouse_right);
pw_vector(msg_win, 0, txt.y+6, msg_rect.r_width, txt.y+6, PIX_SRC, 1);
pw_vector(msg_win, 0, txt.y+8, msg_rect.r_width, txt.y+8, PIX_SRC, 1);
txt.y += 24;
pw_text(msg_win, 5, txt.y, PIX_SRC, fonts[LARGE], "Option");
pw_text(msg_win, twenty, txt.y, PIX_SRC, fonts[LARGE], "On/Off");
pw_text(msg_win, forty, txt.y, PIX_SRC, fonts[LARGE], "Values");
pw_vector(msg_win, 0, txt.y+6, msg_rect.r_width, txt.y+6, PIX_SRC, 1);
pw_vector(msg_win, 0, txt.y+8, msg_rect.r_width, txt.y+8, PIX_SRC, 1);
pw_text(msg_win, 59*l_width(DEFAULT),txt.y,PIX_SRC,fonts[LARGE],"Scroll:");
pw_rop(msg_win, 60*l_width(LARGE), txt.y-13,16,16,PIX_SRC, &dn_arrow,0,0);
pw_rop(msg_win, 60*l_width(LARGE)+20,txt.y-13,16,16,PIX_SRC, &up_arrow,0,0);
display_opts(0); /* create the pixrect and all that */
}
display_opts(count)
register int count;
{
register int total_displayable = (msg_rect.r_height - 60) / 20;
if (count < 0 && start_cnt + count < 0) {
print("At the beginning");
return;
} else if (count && start_cnt + count + total_displayable > total_opts) {
print("At the end");
return;
}
start_cnt += count;
if (!msg_pix) {
register int x = (total_opts+1) * 20;
if (x < msg_rect.r_height)
x = msg_rect.r_height;
if (!(msg_pix = mem_create(msg_rect.r_width, x, 1))) {
error("mem_create");
return;
}
pr_rop(msg_pix,0,0, msg_rect.r_width-1, x-1, PIX_CLR,0,0,0);
for (count = 0; count < total_opts; count++)
option_line(count);
}
pw_rop(msg_win, 0, 50, msg_rect.r_width - 1, msg_rect.r_height - 50,
PIX_SRC, msg_pix, 0, start_cnt * 20);
}
void
toggle_opt(line)
{
register char *p = viewopts[start_cnt+line].v_prompt;
if (do_set(set_options, viewopts[start_cnt+line].v_opt))
un_set(&set_options, viewopts[start_cnt+line].v_opt);
else {
if (p) {
txt.x = 5 + 40 * l_width(DEFAULT) +
(1 + strlen(p) - (*p=='-')) * l_width(DEFAULT);
txt.y = 50 + line*20 + l_height(curfont);
}
if (!p || *p == '-') {
register char *argv[2];
argv[0] = viewopts[start_cnt+line].v_opt;
argv[1] = NULL;
(void) add_option(&set_options, argv);
}
}
option_line(line);
display_opts(0);
if (txt.x > 5)
type_cursor(PIX_SRC);
}
void
help_opt(line)
{
print(viewopts[start_cnt+line].v_description);
}
add_opt(p, line)
register char *p;
{
char buf[80], **argv;
int argc;
u_long save_bang = ison(glob_flags, IGN_BANG);
(void) sprintf(buf, "set %s=\"%s\"", viewopts[start_cnt+line].v_opt, p);
turnon(glob_flags, IGN_BANG);
if (argv = make_command(buf, DUBL_NULL, &argc))
(void) do_command(argc, argv, msg_list);
if (!save_bang)
turnoff(glob_flags, IGN_BANG);
option_line(line); /* make sure new value is entered into database */
}
option_line(count)
register int count;
{
register char *p, *v = do_set(set_options, viewopts[start_cnt+count].v_opt);
struct pr_prpos win;
win.pr = msg_pix;
win.pos.y = (start_cnt + count) * 20 + 16;
win.pos.x = 5;
pf_text(win, PIX_SRC, fonts[DEFAULT], blank);
pf_text(win, PIX_SRC, fonts[DEFAULT], viewopts[start_cnt+count].v_opt);
win.pos.x = twenty+20;
if (!(p = viewopts[start_cnt+count].v_prompt) || *p == '-') {
pr_rop(msg_pix, twenty, win.pos.y-10, 16, 16, PIX_SRC, &cycle, 0, 0);
pf_text(win, PIX_SRC, fonts[DEFAULT], (v)? "TRUE ": "FALSE");
win.pos.x++;
pf_text(win, PIX_SRC, fonts[DEFAULT], (v)? "TRUE ": "FALSE");
}
if (p) {
if (*p == '-')
p++;
win.pos.x = forty;
/* highlight */
pf_text(win, PIX_SRC, fonts[DEFAULT], p);
win.pos.x++;
pf_text(win, PIX_SRC, fonts[DEFAULT], p);
win.pos.x = forty + strlen(p) * l_width(DEFAULT);
pf_text(win, PIX_SRC, fonts[DEFAULT], ":");
if (v) {
win.pos.x += (2 * l_width(DEFAULT));
pf_text(win, PIX_SRC, fonts[DEFAULT], v);
}
}
}
#endif /* SUNTOOL */
/*
* return a string describing a variable.
* parameters: count, str, buf.
* If str != NULL, check str against ALL variables
* in viewopts array. The one that matches, set count to it and
* print up all the stuff from the viewopts[count] into the buffer
* space in "buf" and return it.
*/
char *
variable_stuff(count, str, buf)
register char *str, buf[];
{
if (str)
for (count = 0; count < total_opts; count++)
if (!strcmp(str, viewopts[count].v_opt))
break;
if (count >= total_opts) {
(void) sprintf(buf, "%s: Not a default %s variable.",
str? str : itoa(count), prog_name);
return NULL;
}
return sprintf(buf, "%s: %s",
viewopts[count].v_opt, viewopts[count].v_description);
}