1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/*
| help.c
|
| $Header: /home/hugh/sources/aee/RCS/help.c,v 1.9 1999/02/01 04:28:08 hugh Exp hugh $
*/
/*
| Copyright (c) 1986 - 1988, 1991 - 1995, 1999 Hugh Mahon.
*/
#include "aee.h"
char *help_file_list[4] = {
"/usr/local/aee/help.ae",
"/usr/local/lib/help.ae",
"/usr/lib/aee/help.ae",
"~/.help.ae",
"help.ae"
};
void
help() /* help function */
{
int counter;
char *string;
go_on = TRUE;
if ((fp = fopen(ae_help_file, "r")) == NULL)
{
for (counter = 0; (counter < 4) && (fp == NULL); counter++)
{
string = resolve_name(help_file_list[counter]);
fp = fopen(string, "r");
}
if (fp == NULL)
{
wmove(com_win, 0, 0);
werase(com_win);
wprintw(com_win, help_err_msg, ae_help_file);
wrefresh(com_win);
clr_cmd_line = TRUE;
go_on = FALSE;
}
}
if (go_on)
{
help_win = newwin(LINES-1, COLS, 0, 0);
if ((windows) && (num_of_bufs > 1))
{
t_buff = first_buff;
while (t_buff != NULL)
{
werase(t_buff->win);
wrefresh(t_buff->win);
werase(t_buff->footer);
wrefresh(t_buff->footer);
t_buff = t_buff->next_buff;
}
}
else
{
werase(curr_buff->win);
wrefresh(curr_buff->win);
}
help_line = xalloc(512);
do
{
outfile();
ask();
}
while (go_on);
free(help_line);
werase(help_win);
wrefresh(help_win);
delwin(help_win);
paint_info_win();
new_screen();
clr_cmd_line = TRUE;
}
}
void
outfile() /* output data from help file until a form-feed (separator of subjects) */
{
char *prompt;
int counter;
int scroll_flag = FALSE;
counter = 0;
werase(help_win);
wmove(help_win,0,0);
while (((sline = fgets(help_line, 512, fp)) != NULL) && (*sline != 12))
{
counter++;
if (counter == LINES)
{
wrefresh(help_win);
prompt = get_string(prompt_for_more, FALSE);
if (prompt != NULL)
free(prompt);
scroll_flag = TRUE;
counter = 0;
}
if (scroll_flag)
{
wmove(help_win, 0, 0);
wdeleteln(help_win);
wmove(help_win, (LINES - 2), 0);
}
wprintw(help_win, "%s", sline);
}
wrefresh(help_win);
}
void
ask() /* prompt user what help topic do they wish to learn about */
{
char *topic;
char *tline;
topic = get_string(topic_prompt, FALSE);
if (*topic == (char) NULL)
go_on = FALSE;
else if (*topic != 9)
{
rewind(fp);
do
{
tline = sline = fgets(help_line, 512, fp);
if (tline != NULL)
{
while ((*tline != '\n') && (*tline != (char) NULL))
tline++;
*tline = (char) NULL;
}
}
while ((sline != NULL) && (strncmp(sline, topic, strlen(topic))));
if (sline == NULL)
{
wmove(help_win, LINES -2, 0);
wclrtoeol(help_win);
wstandout(help_win);
wprintw(help_win, topic_err_msg, topic);
wstandend(help_win);
wrefresh(help_win);
rewind(fp);
free(topic);
topic = get_string(continue_prompt, TRUE);
}
else
tline = sline = fgets(help_line, 512, fp);
}
else if (*topic == '\t')
rewind(fp);
free(topic);
}
|