1
0

view.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * view.h
  3. */
  4. /**
  5. \ingroup clish
  6. \defgroup clish_view view
  7. @{
  8. \brief This class is a container of commands.
  9. A particular CLI session may contain a number of different views. Each
  10. view may contain its own specific commands as well as those available at
  11. a global scope.
  12. */
  13. #ifndef _clish_view_h
  14. #define _clish_view_h
  15. typedef struct clish_view_s clish_view_t;
  16. typedef enum {
  17. CLISH_RESTORE_NONE,
  18. CLISH_RESTORE_DEPTH,
  19. CLISH_RESTORE_VIEW
  20. } clish_view_restore_e;
  21. #include "lub/list.h"
  22. #include "clish/command.h"
  23. #include "clish/nspace.h"
  24. #include "clish/var.h"
  25. /*=====================================
  26. * VIEW INTERFACE
  27. *===================================== */
  28. /*-----------------
  29. * meta functions
  30. *----------------- */
  31. clish_view_t *clish_view_new(const char *name, const char *prompt);
  32. int clish_view_bt_compare(const void *clientnode, const void *clientkey);
  33. void clish_view_bt_getkey(const void *clientnode, lub_bintree_key_t * key);
  34. size_t clish_view_bt_offset(void);
  35. /*-----------------
  36. * methods
  37. *----------------- */
  38. lub_bintree_t * clish_view__get_command_tree(clish_view_t *instance);
  39. lub_list_t * clish_view__get_nspace_tree(clish_view_t *instance);
  40. void clish_view_delete(clish_view_t * instance);
  41. clish_command_t *clish_view_new_command(clish_view_t * instance,
  42. const char *name, const char *text);
  43. clish_command_t *clish_view_find_command(clish_view_t * instance,
  44. const char *name, bool_t inherit);
  45. const clish_command_t *clish_view_find_next_completion(clish_view_t * instance,
  46. const char *iter_cmd, const char *line,
  47. clish_nspace_visibility_e field, bool_t inherit);
  48. clish_command_t *clish_view_resolve_command(clish_view_t * instance,
  49. const char *line, bool_t inherit);
  50. clish_command_t *clish_view_resolve_prefix(clish_view_t * instance,
  51. const char *line, bool_t inherit);
  52. void clish_view_dump(clish_view_t * instance);
  53. void clish_view_insert_nspace(clish_view_t * instance, clish_nspace_t * nspace);
  54. void clish_view_clean_proxy(clish_view_t * instance);
  55. /*-----------------
  56. * attributes
  57. *----------------- */
  58. const char *clish_view__get_name(const clish_view_t * instance);
  59. void clish_view__set_prompt(clish_view_t * instance, const char *prompt);
  60. char *clish_view__get_prompt(const clish_view_t *instance);
  61. void clish_view__set_depth(clish_view_t * instance, unsigned depth);
  62. unsigned clish_view__get_depth(const clish_view_t * instance);
  63. void clish_view__set_restore(clish_view_t * instance,
  64. clish_view_restore_e restore);
  65. clish_view_restore_e clish_view__get_restore(const clish_view_t * instance);
  66. int clish_view_insert_hotkey(const clish_view_t *instance, const char *key, const char *cmd);
  67. const char *clish_view_find_hotkey(const clish_view_t *instance, int code);
  68. void clish_view__set_access(clish_view_t *instance, const char *access);
  69. char *clish_view__get_access(const clish_view_t *instance);
  70. #endif /* _clish_view_h */
  71. /** @} clish_view */