00001
00010 #ifndef _tinyrl_tinyrl_h
00011 #define _tinyrl_tinyrl_h
00012
00013 #include <stdio.h>
00014 #include "lub/types.h"
00015 #include "lub/c_decl.h"
00016 #include "tinyrl/history.h"
00017
00018 _BEGIN_C_DECL
00019
00020 typedef struct _tinyrl tinyrl_t;
00021 typedef enum
00022 {
00026 TINYRL_NO_MATCH = 0,
00030 TINYRL_MATCH,
00035 TINYRL_AMBIGUOUS,
00040 TINYRL_COMPLETED_MATCH,
00045 TINYRL_COMPLETED_AMBIGUOUS,
00051 TINYRL_MATCH_WITH_EXTENSIONS
00052 } tinyrl_match_e;
00053
00054
00055 typedef char *
00056 tinyrl_compentry_func_t(tinyrl_t *instance,
00057 const char *text,
00058 unsigned offset,
00059 unsigned state);
00060 typedef int
00061 tinyrl_hook_func_t(tinyrl_t *instance);
00062
00063 typedef char **
00064 tinyrl_completion_func_t(tinyrl_t *instance,
00065 const char *text,
00066 unsigned start,
00067 unsigned end);
00074 typedef bool_t
00075 tinyrl_key_func_t(tinyrl_t *instance,
00076 int key);
00077
00078
00079
00080 extern tinyrl_t *
00081 tinyrl_new(FILE *instream,
00082 FILE *outstream,
00083 unsigned stifle,
00084 tinyrl_completion_func_t *complete_fn);
00085
00086
00087 extern int
00088 tinyrl_printf(const tinyrl_t *instance,
00089 const char *fmt,
00090 ...);
00091
00092 extern void
00093 tinyrl_delete(tinyrl_t *instance);
00094
00095 extern tinyrl_history_t *
00096 tinyrl__get_history(const tinyrl_t *instance);
00097
00098 extern const char *
00099 tinyrl__get_prompt(const tinyrl_t *instance);
00100
00101 extern void
00102 tinyrl_done(tinyrl_t *instance);
00103
00104 extern void
00105 tinyrl_completion_over(tinyrl_t *instance);
00106
00107 extern void
00108 tinyrl_completion_error_over(tinyrl_t *instance);
00109
00110 extern bool_t
00111 tinyrl_is_completion_error_over(const tinyrl_t *instance);
00112
00113 extern void *
00114 tinyrl__get_context(const tinyrl_t *instance);
00115
00121 extern const char *
00122 tinyrl__get_line(const tinyrl_t *instance);
00123
00124 extern void
00125 tinyrl__set_istream(tinyrl_t *instance,
00126 FILE *istream);
00127
00128 extern bool_t
00129 tinyrl__get_isatty(const tinyrl_t *instance);
00130
00131 extern FILE *
00132 tinyrl__get_istream(const tinyrl_t *instance);
00133
00134 extern FILE *
00135 tinyrl__get_ostream(const tinyrl_t *instance);
00136
00137 extern char *
00138 tinyrl_readline(tinyrl_t *instance,
00139 const char *prompt,
00140 void *context);
00141 extern bool_t
00142 tinyrl_bind_key(tinyrl_t *instance,
00143 int key,
00144 tinyrl_key_func_t *fn);
00145 extern void
00146 tinyrl_delete_matches(char **instance);
00147 extern char **
00148 tinyrl_completion(tinyrl_t *instance,
00149 const char *line,
00150 unsigned start,
00151 unsigned end,
00152 tinyrl_compentry_func_t *generator);
00153 extern void
00154 tinyrl_crlf(const tinyrl_t *instance);
00155 extern void
00156 tinyrl_ding(const tinyrl_t *instance);
00157
00158 extern void
00159 tinyrl_reset_line_state(tinyrl_t *instance);
00160
00161 extern bool_t
00162 tinyrl_insert_text(tinyrl_t *instance,
00163 const char *text);
00164 extern void
00165 tinyrl_delete_text(tinyrl_t *instance,
00166 unsigned start,
00167 unsigned end);
00168 extern void
00169 tinyrl_redisplay(tinyrl_t *instance);
00170
00171 extern void
00172 tinyrl_replace_line(tinyrl_t *instance,
00173 const char *text,
00174 int clear_undo);
00175
00186 extern tinyrl_match_e
00187 tinyrl_complete(tinyrl_t *instance);
00188
00202 extern tinyrl_match_e
00203 tinyrl_complete_with_extensions(tinyrl_t *instance);
00204
00209 extern void
00210 tinyrl_disable_echo(
00214 tinyrl_t *instance,
00221 char echo_char
00222 );
00226 extern void
00227 tinyrl_enable_echo(
00231 tinyrl_t *instance
00232 );
00236 extern bool_t
00237 tinyrl_is_quoting(
00241 const tinyrl_t *instance
00242 );
00246 extern void
00247 tinyrl_limit_line_length(
00251 tinyrl_t *instance,
00255 unsigned length
00256 );
00257
00258 _END_C_DECL
00259
00260 #endif
00261