diff options
| author | Chris Davis <cd.rattan@gmail.com> | 2014-08-08 22:25:50 -0700 |
|---|---|---|
| committer | Michael Adam <obnox@samba.org> | 2014-10-01 14:32:09 +0200 |
| commit | 5bbed3d93dfddb0386401a032dc3321bc7f67e33 (patch) | |
| tree | 255e92512f10019d386c906aeb104cb1fe1eb91a | |
| parent | 00765544af53cdfcc6f602b1825f14b97b96beb1 (diff) | |
| download | samba-5bbed3d93dfddb0386401a032dc3321bc7f67e33.tar.gz samba-5bbed3d93dfddb0386401a032dc3321bc7f67e33.tar.xz samba-5bbed3d93dfddb0386401a032dc3321bc7f67e33.zip | |
regedit: don't expand single line text field buffer with cursor movement
Signed-off-by: Chris Davis <cd.rattan@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
| -rw-r--r-- | source3/utils/regedit_dialog.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c index b807c4eda6..b5ab400ed0 100644 --- a/source3/utils/regedit_dialog.c +++ b/source3/utils/regedit_dialog.c @@ -721,8 +721,18 @@ struct dialog_section_text_field { 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) { @@ -775,12 +785,20 @@ static void text_field_on_input(struct dialog *dia, 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; } @@ -829,7 +847,10 @@ static bool text_field_on_right(struct dialog *dia, 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; } @@ -841,6 +862,7 @@ static enum dialog_action text_field_on_enter(struct dialog *dia, 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; } @@ -911,6 +933,7 @@ void dialog_section_text_field_set(struct dialog_section *section, 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); } |
