Browse Source

Don't completed tab fixed.

git-svn-id: https://klish.googlecode.com/svn/trunk@363 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
7e3546daf3
5 changed files with 32 additions and 19 deletions
  1. 1 0
      clish/pargv.h
  2. 4 6
      clish/pargv/pargv.c
  3. 5 10
      clish/ptype/ptype.c
  4. 3 3
      clish/shell/shell_command_generator.c
  5. 19 0
      clish/shell/shell_tinyrl.c

+ 1 - 0
clish/pargv.h

@@ -15,6 +15,7 @@
 
 typedef enum {
 	CLISH_LINE_OK,
+	CLISH_LINE_PARTIAL,
 	CLISH_BAD_CMD,
 	CLISH_BAD_PARAM,
 	CLISH_BAD_HISTORY

+ 4 - 6
clish/pargv/pargv.c

@@ -274,7 +274,7 @@ clish_pargv_parse(clish_pargv_t * this,
 					clish_param__get_optional(param))
 					index++;
 				else
-					return CLISH_BAD_PARAM;
+					break;
 			}
 		} else {
 			return CLISH_BAD_PARAM;
@@ -288,7 +288,7 @@ clish_pargv_parse(clish_pargv_t * this,
 		while (j < paramc) {
 			param = clish_paramv__get_param(paramv, j++);
 			if (BOOL_TRUE != clish_param__get_optional(param))
-				return CLISH_BAD_PARAM;
+				return CLISH_LINE_PARTIAL;
 		}
 	}
 
@@ -313,7 +313,7 @@ clish_pargv_parse(clish_pargv_t * this,
 		char *args = NULL;
 
 		if (!param)
-			return CLISH_BAD_PARAM;
+			return CLISH_BAD_CMD;
 
 		/*
 		 * put all the argument into a single string
@@ -394,9 +394,7 @@ clish_pargv_t *clish_pargv_new(const clish_command_t * cmd,
 	switch (*status) {
 	case CLISH_LINE_OK:
 		break;
-	case CLISH_BAD_CMD:
-	case CLISH_BAD_PARAM:
-	case CLISH_BAD_HISTORY:
+	default:
 		/* commit suicide */
 		clish_pargv_delete(this);
 		this = NULL;

+ 5 - 10
clish/ptype/ptype.c

@@ -225,13 +225,15 @@ char *clish_ptype_word_generator(clish_ptype_t * this,
 				 const char *text, unsigned state)
 {
 	char *result = NULL;
+
+	if (this->method != CLISH_PTYPE_SELECT)
+		return NULL;
 	if (0 == state) {
 		/* first of all simply try to validate the result */
 		result = clish_ptype_validate(this, text);
 	}
 	if (NULL == result) {
 		switch (this->method) {
-	    /*--------------------------------------------- */
 		case CLISH_PTYPE_SELECT:
 			{
 				if (0 == state) {
@@ -253,15 +255,8 @@ char *clish_ptype_word_generator(clish_ptype_t * this,
 				}
 				break;
 			}
-	    /*--------------------------------------------- */
-		case CLISH_PTYPE_INTEGER:
-		case CLISH_PTYPE_UNSIGNEDINTEGER:
-		case CLISH_PTYPE_REGEXP:
-			{
-				/* do nothing */
-				break;
-			}
-	    /*--------------------------------------------- */
+		default:
+			break;
 		}
 	}
 	return result;

+ 3 - 3
clish/shell/shell_command_generator.c

@@ -88,8 +88,8 @@ static char *clish_shell_param_generator(clish_shell_t * this,
 			this->context.completion_index++))) {
 
 			if (param == clish_command__get_args(cmd)) {
-				/* The param is args so it has no format */
-				result = lub_string_dup(text);
+				/* The param is args so it has no completion */
+				result = NULL;
 			} else if (CLISH_PARAM_SUBCOMMAND ==
 				clish_param__get_mode(param)) {
 				/* The subcommand is identified by it's value */
@@ -101,7 +101,7 @@ static char *clish_shell_param_generator(clish_shell_t * this,
 			} else {
 				/* The common param. Let ptype do the work */
 				if ((ptype = clish_param__get_ptype(param))) {
-					result = clish_ptype_word_generator(ptype, text, 
+					result = clish_ptype_word_generator(ptype, text,
 						this->context.completion_pindex++);
 					if (!result)
 						this->context.completion_pindex = 0;

+ 19 - 0
clish/shell/shell_tinyrl.c

@@ -160,6 +160,25 @@ static bool_t clish_shell_tinyrl_key_space(tinyrl_t * this, int key)
 		/* if we are in the middle of a quote then simply enter a space */
 		result = tinyrl_insert_text(this, " ");
 	} else {
+context_t *context = tinyrl__get_context(this);
+const char *line = tinyrl__get_line(this);
+clish_pargv_status_t arg_status;
+			arg_status = clish_shell_parse(context->shell,
+						       line,
+						       &context->command,
+						       &context->pargv);
+//printf("!!!!!!!!%d\n", arg_status);
+			switch (arg_status) {
+			case CLISH_LINE_OK:
+			case CLISH_LINE_PARTIAL:
+				if (' ' != line[strlen(line) - 1])
+					result = tinyrl_insert_text(this, " ");
+				return result;
+				break;
+			default:
+				break;
+			}
+
 		/* perform word completion */
 		status = clish_shell_tinyrl_complete(this);
 		switch (status) {