aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/doc/OLD
diff options
context:
space:
mode:
Diffstat (limited to 'libslang/doc/OLD')
-rw-r--r--libslang/doc/OLD/help/README3
-rw-r--r--libslang/doc/OLD/help/makefile.djg18
-rw-r--r--libslang/doc/OLD/help/makefile.os270
-rw-r--r--libslang/doc/OLD/help/makefile.unx8
-rw-r--r--libslang/doc/OLD/help/slang.hlp241
-rw-r--r--libslang/doc/OLD/help/slhelp.c587
6 files changed, 927 insertions, 0 deletions
diff --git a/libslang/doc/OLD/help/README b/libslang/doc/OLD/help/README
new file mode 100644
index 0000000..fce6919
--- /dev/null
+++ b/libslang/doc/OLD/help/README
@@ -0,0 +1,3 @@
+The program this directory `slhelp' is capable of reading VMS style help
+files. The program `texconv' in ../doc is able to convert the TeX documents
+there to produce VMS style help files.
diff --git a/libslang/doc/OLD/help/makefile.djg b/libslang/doc/OLD/help/makefile.djg
new file mode 100644
index 0000000..67432c5
--- /dev/null
+++ b/libslang/doc/OLD/help/makefile.djg
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS = -Wall -O6
+GO32 = C:\djgpp\bin\go32.exe
+SLIB = ../src#
+LFLAGS = -L$(SLIB) -lslang -lpc
+
+SUFFIXES = .c
+.SUFFIXES: $(SUFFIXES)
+
+.c.o:
+ $(CC) -c $(CFLAGS) -I$(SLIB) $*.c
+
+
+slhelp: slhelp.o
+ $(CC) slhelp.o $(LFLAGS) -o slhelp.386
+ coff2exe -s $(GO32) slhelp.386
+
+
diff --git a/libslang/doc/OLD/help/makefile.os2 b/libslang/doc/OLD/help/makefile.os2
new file mode 100644
index 0000000..9338fa9
--- /dev/null
+++ b/libslang/doc/OLD/help/makefile.os2
@@ -0,0 +1,70 @@
+#================ JED makefile for DMAKE 3.8 ======================
+# This makefile is for DMAKE, either under DOS or OS/2
+# The following OS/Compiler combinations are supported:
+#
+# Target Compiler Command Compiler
+# Operating Mnemoic Line
+# System
+#-----------------------------------------------------------------------
+# OS2 MSC OS=OS2 COMP=MSC Microsoft C
+# OS2 EMX OS=OS2 COMP=EMX emx/gcc
+#-----------------------------------------------------------------------
+MODEL = L
+#-----------------------------------------------------------------------
+# default setup for EMX under OS/2, optimized version
+# change values below or override with -e switch on command line
+#-----------------------------------------------------------------------
+OS=OS2
+COMP=EMX
+OPT=Y
+#-----------------------------------------------------------------------
+.IF $(TOS) == $(NULL)
+ TOS = $(OS)
+.END
+.IF $(OS) == OS2
+#========================================================================
+#========================= OS2 - MSC ====================================
+#========================================================================
+ .IF $(COMP) == MSC
+ CC = cl -nologo -MT
+ LIB_CMD = lib
+ .IF $(OPT) == N
+ CDBUG = -Od -Zi -W2
+ LDEBUG = -Zi
+ .ELSE
+ CDBUG =
+ LDEBUG =
+ .END
+ CDEBUG = $(CDBUG)
+ O = .obj
+ LFLAGS2 = setargv.obj $(SLANG).lib $(SLIB)os2sl16.def -link /NOE $(SLIB)
+#========================================================================
+#========================= OS2 - EMX ====================================
+#========================================================================
+ .ELIF $(COMP) == EMX
+ CC = gcc -Zmtd
+ .IF $(OPT) == N
+ CDEBUG =-g
+ LDEBUG =
+ .ELSE
+ CDEBUG = -O
+ LDEBUG =
+ .END
+ O = .o
+ LFLAGS2 = $(SLIB)os2sl.def -L$(SLIB) -l$(SLANG)
+ .ENDIF
+.ENDIF
+
+CFLAGS=$(CDEBUG) -I$(SLIB) -DHAS_MEMSET
+LFLAGS = $(LDEBUG)
+
+SLIB = ..\src\\
+SLANG = slang
+
+.c$O:
+ $(CC) -c $(CFLAGS) $*.c
+
+slhelp : slhelp.exe
+
+slhelp.exe: slhelp$O
+ $(CC) $(LFLAGS) -o $@ slhelp$O $(LFLAGS2)
diff --git a/libslang/doc/OLD/help/makefile.unx b/libslang/doc/OLD/help/makefile.unx
new file mode 100644
index 0000000..e87eaa0
--- /dev/null
+++ b/libslang/doc/OLD/help/makefile.unx
@@ -0,0 +1,8 @@
+# Uncomment if you have gcc
+# CC = gcc
+#
+# If you compiled with termcap, uncomment next line.
+# THETERMCAP = -ltermcap
+
+slhelp: slhelp.c
+ $(CC) $(CFLAGS) slhelp.c -I../src -L../src -o slhelp -lslang $(THETERMCAP)
diff --git a/libslang/doc/OLD/help/slang.hlp b/libslang/doc/OLD/help/slang.hlp
new file mode 100644
index 0000000..254031e
--- /dev/null
+++ b/libslang/doc/OLD/help/slang.hlp
@@ -0,0 +1,241 @@
+Help file for slang
+
+1 Interpreter
+ See readme files for information--- no help file yet.
+1 Keyboard-Interface
+ SLang's keyboard interface is designed to allow one to read a character
+ at a time in a system independent manner. To initialize the interface,
+ one must first call the function `SLang_init_tty'. Before exiting the
+ program, the function `SLang_reset_tty' must be called to restore the
+ keyboard interface to its original state. This is particularly true for
+ MSDOS since INT-9 is hooked by S-Lang.
+
+2 Functions
+
+3 init_tty
+
+ Prototype: int SLang_init_tty (int abort_char, int flow_ctrl, int opost);
+
+ This function must be called to initialize the tty for single character
+ input. The first parameter `abort_char' must lie in the range 0-255 and
+ is used as an abort character. By default, pressing this character sets
+ the global variable `SLang_Error' to USER_BREAK. See help on the function
+ `SLang_set_abort_signal' to change the default action.
+
+ If the second parameter `flow_ctrl' is non-zero, flow control is enabled.
+
+ If the third parmeter `opost' is zero, output processing is NOT turned on.
+ A value of zero is required for SLang's screen management routines (SLsmg)
+ to work properly.
+
+ This function returns 0 upon success. In addition, if the global variable
+ SLang_TT_Baud_Rate == 0 when this function is called, SLang will attempt
+ to determine the terminals baud rate and set this variable accordingly. As
+ far as the SLang library is concerned, if SLang_TT_Baud_Rate is less than
+ or equal to zero, the baud rate is effectively infinite.
+
+3 reset_tty
+
+ Prototype: void SLang_reset_tty (void);
+
+ This function must be called to reset the tty to the state the terminal
+ was in before a previous call to `SLang_init_tty'.
+
+3 getkey
+
+ Prototype: unsigned int SLang_getkey (void);
+
+ This function returns a single key from the tty. If the read fails,
+ 0xFFFF is returned. Before attempting to use this function, one myust
+ first call SLang_init_tty to initialize the terminal.
+
+ If the abort character is pressed while this function is called, it will
+ return the value of the abort character. In addition, the global variable
+ SLKeyBoard_Quit will be set and SLang_Error will will be set to USER_BREAK
+ unless the variable SLang_Ignore_User_Abort is non-zero.
+
+3 unget_keystring
+
+ Prototype: void SLang_ungetkey_string (unsigned char *buf, int buflen);
+
+3 buffer_keystring
+
+ Prototype: void SLang_buffer_keystring (unsigned char *buf, int buflen);
+
+3 ungetkey
+
+ Prototype: void SLang_ungetkey (unsigned char ch);
+
+3 flush_input
+
+ Prototype: void SLang_flush_input (void);
+
+3 input_pending
+
+ Prototype int SLang_input_pending (int tsecs);
+
+3 set_abort_signal
+
+ Prototype: void SLang_set_abort_signal (void (*f)(int));
+
+ If SIGINT is generated, the function p1 will be called. If `f' is NULL
+ the SLang default signal handler is called. This sets SLang_Error to
+ USER_BREAK. I suspect most users will simply want to pass NULL.
+
+2 Variables
+3 Abort_Char
+
+ int SLang_Abort_Char;
+ The value of the character (0-255) used to trigger SIGINT
+
+3 Ignore_User_Abort
+
+ int SLang_Ignore_User_Abort;
+ If non-zero, pressing the abort character will not result in USER_BREAK
+ SLang_Error.
+
+3 KeyBoard_Quit
+
+ volatile int SLKeyBoard_Quit
+
+3 TT_Baud_Rate
+
+ int SLang_TT_Baud_Rate;
+
+ If this value is zero before SLang_init_tty is called, after the call, it
+ will be set to the baud rate if the terminal on systems which support it.
+
+1Screen_Management
+ S-Lang's screen management routines are located in the slsmg.c file. All
+ exported functions and variables are prefixed by `SLsmg', e.g., `SLsmg_cls'.
+ The screen management code uses the `SLtt' routines for writing output to
+ the terminal.
+
+ To initialize the screen management system, call `SLtt_get_terminfo' first
+ to initialize the display system. Then call `SLsmg_init_smg' to initialize
+ the SLsmg routines. If you are going to read characters from the keyboard,
+ it is also a good idea to initialize the tty at this point via the
+ SLang_init_tty function (See `Keyboard').
+
+ Before exiting the program, call the approriate routines to reset the
+ terminal and display system. Basically, your program will look like
+ something like:
+\begin{verbatim}
+ #include "slang.h"
+
+ int main ()
+ {
+ SLtt_get_terminfo ();
+ SLang_init_tty (7, 0, 0);
+ SLsmg_init_smg ();
+
+ /* do stuff .... */
+
+ SLsmg_reset_smg ();
+ SLang_reset_tty ();
+ return 0;
+ }
+\end{verbatim}
+
+2Functions
+3erase_eol
+ Prototype: void SLsmg_erase_eol (void);
+ Erase line from current position to the end of the line.
+3gotorc
+ Prototype: void SLsmg_gotorc (int row, int col);
+ Move cursor position to ('row', 'col'). (0,0) corresponds to the top left
+ corner of the screen.
+3erase_eos
+ Prototype: void SLsmg_erase_eos (void);
+ Erase fro the current position to the end of the screen.
+3reverse_video
+ Prototype: void SLsmg_reverse_video (void);
+ Start writing characters in reverse video.
+3set_color
+ Prototype: void SLsmg_set_color (int obj);
+ Set the character attributes to those of 'obj'.
+3normal_video
+ Prototype: void SLsmg_normal_video (void);
+ Turn off characters attributes and set attributes to object 0.
+3printf
+ Prototype: void SLsmg_printf (char *, ...);
+ Write a formatted string to the virtual display.
+3vprintf
+ Prototype: void SLsmg_vprintf (char *, va_list);
+ Like 'SLsmg_printf' but uses a variable argument list.
+3write_string
+ Prototype: void SLsmg_write_string (char *);
+3write_char
+ Prototype: void SLsmg_write_char (char);
+3write_nchars
+ Prototype: void SLsmg_write_nchars (char *, int);
+3cls
+ Prototype: void SLsmg_cls (void);
+ Clear the screen
+3refresh
+ Prototype: void SLsmg_refresh (void);
+ Make the physical display look like the virtual display.
+3touch_lines
+ Prototype: void SLsmg_touch_lines (int row, int n);
+ Mark screen rows 'row', 'row + 1', ... 'row + (n - 1)' as modified.
+3init_smg
+ Prototype: int SLsmg_init_smg (void);
+ Must be called before any of the other routines will work.
+3reset_smg
+ Prototype: void SLsmg_reset_smg (void);
+3char_at
+ unsigned short SLsmg_char_at(void);
+ Prototype: unsigned short SLsmg_char_at(void);
+ Returns the character and its attributes object number at the current
+ cursor position.
+2Variables
+ SLsmg_Tab_Width (Default is 8).
+
+1Searching-Functions
+ The S-Lang library incorporates two types of searches: Regular expression
+ pattern matching and ordinary searching.
+2Regular-Expressions
+
+ !!! No documentation available yet !!!
+
+2Simple-Searches
+ The routines for ordinary searching are defined in the `slsearch.c' file.
+ To use these routines, simply include "slang.h" in your program and simply
+ call the appropriate routines.
+
+ The searches can go in either a forward or backward direction and can
+ either be case or case insensitive. The region that is searched may
+ contain null characters (ASCII 0) however, the search string cannot in the
+ current implementation. In addition the length of the string to be found
+ is currently limited to 256 characters.
+
+ Before searching, the function `SLsearch_init' must first be called to
+ ``preprocess'' the search string.
+3initialization
+ The function `SLsearch_init' must be called before a search can take place.
+ Its prototype is:
+
+ int SLsearch_init (char *key, int dir, int case_sens, SLsearch_Type *st);
+
+ Here `key' is the string to be searched for. `dir' specifies the direction
+ of the search: a value greater than zero is used for searching forward and
+ a value less than zero is used for searching backward. The parameter
+ `case_sens' specifies whether the search is case sensitive or not. A
+ non-zero value indicates that case is important. `st' is a pointer to a
+ structure of type `SLsearch_Type' defined in "slang.h". This structure is
+ initialized by this routine and must be passed to `SLsearch' when the
+ search is actually performed.
+
+ This routine returns the length of the string to be searched for.
+
+3SLsearch
+ Prototype: unsigned char *SLsearch (unsigned char *pmin, unsigned char *pmax,
+ SLsearch_Type *st);
+
+ This function performs the search defined by a previous call to
+ `SLsearch_init' over a region specified by the pointers `pmin' and `pmax'.
+
+ It returns a pointer to the start of the match if successful or it will
+ return NULL if a match was not found.
+
+
diff --git a/libslang/doc/OLD/help/slhelp.c b/libslang/doc/OLD/help/slhelp.c
new file mode 100644
index 0000000..be7638f
--- /dev/null
+++ b/libslang/doc/OLD/help/slhelp.c
@@ -0,0 +1,587 @@
+#include "config.h"
+
+#include <stdio.h>
+
+#ifdef unix
+# include <signal.h>
+#endif
+
+#include "slang.h"
+#include "jdmacros.h"
+
+#ifndef HELP_DIR
+#define HELP_DIR ""
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+
+typedef struct SLhlp_Node_Type
+{
+ char *name;
+ struct SLhlp_Node_Type *child;
+ struct SLhlp_Node_Type *sister;
+ unsigned long pos;
+} SLhlp_Node_Type;
+
+typedef struct
+{
+ FILE *fp;
+ SLhlp_Node_Type *root;
+ SLhlp_Node_Type *sub; /* current subtopic node */
+ SLhlp_Node_Type *now; /* Node we are currently reading from */
+ SLhlp_Node_Type *path[10]; /* path to current node */
+ int level;
+} SLhlp_File_Type;
+
+#define MAX_HELP_FILES 10
+
+SLhlp_File_Type Help_Files[MAX_HELP_FILES];
+
+
+static int add_level (int level, int fd, char *name, unsigned long pos)
+{
+ SLhlp_Node_Type *node, *parent, *new_node;
+ int len;
+
+ while (*name == ' ') name++;
+ len = strlen(name);
+
+ if (len) while (name[len - 1] == ' ') len--;
+ if (len == 0) return -1;
+ name[len] = 0;
+
+ parent = node = Help_Files[fd].root;
+ while (level-- > 0)
+ {
+ if (node == NULL)
+ {
+ return -1;
+ }
+ while (node->sister != NULL) node = node->sister;
+ parent = node;
+ node = node->child;
+ }
+
+
+ if ((NULL == (new_node = (SLhlp_Node_Type *) SLMALLOC (sizeof (SLhlp_Node_Type))))
+ || (NULL == (new_node->name = (char *) SLMALLOC (len + 1))))
+ {
+ SLang_Error = SL_MALLOC_ERROR;
+ return -1;
+ }
+
+ new_node->sister = NULL;
+ new_node->child = NULL;
+ new_node->pos = pos;
+ strcpy (new_node->name, name);
+
+ if (node == NULL)
+ {
+ if (parent == NULL)
+ {
+ Help_Files[fd].root = new_node;
+ }
+ else parent->child = new_node;
+ }
+ else
+ {
+ while (node->sister != NULL) node = node->sister;
+ node->sister = new_node;
+ }
+ return 0;
+}
+
+
+static void free_nodes (SLhlp_Node_Type *node)
+{
+ if (node->child != NULL) free_nodes (node->child);
+ if (node->sister != NULL) free_nodes (node->sister);
+ if (node->name != NULL) SLFREE (node->name);
+ SLFREE (node);
+}
+
+
+
+static int check_fd (int fd)
+{
+ if (((fd >= MAX_HELP_FILES) || (fd < 0)) || (Help_Files[fd].fp == NULL))
+ {
+ if (SLang_Error == 0) SLang_Error = INTRINSIC_ERROR;
+ return 0;
+ }
+ return 1;
+}
+
+
+static void SLhlp_close_help (int fd)
+{
+ if (!check_fd (fd)) return;
+ fclose (Help_Files[fd].fp); Help_Files[fd].fp = NULL;
+ if (Help_Files[fd].root != NULL) free_nodes (Help_Files[fd].root);
+}
+
+
+static int SLhlp_open_help (char *file)
+{
+ int fd = 0, ch;
+ FILE *fp;
+ int level;
+ char topic[256], *b;
+ unsigned long pos;
+
+ while ((fd < MAX_HELP_FILES) && (Help_Files[fd].fp != NULL))
+ fd++;
+
+ if (fd == MAX_HELP_FILES) return -1;
+ if (NULL == (Help_Files[fd].fp = fp = fopen (file, "r"))) return -1;
+
+
+ while (1)
+ {
+ ch = getc (fp);
+
+ bypass_getc:
+
+ if ((ch > '9') || (ch == ' ')) continue;
+ if (ch == '\n')
+ {
+ ch = getc (fp);
+ if ((ch == ' ') || (ch > '9')) continue;
+ if (ch >= '1')
+ {
+ level = ch - '1';
+ pos = ftell (fp);
+ b = topic;
+ while (('\n' != (ch = getc (fp))) && (ch != EOF))
+ {
+ *b++ = ch;
+ }
+ *b = 0;
+ if (add_level (level, fd, topic, pos)) goto error;
+ }
+ goto bypass_getc;
+ }
+ if (ch == EOF) break;
+ }
+
+ Help_Files[fd].now = NULL;
+ Help_Files[fd].sub = Help_Files[fd].root;
+ Help_Files[fd].path[0] = NULL;
+
+ return fd;
+
+
+ error:
+ SLhlp_close_help (fd);
+ return -1;
+}
+
+static char *SLhlp_get_subtopic (int fd)
+{
+ SLhlp_Node_Type *node;
+
+ if (!check_fd(fd)) return NULL;
+ if ((node = Help_Files[fd].sub) == NULL) return NULL;
+
+ Help_Files[fd].sub = node->sister;
+ return node->name;
+}
+
+
+static char *SLhlp_gets (int fd, char *buf)
+{
+ SLhlp_Node_Type *node;
+ char ch;
+
+
+ if (!check_fd(fd)) return NULL;
+
+ node = Help_Files[fd].now;
+ if (node == NULL) return NULL;
+
+ if ((NULL == fgets(buf, 255, Help_Files[fd].fp))
+ || ((*buf <= '9') && (*buf >= '0')))
+ {
+ if ((node->child == NULL) && Help_Files[fd].level)
+ {
+ Help_Files[fd].level--;
+ }
+ Help_Files[fd].now = NULL;
+ return NULL;
+ }
+
+ /* First character is reserved. */
+ if (*buf > ' ')
+ {
+ ch = *buf | 0x20;
+ if ((ch < 'a') || (ch > 'z'))
+ {
+ *buf = '\n';
+ *(buf + 1) = 0;
+ }
+ }
+
+ return buf;
+}
+
+static int my_strncasecmp (char *a, char *b, int n)
+{
+ register char cha, chb;
+
+ while (n--)
+ {
+ cha = *a++;
+ chb = *b++;
+ if (cha != 0)
+ {
+ if ((cha == chb)
+ || ((cha | 0x20) == (chb | 0x20))) continue;
+ }
+ return cha - chb;
+ }
+ return 0;
+}
+
+
+
+static int SLhlp_select_topic (int fd, char *topic)
+{
+ char topic_buf[256];
+ char *t, ch;
+ int level = 0;
+ int len;
+
+ SLhlp_Node_Type *node, *parent;
+
+ if (!check_fd (fd)) return -1;
+
+ parent = node = Help_Files[fd].root;
+
+ ch = 0;
+ if (topic != NULL)
+ while (((ch = *topic) <= ' ') && ch) topic++;
+
+ if (ch != 0) while (node != NULL)
+ {
+ parent = node;
+ t = topic_buf;
+
+ while ((ch = *topic) > ' ')
+ {
+ *t++ = ch;
+ topic++;
+ }
+ while (((ch = *topic) <= ' ') && ch) topic++;
+ *t = 0;
+
+ len = strlen (topic_buf);
+
+
+ if (len) while (my_strncasecmp (node->name, topic_buf, len))
+ {
+ node = node->sister;
+ if (node == NULL) break;
+ }
+
+ if (node == NULL) break;
+ Help_Files[fd].path[level++] = node;
+ if ((ch == 0) || (ch == '\n')) break;
+ node = node -> child;
+ }
+
+ /* level comes out at 1 greater than last valid one */
+ Help_Files[fd].level = level;
+
+ if (node != NULL) /* success */
+ {
+ Help_Files[fd].sub = node->child;
+ Help_Files[fd].now = node;
+ fseek (Help_Files[fd].fp, node->pos, SEEK_SET);
+ return 0;
+ }
+ else /* failure */
+ {
+ Help_Files[fd].now = NULL;
+ Help_Files[fd].sub = parent;
+ return -1;
+ }
+}
+
+static int SLhlp_what_topic (int fd, char *buf)
+{
+ int level, i;
+ char *b;
+ if (!check_fd(fd)) return -1;
+
+ level = Help_Files[fd].level;
+ *buf = 0;
+ if (level == 0) return 0;
+
+ b = buf;
+ for (i = 0; i < level; i++)
+ {
+ strcpy (b, Help_Files[fd].path[i]->name);
+ b = b + strlen (b);
+ *b++ = ' ';
+ }
+ *(b - 1) = 0;
+ return level;
+}
+
+static int SLhlp_up_topic (int fd)
+{
+ if (!check_fd(fd)) return -1;
+
+ if (Help_Files[fd].level) Help_Files[fd].level--;
+ return 0;
+}
+
+
+
+
+/* --------------------------------------------------------------------- */
+
+static void cls (void)
+{
+ SLtt_cls ();
+ SLtt_flush_output ();
+}
+
+
+static void newline (int nl, int reset, int cls_flag)
+{
+ static int n;
+
+ if (nl) putc('\n', stdout);
+ n++;
+
+ if (n == SLtt_Screen_Rows - 1)
+ {
+ SLtt_reverse_video (1);
+ SLtt_write_string ("---Press RETURN to continue.---");
+ SLtt_normal_video ();
+ SLtt_flush_output ();
+
+ SLang_getkey ();
+ if (cls_flag) cls ();
+ else
+ fputs("\r \r", stdout);
+
+ cls_flag = 0;
+ n = 0;
+ }
+
+ if (reset)
+ {
+ n = 0;
+ if (cls_flag) cls ();
+ return;
+ }
+}
+
+SLang_RLine_Info_Type *Help_Rli;
+
+static SLang_RLine_Info_Type *init_readline (void)
+{
+ unsigned char *buf = NULL;
+ SLang_RLine_Info_Type *rli;
+
+ if ((NULL == (rli = (SLang_RLine_Info_Type *) SLMALLOC (sizeof(SLang_RLine_Info_Type))))
+ || (NULL == (buf = (unsigned char *) SLMALLOC (256))))
+ {
+ fprintf(stderr, "malloc error.\n");
+ exit(-1);
+ }
+
+ SLMEMSET ((char *) rli, 0, sizeof (SLang_RLine_Info_Type));
+ rli->buf = buf;
+ rli->buf_len = 255;
+ rli->tab = 8;
+ rli->dhscroll = 20;
+ rli->getkey = SLang_getkey;
+ rli->tt_goto_column = NULL;
+ rli->update_hook = NULL;
+
+ if (SLang_init_readline (rli) < 0)
+ {
+ fprintf(stderr, "Unable to initialize readline library.\n");
+ exit (-1);
+ }
+
+ return rli;
+}
+
+static char *hlp_get_input (char *prompt)
+{
+ int i;
+
+ if (Help_Rli == NULL)
+ {
+ Help_Rli = init_readline ();
+ Help_Rli->update_hook = NULL;
+ }
+
+ Help_Rli->edit_width = SLtt_Screen_Cols - 1;
+ Help_Rli->prompt = prompt;
+ *Help_Rli->buf = 0;
+
+
+ i = SLang_read_line (Help_Rli);
+
+ if ((i >= 0) && !SLang_Error && !SLKeyBoard_Quit)
+ {
+ SLang_rline_save_line (Help_Rli);
+ }
+ else return NULL;
+
+ return (char *) Help_Rli->buf;
+}
+
+
+static void do_subtopics (int fd)
+{
+ char *s;
+ int len, dlen;
+
+ if ((s = SLhlp_get_subtopic (fd)) != NULL)
+ {
+ len = 0;
+ newline (1, 0, 0);
+ fprintf(stdout, "Available Topics/Subtopics:");
+ newline (1, 0, 0);
+ newline (1, 0, 0);
+ do
+ {
+ dlen = strlen (s);
+ len += dlen;
+
+ if (len >= 80)
+ {
+ len = dlen;
+ newline (1, 0, 0);
+ }
+ fputs(s, stdout);
+ dlen = 21 - len % 20;
+ len += dlen;
+ if (len < 80)
+ {
+ while (dlen--) putc(' ', stdout);
+ }
+ }
+ while (NULL != (s = SLhlp_get_subtopic(fd)));
+ newline (1, 0, 0);
+ }
+}
+
+static void get_screen_size (int sig)
+{
+ SLtt_get_screen_size ();
+#ifdef SIGWINCH
+ signal (SIGWINCH, get_screen_size);
+#endif
+}
+
+
+
+int main (int argc, char **argv)
+{
+ char *buf, *file;
+ char buffer[256];
+ static int fd = -1;
+ int len;
+
+ if (argc != 2)
+ {
+ fprintf(stderr, "Usage: slhelp HELP-FILE\n");
+ exit (-1);
+ }
+
+ file = argv[1];
+ if (fd < 0) fd = SLhlp_open_help (file);
+ if (fd < 0)
+ {
+ fprintf (stderr, "Unable to open help file %s\n", file);
+ exit (-1);
+ }
+
+ SLang_init_tty (7, 1, 1);
+ SLtt_get_terminfo ();
+ SLtt_init_video ();
+ SLtt_Use_Ansi_Colors = 0;
+
+#ifdef SIGWINCH
+ signal (SIGWINCH, get_screen_size);
+#endif
+
+ get_screen_size (0);
+ cls ();
+
+ fputs ("\n\nSimply press RETURN at the 'Topic>' prompt to quit help.\n\n",
+ stdout);
+
+ if (SLhlp_what_topic (fd, buffer) > 0)
+ {
+ SLhlp_select_topic (fd, buffer);
+ }
+
+ while (1)
+ {
+ while (1)
+ {
+ if (SLhlp_what_topic (fd, buffer) <= 0)
+ {
+ SLhlp_select_topic (fd, "?");
+ *buffer = 0;
+ }
+ do_subtopics (fd);
+
+ len = strlen (buffer);
+ if (len) strcat (buffer, " Subtopic> ");
+ else strcpy (buffer, "Topic> ");
+ newline (1, 1, 0);
+
+ if (NULL == (buf = hlp_get_input (buffer)))
+ {
+ SLang_Error = 0;
+ if (SLKeyBoard_Quit)
+ {
+ SLKeyBoard_Quit = 0;
+ continue;
+ }
+ goto the_return;
+ }
+
+ if ((*buf == '\n') || (*buf == 0))
+ {
+ if (len == 0) goto the_return;
+ SLhlp_up_topic (fd);
+ continue;
+ }
+
+ buffer[len] = ' '; /* kill prompt */
+ strcpy (buffer + (len + 1), buf);
+ break;
+ }
+
+ newline (1, 1, 1);
+ if (-1 == SLhlp_select_topic (fd, buffer))
+ {
+ fprintf(stdout, "No help available on: %s", buf);
+ newline (1, 0, 0);
+ }
+ else while (NULL != SLhlp_gets (fd, buffer))
+ {
+ fputs(buffer, stdout);
+ newline (0, 0, 1);
+ }
+ }
+
+ the_return:
+
+ SLtt_reset_video ();
+ SLang_reset_tty ();
+ return 0;
+}