123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
-
- #ifndef _tinyrl_tinyrl_h
- #define _tinyrl_tinyrl_h
- #include <stdio.h>
- #include "lub/types.h"
- #include "lub/c_decl.h"
- #include "tinyrl/history.h"
- _BEGIN_C_DECL typedef struct _tinyrl tinyrl_t;
- typedef enum {
-
- TINYRL_NO_MATCH = 0,
-
- TINYRL_MATCH,
-
- TINYRL_AMBIGUOUS,
-
- TINYRL_COMPLETED_MATCH,
-
- TINYRL_COMPLETED_AMBIGUOUS,
-
- TINYRL_MATCH_WITH_EXTENSIONS
- } tinyrl_match_e;
- typedef char *tinyrl_compentry_func_t(tinyrl_t * instance,
- const char *text, unsigned offset, unsigned state);
- typedef int tinyrl_hook_func_t(tinyrl_t * instance);
- typedef char **tinyrl_completion_func_t(tinyrl_t * instance,
- const char *text, unsigned start, unsigned end);
- typedef int tinyrl_timeout_fn_t(tinyrl_t *instance);
- typedef int tinyrl_keypress_fn_t(tinyrl_t *instance, int key);
- typedef bool_t tinyrl_key_func_t(tinyrl_t * instance, int key);
- extern tinyrl_t *tinyrl_new(FILE * instream,
- FILE * outstream,
- unsigned stifle,
- tinyrl_completion_func_t * complete_fn);
- extern int tinyrl_printf(const tinyrl_t * instance, const char *fmt, ...);
- extern void tinyrl_delete(tinyrl_t * instance);
- extern tinyrl_history_t *tinyrl__get_history(const tinyrl_t * instance);
- extern const char *tinyrl__get_prompt(const tinyrl_t * instance);
- extern void tinyrl__set_prompt(tinyrl_t *instance, const char *prompt);
- extern void tinyrl_done(tinyrl_t * instance);
- extern void tinyrl_completion_over(tinyrl_t * instance);
- extern void tinyrl_completion_error_over(tinyrl_t * instance);
- extern bool_t tinyrl_is_completion_error_over(const tinyrl_t * instance);
- extern void *tinyrl__get_context(const tinyrl_t * instance);
- extern const char *tinyrl__get_line(const tinyrl_t * instance);
- extern void tinyrl__set_istream(tinyrl_t * instance, FILE * istream);
- extern bool_t tinyrl__get_isatty(const tinyrl_t * instance);
- extern FILE *tinyrl__get_istream(const tinyrl_t * instance);
- extern FILE *tinyrl__get_ostream(const tinyrl_t * instance);
- extern bool_t tinyrl__get_utf8(const tinyrl_t * instance);
- extern void tinyrl__set_utf8(tinyrl_t * instance, bool_t utf8);
- extern void tinyrl__set_timeout(tinyrl_t *instance, int timeout);
- extern void tinyrl__set_timeout_fn(tinyrl_t *instance,
- tinyrl_timeout_fn_t *fn);
- extern void tinyrl__set_keypress_fn(tinyrl_t *instance,
- tinyrl_keypress_fn_t *fn);
- extern void tinyrl__set_hotkey_fn(tinyrl_t *instance,
- tinyrl_key_func_t *fn);
- extern char *tinyrl_readline(tinyrl_t *instance, void *context);
- extern char *tinyrl_forceline(tinyrl_t *instance,
- void *context, const char *line);
- extern bool_t tinyrl_bind_key(tinyrl_t *instance, int key,
- tinyrl_key_func_t *fn);
- extern void tinyrl_delete_matches(char **instance);
- extern char **tinyrl_completion(tinyrl_t *instance,
- const char *line, unsigned start, unsigned end,
- tinyrl_compentry_func_t *generator);
- extern void tinyrl_crlf(const tinyrl_t * instance);
- extern void tinyrl_multi_crlf(const tinyrl_t * instance);
- extern void tinyrl_ding(const tinyrl_t * instance);
- extern void tinyrl_reset_line_state(tinyrl_t * instance);
- extern bool_t tinyrl_insert_text(tinyrl_t * instance, const char *text);
- extern void
- tinyrl_delete_text(tinyrl_t * instance, unsigned start, unsigned end);
- extern void tinyrl_redisplay(tinyrl_t * instance);
- extern void
- tinyrl_replace_line(tinyrl_t * instance, const char *text, int clear_undo);
- extern tinyrl_match_e tinyrl_complete(tinyrl_t * instance);
- extern tinyrl_match_e tinyrl_complete_with_extensions(tinyrl_t * instance);
- extern void tinyrl_disable_echo(
-
- tinyrl_t * instance,
-
- char echo_char);
- extern void tinyrl_enable_echo(
-
- tinyrl_t * instance);
- extern bool_t tinyrl_is_quoting(
-
- const tinyrl_t * instance);
- extern bool_t
- tinyrl_is_empty(
-
- const tinyrl_t *instance
- );
- extern void tinyrl_limit_line_length(
-
- tinyrl_t * instance,
-
- unsigned length);
- extern unsigned tinyrl__get_width(const tinyrl_t *instance);
- extern unsigned tinyrl__get_height(const tinyrl_t *instance);
- extern int tinyrl__save_history(const tinyrl_t *instance, const char *fname);
- extern int tinyrl__restore_history(tinyrl_t *instance, const char *fname);
- extern void tinyrl__stifle_history(tinyrl_t *instance, unsigned int stifle);
- _END_C_DECL
- #endif
|