“d595fe6ba1b70b24199fb26962e0bccb1242e03b”上不存在“source/dnode/mgmt/node_common/src/dmUtil.c”
提交 c7c735dc 编写于 作者: A Alex Duan

fix(shell): supported input with chinese

上级 d28de946
......@@ -31,7 +31,7 @@
// extern function
void insertChar(Command *cmd, char *c, int size);
void insertStr(Command *cmd, char *str, int size);
typedef struct SAutoPtr {
......@@ -1077,7 +1077,7 @@ void printScreen(TAOS * con, Command * cmd, SWords * match) {
}
// insert new
insertChar(cmd, (char *)str, strLen);
insertStr(cmd, (char *)str, strLen);
}
......@@ -1192,7 +1192,7 @@ bool fillWithType(TAOS * con, Command * cmd, char* pre, int type) {
// show
int count = strlen(part);
insertChar(cmd, part, count);
insertStr(cmd, part, count);
cntDel = count; // next press tab delete current append count
free(str);
......@@ -1220,7 +1220,7 @@ bool fillTableName(TAOS * con, Command * cmd, char* pre) {
// show
int count = strlen(part);
insertChar(cmd, part, count);
insertStr(cmd, part, count);
cntDel = count; // next press tab delete current append count
free(str);
......@@ -1344,7 +1344,7 @@ bool appendAfterSelect(TAOS * con, Command * cmd, char* sql, int32_t len) {
bool fieldEnd = fieldsInputEnd(p);
// cheeck fields input end then insert from keyword
if (fieldEnd && p[len-1] == ' ') {
insertChar(cmd, "from", 4);
insertStr(cmd, "from", 4);
free(p);
return true;
}
......@@ -1527,7 +1527,7 @@ bool matchOther(TAOS * con, Command * cmd) {
if (p[len - 1] == '\\') {
// append '\G'
char a[] = "G;";
insertChar(cmd, a, 2);
insertStr(cmd, a, 2);
return true;
}
......
......@@ -79,11 +79,22 @@ void insertChar(Command *cmd, char *c, int size) {
/* update the values */
cmd->commandSize += size;
cmd->cursorOffset += size;
for (int i = 0; i < size; i++) {
mbtowc(&wc, c + i, size);
cmd->screenOffset += wcwidth(wc);
cmd->endOffset += wcwidth(wc);
}
showOnScreen(cmd);
}
void insertStr(Command *cmd, char *str, int size) {
clearScreen(cmd->endOffset + prompt_size, cmd->screenOffset + prompt_size);
/* update the buffer */
memmove(cmd->command + cmd->cursorOffset + size, cmd->command + cmd->cursorOffset,
cmd->commandSize - cmd->cursorOffset);
memcpy(cmd->command + cmd->cursorOffset, str, size);
/* update the values */
cmd->commandSize += size;
cmd->cursorOffset += size;
cmd->screenOffset += size;
cmd->endOffset += size;
showOnScreen(cmd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册