zori_console.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef zori_console_H_INCLUDED
  2. #define zori_console_H_INCLUDED
  3. #define ZORI_WIDGET_TYPE_CONSOLE ZORI_WIDGET_TYPE('z','c','o','n')
  4. typedef int (zori_console_command)(struct zori_widget *, const char * command, void * data);
  5. /* A console is a console for command-line interaction and error display. When it's active it captures all input (as long as it's active) */
  6. struct zori_console {
  7. struct zori_widget widget;
  8. USTRList text;
  9. int count;
  10. int max;
  11. int start;
  12. int charw;
  13. int cursor;
  14. char * buf;
  15. USTR * input;
  16. zori_console_command * command; // called when a command has been entered, if set.
  17. void * command_data; // command data.
  18. };
  19. struct zori_console *zori_widget_console(struct zori_widget *widget);
  20. int zori_console_docommand(struct zori_console *self, const char *text);
  21. int zori_console_addstr(struct zori_console *self, const char *str);
  22. int zori_console_addustr(struct zori_console *self, const ALLEGRO_USTR *ustr);
  23. int zori_console_puts(struct zori_console *self, const char *str);
  24. int zori_console_vprintf(struct zori_console *self, const char *format, va_list args);
  25. int zori_console_printf(struct zori_console *self, const char *format, ...);
  26. int zori_console_draw(union zori_event *zevent);
  27. void zori_console_active_(struct zori_console *self, int active);
  28. int zori_console_active(struct zori_console *self);
  29. int zori_console_scroll(struct zori_console *self, int direction);
  30. int zori_console_handle_keychar(union zori_event *zevent);
  31. int zori_console_handle_keydown(union zori_event *zevent);
  32. int zori_console_handle_mouseaxes(union zori_event *zevent);
  33. int zori_console_handle_ignore(union zori_event *zevent);
  34. int zori_console_handle(struct zori_widget *widget, zori_system_event *sevent);
  35. int zori_console_done(struct zori_widget *widget);
  36. int zori_console_free(struct zori_widget *widget);
  37. struct zori_console *zori_console_alloc(void);
  38. struct zori_console *zori_console_initall(struct zori_console *self, int id, zori_rebox *bounds, struct zori_style *style);
  39. struct zori_console *zori_console_new(int id, zori_rebox *bounds, struct zori_style *style);
  40. #endif