diff options
author | Andrey Nazarov <skuller@skuller.net> | 2008-04-02 23:03:09 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2008-04-02 23:03:09 +0000 |
commit | 7ec50f12252b4dfb97f3249ccf05a771b98785c1 (patch) | |
tree | 279e4e8bd7b940368331a43869c165de9637ae99 /source/q_field.c | |
parent | 80e48417564f1ce50a39a7c552ad95e651362c1f (diff) |
Use size_t instead of int where possible.
Added initial support for Win64 port.
Diffstat (limited to 'source/q_field.c')
-rw-r--r-- | source/q_field.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/source/q_field.c b/source/q_field.c index f622217..7400434 100644 --- a/source/q_field.c +++ b/source/q_field.c @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. IF_Init ================ */ -void IF_Init( inputField_t *field, int visibleChars, int maxChars ) { +void IF_Init( inputField_t *field, size_t visibleChars, size_t maxChars, const char *text ) { memset( field, 0, sizeof( *field ) ); clamp( maxChars, 1, sizeof( field->text ) ); @@ -42,25 +42,10 @@ void IF_Init( inputField_t *field, int visibleChars, int maxChars ) { field->maxChars = maxChars; field->visibleChars = visibleChars; -} -/* -================ -IF_InitText -================ -*/ -void IF_InitText( inputField_t *field, int visibleChars, int maxChars, - const char *text ) -{ - memset( field, 0, sizeof( *field ) ); - - clamp( maxChars, 1, sizeof( field->text ) ); - clamp( visibleChars, 1, maxChars ); - - field->maxChars = maxChars; - field->visibleChars = visibleChars; - - field->cursorPos = Q_strncpyz( field->text, text, sizeof( field->text ) ); + if( text ) { + field->cursorPos = Q_strncpyz( field->text, text, maxChars ); + } } /* @@ -111,7 +96,7 @@ qboolean IF_KeyEvent( inputField_t *field, int key ) { } if( key == 'w' && keys.IsDown( K_CTRL ) ) { - int oldpos = field->cursorPos; + size_t oldpos = field->cursorPos; // kill trailing whitespace while( field->cursorPos > 0 && field->text[field->cursorPos] <= 32 ) { @@ -241,7 +226,8 @@ Returns x offset of the rightmost character drawn. */ int IF_Draw( inputField_t *field, int x, int y, int flags, qhandle_t hFont ) { char *text; - int cursorPos, offset, ret; + size_t cursorPos, offset; + int ret; int cw, ch; if( field->cursorPos > sizeof( field->text ) - 1 ) { |