Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
802fd01b
Commit
802fd01b
authored
Feb 22, 2011
by
antirez
Browse files
linenoise updated
parent
4a67d194
Changes
1
Hide whitespace changes
Inline
Side-by-side
deps/linenoise/linenoise.c
View file @
802fd01b
...
@@ -320,10 +320,9 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
...
@@ -320,10 +320,9 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
switch
(
c
)
{
switch
(
c
)
{
case
13
:
/* enter */
case
13
:
/* enter */
case
4
:
/* ctrl-d */
history_len
--
;
history_len
--
;
free
(
history
[
history_len
]);
free
(
history
[
history_len
]);
return
(
len
==
0
&&
c
==
4
)
?
-
1
:
(
int
)
len
;
return
(
int
)
len
;
case
3
:
/* ctrl-c */
case
3
:
/* ctrl-c */
errno
=
EAGAIN
;
errno
=
EAGAIN
;
return
-
1
;
return
-
1
;
...
@@ -337,6 +336,18 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
...
@@ -337,6 +336,18 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
refreshLine
(
fd
,
prompt
,
buf
,
len
,
pos
,
cols
);
refreshLine
(
fd
,
prompt
,
buf
,
len
,
pos
,
cols
);
}
}
break
;
break
;
case
4
:
/* ctrl-d, remove char at right of cursor */
if
(
len
>
1
&&
pos
<
(
len
-
1
))
{
memmove
(
buf
+
pos
,
buf
+
pos
+
1
,
len
-
pos
);
len
--
;
buf
[
len
]
=
'\0'
;
refreshLine
(
fd
,
prompt
,
buf
,
len
,
pos
,
cols
);
}
else
if
(
len
==
0
)
{
history_len
--
;
free
(
history
[
history_len
]);
return
-
1
;
}
break
;
case
20
:
/* ctrl-t */
case
20
:
/* ctrl-t */
if
(
pos
>
0
&&
pos
<
len
)
{
if
(
pos
>
0
&&
pos
<
len
)
{
int
aux
=
buf
[
pos
-
1
];
int
aux
=
buf
[
pos
-
1
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment