unsigned opts;
FIELD *field[2];
FORM *form;
+ int length;
};
+static int get_cursor_col(struct dialog_section_text_field *field)
+{
+ int col;
+
+ col = field->form->curcol + field->form->begincol;
+
+ return col;
+}
+
static WERROR text_field_create(struct dialog *dia,
struct dialog_section *section)
{
switch (c) {
case KEY_BACKSPACE:
+ if (text_field->length) {
+ text_field->length--;
+ }
form_driver(text_field->form, REQ_DEL_PREV);
break;
+ case '\x7f':
case KEY_DC:
+ if (text_field->length) {
+ text_field->length--;
+ }
form_driver(text_field->form, REQ_DEL_CHAR);
break;
default:
+ text_field->length++;
form_driver(text_field->form, c);
break;
}
struct dialog_section_text_field *text_field =
talloc_get_type_abort(section, struct dialog_section_text_field);
- form_driver(text_field->form, REQ_RIGHT_CHAR);
+ if (section->nlines > 1 ||
+ get_cursor_col(text_field) < text_field->length) {
+ form_driver(text_field->form, REQ_RIGHT_CHAR);
+ }
return true;
}
talloc_get_type_abort(section, struct dialog_section_text_field);
if (section->nlines > 1) {
+ text_field->length += text_field->form->cols;
form_driver(text_field->form, REQ_NEW_LINE);
return DIALOG_IGNORE;
}
struct dialog_section_text_field *text_field =
talloc_get_type_abort(section, struct dialog_section_text_field);
+ text_field->length = strlen(s);
set_field_buffer(text_field->field[0], 0, s);
}