Browse Source

Track the parent view of namespaces

Obviously useful for many purposes.
Ingo Albrecht 3 years ago
parent
commit
013be87035
4 changed files with 7 additions and 0 deletions
  1. 2 0
      clish/nspace.h
  2. 3 0
      clish/nspace/nspace.c
  3. 1 0
      clish/nspace/private.h
  4. 1 0
      clish/view/view.c

+ 2 - 0
clish/nspace.h

@@ -43,6 +43,8 @@ _CLISH_SET(nspace, bool_t, inherit);
 _CLISH_GET(nspace, bool_t, inherit);
 _CLISH_GET(nspace, bool_t, inherit);
 _CLISH_SET(nspace, clish_view_t *, view);
 _CLISH_SET(nspace, clish_view_t *, view);
 _CLISH_GET(nspace, clish_view_t *, view);
 _CLISH_GET(nspace, clish_view_t *, view);
+_CLISH_SET(nspace, clish_view_t *, pview);
+_CLISH_GET(nspace, clish_view_t *, pview);
 _CLISH_SET_STR(nspace, view_name);
 _CLISH_SET_STR(nspace, view_name);
 _CLISH_GET_STR(nspace, view_name);
 _CLISH_GET_STR(nspace, view_name);
 _CLISH_SET_STR(nspace, access);
 _CLISH_SET_STR(nspace, access);

+ 3 - 0
clish/nspace/nspace.c

@@ -22,6 +22,7 @@ static void clish_nspace_init(clish_nspace_t *this,  const char *view_name)
 
 
 	/* Set up defaults */
 	/* Set up defaults */
 	this->view = NULL;
 	this->view = NULL;
+	this->pview = NULL;
 	this->prefix = NULL;
 	this->prefix = NULL;
 	this->help = BOOL_FALSE;
 	this->help = BOOL_FALSE;
 	this->completion = BOOL_TRUE;
 	this->completion = BOOL_TRUE;
@@ -285,6 +286,8 @@ CLISH_SET(nspace, bool_t, inherit);
 CLISH_GET(nspace, bool_t, inherit);
 CLISH_GET(nspace, bool_t, inherit);
 CLISH_SET(nspace, clish_view_t *, view);
 CLISH_SET(nspace, clish_view_t *, view);
 CLISH_GET(nspace, clish_view_t *, view);
 CLISH_GET(nspace, clish_view_t *, view);
+CLISH_SET(nspace, clish_view_t *, pview);
+CLISH_GET(nspace, clish_view_t *, pview);
 CLISH_SET_STR(nspace, view_name);
 CLISH_SET_STR(nspace, view_name);
 CLISH_GET_STR(nspace, view_name);
 CLISH_GET_STR(nspace, view_name);
 CLISH_SET_STR(nspace, access);
 CLISH_SET_STR(nspace, access);

+ 1 - 0
clish/nspace/private.h

@@ -11,6 +11,7 @@
 struct clish_nspace_s {
 struct clish_nspace_s {
 	lub_bintree_t tree;	/* Tree of command links */
 	lub_bintree_t tree;	/* Tree of command links */
 	clish_view_t *view;	/* The view to import commands from */
 	clish_view_t *view;	/* The view to import commands from */
+	clish_view_t *pview; /* The view we are a child of */
 	char *view_name;	/* The text name of view to import command from */
 	char *view_name;	/* The text name of view to import command from */
 	char *prefix;		/* if non NULL the prefix for imported commands */
 	char *prefix;		/* if non NULL the prefix for imported commands */
 	char *access;
 	char *access;

+ 1 - 0
clish/view/view.c

@@ -279,6 +279,7 @@ const clish_command_t *clish_view_find_next_completion(clish_view_t * this,
 void clish_view_insert_nspace(clish_view_t * this, clish_nspace_t * nspace)
 void clish_view_insert_nspace(clish_view_t * this, clish_nspace_t * nspace)
 {
 {
 	lub_list_add(this->nspaces, nspace);
 	lub_list_add(this->nspaces, nspace);
+	clish_nspace__set_pview(nspace, this);
 }
 }
 
 
 /*--------------------------------------------------------- */
 /*--------------------------------------------------------- */