Browse Source

The 'restore' field for NAMESPACE tag. The field can be set but is not working yet.

git-svn-id: https://klish.googlecode.com/svn/trunk@148 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
e87421db56
5 changed files with 44 additions and 0 deletions
  1. 12 0
      clish.xsd
  2. 9 0
      clish/nspace.h
  3. 13 0
      clish/nspace/nspace.c
  4. 1 0
      clish/nspace/private.h
  5. 9 0
      clish/shell/shell_tinyxml_read.cpp

+ 12 - 0
clish.xsd

@@ -356,8 +356,19 @@
 *
 * [inherit]      - a boolean flag to inherit nested
 *                namespace commands recursively
+*
+* [restore]      - restore the depth or view of commands
+*                included by this namespace
 ********************************************************
 -->
+    <xs:simpleType name="restore_t">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="none"/>
+            <xs:enumeration value="depth"/>
+            <xs:enumeration value="view"/>
+        </xs:restriction>
+    </xs:simpleType>
+
     <xs:complexType name="namespace_t">
         <xs:attribute name="ref" type="xs:string" use="required"/>
         <xs:attribute name="prefix" type="xs:string" use="required"/>
@@ -365,6 +376,7 @@
         <xs:attribute name="completion" type="bool_t" use="optional" default="true"/>
         <xs:attribute name="context_help" type="bool_t" use="optional" default="false"/>
         <xs:attribute name="inherit" type="bool_t" use="optional" default="true"/>
+        <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
     </xs:complexType>
     <!--
 *******************************************************

+ 9 - 0
clish/nspace.h

@@ -24,6 +24,12 @@ typedef enum {
 	CLISH_NSPACE_CHELP
 } clish_nspace_visibility_t;
 
+typedef enum {
+	CLISH_RESTORE_NONE,
+	CLISH_RESTORE_DEPTH,
+	CLISH_RESTORE_VIEW
+} clish_nspace_restore_t;
+
 #include "clish/view.h"
 
 /*=====================================
@@ -59,6 +65,9 @@ void clish_nspace__set_help(clish_nspace_t * instance, bool_t help);
 void clish_nspace__set_completion(clish_nspace_t * instance, bool_t help);
 void clish_nspace__set_context_help(clish_nspace_t * instance, bool_t help);
 void clish_nspace__set_inherit(clish_nspace_t * instance, bool_t inherit);
+void clish_nspace__set_restore(clish_nspace_t * instance,
+	clish_nspace_restore_t restore);
+clish_nspace_restore_t clish_nspace__get_restore(const clish_nspace_t * instance);
 
 #endif				/* _clish_nspace_h */
 /** @} clish_nspace */

+ 13 - 0
clish/nspace/nspace.c

@@ -271,3 +271,16 @@ clish_nspace__get_visibility(const clish_nspace_t * instance,
 }
 
 /*--------------------------------------------------------- */
+void clish_nspace__set_restore(clish_nspace_t * this,
+	clish_nspace_restore_t restore)
+{
+	this->restore = restore;
+}
+
+/*--------------------------------------------------------- */
+clish_nspace_restore_t clish_nspace__get_restore(const clish_nspace_t * this)
+{
+	return this->restore;
+}
+
+/*--------------------------------------------------------- */

+ 1 - 0
clish/nspace/private.h

@@ -14,4 +14,5 @@ struct clish_nspace_s {
 	bool_t completion;
 	bool_t context_help;
 	bool_t inherit;
+	clish_nspace_restore_t restore;
 };

+ 9 - 0
clish/shell/shell_tinyxml_read.cpp

@@ -449,6 +449,7 @@ process_namespace(clish_shell_t * shell, TiXmlElement * element, void *parent)
 	const char *completion = element->Attribute("completion");
 	const char *context_help = element->Attribute("context_help");
 	const char *inherit = element->Attribute("inherit");
+	const char *restore = element->Attribute("restore");
 
 	assert(view);
 	clish_view_t *ref_view =
@@ -481,6 +482,14 @@ process_namespace(clish_shell_t * shell, TiXmlElement * element, void *parent)
 		clish_nspace__set_inherit(nspace, BOOL_FALSE);
 	else
 		clish_nspace__set_inherit(nspace, BOOL_TRUE);
+
+	if (restore && !lub_string_nocasecmp(restore, "depth"))
+		clish_nspace__set_restore(nspace, CLISH_RESTORE_DEPTH);
+	else if (restore && !lub_string_nocasecmp(restore, "view"))
+		clish_nspace__set_restore(nspace, CLISH_RESTORE_VIEW);
+	else
+		clish_nspace__set_restore(nspace, CLISH_RESTORE_NONE);
+
 }
 
 ////////////////////////////////////////