rline.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. struct rline_callback;
  3. typedef struct {
  4. char * buffer;
  5. struct rline_callback * callbacks;
  6. int collected;
  7. int requested;
  8. int newline;
  9. int cancel;
  10. int offset;
  11. int tabbed;
  12. } rline_context_t;
  13. typedef void (*rline_callback_t)(rline_context_t * context);
  14. typedef struct rline_callback {
  15. rline_callback_t tab_complete;
  16. rline_callback_t redraw_prompt;
  17. rline_callback_t special_key;
  18. rline_callback_t key_up;
  19. rline_callback_t key_down;
  20. rline_callback_t key_left;
  21. rline_callback_t key_right;
  22. rline_callback_t rev_search;
  23. } rline_callbacks_t;
  24. extern void rline_redraw(rline_context_t * context);
  25. extern void rline_redraw_clean(rline_context_t * context);
  26. extern void rline_insert(rline_context_t * context, const char * what);
  27. extern int rline(char * buffer, int buf_size, rline_callbacks_t * callbacks);
  28. extern void rline_history_insert(char * str);
  29. extern void rline_history_append_line(char * str);
  30. extern char * rline_history_get(int item);
  31. extern char * rline_history_prev(int item);
  32. #define RLINE_HISTORY_ENTRIES 128
  33. extern char * rline_history[RLINE_HISTORY_ENTRIES];
  34. extern int rline_history_count;
  35. extern int rline_history_offset;
  36. extern int rline_scroll;
  37. extern char * rline_exit_string;