private.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <termios.h>
  2. #include <faux/faux.h>
  3. #include "tinyrl/vt100.h"
  4. #include "tinyrl/hist.h"
  5. #include "tinyrl/tinyrl.h"
  6. ssize_t utf8_to_wchar(const char *sp, unsigned long *sym_out);
  7. bool_t utf8_wchar_is_cjk(unsigned long sym);
  8. char *utf8_move_left(const char *line, char *cur_pos);
  9. char *utf8_move_right(const char *line, char *cur_pos);
  10. /* define the class member data and virtual methods */
  11. struct _tinyrl {
  12. const char *line;
  13. unsigned max_line_length;
  14. char *prompt;
  15. size_t prompt_size; /* strlen() */
  16. size_t prompt_len; /* Symbol positions */
  17. char *buffer;
  18. size_t buffer_size;
  19. bool_t done;
  20. bool_t completion_over;
  21. bool_t completion_error_over;
  22. unsigned point;
  23. unsigned end;
  24. tinyrl_completion_func_t *attempted_completion_function;
  25. tinyrl_timeout_fn_t *timeout_fn; /* timeout callback */
  26. tinyrl_keypress_fn_t *keypress_fn; /* keypress callback */
  27. int state;
  28. #define RL_STATE_COMPLETING (0x00000001)
  29. char *kill_string;
  30. #define NUM_HANDLERS 256
  31. tinyrl_key_func_t *handlers[NUM_HANDLERS];
  32. tinyrl_key_func_t *hotkey_fn;
  33. // tinyrl_history_t *history;
  34. // tinyrl_history_iterator_t hist_iter;
  35. vt100_t *term;
  36. void *context; /* context supplied by caller
  37. * to tinyrl_readline()
  38. */
  39. char echo_char;
  40. bool_t echo_enabled;
  41. struct termios default_termios;
  42. bool_t isatty;
  43. char *last_buffer; /* hold record of the previous
  44. buffer for redisplay purposes */
  45. unsigned int last_point; /* hold record of the previous
  46. cursor position for redisplay purposes */
  47. unsigned int last_line_size; /* The length of last_buffer */
  48. unsigned int last_width; /* Last terminal width. For resize */
  49. bool_t utf8; /* Is the encoding UTF-8 */
  50. };