Count the number of possible nicks to complete
*/
-static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon)
+static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon, qbool only_pnumbers)
{
char name[MAX_SCOREBOARDNAME];
int i, p;
int match;
int spos;
+ int digits = 0;
int count = 0;
if(!con_nickcompletion.integer)
}
if(isCon && spos == 0)
break;
- if(Nicks_strncasecmp(line+spos, name, pos-spos) == 0)
+ if(only_pnumbers)
+ {
+ if(line[spos] == '#')
+ {
+ digits = (int) strspn(line+spos+1, "0123456789");
+ // word lenght EQUAL digits count OR digits count + 1 trailing space
+ if(((pos)-(spos+1)) == (line[pos-1] == ' ' ? digits+1 : digits) && p == (atoi(line+spos+1)-1))
+ match = spos;
+ }
+ }
+ else if(Nicks_strncasecmp(line+spos, name, pos-spos) == 0)
match = spos;
--spos;
}
Directory support by divVerent
Escaping support by bones_was_here
*/
-int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console)
+int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console, qbool only_pnumbers)
{
const char *text = "";
char *s;
line[linepos] = 0; //hide them
c = v = a = n = cmd_len = 0;
- if (!is_console)
+ if (!is_console || only_pnumbers)
goto nicks;
space = strchr(line + 1, ' ');
}
nicks:
- n = Nicks_CompleteCountPossible(line, linepos, s, is_console);
+ n = Nicks_CompleteCountPossible(line, linepos, s, is_console, only_pnumbers);
if (n)
{
Con_Printf("\n%i possible nick%s\n", n, (n > 1) ? "s: " : ":");
/// or to list possible matches grouped by type
/// (i.e. will display possible variables, aliases, commands
/// that match what they've typed so far)
-int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console);
+int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console, qbool only_pnumbers);
/// Generic libs/util/console.c function to display a list
/// formatted in columns on the console
return linepos;
}
+ if (KM_SHIFT) // only complete player references #N as names
+ return Con_CompleteCommandLine(cmd, is_console, true);
if (KM_NONE)
- return Con_CompleteCommandLine(cmd, is_console);
+ return Con_CompleteCommandLine(cmd, is_console, false);
}
// Advanced Console Editing by Radix radix@planetquake.com