summaryrefslogtreecommitdiffstats
path: root/src/tk
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-12-24 01:04:41 (EST)
committer P. J. McDermott <pj@pehjota.net>2021-12-24 01:04:41 (EST)
commit8b52102fa434b35d2797e59f7afe80a44acad21b (patch)
tree3665b18c727f26cb2e5f15ad92c92892c409395a /src/tk
parente7cf4adb92206f49c42dc2de3ae900de16449107 (diff)
downloadmazefight-8b52102fa434b35d2797e59f7afe80a44acad21b.zip
mazefight-8b52102fa434b35d2797e59f7afe80a44acad21b.tar.gz
mazefight-8b52102fa434b35d2797e59f7afe80a44acad21b.tar.bz2
tk/text: Replace min_char and max_char with allowed_chars
Diffstat (limited to 'src/tk')
-rw-r--r--src/tk/text.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/tk/text.c b/src/tk/text.c
index c96c924..644200b 100644
--- a/src/tk/text.c
+++ b/src/tk/text.c
@@ -28,8 +28,7 @@
struct mftk_text {
struct mftk_widget parent;
- char min_char;
- char max_char;
+ const char *allowed_chars;
int len;
int cur;
int y;
@@ -307,7 +306,7 @@ _mftk_text_destroy(struct mftk_widget *w)
}
struct mftk_widget *
-mftk_text_new(char min_char, char max_char, int len, const char *val,
+mftk_text_new(const char *allowed_chars, int len, const char *val,
TTF_Font *font, int editable, int (*allowed)(void *, char),
int (*action)(void *, const char *), int (*submit)(void *),
void *user_data)
@@ -323,18 +322,17 @@ mftk_text_new(char min_char, char max_char, int len, const char *val,
mftk_widget_init(w, t, text);
}
- t->min_char = min_char;
- t->max_char = max_char;
- t->len = len;
- t->font = font;
- t->line_skip = TTF_FontLineSkip(font);
- 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;
+ t->allowed_chars = allowed_chars;
+ t->len = len;
+ t->font = font;
+ t->line_skip = TTF_FontLineSkip(font);
+ 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;
t->val = calloc(len + 1, sizeof(*t->val));
if (t->val == NULL) {
@@ -361,7 +359,7 @@ mftk_text_new(char min_char, char max_char, int len, const char *val,
memcpy(t->val, val, t->cur);
w->w = 0;
- for (ch = min_char; ch <= max_char; ++ch) {
+ for (ch = allowed_chars[0]; ch != '\0'; ++ch) {
if (TTF_GlyphMetrics(font, ch, NULL, NULL, NULL, NULL, &advance)
< 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,