view.h 2.2 KB

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