summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/game.c2
-rw-r--r--src/menu.c14
-rw-r--r--src/tk.h2
-rw-r--r--src/tk/text.c9
4 files changed, 9 insertions, 18 deletions
diff --git a/src/game.c b/src/game.c
index 1db249a..d748b11 100644
--- a/src/game.c
+++ b/src/game.c
@@ -53,7 +53,7 @@ _mf_game_form(SDL_Renderer *renderer, TTF_Font *text_font,
struct _mf_game *game)
{
game->timer = mftk_text_new(MF_DIGITS ":", 5, "00:00", text_font,
- SDL_FALSE, NULL, NULL, NULL, NULL);
+ SDL_FALSE, NULL, NULL, NULL);
return mftk_grid_new(2, 1, MF_ROW_M, MF_COL_M,
game->timer,
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
diff --git a/src/menu.c b/src/menu.c
index e82cf93..4287c03 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -50,12 +50,6 @@ struct _mf_menu {
};
static int
-_mf_menu_isdigit(void *user_data __attribute__((__unused__)), char c)
-{
- return isdigit(c);
-}
-
-static int
_mf_menu_seed(void *user_data, const char *seed)
{
struct _mf_menu *menu = (struct _mf_menu *) user_data;
@@ -173,11 +167,11 @@ _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font,
}
menu->seed_text = mftk_text_new(MF_DIGITS, rand_max_len, menu->seed_buf,
- text_font, SDL_TRUE, &_mf_menu_isdigit, &_mf_menu_seed,
- &_mf_menu_play, menu);
+ text_font, SDL_TRUE, &_mf_menu_seed, &_mf_menu_play,
+ menu);
menu->enemies_text = mftk_text_new(MF_DIGITS, 2, menu->enemies_buf,
- text_font, SDL_TRUE, &_mf_menu_isdigit,
- &_mf_menu_enemies, &_mf_menu_play, menu);
+ text_font, SDL_TRUE, &_mf_menu_enemies, &_mf_menu_play,
+ menu);
grid = mftk_grid_new(6, 2, MF_ROW_M, MF_COL_M,
mftk_label_new(text_font, "Seed", renderer),
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
diff --git a/src/tk.h b/src/tk.h
index 55ac0a3..165e83e 100644
--- a/src/tk.h
+++ b/src/tk.h
@@ -71,7 +71,7 @@ mftk_radio_new(int butn_width, int butn_padding, int label_padding,
struct mftk_widget *
mftk_text_new(const char *allowed_chars, int len, const char *val,
- TTF_Font *font, int editable, int (*allowed)(void *, char),
+ TTF_Font *font, int editable,
int (*action)(void *, const char *), int (*submit)(void *),
void *user_data);
diff --git a/src/tk/text.c b/src/tk/text.c
index 644200b..9ba9faa 100644
--- a/src/tk/text.c
+++ b/src/tk/text.c
@@ -41,7 +41,6 @@ struct mftk_text {
int ascent;
SDL_Texture *texture;
int editable;
- int (*allowed)(void *, char);
int (*action)(void *, const char *);
int (*submit)(void *);
void *user_data;
@@ -150,9 +149,8 @@ _mftk_text_key_event(struct mftk_widget *w, SDL_Event *e)
for (i = 0, j = 0;
i < newlen && e->text.text[j] != '\0';
++j) {
- if (t->allowed != NULL &&
- t->allowed(t->user_data,
- e->text.text[j]) <= 0) {
+ if (strchr(t->allowed_chars, e->text.text[j])
+ == NULL) {
continue;
}
t->val[t->cur + i] = e->text.text[j];
@@ -307,7 +305,7 @@ _mftk_text_destroy(struct mftk_widget *w)
struct mftk_widget *
mftk_text_new(const char *allowed_chars, int len, const char *val,
- TTF_Font *font, int editable, int (*allowed)(void *, char),
+ TTF_Font *font, int editable,
int (*action)(void *, const char *), int (*submit)(void *),
void *user_data)
{
@@ -329,7 +327,6 @@ mftk_text_new(const char *allowed_chars, int len, const char *val,
t->ascent = TTF_FontAscent (font);
t->texture = NULL;
t->editable = editable;
- t->allowed = allowed;
t->action = action;
t->submit = submit;
t->user_data = user_data;