home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / newlibs / rawil110.lha / RawIN.h < prev    next >
C/C++ Source or Header  |  1992-08-04  |  6KB  |  159 lines

  1. #ifndef RAWIN_H
  2. #define RAWIN_H
  3.  
  4. /*  $Filename: RawIN.h $
  5. **  $Release: 1.10 $
  6. **  $Date: August 4, 1992 $
  7. **  $Author: Sam Yee (samy@sfu.ca/1:153/765) $
  8. **
  9. **  Header file for RawIN.lib
  10. **
  11. **  Freely redistributable if this file is unmodified.
  12. */
  13.  
  14. #include <exec/types.h>
  15. #include <dos/dosextens.h>
  16. #include <dos/dos.h>
  17.  
  18. /*
  19. *********************************************************************
  20. ** structures
  21. *********************************************************************
  22. */
  23.  
  24. struct Line
  25. {
  26.     char    *buf,       /* buffer for command line */
  27.             lastchar,   /* last input character */
  28.             InputChar,  /* incoming character */
  29.             flag,       /* flags, look below */
  30.             pad;
  31.     unsigned long   bufindex,       /* index into buf */
  32.                     buflen,         /* length of current command line */
  33.                     bufmax,         /* max length of buffer */
  34.                     hist_linesmax,  /* maximum number of history lines */
  35.                     hist_linecount, /* as of right now, the number of lines */
  36.                     hist_lineindex; /* current history line */
  37.     struct History  *hist_head,     /* first history line */
  38.                     *hist_tail;     /* last history line */
  39.     struct MsgPort  *ReadReplyPort; /* created by AllocLine() */
  40.     struct StandardPacket   packet; /* for packet reads */
  41. };
  42.  
  43. #define LNF_ANSI        1<<0    /* you may set this flag, else CSI sets it */
  44. #define LNF_CSI         1<<1    /* control sequence introducer. read only. */
  45. #define LNF_RAWMODE     1<<2    /* if on, we are in raw mode. */
  46. #define LNF_STARTEDREAD 1<<3    /* if on, we've requested a read. */
  47. #define LNF_EOF         1<<4    /* if on, end-of-file on standard input. read only */
  48. #define LNF_BREAKC      1<<5    /* i've received a signal C (break) */
  49.  
  50. /* history node */
  51. struct History
  52. {
  53.     struct History  *last,  /* previous history line */
  54.                     *next;  /* next history line */
  55.     char            *buf;   /* buffer of the history line */
  56.     unsigned long   buflen; /* length of this history line */
  57. };
  58.  
  59.  
  60. /*
  61. *********************************************************************
  62. ** prototypes
  63. *********************************************************************
  64. */
  65.  
  66. /*
  67. ** Startup/cleanup/init routines
  68. */
  69.  
  70. struct Line *       /* returns allocated Line structure, NULL == failure */
  71. AllocLine(unsigned long buf_size,   /* size of input buffer to allocate */
  72.           unsigned long hist_size); /* number of history lines */
  73.  
  74. void    /* de-allocate a Line structure */
  75. FreeLine(struct Line *line);
  76.  
  77. void    /* reset a Line (eg. initialize the indices, etc.) */
  78. ResetLine(struct Line *line);
  79.  
  80. /*
  81. ** Misc. routines
  82. */
  83.  
  84. /* set stdout to raw mode */
  85. void
  86. RawMode(struct Line *line,      /* line allocated with AllocLine */
  87.         BOOL raw);              /* TRUE == rawmode, FALSE == cooked mode */
  88.  
  89. /* start the next raw read */
  90. void
  91. StartAsyncRead(struct Line *line);
  92.  
  93. BOOL    /* returns non-zero if user has pressed CR or LF */
  94. BuildLine(struct Line *line,    /* line to build */
  95.           long max_chars,       /* # of characters for this command line, -1 == default */
  96.           BOOL echo);           /* if TRUE, output changes to command line */
  97.  
  98. BOOL /* check for a keypress.  if TRUE, a key has been typed */
  99. KeyPressed(struct Line *line);
  100.  
  101.  
  102. /*
  103. ** History routines
  104. */
  105.  
  106. void
  107. MakeHistory(struct Line *line,
  108.             char *buf,          /* history buffer to add */
  109.             long max_chars);    /* length of buffer to add, if -1 use default (strlen()) */
  110.  
  111. struct History *    /* returns pointer to History, else NULL on failure */
  112. GetHistory(struct Line  *line,  /* line to get history from */
  113.            long num);           /* history line # */
  114.  
  115. void
  116. ShowHistory(struct Line *line,
  117.             long hist_start,    /* start listing history lines from this location,
  118.                                    1 is the beginning, -1 is the end. */
  119.             long hist_lines,    /* # of history lines to display, -1L == all */
  120.             BOOL reverse);      /* if TRUE then reverse order of output */
  121.  
  122. void
  123. DeleteHistory(struct Line *line,    /* line to delete history*/
  124.               long num);            /* history # to delete, 1 is the first, -1 is the last */
  125.  
  126.  
  127. /*
  128. ** Input routines
  129. */
  130.  
  131. long /* -1L == read unsuccessful due to EOL or break.
  132.          0L == user only pressed return, else the # of chars read */
  133. RawGets(struct Line *line,
  134.         char *buf,              /* buffer to store command line, if NULL use line->buf */
  135.         unsigned long buflen,   /* length of buffer */
  136.         unsigned long defsize,  /* default size of buffer to display */
  137.         BOOL hot,               /* hotkey if true, returns when a key is hit. */
  138.         BOOL caps,              /* CAPS if true */
  139.         BOOL echo);             /* if TRUE, output keypresses */
  140.  
  141. char    /* if non-zero then the user has typed a character, else read line->flag
  142.            for reason. */
  143. WaitKey(struct Line *line,
  144.         BOOL    caps,   /* if TRUE, capitalize input */
  145.         BOOL    echo);  /* if TRUE, echo input */
  146.  
  147. char    /* if non-zero then the user has typed a character */
  148. GetKey(struct Line *line,
  149.        BOOL caps,   /* if TRUE, capitalize input */
  150.        BOOL echo);  /* if TRUE, echo input */
  151.  
  152. char    /* key user pressed, else 0 */
  153. PauseKey(struct Line *line,
  154.          char   pause_key,      /* key to press to go into paused mode. -1 is any */
  155.          char   unpause_key,    /* key to press to return from pause mode. -1 is any */
  156.          char   *pause_text);   /* text to display when paused, NULL if none */
  157.  
  158. #endif  /* RAWIN_H */
  159.