view.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include "clish/var.h"
  24. /*=====================================
  25. * VIEW INTERFACE
  26. *===================================== */
  27. /*-----------------
  28. * meta functions
  29. *----------------- */
  30. clish_view_t *clish_view_new(const char *name, const char *prompt,
  31. clish_var_expand_fn_t *fn);
  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. void clish_view_delete(clish_view_t * instance);
  39. clish_command_t *clish_view_new_command(clish_view_t * instance,
  40. const char *name, const char *text);
  41. clish_command_t *clish_view_find_command(clish_view_t * instance,
  42. const char *name, bool_t inherit);
  43. const clish_command_t *clish_view_find_next_completion(clish_view_t * instance,
  44. const char *iter_cmd, const char *line,
  45. clish_nspace_visibility_t field, bool_t inherit);
  46. clish_command_t *clish_view_resolve_command(clish_view_t * instance,
  47. const char *line, bool_t inherit);
  48. clish_command_t *clish_view_resolve_prefix(clish_view_t * instance,
  49. const char *line, bool_t inherit);
  50. void clish_view_dump(clish_view_t * instance);
  51. void clish_view_insert_nspace(clish_view_t * instance, clish_nspace_t * nspace);
  52. void clish_view_clean_proxy(clish_view_t * instance);
  53. /*-----------------
  54. * attributes
  55. *----------------- */
  56. const char *clish_view__get_name(const clish_view_t * instance);
  57. void clish_view__set_prompt(clish_view_t * instance, const char *prompt);
  58. char *clish_view__get_prompt(const clish_view_t *instance, void *context);
  59. const unsigned clish_view__get_nspace_count(const clish_view_t * instance);
  60. clish_nspace_t *clish_view__get_nspace(const clish_view_t * instance,
  61. unsigned index);
  62. void clish_view__set_depth(clish_view_t * instance, unsigned depth);
  63. unsigned clish_view__get_depth(const clish_view_t * instance);
  64. void clish_view__set_restore(clish_view_t * instance,
  65. clish_view_restore_t restore);
  66. clish_view_restore_t clish_view__get_restore(const clish_view_t * instance);
  67. #endif /* _clish_view_h */
  68. /** @} clish_view */