summaryrefslogtreecommitdiff
path: root/src/widget
diff options
context:
space:
mode:
authorMichal Zima <xhire@mujmalysvet.cz>2009-12-11 19:23:07 +0100
committerMichal Zima <xhire@mujmalysvet.cz>2009-12-11 19:23:07 +0100
commita0385ddb1e05c96af324ba25073129655eb4334e (patch)
treee44a05de06a7cef06e6c61c4591307687e699aed /src/widget
parent140a27d1579a747f36141d90708fb275aac6a768 (diff)
We should follow the HandBook
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/widget_textfield.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
index 51dda50..53d03a3 100644
--- a/src/widget/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <assert.h>
+#include <SDL_keyboard.h>
#include "main.h"
#include "interface.h"
@@ -12,8 +13,6 @@
#include "keyboardBuffer.h"
-#include <SDL_keyboard.h>
-
widget_t *text_field_new(char *text, int filter, int x, int y)
{
widget_textfield_t *new;
@@ -196,14 +195,17 @@ static void readKey(widget_textfield_t *p)
char *name = (char *) SDL_GetKeyName(k.sym);
- if (!name)
+ if (!name) {
continue;
+ }
- if (len >= STR_SIZE)
+ if (len >= STR_SIZE) {
break;
+ }
- if (k.sym == SDLK_RETURN)
+ if (k.sym == SDLK_RETURN) {
break;
+ }
char c = '\0';
@@ -211,17 +213,19 @@ static void readKey(widget_textfield_t *p)
case 1:
c = name[0];
break;
+
case 3:
c = name[1];
break;
}
- if ((k.unicode & 0xFF80) == 0)
+ if ((k.unicode & 0xFF80) == 0) {
c = k.unicode & 0x7F;
+ }
- if (k.sym == SDLK_SPACE || k.sym == SDLK_TAB)
+ if (k.sym == SDLK_SPACE || k.sym == SDLK_TAB) {
c = ' ';
- else if (k.sym == SDLK_BACKSPACE) {
+ } else if (k.sym == SDLK_BACKSPACE) {
if (len > 0) {
p->text[len-1] = '\0';
checkText(p, len);
@@ -230,12 +234,13 @@ static void readKey(widget_textfield_t *p)
break;
}
- if (c == '\0' || p->w > WIDGET_TEXTFIELD_WIDTH - 40)
+ if (c == '\0' || p->w > WIDGET_TEXTFIELD_WIDTH - 40) {
continue;
+ }
p->text[len] = c;
- len ++;
+ len++;
checkText(p, len);
}
}