console.c: some long input line fixes (keep cursor on screen, don't clip line early, buffer size fix)

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@598 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2012-01-06 21:25:42 +00:00
parent fb02af5a08
commit dc9166c3b8
1 changed files with 7 additions and 4 deletions

View File

@ -1140,7 +1140,7 @@ void Con_DrawInput (void)
extern double key_blinktime; extern double key_blinktime;
extern int key_insert; extern int key_insert;
int i, len; int i, len;
char c[MAXCMDLINE], *text; char c[MAXCMDLINE+1] /* extra space == +1 */, *text;
if (key_dest != key_console && !con_forcedup) if (key_dest != key_console && !con_forcedup)
return; // don't draw anything return; // don't draw anything
@ -1154,15 +1154,18 @@ void Con_DrawInput (void)
// prestep if horizontally scrolling // prestep if horizontally scrolling
if (key_linepos >= con_linewidth) if (key_linepos >= con_linewidth)
text += 1 + key_linepos - con_linewidth; text += key_linepos - con_linewidth;
// draw input string // draw input string
for (i = 0; i <= (int)strlen(text) - 1; i++) //only write enough letters to go from *text to cursor for (i = 0; i < q_min((int)strlen(text), con_linewidth + 1); i++) //only write enough letters to go from *text to cursor
Draw_Character ((i+1)<<3, vid.conheight - 16, text[i]); Draw_Character ((i+1)<<3, vid.conheight - 16, text[i]);
// johnfitz -- new cursor handling // johnfitz -- new cursor handling
if (!((int)((realtime-key_blinktime)*con_cursorspeed) & 1)) if (!((int)((realtime-key_blinktime)*con_cursorspeed) & 1))
Draw_Pic ((key_linepos+1)<<3, vid.conheight - 16, key_insert ? pic_ins : pic_ovr); {
i = key_linepos < con_linewidth ? key_linepos : con_linewidth;
Draw_Pic ((i+1)<<3, vid.conheight - 16, key_insert ? pic_ins : pic_ovr);
}
} }
/* /*