vim-patch:8.1.1201: output of :command is hard to read

Problem:    Output of :command is hard to read.
Solution:   Make some columns wider, some narrower.  Truncate the command when
            listing all.
725310d89e
This commit is contained in:
Jan Edmund Lazo 2019-10-30 00:56:49 -04:00
parent 986eafce47
commit 7955c05acc
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
6 changed files with 80 additions and 43 deletions

View File

@ -1773,7 +1773,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):
fncall = match.group(1)
break
# Except in if/for/while/switch, there should never be space
# Except in if/for/while/switch/case, there should never be space
# immediately inside parens (eg "f( 3, 4 )"). We make an exception
# for nested parens ( (a+b) + c ). Likewise, there should never be
# a space before a ( when it's a function argument. I assume it's a
@ -1787,7 +1787,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):
# Note that we assume the contents of [] to be short enough that
# they'll never need to wrap.
if ( # Ignore control structures.
not Search(r'\b(if|for|while|switch|return|sizeof)\b', fncall) and
not Search(r'\b(if|for|while|switch|case|return|sizeof)\b', fncall) and
# Ignore pointers/references to functions.
not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and
# Ignore pointers/references to arrays.

View File

@ -5130,9 +5130,8 @@ static char *get_command_complete(int arg)
static void uc_list(char_u *name, size_t name_len)
{
int i, j;
int found = FALSE;
bool found = false;
ucmd_T *cmd;
int len;
uint32_t a;
// In cmdwin, the alternative buffer should be used.
@ -5151,62 +5150,96 @@ static void uc_list(char_u *name, size_t name_len)
continue;
}
/* Put out the title first time */
if (!found)
MSG_PUTS_TITLE(_("\n Name Args Address Complete Definition"));
found = TRUE;
// Put out the title first time
if (!found) {
MSG_PUTS_TITLE(_("\n Name Args Address "
"Complete Definition"));
}
found = true;
msg_putchar('\n');
if (got_int)
break;
/* Special cases */
msg_putchar(a & BANG ? '!' : ' ');
msg_putchar(a & REGSTR ? '"' : ' ');
msg_putchar(gap != &ucmds ? 'b' : ' ');
msg_putchar(' ');
// Special cases
int len = 4;
if (a & BANG) {
msg_putchar('!');
len--;
}
if (a & REGSTR) {
msg_putchar('"');
len--;
}
if (gap != &ucmds) {
msg_putchar('b');
len--;
}
if (a & TRLBAR) {
msg_putchar('|');
len--;
}
while (len-- > 0) {
msg_putchar(' ');
}
msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));
len = (int)STRLEN(cmd->uc_name) + 4;
do {
msg_putchar(' ');
++len;
} while (len < 16);
len++;
} while (len < 22);
// "over" is how much longer the name is than the column width for
// the name, we'll try to align what comes after.
const int over = len - 22;
len = 0;
/* Arguments */
// Arguments
switch (a & (EXTRA|NOSPC|NEEDARG)) {
case 0: IObuff[len++] = '0'; break;
case (EXTRA): IObuff[len++] = '*'; break;
case (EXTRA|NOSPC): IObuff[len++] = '?'; break;
case (EXTRA|NEEDARG): IObuff[len++] = '+'; break;
case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break;
case 0:
IObuff[len++] = '0';
break;
case (EXTRA):
IObuff[len++] = '*';
break;
case (EXTRA|NOSPC):
IObuff[len++] = '?';
break;
case (EXTRA|NEEDARG):
IObuff[len++] = '+';
break;
case (EXTRA|NOSPC|NEEDARG):
IObuff[len++] = '1';
break;
}
do {
IObuff[len++] = ' ';
} while (len < 5);
} while (len < 5 - over);
/* Range */
// Address / Range
if (a & (RANGE|COUNT)) {
if (a & COUNT) {
/* -count=N */
sprintf((char *)IObuff + len, "%" PRId64 "c", (int64_t)cmd->uc_def);
// -count=N
snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "c",
(int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len);
} else if (a & DFLALL)
} else if (a & DFLALL) {
IObuff[len++] = '%';
else if (cmd->uc_def >= 0) {
/* -range=N */
sprintf((char *)IObuff + len, "%" PRId64 "", (int64_t)cmd->uc_def);
} else if (cmd->uc_def >= 0) {
// -range=N
snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "",
(int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len);
} else
} else {
IObuff[len++] = '.';
}
}
do {
IObuff[len++] = ' ';
} while (len < 11);
} while (len < 9 - over);
// Address Type
for (j = 0; addr_type_complete[j].expand != -1; j++) {
@ -5220,7 +5253,7 @@ static void uc_list(char_u *name, size_t name_len)
do {
IObuff[len++] = ' ';
} while (len < 21);
} while (len < 13 - over);
// Completion
char *cmd_compl = get_command_complete(cmd->uc_compl);
@ -5231,12 +5264,13 @@ static void uc_list(char_u *name, size_t name_len)
do {
IObuff[len++] = ' ';
} while (len < 35);
} while (len < 24 - over);
IObuff[len] = '\0';
msg_outtrans(IObuff);
msg_outtrans_special(cmd->uc_rep, false);
msg_outtrans_special(cmd->uc_rep, false,
name_len == 0 ? Columns - 46 : 0);
if (p_verbose > 0) {
last_set_msg(cmd->uc_script_ctx);
}
@ -5424,9 +5458,8 @@ static void ex_command(exarg_T *eap)
end = p;
name_len = (int)(end - name);
/* If there is nothing after the name, and no attributes were specified,
* we are listing commands
*/
// If there is nothing after the name, and no attributes were specified,
// we are listing commands
p = skipwhite(end);
if (!has_attr && ends_excmd(*p)) {
uc_list(name, end - name);

View File

@ -3361,7 +3361,7 @@ showmap (
msg_putchar(' ');
// Display the LHS. Get length of what we write.
len = (size_t)msg_outtrans_special(mp->m_keys, true);
len = (size_t)msg_outtrans_special(mp->m_keys, true, 0);
do {
msg_putchar(' '); /* padd with blanks */
++len;
@ -3389,7 +3389,7 @@ showmap (
// as typeahead.
char_u *s = vim_strsave(mp->m_str);
vim_unescape_csi(s);
msg_outtrans_special(s, FALSE);
msg_outtrans_special(s, false, 0);
xfree(s);
}
if (p_verbose > 0) {

View File

@ -868,7 +868,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
if (*menu->strings[bit] == NUL) {
msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
} else {
msg_outtrans_special(menu->strings[bit], false);
msg_outtrans_special(menu->strings[bit], false, 0);
}
}
} else {

View File

@ -1521,7 +1521,8 @@ void msg_make(char_u *arg)
/// the character/string -- webb
int msg_outtrans_special(
const char_u *strstart,
int from ///< true for LHS of a mapping
bool from, ///< true for LHS of a mapping
int maxlen ///< screen columns, 0 for unlimeted
)
{
if (strstart == NULL) {
@ -1541,6 +1542,9 @@ int msg_outtrans_special(
string = str2special((const char **)&str, from, false);
}
const int len = vim_strsize((char_u *)string);
if (maxlen > 0 && retval + len >= maxlen) {
break;
}
// Highlight special keys
msg_puts_attr(string, (len > 1
&& (*mb_ptr2len)((char_u *)string) <= 1

View File

@ -187,7 +187,7 @@ void terminfo_info_msg(const unibi_term *const ut)
msg_printf_attr(0, " %-25s %-10s = ", unibi_name_str(i),
unibi_short_name_str(i));
// Most of these strings will contain escape sequences.
msg_outtrans_special((char_u *)s, false);
msg_outtrans_special((char_u *)s, false, 0);
msg_putchar('\n');
}
}
@ -214,7 +214,7 @@ void terminfo_info_msg(const unibi_term *const ut)
msg_puts("Extended string capabilities:\n");
for (size_t i = 0; i < unibi_count_ext_str(ut); i++) {
msg_printf_attr(0, " %-25s = ", unibi_get_ext_str_name(ut, i));
msg_outtrans_special((char_u *)unibi_get_ext_str(ut, i), false);
msg_outtrans_special((char_u *)unibi_get_ext_str(ut, i), false, 0);
msg_putchar('\n');
}
}