[523079]: joe / termcapj.h  Maximize  Restore  History

Download this file

168 lines (140 with data), 6.2 kB

  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
159
160
161
162
163
164
165
166
167
/*
* TERMCAP/TERMINFO header file
* Copyright
* (C) 1992 Joseph H. Allen
*
* This file is part of JOE (Joe's Own Editor)
*/
#ifndef _JOE_TERMCAP_H
#define _JOE_TERMCAP_H 1
struct sortentry {
unsigned char *name;
unsigned char *value;
};
struct cap {
unsigned char *tbuf; /* Termcap entry loaded here */
struct sortentry *sort; /* Pointers to each capability stored in here */
int sortlen; /* Number of capabilities */
unsigned char *abuf; /* For terminfo compatible version */
unsigned char *abufp;
int div; /* tenths of MS per char */
int baud; /* Baud rate */
unsigned char *pad; /* Padding string or NULL to use NUL */
void (*out) (unsigned char *, unsigned char); /* Character output routine */
void *outptr; /* First arg passed to output routine. Second
arg is character to write */
int dopadding; /* Set if pad characters should be used */
};
/* CAP *getcap(char *s,int baud,void (*out)(void *outptr,char c),void *outptr);
*
* Get CAP entry for terminal named in 's'. If 's' is zero, the name in
* the environment variable 'TERM' is used instead. Space for the returned
* CAP is allocated from the heap using malloc.
*
* 'baud' is the baud rate used for 'texec' to calculate number of pad chars
* 'out' is the function 'texec' uses to output characters
* 'outptr' is the passed as the first arg to 'out'
* the second arg contains the char to output
*
* This is how 'getcap' finds the entry: First a list of file names is
* built. If the environment variable 'TERMCAP' begins with a '/', it
* is used as the list of file names. Otherwise, if the environment
* variable 'TERMPATH' is set, it is used as the list of file names. If
* that isn't set, then the string TERMPATH defined above is appended
* to value of the 'HOME' environment variable, and that is used as the
* list of names (a '/' is placed between the value of the environment
* variable and the string). If HOME isn't set, then TERMPATH alone is
* used as the list of file names (without prepending a '/').
*
* Now the contents of the environment variable 'TERMCAP' (if it's defined and
* if it doesn't begin with a '/') and the files from the above list are
* scanned for the terminal name. The contents of the environment variable
* are scanned first, then the files are scanned in the order they appear in
* the named list.
*
* If the last part of a matching termcap entry is a 'tc=filename', then
* the current file is rewound and rescanned for the matching entry (and if
* it's not found, the next entry in the file name list is searched). If
* a matching termcap entry in the TERMCAP environment variable ends with
* a 'tc=filename', then all of the files in the name list are searched.
*
* There is no limit on the size of the termcap entries. No checking is
* done for self-refering 'tc=filename' links (so all of core will be
* allocated if there are any).
*/
CAP *getcap PARAMS((unsigned char *name, unsigned int baud, void (*out) (unsigned char *, unsigned char), void *outptr));
/* CAP *setcap(CAP *cap,int baud,void (*out)(void *outptr,char c),void *outptr);
*
* Reset baud, out and outptr for a CAP
*/
CAP *setcap PARAMS((CAP *cap, unsigned int baud, void (*out) (unsigned char *, unsigned char), void *outptr));
/* char *jgetstr(CAP *cap,char *name);
*
* Get value of string capability or return NULL if it's not found. A fast
* binary search is used to find the capability. The char * returned points into
* the buffer used to load the termcap entry. It should not be modified or
* freed.
*/
unsigned char *jgetstr PARAMS((CAP *cap, unsigned char *name));
/* int getflag(CAP *cap,char *name);
*
* Return true if the named capability is found in 'cap'. A fast binary
* search is used to lookup the capability.
*/
int getflag PARAMS((CAP *cap, unsigned char *name));
/* int getnum(CAP *cap,char *name);
*
* Return value of numeric capability or return -1 if it's not found. A fast
* binary search is used to lookup the capability.
*/
int getnum PARAMS((CAP *cap, unsigned char *name));
/* void rmcap(CAP *cap);
*
* Eliminate a CAP entry.
*/
void rmcap PARAMS((CAP *cap));
/* void texec(CAP *cap,char *str,int l,int a0,int a1,int a2,int a3);
Execute and output a termcap string capability.
'cap' is the CAP returned by getcap which contains the baud rate and output
function.
'str' is the string to execute. If 'str'==NULL, nothing happens.
'l' is the number of lines effected by this string. For example, if you
use the clear to end of screen capability, the number of lines between
the current cursor position and the end of the screen should be
given here.
'a0' - 'a1' are the arguments for the string
*/
void texec PARAMS((CAP *cap, unsigned char *s, int l, int a0, int a1, int a2, int a3));
/* int tcost(CAP *cap,char *str, int l, int a0, int a1, int a2, int a3);
Return cost in number of characters which need to be sent
to execute a termcap string capability.
'cap' is the CAP returned by getcap which contains the baud rate and output
functions.
'str' is the string to execute. If 'str'==NULL, tcost return 10000.
'l' is the number of lines effected by this string. Ex: if you
use the clear to end of screen capability, the number of lines between
the current cursor position and the end of the screen should be
given here.
'a0' - 'a3' are arguements passed to the string
*/
int tcost PARAMS((CAP *cap, unsigned char *s, int l, int a0, int a1, int a2, int a3));
/* char *tcompile(CAP *cap,char *str,int a0,int a1,int a2,int a3);
Compile a string capability. Returns a pointer to a variable length
string (see vs.h) containing the compiled string capability.
Pad characters are not placed in the string.
*/
unsigned char *tcompile PARAMS((CAP *cap, unsigned char *s, int a0, int a1, int a2, int a3));
/* Old termcap support */
#ifdef junk
int tgetent();
unsigned char *tgetstr();
int tgetflag();
int tgetnum();
unsigned char *tgoto();
void tputs();
extern short ospeed;
extern unsigned char PC, *UP, *BC;
#endif
extern int dopadding;
extern unsigned char *joeterm;
#endif