further Key_Console() cleanup. made Shift-Ins to paste text like Ctrl-v.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@750 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2012-09-30 12:55:09 +00:00
parent f2a2cd3fcf
commit 53c55f6bd3

View file

@ -235,7 +235,7 @@ extern int con_current, con_linewidth, con_vislines;
void Key_Console (int key) void Key_Console (int key)
{ {
static char current[MAXCMDLINE] = ""; static char current[MAXCMDLINE] = "";
int history_line_last, i, x; int history_line_last;
size_t len; size_t len;
char *line, *workline = key_lines[edit_line]; char *line, *workline = key_lines[edit_line];
@ -280,10 +280,6 @@ void Key_Console (int key)
} }
return; return;
case K_INS:
key_insert ^= 1;
return;
case K_DEL: case K_DEL:
key_tabpartial[0] = 0; key_tabpartial[0] = 0;
workline += key_linepos; workline += key_linepos;
@ -301,8 +297,7 @@ void Key_Console (int key)
case K_HOME: case K_HOME:
if (keydown[K_CTRL]) if (keydown[K_CTRL])
{ {
//skip initial empty lines int i, x;//skip initial empty lines
for (i = con_current - con_totallines + 1; i <= con_current; i++) for (i = con_current - con_totallines + 1; i <= con_current; i++)
{ {
line = con_text + (i % con_totallines) * con_linewidth; line = con_text + (i % con_totallines) * con_linewidth;
@ -314,18 +309,15 @@ void Key_Console (int key)
if (x != con_linewidth) if (x != con_linewidth)
break; break;
} }
con_backscroll = CLAMP(0, con_current-i%con_totallines-2, con_totallines-(glheight>>3)-1); con_backscroll = CLAMP(0, con_current-i%con_totallines-2, con_totallines-(glheight>>3)-1);
} }
else else key_linepos = 1;
key_linepos = 1;
return; return;
case K_END: case K_END:
if (keydown[K_CTRL]) if (keydown[K_CTRL])
con_backscroll = 0; con_backscroll = 0;
else else key_linepos = strlen(workline);
key_linepos = strlen(workline);
return; return;
case K_PGUP: case K_PGUP:
@ -401,8 +393,7 @@ void Key_Console (int key)
do do
{ {
history_line = (history_line + 1) & 31; history_line = (history_line + 1) & 31;
} } while (history_line != edit_line && !key_lines[history_line][1]);
while (history_line != edit_line && !key_lines[history_line][1]);
if (history_line == edit_line) if (history_line == edit_line)
Q_strcpy(workline, current); Q_strcpy(workline, current);
@ -410,35 +401,37 @@ void Key_Console (int key)
key_linepos = Q_strlen(workline); key_linepos = Q_strlen(workline);
return; return;
case 'c': case K_INS:
case 'C': if (keydown[K_SHIFT]) /* Shift-Ins paste */
if (keydown[K_CTRL]) { PasteToConsole();
// Control+C : abort this line -- S.A else key_insert ^= 1;
Con_Printf ("%s\n", workline);
workline[0] = ']';
workline[1] = 0; //johnfitz -- otherwise old history items show up in the new edit line
key_linepos = 1;
history_line= edit_line;
return; return;
}
break;
case 'v': case 'v':
case 'V': case 'V':
#if defined(__MACOSX__) || defined(__MACOS__) #if defined(__MACOSX__) || defined(__MACOS__)
/* Cmd+V paste request for Mac : */ if (keydown[K_COMMAND]) { /* Cmd+v paste (Mac-only) */
if (keydown[K_COMMAND])
{
PasteToConsole(); PasteToConsole();
return; return;
} }
#endif #endif
if (keydown[K_CTRL]) if (keydown[K_CTRL]) { /* Ctrl+v paste */
{
PasteToConsole(); PasteToConsole();
return; return;
} }
break; break;
case 'c':
case 'C':
if (keydown[K_CTRL]) { /* Ctrl+C: abort the line -- S.A */
Con_Printf ("%s\n", workline);
workline[0] = ']';
workline[1] = 0;
key_linepos = 1;
history_line= edit_line;
return;
}
break;
} }
if (key < 32 || key > 127) if (key < 32 || key > 127)