float con_cursorspeed = 4;
// lines up from bottom to display
+int hash_completion_player;
int con_backscroll;
conbuffer_t con;
Count the number of possible nicks to complete
*/
-static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon, qbool only_pnumbers)
+static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon, int hash_completion)
{
char name[MAX_SCOREBOARDNAME];
int i, p;
if(!line[0])// || !line[1]) // we want at least... 2 written characters
return 0;
+ if(hash_completion == 1) // cycle through players
+ {
+ int initial;
+ if (hash_completion_player < 0)
+ hash_completion_player = 0;
+ initial = hash_completion_player;
+ while(true)
+ {
+ hash_completion_player = (hash_completion_player + 1) % cl.maxclients;
+ if (hash_completion_player == initial || cl.scores[hash_completion_player].name[0])
+ break;
+ }
+ }
+
for(i = 0; i < cl.maxclients; ++i)
{
p = i;
}
if(isCon && spos == 0)
break;
- if(only_pnumbers)
+ if(hash_completion)
{
if(line[spos] == '#')
{
int len = (int) strspn(line+spos+1, "0123456789"); // number of digits
- if (line[pos-1] == ' ')
- ++len;
- // word lenght EQUAL digits count OR digits count + 1 trailing space
- if(((pos)-(spos+1)) == len && p == (atoi(line+spos+1)-1))
- match = spos;
+ if (len == 0)
+ {
+ if (p == hash_completion_player)
+ match = spos;
+ }
+ else
+ {
+ hash_completion_player = -1;
+ if (line[pos-1] == ' ')
+ ++len;
+ // word lenght EQUAL digits count OR digits count + 1 trailing space
+ if(((pos)-(spos+1)) == len && p == (atoi(line+spos+1)-1))
+ match = spos;
+ }
}
}
else if(Nicks_strncasecmp(line+spos, name, pos-spos) == 0)
return count;
}
-static void Cmd_CompleteNicksPrint(int count)
+static void Cmd_CompleteNicksPrint(int count, int hash_completion)
{
int i;
for(i = 0; i < count; ++i)
- Con_Printf("%s\n", Nicks_list[i]);
+ {
+ if (hash_completion == 1 && hash_completion_player >= 0)
+ Con_Printf("#%d %s\n", hash_completion_player + 1, Nicks_list[i]);
+ else
+ Con_Printf("%s\n", Nicks_list[i]);
+ }
}
static void Nicks_CutMatchesNormal(int count)
Directory support by divVerent
Escaping support by bones_was_here
*/
-int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console, qbool only_pnumbers)
+int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console, int hash_completion)
{
const char *text = "";
char *s;
line[linepos] = 0; //hide them
c = v = a = n = cmd_len = 0;
- if (!is_console || only_pnumbers)
+ if (!is_console || hash_completion)
goto nicks;
space = strchr(line + 1, ' ');
}
nicks:
- n = Nicks_CompleteCountPossible(line, linepos, s, is_console, only_pnumbers);
+ n = Nicks_CompleteCountPossible(line, linepos, s, is_console, hash_completion);
if (n)
{
Con_Printf("\n%i possible nick%s\n", n, (n > 1) ? "s: " : ":");
- Cmd_CompleteNicksPrint(n);
+ Cmd_CompleteNicksPrint(n, hash_completion);
+ if (hash_completion == 1 && hash_completion_player >= 0)
+ n = 0; // cycle player names without autocompleting
}
if (!(c + v + a + n)) // No possible matches
//
// console
//
+extern int hash_completion_player;
extern int con_totallines;
extern int con_backscroll;
extern qbool con_initialized;
/// 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, qbool only_pnumbers);
+int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console, int hash_completion);
/// 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_SHIFT) // SHIFT-TAB after #N autocompletes the name of player N; after # it cycles through player names
+ return Con_CompleteCommandLine(cmd, is_console, 1);
if (KM_NONE)
- return Con_CompleteCommandLine(cmd, is_console, false);
+ {
+ if (hash_completion_player >= 0) // TAB after # autocompletes the name of hash_completion_player
+ {
+ int r = Con_CompleteCommandLine(cmd, is_console, 2);
+ hash_completion_player = -1;
+ return r;
+ }
+ return Con_CompleteCommandLine(cmd, is_console, 0);
+ }
}
// Advanced Console Editing by Radix radix@planetquake.com