mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 23:02:16 +00:00
A partion of Key_Console() can be simplified by using memmove()
This commit is contained in:
parent
858a0e5db2
commit
b0f20f955c
1 changed files with 7 additions and 12 deletions
|
@ -428,19 +428,14 @@ no_lf:
|
||||||
if (key < 32 || key > 127)
|
if (key < 32 || key > 127)
|
||||||
return; // non printable
|
return; // non printable
|
||||||
|
|
||||||
if (key_linepos < MAXCMDLINE-1)
|
i = strlen(key_lines[edit_line]);
|
||||||
{
|
if (i >= MAXCMDLINE-1)
|
||||||
i = strlen(key_lines[edit_line]) - 1;
|
return;
|
||||||
if (i == MAXCMDLINE-2) i--;
|
|
||||||
for (; i >= key_linepos; i--)
|
|
||||||
key_lines[edit_line][i + 1] = key_lines[edit_line][i];
|
|
||||||
i = key_lines[edit_line][key_linepos];
|
|
||||||
key_lines[edit_line][key_linepos] = key;
|
|
||||||
key_linepos++;
|
|
||||||
if (!i) // // only null terminate if at the end
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// This also moves the ending \0
|
||||||
|
memmove (key_lines[edit_line]+key_linepos+1, key_lines[edit_line]+key_linepos, i-key_linepos+1);
|
||||||
|
key_lines[edit_line][key_linepos] = key;
|
||||||
|
key_linepos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
Loading…
Reference in a new issue