提交 a6dda144 编写于 作者: A Alex Duan

feat(shell): support maxos autotab

上级 199dbab9
...@@ -46,6 +46,8 @@ ELSEIF (TD_DARWIN) ...@@ -46,6 +46,8 @@ ELSEIF (TD_DARWIN)
LIST(APPEND SRC ./src/shellCommand.c) LIST(APPEND SRC ./src/shellCommand.c)
LIST(APPEND SRC ./src/shellImport.c) LIST(APPEND SRC ./src/shellImport.c)
LIST(APPEND SRC ./src/shellCheck.c) LIST(APPEND SRC ./src/shellCheck.c)
LIST(APPEND SRC ./src/shellAuto.c)
LIST(APPEND SRC ./src/tire.c)
ADD_EXECUTABLE(shell ${SRC}) ADD_EXECUTABLE(shell ${SRC})
# linking with dylib # linking with dylib
TARGET_LINK_LIBRARIES(shell taos cJson) TARGET_LINK_LIBRARIES(shell taos cJson)
......
...@@ -118,6 +118,7 @@ SWords shellCommands[] = { ...@@ -118,6 +118,7 @@ SWords shellCommands[] = {
{"show variables;", 0, 0, NULL}, {"show variables;", 0, 0, NULL},
{"show vgroups;", 0, 0, NULL}, {"show vgroups;", 0, 0, NULL},
{"insert into <tb_name> values(", 0, 0, NULL}, {"insert into <tb_name> values(", 0, 0, NULL},
{"insert into <tb_name> using <stb_name> tags(", 0, 0, NULL},
{"use <db_name>", 0, 0, NULL} {"use <db_name>", 0, 0, NULL}
}; };
...@@ -227,14 +228,14 @@ char * db_options[] = { ...@@ -227,14 +228,14 @@ char * db_options[] = {
char * data_types[] = { char * data_types[] = {
"timestamp", "timestamp",
"int", "int",
"bigint",
"float", "float",
"double", "double",
"binary", "binary(16)",
"nchar(16)",
"bigint",
"smallint", "smallint",
"tinyint", "tinyint",
"bool", "bool",
"nchar",
"json" "json"
}; };
...@@ -564,7 +565,7 @@ bool shellAutoInit() { ...@@ -564,7 +565,7 @@ bool shellAutoInit() {
pthread_mutex_init(&tiresMutex, NULL); pthread_mutex_init(&tiresMutex, NULL);
// threads // threads
memset(threads, 0, sizeof(pthread_t*) * WT_VAR_CNT); memset(threads, 0, sizeof(pthread_t*) * WT_FROM_DB_CNT);
// generate varType // generate varType
GenerateVarType(WT_VAR_FUNC, functions, sizeof(functions) /sizeof(char *)); GenerateVarType(WT_VAR_FUNC, functions, sizeof(functions) /sizeof(char *));
...@@ -1535,9 +1536,6 @@ void pressOtherKey(char c) { ...@@ -1535,9 +1536,6 @@ void pressOtherKey(char c) {
freeMatch(lastMatch); freeMatch(lastMatch);
lastMatch = NULL; lastMatch = NULL;
} }
//printf(" -> %d <-\n", c);
} }
// put name into name, return name length // put name into name, return name length
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "tkey.h" #include "tkey.h"
#include "tscLog.h" #include "tscLog.h"
#include "shellAuto.h"
#define OPT_ABORT 1 /* �Cabort */ #define OPT_ABORT 1 /* �Cabort */
...@@ -255,7 +256,12 @@ int32_t shellReadCommand(TAOS *con, char *command) { ...@@ -255,7 +256,12 @@ int32_t shellReadCommand(TAOS *con, char *command) {
utf8_array[k] = c; utf8_array[k] = c;
} }
insertChar(&cmd, utf8_array, count); insertChar(&cmd, utf8_array, count);
pressOtherKey(c);
} else if (c == TAB_KEY) {
// press TAB key
pressTabKey(con, &cmd);
} else if (c < '\033') { } else if (c < '\033') {
pressOtherKey(c);
// Ctrl keys. TODO: Implement ctrl combinations // Ctrl keys. TODO: Implement ctrl combinations
switch (c) { switch (c) {
case 1: // ctrl A case 1: // ctrl A
...@@ -377,9 +383,11 @@ int32_t shellReadCommand(TAOS *con, char *command) { ...@@ -377,9 +383,11 @@ int32_t shellReadCommand(TAOS *con, char *command) {
break; break;
} }
} else if (c == 0x7f) { } else if (c == 0x7f) {
pressOtherKey(c);
// press delete key // press delete key
backspaceChar(&cmd); backspaceChar(&cmd);
} else { } else {
pressOtherKey(c);
insertChar(&cmd, &c, 1); insertChar(&cmd, &c, 1);
} }
} }
...@@ -528,14 +536,14 @@ void showOnScreen(Command *cmd) { ...@@ -528,14 +536,14 @@ void showOnScreen(Command *cmd) {
/* assert(size >= 0); */ /* assert(size >= 0); */
int width = wcwidth(wc); int width = wcwidth(wc);
if (remain_column > width) { if (remain_column > width) {
printf("%lc", wc); fprintf(stdout, "%lc", wc);
remain_column -= width; remain_column -= width;
} else { } else {
if (remain_column == width) { if (remain_column == width) {
printf("%lc\n\r", wc); fprintf(stdout, "%lc\n\r", wc);
remain_column = w.ws_col; remain_column = w.ws_col;
} else { } else {
printf("\n\r%lc", wc); fprintf(stdout, "\n\r%lc", wc);
remain_column = w.ws_col - width; remain_column = w.ws_col - width;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册