summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libdialog/help.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-04-20 17:39:37 +0000
committerache <ache@FreeBSD.org>1995-04-20 17:39:37 +0000
commit64d059015a846d87cebe34d7ab5c1c60826bc78b (patch)
tree704f5dc77611312a174a02ade2261d68f64fe0c2 /gnu/lib/libdialog/help.c
parent936b7c1314ac293785af1174e3070079001615ba (diff)
downloadFreeBSD-src-64d059015a846d87cebe34d7ab5c1c60826bc78b.zip
FreeBSD-src-64d059015a846d87cebe34d7ab5c1c60826bc78b.tar.gz
Upgrade.
Submitted by: Marc van Kempen <wmbfmk@urc.tue.nl>
Diffstat (limited to 'gnu/lib/libdialog/help.c')
-rw-r--r--gnu/lib/libdialog/help.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/gnu/lib/libdialog/help.c b/gnu/lib/libdialog/help.c
index fbc2e83..51a1826 100644
--- a/gnu/lib/libdialog/help.c
+++ b/gnu/lib/libdialog/help.c
@@ -69,38 +69,37 @@ display_helpfile(void)
if (in_help) return; /* dont call help when you're in help */
if (_helpfile != NULL) {
- if (_helpline != NULL) {
- savehline = _helpline;
- _helpline = NULL;
- }
if ((w = dupwin(newscr)) == NULL) {
dialog_notify("No memory to dup previous screen\n");
- goto ret;
+ return;
}
if ((f = fopen(_helpfile, "r")) == NULL) {
sprintf(msg, "Can't open helpfile : %s\n", _helpfile);
dialog_notify(msg);
- goto ret;
+ return;
}
if (fstat(fileno(f), &sb)) {
sprintf(msg, "Can't stat helpfile : %s\n", _helpfile);
dialog_notify(msg);
- goto ret;
+ return;
}
if ((buf = (char *) malloc( sb.st_size )) == NULL) {
sprintf(msg, "Could not malloc space for helpfile : %s\n", _helpfile);
dialog_notify(msg);
- goto ret;
+ return;
}
if (fread(buf, 1, sb.st_size, f) != sb.st_size) {
sprintf(msg, "Could not read entire help file : %s", _helpfile);
dialog_notify(msg);
free(buf);
- goto ret;
+ return;
}
buf[sb.st_size] = 0;
in_help = TRUE;
+ savehline = get_helpline();
+ use_helpline("Use arrowkeys, PgUp, PgDn, Home and End to move through text");
dialog_mesgbox("Online help", buf, LINES-4, COLS-4);
+ restore_helpline(savehline);
in_help = FALSE;
touchwin(w);
wrefresh(w);
@@ -110,10 +109,6 @@ display_helpfile(void)
/* do nothing */
}
-ret:
- if (savehline != NULL)
- _helpline = savehline;
-
return;
} /* display_helpfile() */
@@ -167,3 +162,33 @@ display_helpline(WINDOW *w, int y, int width)
return;
}
+
+char *
+get_helpline(void)
+/*
+ * desc: allocate new space, copy the helpline to it and return a pointer to it
+ */
+{
+ char *hlp;
+
+ if (_helpline) {
+ hlp = (char *) malloc( strlen(_helpline) + 1 );
+ strcpy(hlp, _helpline);
+ } else {
+ hlp = NULL;
+ }
+
+ return(hlp);
+} /* get_helpline() */
+
+void
+restore_helpline(char *helpline)
+/*
+ * Desc: set the helpline to <helpline> and free the space allocated to it
+ */
+{
+ use_helpline(helpline);
+ free(helpline);
+
+ return;
+} /* restore_helpline() */
OpenPOWER on IntegriCloud