fix(shell): fixed chinese input error
This commit is contained in:
parent
abff4fb1f2
commit
892bdb75fc
|
@ -30,6 +30,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
void shellGetPrevCharSize(const char* str, int32_t pos, int32_t* size, int32_t* width);
|
void shellGetPrevCharSize(const char* str, int32_t pos, int32_t* size, int32_t* width);
|
||||||
void shellShowOnScreen(SShellCmd* cmd);
|
void shellShowOnScreen(SShellCmd* cmd);
|
||||||
void shellInsertChar(SShellCmd* cmd, char* c, int size);
|
void shellInsertChar(SShellCmd* cmd, char* c, int size);
|
||||||
|
void shellInsertStr(SShellCmd* cmd, char* str, int size);
|
||||||
bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* p, int32_t len);
|
bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* p, int32_t len);
|
||||||
|
|
||||||
typedef struct SAutoPtr {
|
typedef struct SAutoPtr {
|
||||||
|
@ -1099,7 +1100,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert new
|
// insert new
|
||||||
shellInsertChar(cmd, (char*)str, strLen);
|
shellInsertStr(cmd, (char*)str, strLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// main key press tab , matched return true else false
|
// main key press tab , matched return true else false
|
||||||
|
@ -1220,7 +1221,7 @@ bool fillWithType(TAOS* con, SShellCmd* cmd, char* pre, int type) {
|
||||||
|
|
||||||
// show
|
// show
|
||||||
int count = strlen(part);
|
int count = strlen(part);
|
||||||
shellInsertChar(cmd, part, count);
|
shellInsertStr(cmd, part, count);
|
||||||
cntDel = count; // next press tab delete current append count
|
cntDel = count; // next press tab delete current append count
|
||||||
|
|
||||||
taosMemoryFree(str);
|
taosMemoryFree(str);
|
||||||
|
@ -1247,7 +1248,7 @@ bool fillTableName(TAOS* con, SShellCmd* cmd, char* pre) {
|
||||||
|
|
||||||
// show
|
// show
|
||||||
int count = strlen(part);
|
int count = strlen(part);
|
||||||
shellInsertChar(cmd, part, count);
|
shellInsertStr(cmd, part, count);
|
||||||
cntDel = count; // next press tab delete current append count
|
cntDel = count; // next press tab delete current append count
|
||||||
|
|
||||||
taosMemoryFree(str);
|
taosMemoryFree(str);
|
||||||
|
@ -1371,7 +1372,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
|
||||||
bool fieldEnd = fieldsInputEnd(p);
|
bool fieldEnd = fieldsInputEnd(p);
|
||||||
// check fields input end then insert from keyword
|
// check fields input end then insert from keyword
|
||||||
if (fieldEnd && p[len - 1] == ' ') {
|
if (fieldEnd && p[len - 1] == ' ') {
|
||||||
shellInsertChar(cmd, "from", 4);
|
shellInsertStr(cmd, "from", 4);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1570,7 @@ bool matchOther(TAOS* con, SShellCmd* cmd) {
|
||||||
if (p[len - 1] == '\\') {
|
if (p[len - 1] == '\\') {
|
||||||
// append '\G'
|
// append '\G'
|
||||||
char a[] = "G;";
|
char a[] = "G;";
|
||||||
shellInsertChar(cmd, a, 2);
|
shellInsertStr(cmd, a, 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
void shellShowOnScreen(SShellCmd *cmd);
|
void shellShowOnScreen(SShellCmd *cmd);
|
||||||
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width);
|
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width);
|
||||||
void shellInsertChar(SShellCmd *cmd, char *c, int size);
|
void shellInsertChar(SShellCmd *cmd, char *c, int size);
|
||||||
|
void shellInsertString(SShellCmd *cmd, char *str, int size);
|
||||||
|
|
||||||
int32_t shellCountPrefixOnes(uint8_t c) {
|
int32_t shellCountPrefixOnes(uint8_t c) {
|
||||||
uint8_t mask = 127;
|
uint8_t mask = 127;
|
||||||
|
@ -114,6 +115,27 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insert string . count is str char count
|
||||||
|
void shellInsertStr(SShellCmd *cmd, char *str, int32_t size) {
|
||||||
|
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
// set string end
|
||||||
|
cmd->command[cmd->commandSize] = 0;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#else
|
||||||
|
shellShowOnScreen(cmd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void shellBackspaceChar(SShellCmd *cmd) {
|
void shellBackspaceChar(SShellCmd *cmd) {
|
||||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue