xiaoxiang781216 commented on code in PR #3657:
URL: https://github.com/apache/nuttx-apps/pull/3657#discussion_r3652553775
##########
system/readline/readline_common.c:
##########
@@ -1117,6 +1142,35 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl,
FAR char *buf,
}
#endif /* CONFIG_READLINE_EDIT */
+ if (escape == 10) /* Unrecognized CSI -- consume to final byte */
+ {
+ if (ch >= 0x20 && ch <= 0x3f)
+ {
+ continue; /* still a parameter/intermediate byte */
+ }
+
+ /* ch is the final byte (0x40-0x7e), or something
+ * malformed -- either way the sequence is over now and
+ * is discarded; nothing was ever inserted into the
+ * buffer. Still issue a corrective redraw: some serial
+ * drivers only know how to suppress local echo for
+ * fixed 3-byte "ESC [ x" sequences and leak bytes from
+ * any longer, unrecognized sequence as literal
+ * characters, the same class of issue Delete has for
+ * its own "ESC [ 3 ~". redraw_line() cleans up any
+ * such leaked characters even though the buffer itself
+ * was never affected by them.
+ */
+
+ escape = 0;
+# ifdef CONFIG_READLINE_ECHO
+# ifdef CONFIG_READLINE_EDIT
Review Comment:
merge into one ifdef
##########
system/readline/readline_common.c:
##########
@@ -1042,19 +1042,44 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl,
FAR char *buf,
if (escape == 3)
{
escape = 0;
- if (ch == '~' && cursor < nch)
+ if (ch == '~')
{
- int k;
- for (k = cursor + 1; k < nch; k++)
- buf[k - 1] = buf[k];
- nch--;
+ if (cursor < nch)
+ {
+ int k;
+ for (k = cursor + 1; k < nch; k++)
+ buf[k - 1] = buf[k];
Review Comment:
add {}
##########
system/readline/readline_common.c:
##########
@@ -515,6 +495,41 @@ static bool isearch_find(FAR const char *search, int
searchlen,
}
#endif
+#ifdef CONFIG_READLINE_EDIT
+/****************************************************************************
+ * Name: word_skip
+ *
+ * Description:
+ * Used by Ctrl+Left/Ctrl+Right. Starting from 'cursor', skip over any
+ * run of spaces then the following word (or, going backward, the
+ * preceding word then any run of spaces before it), stopping at
+ * 'bound' (0 going backward, 'nch' going forward). Returns the new
+ * cursor position.
+ *
+ ****************************************************************************/
+
+static int word_skip(FAR const char *buf, int cursor, int bound,
+ bool forward)
+{
+ if (forward)
+ {
+ while (cursor < bound && buf[cursor] != ' ')
+ cursor++;
Review Comment:
add {}
##########
system/readline/readline_common.c:
##########
@@ -515,6 +495,41 @@ static bool isearch_find(FAR const char *search, int
searchlen,
}
#endif
+#ifdef CONFIG_READLINE_EDIT
+/****************************************************************************
+ * Name: word_skip
+ *
+ * Description:
+ * Used by Ctrl+Left/Ctrl+Right. Starting from 'cursor', skip over any
+ * run of spaces then the following word (or, going backward, the
+ * preceding word then any run of spaces before it), stopping at
+ * 'bound' (0 going backward, 'nch' going forward). Returns the new
+ * cursor position.
+ *
+ ****************************************************************************/
+
+static int word_skip(FAR const char *buf, int cursor, int bound,
+ bool forward)
+{
+ if (forward)
+ {
+ while (cursor < bound && buf[cursor] != ' ')
+ cursor++;
+ while (cursor < bound && buf[cursor] == ' ')
+ cursor++;
+ }
+ else
+ {
+ while (cursor > bound && buf[cursor - 1] == ' ')
+ cursor--;
+ while (cursor > bound && buf[cursor - 1] != ' ')
+ cursor--;
Review Comment:
add {}
##########
system/readline/readline_common.c:
##########
@@ -515,6 +495,41 @@ static bool isearch_find(FAR const char *search, int
searchlen,
}
#endif
+#ifdef CONFIG_READLINE_EDIT
+/****************************************************************************
+ * Name: word_skip
+ *
+ * Description:
+ * Used by Ctrl+Left/Ctrl+Right. Starting from 'cursor', skip over any
+ * run of spaces then the following word (or, going backward, the
+ * preceding word then any run of spaces before it), stopping at
+ * 'bound' (0 going backward, 'nch' going forward). Returns the new
+ * cursor position.
+ *
+ ****************************************************************************/
+
+static int word_skip(FAR const char *buf, int cursor, int bound,
+ bool forward)
+{
+ if (forward)
+ {
+ while (cursor < bound && buf[cursor] != ' ')
+ cursor++;
+ while (cursor < bound && buf[cursor] == ' ')
+ cursor++;
+ }
+ else
+ {
+ while (cursor > bound && buf[cursor - 1] == ' ')
+ cursor--;
Review Comment:
add {}
##########
system/readline/readline_common.c:
##########
@@ -515,6 +495,41 @@ static bool isearch_find(FAR const char *search, int
searchlen,
}
#endif
+#ifdef CONFIG_READLINE_EDIT
+/****************************************************************************
+ * Name: word_skip
+ *
+ * Description:
+ * Used by Ctrl+Left/Ctrl+Right. Starting from 'cursor', skip over any
+ * run of spaces then the following word (or, going backward, the
+ * preceding word then any run of spaces before it), stopping at
+ * 'bound' (0 going backward, 'nch' going forward). Returns the new
+ * cursor position.
+ *
+ ****************************************************************************/
+
+static int word_skip(FAR const char *buf, int cursor, int bound,
+ bool forward)
+{
+ if (forward)
+ {
+ while (cursor < bound && buf[cursor] != ' ')
+ cursor++;
+ while (cursor < bound && buf[cursor] == ' ')
+ cursor++;
Review Comment:
add {}
##########
system/readline/readline_common.c:
##########
@@ -158,6 +158,36 @@ static int count_builtin_matches(FAR char *buf, FAR int
*matches,
}
#endif
+#if defined(CONFIG_READLINE_TABCOMPLETION) && \
+ (defined(CONFIG_BUILTIN) || defined(CONFIG_READLINE_HAVE_EXTMATCH))
+static void tab_print_match(FAR struct rl_common_s *vtbl,
+ FAR const char *name, FAR char *tmp_name,
Review Comment:
remove one space
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]