#include <util/util.h>
#include <i18n/i18n.h>
#include <fold/fold.h>
+#include <url/url.h>
#include "nc-cui.h"
#include "nc-widgets.h"
/* custom validators */
FIELDTYPE *ipv4_multi_type;
+ FIELDTYPE *url_type;
};
struct nc_widget {
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);
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:
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) {