summaryrefslogtreecommitdiffstats
path: root/src/tk/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tk/text.c')
-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,