diff --git a/android/client/history.c b/android/client/history.c
index 6481174..ee285da 100644
--- a/android/client/history.c
+++ b/android/client/history.c
for (;;) {
if (fgets(line, 1000, f) != NULL) {
int l = strlen(line);
+
while (l > 0 && isspace(line[--l]))
line[l] = 0;
+
if (l > 0)
history_add_line(line);
} else
break;
}
+
fclose(f);
}
diff --git a/android/client/tabcompletion.c b/android/client/tabcompletion.c
index cc1a5d3..4a6329f 100644
--- a/android/client/tabcompletion.c
+++ b/android/client/tabcompletion.c
/*
* This function splits command line into linked list of arguments.
- * line_buffer - pointer to input comman line
+ * line_buffer - pointer to input command line
* size - size of command line to parse
- * buf - output buffer to keep splited arguments list
+ * buf - output buffer to keep split arguments list
* buf_size_in_bytes - size of buf
*/
static int split_command(const char *line_buffer, int size, split_arg_t *buf,
/* prefix does not match */
if (strncmp(enum_name, name, len) != 0)
continue;
+
/* prefix matches first time */
if (count++ == 0) {
strcpy(prefix, enum_name);
prefix_len = strlen(prefix);
continue;
}
+
/*
* Prefix matches next time
* reduce prefix to common part
tab_hit_count = 0;
return;
}
+
/* len == prefix_len => nothing new was added */
if (len == prefix_len) {
if (count != 1) {
- if (tab_hit_count == 1)
+ if (tab_hit_count == 1) {
putchar('\a');
- else if (tab_hit_count == 2 ||
+ } else if (tab_hit_count == 2 ||
args->help == NULL) {
print_matches(args->func,
args->user, name, len);
prefix[prefix_len++] = ' ';
prefix[prefix_len] = '\0';
}
+
terminal_insert_into_command_line(prefix + len);
tab_hit_count = 0;
}
* parameter completion function
* argc - number of elements in arg list
* arg - list of arguments
- * megthod - method to get completion from (can be NULL)
+ * method - method to get completion from (can be NULL)
*/
static void param_completion(int argc, const split_arg_t *arg,
const struct method *method, int hlpix)
}
/*
- * This methd gets called when user tapped tab key.
- * line - points to comman line
- * len - size of line that should be used for comletions. This should be
+ * This method gets called when user tapped tab key.
+ * line - points to command line
+ * len - size of line that should be used for completions. This should be
* cursor position during tab hit.
*/
void process_tab(const char *line, int len)
command_completion(buf);
return;
}
+
method = get_command(buf[0].ntcopy);
if (method != NULL) {
param_completion(argc, buf, method, 1);
diff --git a/android/client/terminal.c b/android/client/terminal.c
index 22a1d8a..b152bf3 100644
--- a/android/client/terminal.c
+++ b/android/client/terminal.c
#define isseqence(c) ((c) == 0x1B)
/*
- * Number of characters that consist of ANSII sequence
- * Should not be less then longest string in ansii_sequnces
+ * Number of characters that consist of ANSI sequence
+ * Should not be less then longest string in ansi_sequences
*/
#define MAX_ASCII_SEQUENCE 10
void terminal_draw_command_line(void)
{
/*
- * this needs to be checked here since line_buf is not cleard
+ * this needs to be checked here since line_buf is not cleared
* before parsing event though line_len and line_buf_ix are
*/
if (line_len > 0)
terminal_line_replaced();
}
-static void terminal_clear_sceen(void)
+static void terminal_clear_screen(void)
{
line_buf[0] = '\0';
line_buf_ix = 0;
if (matching_line >= 0) {
int pos = line_buf_ix;
terminal_get_line_from_history(matching_line);
- /* move back to cursor position to origianl place */
+ /* move back to cursor position to original place */
line_buf_ix = pos;
terminal_move_cursor(pos - line_len);
}
/* Not in sequence yet? */
if (current_sequence_len == -1) {
- /* Is ansii sequence detected by 0x1B ? */
+ /* Is ansi sequence detected by 0x1B ? */
if (isseqence(c)) {
current_sequence_len++;
return KEY_SEQUNCE_NOT_FINISHED;
- }
- return c;
+ }
+
+ return c;
}
/* Inside sequence */
current_sequence_len = -1;
return ansii_sequnces[i].code;
}
+
/* partial match (not whole sequence yet) */
return KEY_SEQUNCE_NOT_FINISHED;
}
- terminal_print("ansii char 0x%X %c\n", c);
+ terminal_print("ansi char 0x%X %c\n", c);
/*
* Sequence does not match
* mark that no in sequence any more, return char
line_buf_ix--;
/* skip all non spaces to the left */
while (line_buf_ix > 0 &&
- !isspace(line_buf[line_buf_ix - 1]))
+ !isspace(line_buf[line_buf_ix - 1]))
line_buf_ix--;
/* move cursor to new position */
terminal_move_cursor(line_buf_ix - old_pos);
}
break;
case KEY_C_L:
- terminal_clear_sceen();
+ terminal_clear_screen();
break;
default:
if (!isprint(c)) {
/*
* Turn off echo since all editing is done by hand,
- * Ctrl-c handled internaly
+ * Ctrl-c handled internally
*/
tios.c_lflag &= ~(ICANON | ECHO | BRKINT | IGNBRK);
tcsetattr(0, TCSANOW, &tios);