summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/chat.c28
-rw-r--r--src/screen/browser.c8
-rw-r--r--src/widget/widget_textfield.c45
3 files changed, 43 insertions, 38 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
index 019445f..b6904c9 100644
--- a/src/client/chat.c
+++ b/src/client/chat.c
@@ -119,7 +119,21 @@ static void processMessageKey(SDL_keysym keysym)
{
int w, h;
int len;
- //int i;
+ unsigned n;
+
+ char shift_map[] = {
+ '-', '_',
+ '=', '+',
+ '[', '{',
+ ']', '}',
+ ';', ':',
+ '/', '\"',
+ '\\', '|',
+ ',', '<',
+ '.', '>',
+ '/', '?',
+ ')', '(',
+ };
if (line_atime < 100)
line_atime++;
@@ -145,9 +159,15 @@ static void processMessageKey(SDL_keysym keysym)
*/
char c = keysym.sym;
- /* TODO: should correspond with ASCII table */
- if (keysym.mod & KMOD_RSHIFT)
- c --;
+ if (keysym.mod & KMOD_RSHIFT) {
+ for (n = 0; n < sizeof (shift_map); n += 2) {
+ if (c == shift_map[n]) {
+ c = shift_map[n+1];
+ break;
+ }
+ }
+ }
+
line[len] = c;
return;
diff --git a/src/screen/browser.c b/src/screen/browser.c
index 4369fa4..769fd46 100644
--- a/src/screen/browser.c
+++ b/src/screen/browser.c
@@ -128,8 +128,7 @@ void browser_stop()
while (1) {
i = 0;
- for (server = server_list.next; server != &server_list;
- server = server->next) {
+ for (server = server_list.next; server != &server_list; server = server->next) {
server->next->prev = server->prev;
server->prev->next = server->next;
@@ -165,7 +164,7 @@ static void eventWidget(void *p)
if (!server)
return;
- /* server je offline */
+ /* server is offline */
if (!server->state)
return;
@@ -206,7 +205,7 @@ server_t *server_getcurr()
return 0;
}
-int server_getinfo(server_t * server)
+int server_getinfo(server_t *server)
{
struct sockaddr_in srv;
int mySocket;
@@ -550,7 +549,6 @@ static int LoadServers()
ctx->version = 0;
ctx->arena = 0;
- //int ret = server_getinfo(ctx);
ret = server_getinfo(ctx);
srv.s_addr = ctx->ip;
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
index 41428ff..3706c97 100644
--- a/src/widget/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -27,8 +27,7 @@ widget_t *text_field_new(char *text, int filter, int x, int y)
new->filter = filter;
font_text_size(text, &new->w, &new->h);
- return widget_new(WIDGET_TYPE_TEXTFILED, x, y,
- WIDGET_TEXTFIELD_WIDTH, WIDGET_TEXTFIELD_HEIGHT, new);
+ return widget_new(WIDGET_TYPE_TEXTFILED, x, y, WIDGET_TEXTFIELD_WIDTH, WIDGET_TEXTFIELD_HEIGHT, new);
}
static void drawBackground(widget_t * widget)
@@ -42,19 +41,16 @@ static void drawBackground(widget_t * widget)
p = (widget_textfield_t *) widget->private_data;
- if (g_textfield0 == NULL) {
+ if (g_textfield0 == NULL)
g_textfield0 = image_add("textfield0.png", IMAGE_ALPHA, "textfiled0", IMAGE_GROUP_BASE);
- }
- if (g_textfield1 == NULL) {
+ if (g_textfield1 == NULL)
g_textfield1 = image_add("textfield1.png", IMAGE_ALPHA, "textfiled1", IMAGE_GROUP_BASE);
- }
- if (p->active) {
+ if (p->active)
image_draw(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w, g_textfield1->h);
- } else {
+ else
image_draw(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w, g_textfield0->h);
- }
}
static void drawText(widget_t * widget)
@@ -70,16 +66,12 @@ static void drawText(widget_t * widget)
strcpy(str, p->text);
if (p->timeBlick > WIDGET_TEXTFIELD_TIME_BLICK_CURSOR / 2 && p->active == TRUE)
- {
- //strcat(str, ">");
strcat(str, "\f");
- }
p->timeBlick++;
- if (p->timeBlick == WIDGET_TEXTFIELD_TIME_BLICK_CURSOR) {
+ if (p->timeBlick == WIDGET_TEXTFIELD_TIME_BLICK_CURSOR)
p->timeBlick = 0;
- }
//font_draw(str, p->x+WIDGET_TEXTFIELD_TEXT_OFFSET_X, p->y+p->h/2, COLOR_WHITE);
//printf("p->y: %d\nheight: %d\n p->h: %d\n", p->y, WIDGET_TEXTFIELD_HEIGHT, p->h);
@@ -111,7 +103,7 @@ void text_field_set_text(widget_t * widget, char *text)
font_text_size(text, &p->w, &p->h);
}
-char *text_field_get_text(widget_t * widget)
+char *text_field_get_text(widget_t *widget)
{
widget_textfield_t *p;
@@ -122,15 +114,10 @@ char *text_field_get_text(widget_t * widget)
return p->text;
}
-static void checkText(widget_textfield_t * p)
+static void checkText(widget_textfield_t *p, unsigned len)
{
- int len;
int i;
- //printf("check\n");
-
- len = strlen(p->text);
-
for (i = 0; i < len; i++) {
char c;
bool_t isDel;
@@ -160,7 +147,8 @@ static void checkText(widget_textfield_t * p)
case WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN:
if ((c >= '0' && c <= '9') ||
- (c == '.' || c == ':' || c == '-')) {
+ (c == '.' || c == ':' || c == '-') ||
+ (c >= 'a' && c <= 'z')) {
isDel = FALSE;
}
break;
@@ -186,8 +174,6 @@ static void readKey (widget_textfield_t *p)
int len;
int i;
- const int len_shift_map = 20;
-
char shift_map[] = {
'-', '_',
'=', '+',
@@ -198,7 +184,8 @@ static void readKey (widget_textfield_t *p)
'\\', '|',
',', '<',
'.', '>',
- '/', '?'
+ '/', '?',
+ ')', '(',
};
if (p->active == FALSE)
@@ -234,7 +221,7 @@ static void readKey (widget_textfield_t *p)
c = ' ';
else if (k.sym == SDLK_BACKSPACE && len > 0 ) {
p->text[len-1] = '\0';
- checkText (p);
+ checkText (p, len);
break;
}
@@ -247,7 +234,7 @@ static void readKey (widget_textfield_t *p)
int n;
int m = 0;
- for (n = 0; n < len_shift_map; n += 2) {
+ for (n = 0; n < sizeof (shift_map); n += 2) {
if (c == shift_map[n]) {
p->text[len] = shift_map[n+1];
m ++;
@@ -293,9 +280,9 @@ static void readKey (widget_textfield_t *p)
break;
}
*/
+ len ++;
+ checkText (p, len);
- checkText (p);
- len ++;
}
}