mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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.
This commit is contained in:
@@ -6000,6 +6000,7 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
int found = FALSE;
|
int found = FALSE;
|
||||||
ucmd_T *cmd;
|
ucmd_T *cmd;
|
||||||
int len;
|
int len;
|
||||||
|
int over;
|
||||||
long a;
|
long a;
|
||||||
garray_T *gap;
|
garray_T *gap;
|
||||||
|
|
||||||
@@ -6019,17 +6020,36 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
|
|
||||||
/* Put out the title first time */
|
/* Put out the title first time */
|
||||||
if (!found)
|
if (!found)
|
||||||
msg_puts_title(_("\n Name Args Address Complete Definition"));
|
msg_puts_title(_("\n Name Args Address Complete Definition"));
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
if (got_int)
|
if (got_int)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Special cases */
|
// Special cases
|
||||||
msg_putchar(a & BANG ? '!' : ' ');
|
len = 4;
|
||||||
msg_putchar(a & REGSTR ? '"' : ' ');
|
if (a & BANG)
|
||||||
msg_putchar(gap != &ucmds ? 'b' : ' ');
|
{
|
||||||
msg_putchar(' ');
|
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));
|
msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));
|
||||||
len = (int)STRLEN(cmd->uc_name) + 4;
|
len = (int)STRLEN(cmd->uc_name) + 4;
|
||||||
@@ -6037,30 +6057,33 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
do {
|
do {
|
||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
++len;
|
++len;
|
||||||
} while (len < 16);
|
} 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.
|
||||||
|
over = len - 22;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
/* Arguments */
|
// Arguments
|
||||||
switch ((int)(a & (EXTRA|NOSPC|NEEDARG)))
|
switch ((int)(a & (EXTRA|NOSPC|NEEDARG)))
|
||||||
{
|
{
|
||||||
case 0: IObuff[len++] = '0'; break;
|
case 0: IObuff[len++] = '0'; break;
|
||||||
case (EXTRA): IObuff[len++] = '*'; break;
|
case (EXTRA): IObuff[len++] = '*'; break;
|
||||||
case (EXTRA|NOSPC): IObuff[len++] = '?'; break;
|
case (EXTRA|NOSPC): IObuff[len++] = '?'; break;
|
||||||
case (EXTRA|NEEDARG): IObuff[len++] = '+'; break;
|
case (EXTRA|NEEDARG): IObuff[len++] = '+'; break;
|
||||||
case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break;
|
case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
IObuff[len++] = ' ';
|
IObuff[len++] = ' ';
|
||||||
} while (len < 5);
|
} while (len < 5 - over);
|
||||||
|
|
||||||
/* Range */
|
// Address / Range
|
||||||
if (a & (RANGE|COUNT))
|
if (a & (RANGE|COUNT))
|
||||||
{
|
{
|
||||||
if (a & COUNT)
|
if (a & COUNT)
|
||||||
{
|
{
|
||||||
/* -count=N */
|
// -count=N
|
||||||
sprintf((char *)IObuff + len, "%ldc", cmd->uc_def);
|
sprintf((char *)IObuff + len, "%ldc", cmd->uc_def);
|
||||||
len += (int)STRLEN(IObuff + len);
|
len += (int)STRLEN(IObuff + len);
|
||||||
}
|
}
|
||||||
@@ -6068,7 +6091,7 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
IObuff[len++] = '%';
|
IObuff[len++] = '%';
|
||||||
else if (cmd->uc_def >= 0)
|
else if (cmd->uc_def >= 0)
|
||||||
{
|
{
|
||||||
/* -range=N */
|
// -range=N
|
||||||
sprintf((char *)IObuff + len, "%ld", cmd->uc_def);
|
sprintf((char *)IObuff + len, "%ld", cmd->uc_def);
|
||||||
len += (int)STRLEN(IObuff + len);
|
len += (int)STRLEN(IObuff + len);
|
||||||
}
|
}
|
||||||
@@ -6078,9 +6101,9 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
IObuff[len++] = ' ';
|
IObuff[len++] = ' ';
|
||||||
} while (len < 11);
|
} while (len < 9 - over);
|
||||||
|
|
||||||
/* Address Type */
|
// Address Type
|
||||||
for (j = 0; addr_type_complete[j].expand != -1; ++j)
|
for (j = 0; addr_type_complete[j].expand != -1; ++j)
|
||||||
if (addr_type_complete[j].expand != ADDR_LINES
|
if (addr_type_complete[j].expand != ADDR_LINES
|
||||||
&& addr_type_complete[j].expand == cmd->uc_addr_type)
|
&& addr_type_complete[j].expand == cmd->uc_addr_type)
|
||||||
@@ -6092,9 +6115,9 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
IObuff[len++] = ' ';
|
IObuff[len++] = ' ';
|
||||||
} while (len < 21);
|
} while (len < 13 - over);
|
||||||
|
|
||||||
/* Completion */
|
// Completion
|
||||||
for (j = 0; command_complete[j].expand != 0; ++j)
|
for (j = 0; command_complete[j].expand != 0; ++j)
|
||||||
if (command_complete[j].expand == cmd->uc_compl)
|
if (command_complete[j].expand == cmd->uc_compl)
|
||||||
{
|
{
|
||||||
@@ -6105,12 +6128,13 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
IObuff[len++] = ' ';
|
IObuff[len++] = ' ';
|
||||||
} while (len < 35);
|
} while (len < 24 - over);
|
||||||
|
|
||||||
IObuff[len] = '\0';
|
IObuff[len] = '\0';
|
||||||
msg_outtrans(IObuff);
|
msg_outtrans(IObuff);
|
||||||
|
|
||||||
msg_outtrans_special(cmd->uc_rep, FALSE);
|
msg_outtrans_special(cmd->uc_rep, FALSE,
|
||||||
|
name_len == 0 ? Columns - 46 : 0);
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
if (p_verbose > 0)
|
if (p_verbose > 0)
|
||||||
last_set_msg(cmd->uc_script_ctx);
|
last_set_msg(cmd->uc_script_ctx);
|
||||||
@@ -6344,9 +6368,8 @@ ex_command(exarg_T *eap)
|
|||||||
end = p;
|
end = p;
|
||||||
name_len = (int)(end - name);
|
name_len = (int)(end - name);
|
||||||
|
|
||||||
/* If there is nothing after the name, and no attributes were specified,
|
// If there is nothing after the name, and no attributes were specified,
|
||||||
* we are listing commands
|
// we are listing commands
|
||||||
*/
|
|
||||||
p = skipwhite(end);
|
p = skipwhite(end);
|
||||||
if (!has_attr && ends_excmd(*p))
|
if (!has_attr && ends_excmd(*p))
|
||||||
{
|
{
|
||||||
|
@@ -4022,7 +4022,7 @@ showmap(
|
|||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
|
|
||||||
/* Display the LHS. Get length of what we write. */
|
/* Display the LHS. Get length of what we write. */
|
||||||
len = msg_outtrans_special(mp->m_keys, TRUE);
|
len = msg_outtrans_special(mp->m_keys, TRUE, 0);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
msg_putchar(' '); /* padd with blanks */
|
msg_putchar(' '); /* padd with blanks */
|
||||||
@@ -4053,7 +4053,7 @@ showmap(
|
|||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
{
|
{
|
||||||
vim_unescape_csi(s);
|
vim_unescape_csi(s);
|
||||||
msg_outtrans_special(s, FALSE);
|
msg_outtrans_special(s, FALSE, 0);
|
||||||
vim_free(s);
|
vim_free(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1214,7 +1214,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
|||||||
if (*menu->strings[bit] == NUL)
|
if (*menu->strings[bit] == NUL)
|
||||||
msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
|
msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
|
||||||
else
|
else
|
||||||
msg_outtrans_special(menu->strings[bit], FALSE);
|
msg_outtrans_special(menu->strings[bit], FALSE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -1594,7 +1594,8 @@ msg_make(char_u *arg)
|
|||||||
int
|
int
|
||||||
msg_outtrans_special(
|
msg_outtrans_special(
|
||||||
char_u *strstart,
|
char_u *strstart,
|
||||||
int from) /* TRUE for lhs of a mapping */
|
int from, // TRUE for lhs of a mapping
|
||||||
|
int maxlen) // screen columns, 0 for unlimeted
|
||||||
{
|
{
|
||||||
char_u *str = strstart;
|
char_u *str = strstart;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
@@ -1614,6 +1615,8 @@ msg_outtrans_special(
|
|||||||
else
|
else
|
||||||
text = (char *)str2special(&str, from);
|
text = (char *)str2special(&str, from);
|
||||||
len = vim_strsize((char_u *)text);
|
len = vim_strsize((char_u *)text);
|
||||||
|
if (maxlen > 0 && retval + len >= maxlen)
|
||||||
|
break;
|
||||||
/* Highlight special keys */
|
/* Highlight special keys */
|
||||||
msg_puts_attr(text, len > 1
|
msg_puts_attr(text, len > 1
|
||||||
&& (*mb_ptr2len)((char_u *)text) <= 1 ? attr : 0);
|
&& (*mb_ptr2len)((char_u *)text) <= 1 ? attr : 0);
|
||||||
|
@@ -35,7 +35,7 @@ int msg_outtrans_len(char_u *str, int len);
|
|||||||
char_u *msg_outtrans_one(char_u *p, int attr);
|
char_u *msg_outtrans_one(char_u *p, int attr);
|
||||||
int msg_outtrans_len_attr(char_u *msgstr, int len, int attr);
|
int msg_outtrans_len_attr(char_u *msgstr, int len, int attr);
|
||||||
void msg_make(char_u *arg);
|
void msg_make(char_u *arg);
|
||||||
int msg_outtrans_special(char_u *strstart, int from);
|
int msg_outtrans_special(char_u *strstart, int from, int maxlen);
|
||||||
char_u *str2special_save(char_u *str, int is_lhs);
|
char_u *str2special_save(char_u *str, int is_lhs);
|
||||||
char_u *str2special(char_u **sp, int from);
|
char_u *str2special(char_u **sp, int from);
|
||||||
void str2specialbuf(char_u *sp, char_u *buf, int len);
|
void str2specialbuf(char_u *sp, char_u *buf, int len);
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1201,
|
||||||
/**/
|
/**/
|
||||||
1200,
|
1200,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user