view.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_t;
  21. #include "clish/command.h"
  22. #include "clish/nspace.h"
  23. /*=====================================
  24. * VIEW INTERFACE
  25. *===================================== */
  26. /*-----------------
  27. * meta functions
  28. *----------------- */
  29. clish_view_t *clish_view_new(const char *name, const char *prompt);
  30. int clish_view_bt_compare(const void *clientnode, const void *clientkey);
  31. void clish_view_bt_getkey(const void *clientnode, lub_bintree_key_t * key);
  32. size_t clish_view_bt_offset(void);
  33. /*-----------------
  34. * methods
  35. *----------------- */
  36. void clish_view_delete(clish_view_t * instance);
  37. clish_command_t *clish_view_new_command(clish_view_t * instance,
  38. const char *name, const char *text);
  39. clish_command_t *clish_view_find_command(clish_view_t * instance,
  40. const char *name, bool_t inherit);
  41. const clish_command_t *clish_view_find_next_completion(clish_view_t * instance,
  42. const char *iter_cmd, const char *line,
  43. clish_nspace_visibility_t field, bool_t inherit);
  44. clish_command_t *clish_view_resolve_command(clish_view_t * instance,
  45. const char *line, bool_t inherit);
  46. clish_command_t *clish_view_resolve_prefix(clish_view_t * instance,
  47. const char *line, bool_t inherit);
  48. void clish_view_dump(clish_view_t * instance);
  49. void clish_view_insert_nspace(clish_view_t * instance, clish_nspace_t * nspace);
  50. /*-----------------
  51. * attributes
  52. *----------------- */
  53. const char *clish_view__get_name(const clish_view_t * instance);
  54. void clish_view__set_prompt(clish_view_t * instance, const char *prompt);
  55. char *clish_view__get_prompt(const clish_view_t * instance, const char *viewid);
  56. const unsigned clish_view__get_nspace_count(const clish_view_t * instance);
  57. clish_nspace_t *clish_view__get_nspace(const clish_view_t * instance,
  58. unsigned index);
  59. void clish_view__set_depth(clish_view_t * instance, unsigned depth);
  60. unsigned clish_view__get_depth(const clish_view_t * instance);
  61. void clish_view__set_restore(clish_view_t * instance,
  62. clish_view_restore_t restore);
  63. clish_view_restore_t clish_view__get_restore(const clish_view_t * instance);
  64. #endif /* _clish_view_h */
  65. /** @} clish_view */