X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-widgets.c;h=93c882b0849af43a00cbe417584e7edd375eb46b;hp=7dc2df3f1d1fc2138c001b7511bac6bfc0e8041a;hb=18a47a31b46d916c58a31e8784a7c3a3abcae446;hpb=297d2f0cc9c0a233fadf42dacc08708ad3909f77 diff --git a/ui/ncurses/nc-widgets.c b/ui/ncurses/nc-widgets.c index 7dc2df3..93c882b 100644 --- a/ui/ncurses/nc-widgets.c +++ b/ui/ncurses/nc-widgets.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "nc-cui.h" #include "nc-widgets.h" @@ -83,6 +84,7 @@ struct nc_widgetset { /* custom validators */ FIELDTYPE *ipv4_multi_type; + FIELDTYPE *url_type; }; struct nc_widget { @@ -399,6 +401,20 @@ void widget_textbox_set_validator_integer(struct nc_widget_textbox *textbox, set_field_type(textbox->widget.field, TYPE_INTEGER, 1, min, max); } +static bool check_url_field(FIELD *field, + const void *arg __attribute__((unused))) +{ + return is_url(field_buffer(field, 0)); +} + +void widget_textbox_set_validator_url(struct nc_widget_textbox *textbox) +{ + if (!textbox->set->url_type) + textbox->set->url_type = new_fieldtype(check_url_field, NULL); + + set_field_type(textbox->widget.field, textbox->set->url_type); +} + void widget_textbox_set_validator_ipv4(struct nc_widget_textbox *textbox) { set_field_type(textbox->widget.field, TYPE_IPV4); @@ -1132,14 +1148,12 @@ bool widgetset_process_key(struct nc_widgetset *set, int key) tab = true; /* fall through */ case KEY_UP: - case KEY_LEFT: req = REQ_SPREV_FIELD; break; case '\t': tab = true; /* fall through */ case KEY_DOWN: - case KEY_RIGHT: req = REQ_SNEXT_FIELD; break; case KEY_PPAGE: @@ -1148,6 +1162,12 @@ bool widgetset_process_key(struct nc_widgetset *set, int key) case KEY_NPAGE: req = REQ_SLAST_FIELD; break; + case KEY_LEFT: + req = REQ_LEFT_FIELD; + break; + case KEY_RIGHT: + req = REQ_RIGHT_FIELD; + break; } if (req) {