Browse Source

navigation: Documentation

Serj Kalichev 2 years ago
parent
commit
78337fd233
2 changed files with 51 additions and 1 deletions
  1. 50 0
      plugins/klish/nav.c
  2. 1 1
      plugins/klish/ptypes.c

+ 50 - 0
plugins/klish/nav.c

@@ -0,0 +1,50 @@
+/** @file nav.c
+ * @brief Navigation
+ *
+ * Example:
+ * <ACTION sym="nav">
+ *     pop
+ *     push /view_name
+ * </ACTION>
+ *
+ * Possible navigation commands:
+ * * push <view_name> - Push "view_name" view to new level of path and change
+ *     current path to it.
+ * * pop [num] - Pop up path levels. Optional "num" argument specifies number
+ *     of levels to pop.
+ * * top - Pop up to first path level.
+ * * exit - Exit klish.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <faux/str.h>
+#include <faux/list.h>
+#include <klish/kcontext.h>
+#include <klish/kentry.h>
+
+
+int klish_nav(kcontext_t *context)
+{
+	kparg_t *parg = NULL;
+	const kentry_t *entry = NULL;
+	const char *value = NULL;
+	const char *command_name = NULL;
+
+	parg = kcontext_candidate_parg(context);
+	entry = kparg_entry(parg);
+	value = kparg_value(parg);
+
+	command_name = kentry_value(entry);
+	if (!command_name)
+		command_name = kentry_name(entry);
+	if (!command_name)
+		return -1;
+
+	return faux_str_casecmp(value, command_name);
+}

+ 1 - 1
plugins/klish/ptypes.c

@@ -1,5 +1,5 @@
 /*
- *
+ * Implementation of standard PTYPEs
  */
 
 #include <assert.h>