4
/* Copyright (c) 1995,1996 Sascha Demetrio
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* If you modify any part of HEXER and resitribute it, you must add
13
* a notice to the `README' file and the modified source files containing
14
* information about the changes you made. I do not want to take
15
* credit or be blamed for your modifications.
16
* 2. Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in the
18
* documentation and/or other materials provided with the distribution.
19
* If you modify any part of HEXER and resitribute it in binary form,
20
* you must supply a `README' file containing information about the
22
* 3. The name of the developer may not be used to endorse or promote
23
* products derived from this software without specific prior written
26
* HEXER WAS DEVELOPED BY SASCHA DEMETRIO.
27
* THIS SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
28
* THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
29
* NOT MAKE USE OF THIS WORK.
32
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
33
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
* ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
36
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51
#define TIO_MAX_UNGET 4096
97
#define KEY_BIAS 254 /* bias used for storing non-character
98
* keys in character strings */
100
extern struct t_keynames_s {
106
extern void (*error_msg)( const char *, ... );
108
extern void (*error_msg)( /* const char *, ... */ );
110
/* Pointer to the error message function.
114
tio_isprint( /* int x */ );
118
nprintf( const char *fmt, ... );
120
nprintf( /* const char *fmt, ... */ );
124
vnprintf( /* const char *fmt, va_list ap */ );
125
/* Returns the number of output characters a call to a printf-like function
130
tio_init( /* char *program_name */ );
131
/* Initialize. This function should be called before any other
132
* `tio_*'-function. `program_name' should be the name of the application.
135
#define tio_flush() (void)fflush(stdout)
140
tio_start_application( /* void */ );
141
/* Send the start-application string to the terminal.
145
tio_end_application( /* void */ );
146
/* Send the end-application string to the terminal.
150
tio_keypad( /* int on */ );
151
/* Set the keypad mode.
152
* on=0: numeric keypad.
153
* on=1: application keypad. Select this mode if you want to use the
154
* keypad (i.e. arrow-keys).
158
tio_getch( /* void */ );
161
tio_get( /* void */ );
162
/* Read a character from the keyboard. `tio_getch()' waits for input,
163
* `tio_get()' returns `KEY_NONE' (0) if no input is available.
164
* The functions return the following special keys:
165
* KEY_ERROR an error occured while waiting for input.
166
* NOTE: Changing the size of the window causes
167
* `tio_getch()' to return `KEY_ERROR'.
169
* KEY_BACKSPACE backspace key.
171
* KEY_RETURN return key.
172
* KEY_ESCAPE escape key.
173
* KEY_DELETE delete key.
175
* KEY_DOWN down arrow.
176
* KEY_LEFT left arrow.
177
* KEY_RIGHT right arrow.
178
* KEY_BACKTAB BACKTAB key.
179
* KEY_F0, ... KEY_F10 function keys F0-F10.
180
* KEY_BEGIN begin key.
181
* KEY_CANCEL cancel key.
182
* KEY_CLOSE close key.
184
* KEY_CREATE create key.
186
* KEY_ENTER enter key.
188
* KEY_UPPER_LEFT upper left key on keypad.
189
* KEY_UPPER_RIGHT upper right key on keypad.
190
* KEY_CENTER center key on keypad.
191
* KEY_BOTTOM_LEFT bottom left key on keypad.
192
* KEY_BOTTOM_RIGHT bottom right key on keypad.
194
* KEY_PAGE_UP page up key.
195
* KEY_PAGE_DOWN page down key.
199
tio_tget( /* int timeout */ );
200
/* Like `tio_get()', but waits `timeout' tenths of a second for input.
201
* `tio_tget()' returns `KEY_NONE' (0) if nothing has been read.
205
tio_ungetch( /* int x */ );
206
/* Put the character `x' back into the input stream. At most
207
* `IO_MAX_UNGET' characters can be ungetch. The return value is `x'
212
tio_ungets( /* int *x */ );
213
/* Put the character string `x' back into the input stream using
214
* `tio_ungetch()'. The return value is 0 and -1 on error.
218
tio_readmore( /* void */ );
219
/* Returns a non-zero value iff there are pending input characters.
220
* NOTE: Keys put into the unput-queue (via `tio_ungetch()' or
221
* `tio_ungets()') are not counted.
225
tio_getmore( /* void */ );
226
/* Returns a non-zero value iff there are any keys in the unget-queue.
230
tio_testkey( /* int key */ );
231
/* Returns 1, if a termcap entry for the requested key exists, else 0.
232
* The function return always 1 for the keys `KEY_BACKSPACE', `KEY_TAB',
233
* `KEY_RETURN', `KEY_ESCAPE', `KEY_DELETE', `KEY_NONE' and `KEY_ERROR'.
237
tio_keyname( /* int key */ );
238
/* Returns the name of the key `key'. If `key' is a printable character,
239
* it is returned as a string. If `key' is a special key, the name of
240
* that key is returned. If `key' is unknown and greater than 0xff "??"
241
* is returned, else a `\x??' hexadecimal code.
245
tio_keyrep( /* int key */ );
246
/* Returs a string representation of `key'. If `key' is not a printable
247
* character an escape sequence is generated:
248
* key > 0xff if key is a known special key, a unique sequence
249
* ~<keyname> (i.e. ~UP for up-arrow)
250
* key < 0x1f standard ^<char> escape sequence
251
* key == 0x7f ^? (delete)
252
* else a \x?? escape (hex representation of the key)
253
* if `key' is a printable character, a string containing that character
258
tio_vkeyrep( /* int key */ );
259
/* Similar to `tio_keyrep', but returns a long string representation
260
* whenever available.
264
tio_keyscan( /* int *key, char *s, int mode */ );
265
/* Check if `s' is a sting representation of a key. on success,
266
* the keycode is written to `*key' and a pointer to the first
267
* character after the srep is returned, else `*key' is set to 0
268
* and `s' is returned.
269
* mode & 1: scan for escapes starting with a `^'.
270
* mode & 2: scan for escapes starting with a `~'.
271
* mode == 0: scan for all known escapes.
275
tio_echo( /* int on */ );
276
/* on=1: characters are echoed as they are typed.
277
* on=0: characters are not echoed.
278
* RETURN VALUE: Previous echo-state.
282
tio_return( /* void */ );
283
/* Move cursor to column 0.
287
tio_home( /* void */ );
292
tio_goto_line( /* int line */ );
293
/* Move cursor to line `line'.
297
tio_goto_column( /* int line */ );
298
/* Move cursor to column `column'.
302
tio_last_line( /* void */ );
303
/* Move cursor to the last line, column 0.
307
tio_scroll_up( /* int count, int first, int last */ );
308
/* Scroll up `count' lines; insert `count' lines at the bottom of the
310
* The function returns -1 if the terminal can't scroll backwards.
314
tio_scroll_down( /* int count, int first, int last */ );
315
/* Scroll down `count' lines; insert `count' lines at the top of the screen.
316
* The function returns -1 if the terminal can't scroll backwards.
320
tio_display( /* char *text, int indent */ );
321
/* Send the string `text' to the terminal. The string may contain the
322
* following `@*'-commands:
326
* @M[+-]rrr[+-]ccc absolute move.
327
* Move the cursor to position row rrr, column ccc.
328
* If a value is prefixed by a `-', it is interpreted
329
* relative to the bottom-right corner of the screen.
330
* @m[+-]rrr[+-]ccc relative move.
333
* @v flash, visible bell.
336
* @Am set attribute m, where m is one of the
342
* u underline (equivalent to `@U').
348
* `indent' sets the indent. If `indent < 0', the indent stays unchanged.
352
tio_message( /* char **message, int indent */ );
353
/* displays the array of strings `message' via `tio_display()' providing
354
* a simple pager. this function assumes, that every string in
355
* `message' displays as a single line.
360
tio_printf( const char *fmt, ... );
366
tio_vprintf( /* const char *fmt, va_list */ );
367
/* Similar to `printf()'. `tio_printf()' understands the same @-commands
368
* as `tio_display()'. Note that @-commands in strings inserted via %s
369
* are executed. Use `tio_raw_printf()' if you don't wan't @-commands to
375
tio_raw_printf( const char *fmt, ... );
377
tio_raw_printf( /* const char *fmt, ... */ );
381
tio_raw_vprintf( /* const char *fmt, va_list */ );
382
/* Like `printf()'. No @-commands.
386
tio_puts( /* char *s */ );
387
/* Like `fputs(s, stdout)'.
391
tio_putchar( /* int x */ );
392
/* Like `putchar(x)'.
396
tio_up( /* int count */ );
397
/* Move cursor up `count' lines.
401
tio_down( /* int count */ );
402
/* Move cursor down `count' lines.
406
tio_left( /* int count */ );
407
/* Move cursor left `count' lines.
410
tio_right( /* int count */ );
411
/* Move cursor right `count' lines.
415
tio_move( /* int line, int column */ );
416
/* Move the cursor to position `line'/`column'.
420
tio_rel_move( /* int line, int column */ );
421
/* Move the cursor relative to the cursor position.
425
tio_last_line( /* void */ );
426
/* Move the cursor to the last line, first column.
430
tio_clear( /* void */ );
435
tio_clear_to_eol( /* void */ );
436
/* Clear to end of line.
440
tio_bell( /* void */ );
443
tio_visible_bell( /* void */ );
446
tio_underscore( /* void */ );
449
tio_underscore_off( /* void */ );
452
tio_bold( /* void */ );
455
tio_blink( /* void */ );
458
tio_half_bright( /* void */ );
461
tio_reverse( /* void */ );
464
tio_normal( /* void */ );
465
/* End all standout modes.
469
tio_set_cursor( /* int mode */ );
470
/* Set the visibility of the cursor.
471
* `mode == 0': invisible.
472
* `mode == 1': normal.
473
* `mode == 2': standout.
477
tio_have_color( /* void */ );
478
/* returns a non-zero value if color is available, 0 else.
482
tio_set_colors( /* int fg_color, int bg_color */ );
485
tio_set_fg( /* int color */ );
486
/* set the foreground color to `color'.
490
tio_set_bg( /* int color */ );
491
/* set the background color to `color'.
495
tio_get_fg( /* void */ );
496
/* return the current foreground color.
500
tio_get_bg( /* void */ );
501
/* return the current background color.
505
tio_insert_character( /* char x */ );
506
/* Insert the character `x' at the current position.
510
tio_delete_character( /* void */ );
511
/* Delete the character under the cursor.
515
tio_readwait( /* int timeout */ );
516
/* Wait until input is availabe on `stdin' using `select()'.
517
* The `timeout' is measured in microseconds. If `timeout' is a negative
518
* value, `tio_readwait()' blocks until input is availabe. If
519
* `timeout == 0', `tio_readwait()' will return immeiately.
521
* 1 Success. Data available on `stdin'.
522
* 0 Timeout. No input availabe.
523
* -1 Error. See `select(2)'.
524
* If `tio_readwait()' is interrupted by a signal, -1 is returned and
525
* `errno' is set to `EINTR'.
526
* NOTE: if the unread-buffer is not empty, 1 is returned.
530
tio_raw_readwait( /* int timeout */ );
531
/* Similar to `tio_readwait()', but ignores the unread buffer.
535
tio_getwait( /* int timeout */ );
536
/* Similar to `tio_readwait()', but returns also if the unget buffer is
541
tio_reset( /* void */ );
544
tio_suspend( /* void */ );
547
tio_restart( /* void */ );
556
tio_mgetch( /* int map, char *map_string */ );
559
tio_map( /* int map, int *from, int *to */ );
562
tio_unmap( /* int map, int *from */ );
565
tio_maplist( /* int map */ );
573
/* VIM configuration: (do not delete this line)
575
* vim:aw:bk:bdir=./bak:ch=2:nodg:ef=make.log:efm=%f\:%l\:%m:et:hid:icon:
576
* vim:sw=2:sc:sm:si:textwidth=79:to:ul=1024:wh=12:wrap:wb: