Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
00e2304d
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
00e2304d
编写于
10月 21, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
10月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17537 from taosdata/fix/TS-1924-V30
fix(shell): correct the position of cursor error when input chinese
上级
d2ab3038
50396481
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
10 deletion
+33
-10
tools/shell/src/shellAuto.c
tools/shell/src/shellAuto.c
+6
-5
tools/shell/src/shellCommand.c
tools/shell/src/shellCommand.c
+27
-5
未找到文件。
tools/shell/src/shellAuto.c
浏览文件 @
00e2304d
...
...
@@ -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
shellShowOnScreen
(
SShellCmd
*
cmd
);
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
);
typedef
struct
SAutoPtr
{
...
...
@@ -1099,7 +1100,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
}
// insert new
shellInsert
Cha
r
(
cmd
,
(
char
*
)
str
,
strLen
);
shellInsert
St
r
(
cmd
,
(
char
*
)
str
,
strLen
);
}
// main key press tab , matched return true else false
...
...
@@ -1220,7 +1221,7 @@ bool fillWithType(TAOS* con, SShellCmd* cmd, char* pre, int type) {
// show
int
count
=
strlen
(
part
);
shellInsert
Cha
r
(
cmd
,
part
,
count
);
shellInsert
St
r
(
cmd
,
part
,
count
);
cntDel
=
count
;
// next press tab delete current append count
taosMemoryFree
(
str
);
...
...
@@ -1247,7 +1248,7 @@ bool fillTableName(TAOS* con, SShellCmd* cmd, char* pre) {
// show
int
count
=
strlen
(
part
);
shellInsert
Cha
r
(
cmd
,
part
,
count
);
shellInsert
St
r
(
cmd
,
part
,
count
);
cntDel
=
count
;
// next press tab delete current append count
taosMemoryFree
(
str
);
...
...
@@ -1371,7 +1372,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
bool
fieldEnd
=
fieldsInputEnd
(
p
);
// check fields input end then insert from keyword
if
(
fieldEnd
&&
p
[
len
-
1
]
==
' '
)
{
shellInsert
Cha
r
(
cmd
,
"from"
,
4
);
shellInsert
St
r
(
cmd
,
"from"
,
4
);
taosMemoryFree
(
p
);
return
true
;
}
...
...
@@ -1569,7 +1570,7 @@ bool matchOther(TAOS* con, SShellCmd* cmd) {
if
(
p
[
len
-
1
]
==
'\\'
)
{
// append '\G'
char
a
[]
=
"G;"
;
shellInsert
Cha
r
(
cmd
,
a
,
2
);
shellInsert
St
r
(
cmd
,
a
,
2
);
return
true
;
}
...
...
tools/shell/src/shellCommand.c
浏览文件 @
00e2304d
...
...
@@ -47,6 +47,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
void
shellShowOnScreen
(
SShellCmd
*
cmd
);
void
shellGetPrevCharSize
(
const
char
*
str
,
int32_t
pos
,
int32_t
*
size
,
int32_t
*
width
);
void
shellInsertChar
(
SShellCmd
*
cmd
,
char
*
c
,
int
size
);
void
shellInsertString
(
SShellCmd
*
cmd
,
char
*
str
,
int
size
);
int32_t
shellCountPrefixOnes
(
uint8_t
c
)
{
uint8_t
mask
=
127
;
...
...
@@ -101,11 +102,30 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
/* update the values */
cmd
->
commandSize
+=
size
;
cmd
->
cursorOffset
+=
size
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
taosMbToWchar
(
&
wc
,
c
+
i
,
size
);
cmd
->
screenOffset
+=
taosWcharWidth
(
wc
);
cmd
->
endOffset
+=
taosWcharWidth
(
wc
);
}
cmd
->
screenOffset
+=
taosWcharWidth
(
wc
);
cmd
->
endOffset
+=
taosWcharWidth
(
wc
);
// set string end
cmd
->
command
[
cmd
->
commandSize
]
=
0
;
#ifdef WINDOWS
#else
shellShowOnScreen
(
cmd
);
#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
...
...
@@ -480,9 +500,11 @@ int32_t shellReadCommand(char *command) {
}
shellInsertChar
(
&
cmd
,
utf8_array
,
count
);
pressOtherKey
(
c
);
#ifndef WINDOWS
}
else
if
(
c
==
TAB_KEY
)
{
// press TAB key
pressTabKey
(
&
cmd
);
#endif
}
else
if
(
c
<
'\033'
)
{
pressOtherKey
(
c
);
// Ctrl keys. TODO: Implement ctrl combinations
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录