Browse Source

Navigation command 'pop' exits process if pop from top level

Serj Kalichev 1 year ago
parent
commit
267e5a4eb8
4 changed files with 36 additions and 7 deletions
  1. 2 2
      bin/klish/interactive.c
  2. 28 0
      examples/simple/example.xml
  3. 3 1
      plugins/klish/nav.c
  4. 3 4
      tinyrl/tinyrl/tinyrl.c

+ 2 - 2
bin/klish/interactive.c

@@ -72,9 +72,9 @@ bool_t cmd_ack_cb(ktp_session_t *ktp, const faux_msg_t *msg, void *udata)
 	ctx_t *ctx = (ctx_t *)udata;
 
 //	ktp_session_set_done(ktp, BOOL_TRUE);
+	tinyrl_set_busy(ctx->tinyrl, BOOL_FALSE);
 	tinyrl_redisplay(ctx->tinyrl);
 
-
 	// Happy compiler
 	ktp = ktp;
 	msg = msg;
@@ -105,7 +105,7 @@ static bool_t tinyrl_key_enter(tinyrl_t *tinyrl, unsigned char key)
 
 	line = tinyrl_line(tinyrl);
 	if (line) {
-		printf("cmd = %s\n", line);
+//		printf("cmd = %s\n", line);
 		ktp_session_cmd(ctx->ktp, line, NULL, BOOL_FALSE);
 	}
 

+ 28 - 0
examples/simple/example.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<KLISH
+	xmlns="http://clish.sourceforge.net/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema http://clish.sourceforge.net/XMLSchema/clish.xsd">
+
+<PLUGIN name="klish"/>
+
+<ENTRY name="COMMAND" purpose="ptype">
+	<ACTION sym="COMMAND"/>
+</ENTRY>
+
+<ENTRY name="main" mode="switch" container="true">
+
+  <ENTRY name="cmd" help="Clear settings" mode="sequence">
+	<ENTRY name="COMMAND" purpose="ptype" ref="/COMMAND"/>
+	<ACTION sym="tsym">test</ACTION>
+  </ENTRY>
+
+  <ENTRY name="exit" help="Exit view">
+	<ENTRY name="COMMAND" purpose="ptype" ref="/COMMAND"/>
+	<ACTION sym="nav">pop</ACTION>
+	<ACTION sym="tsym">Exiting klish session</ACTION>
+  </ENTRY>
+
+</ENTRY>
+
+</KLISH>

+ 3 - 1
plugins/klish/nav.c

@@ -99,9 +99,11 @@ int klish_nav(kcontext_t *context)
 				lnum = val;
 			}
 			// Don't pop upper than top level
+			// Such "pop" means exit
 			if (lnum > (kpath_len(path) - 1)) {
+				ksession_set_done(session, BOOL_TRUE);
 				faux_argv_free(argv);
-				return -1;
+				break;
 			}
 			// Pop levels
 			for (i = 0; i < lnum; i++) {

+ 3 - 4
tinyrl/tinyrl/tinyrl.c

@@ -394,15 +394,14 @@ int tinyrl_read(tinyrl_t *tinyrl)
 
 	assert(tinyrl);
 
-	// Some commands can't be processed immediately by handlers and need some
-	// network exchange for example. In this case we will not execute
-	// redisplay() after char processing because command is not really
-	// finished. Drop busy flag here because engine ready to get new input.
 	tinyrl_set_busy(tinyrl, BOOL_FALSE);
 
 	while ((rc = vt100_getchar(tinyrl->term, &key)) > 0) {
 		count++;
 		process_char(tinyrl, key);
+		// Some commands can't be processed immediately by handlers and
+		// need some network exchange for example. In this case we will
+		// not execute redisplay() here.
 		if (!tinyrl->utf8_cont && !tinyrl_busy(tinyrl)) {
 			tinyrl_redisplay(tinyrl);
 	//		printf("%s\n", tinyrl->line.str);