summaryrefslogtreecommitdiffstats
path: root/src/tk
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-12-24 01:18:33 (EST)
committer P. J. McDermott <pj@pehjota.net>2021-12-24 01:18:33 (EST)
commitaaefbcddbbc2fb8c71e0a2ea40f76fce3c18c0aa (patch)
treeae9b840ca0ca4d44e7d1efeef71f82dcc61fe7cc /src/tk
parent8b52102fa434b35d2797e59f7afe80a44acad21b (diff)
downloadmazefight-aaefbcddbbc2fb8c71e0a2ea40f76fce3c18c0aa.zip
mazefight-aaefbcddbbc2fb8c71e0a2ea40f76fce3c18c0aa.tar.gz
mazefight-aaefbcddbbc2fb8c71e0a2ea40f76fce3c18c0aa.tar.bz2
tk/text: strchr() allowed_chars for validation
Diffstat (limited to 'src/tk')
-rw-r--r--src/tk/text.c9
1 files changed, 3 insertions, 6 deletions
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;