home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
newlibs
/
rawil110.lha
/
RawIN.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-04
|
6KB
|
159 lines
#ifndef RAWIN_H
#define RAWIN_H
/* $Filename: RawIN.h $
** $Release: 1.10 $
** $Date: August 4, 1992 $
** $Author: Sam Yee (samy@sfu.ca/1:153/765) $
**
** Header file for RawIN.lib
**
** Freely redistributable if this file is unmodified.
*/
#include <exec/types.h>
#include <dos/dosextens.h>
#include <dos/dos.h>
/*
*********************************************************************
** structures
*********************************************************************
*/
struct Line
{
char *buf, /* buffer for command line */
lastchar, /* last input character */
InputChar, /* incoming character */
flag, /* flags, look below */
pad;
unsigned long bufindex, /* index into buf */
buflen, /* length of current command line */
bufmax, /* max length of buffer */
hist_linesmax, /* maximum number of history lines */
hist_linecount, /* as of right now, the number of lines */
hist_lineindex; /* current history line */
struct History *hist_head, /* first history line */
*hist_tail; /* last history line */
struct MsgPort *ReadReplyPort; /* created by AllocLine() */
struct StandardPacket packet; /* for packet reads */
};
#define LNF_ANSI 1<<0 /* you may set this flag, else CSI sets it */
#define LNF_CSI 1<<1 /* control sequence introducer. read only. */
#define LNF_RAWMODE 1<<2 /* if on, we are in raw mode. */
#define LNF_STARTEDREAD 1<<3 /* if on, we've requested a read. */
#define LNF_EOF 1<<4 /* if on, end-of-file on standard input. read only */
#define LNF_BREAKC 1<<5 /* i've received a signal C (break) */
/* history node */
struct History
{
struct History *last, /* previous history line */
*next; /* next history line */
char *buf; /* buffer of the history line */
unsigned long buflen; /* length of this history line */
};
/*
*********************************************************************
** prototypes
*********************************************************************
*/
/*
** Startup/cleanup/init routines
*/
struct Line * /* returns allocated Line structure, NULL == failure */
AllocLine(unsigned long buf_size, /* size of input buffer to allocate */
unsigned long hist_size); /* number of history lines */
void /* de-allocate a Line structure */
FreeLine(struct Line *line);
void /* reset a Line (eg. initialize the indices, etc.) */
ResetLine(struct Line *line);
/*
** Misc. routines
*/
/* set stdout to raw mode */
void
RawMode(struct Line *line, /* line allocated with AllocLine */
BOOL raw); /* TRUE == rawmode, FALSE == cooked mode */
/* start the next raw read */
void
StartAsyncRead(struct Line *line);
BOOL /* returns non-zero if user has pressed CR or LF */
BuildLine(struct Line *line, /* line to build */
long max_chars, /* # of characters for this command line, -1 == default */
BOOL echo); /* if TRUE, output changes to command line */
BOOL /* check for a keypress. if TRUE, a key has been typed */
KeyPressed(struct Line *line);
/*
** History routines
*/
void
MakeHistory(struct Line *line,
char *buf, /* history buffer to add */
long max_chars); /* length of buffer to add, if -1 use default (strlen()) */
struct History * /* returns pointer to History, else NULL on failure */
GetHistory(struct Line *line, /* line to get history from */
long num); /* history line # */
void
ShowHistory(struct Line *line,
long hist_start, /* start listing history lines from this location,
1 is the beginning, -1 is the end. */
long hist_lines, /* # of history lines to display, -1L == all */
BOOL reverse); /* if TRUE then reverse order of output */
void
DeleteHistory(struct Line *line, /* line to delete history*/
long num); /* history # to delete, 1 is the first, -1 is the last */
/*
** Input routines
*/
long /* -1L == read unsuccessful due to EOL or break.
0L == user only pressed return, else the # of chars read */
RawGets(struct Line *line,
char *buf, /* buffer to store command line, if NULL use line->buf */
unsigned long buflen, /* length of buffer */
unsigned long defsize, /* default size of buffer to display */
BOOL hot, /* hotkey if true, returns when a key is hit. */
BOOL caps, /* CAPS if true */
BOOL echo); /* if TRUE, output keypresses */
char /* if non-zero then the user has typed a character, else read line->flag
for reason. */
WaitKey(struct Line *line,
BOOL caps, /* if TRUE, capitalize input */
BOOL echo); /* if TRUE, echo input */
char /* if non-zero then the user has typed a character */
GetKey(struct Line *line,
BOOL caps, /* if TRUE, capitalize input */
BOOL echo); /* if TRUE, echo input */
char /* key user pressed, else 0 */
PauseKey(struct Line *line,
char pause_key, /* key to press to go into paused mode. -1 is any */
char unpause_key, /* key to press to return from pause mode. -1 is any */
char *pause_text); /* text to display when paused, NULL if none */
#endif /* RAWIN_H */