summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Davis <cd.rattan@gmail.com>2014-06-11 10:40:38 -0700
committerMichael Adam <obnox@samba.org>2014-10-01 14:32:08 +0200
commitd38eba5244d0615994249070adee1f3df4c0d4aa (patch)
tree1b071780f911eb4d7ef85ab4e63840e50aed3b49
parentec6a7a7335f5b9e3a54b9967563ba198fc67b120 (diff)
downloadsamba-d38eba5244d0615994249070adee1f3df4c0d4aa.tar.gz
samba-d38eba5244d0615994249070adee1f3df4c0d4aa.tar.xz
samba-d38eba5244d0615994249070adee1f3df4c0d4aa.zip
regedit: restore list cursor when window is resized
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_list.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/source3/utils/regedit_list.c b/source3/utils/regedit_list.c
index 2da70bfcb2..417dea8abc 100644
--- a/source3/utils/regedit_list.c
+++ b/source3/utils/regedit_list.c
@@ -406,6 +406,23 @@ WERROR multilist_set_data(struct multilist *list, const void *data)
return WERR_OK;
}
+static void fix_start_row(struct multilist *list)
+{
+ int height;
+
+ /* adjust start_row so that the cursor appears on the screen */
+
+ height = list->window_height;
+ if (list->cb->get_column_header) {
+ height--;
+ }
+ if (list->cursor_row < list->start_row) {
+ list->start_row = list->cursor_row;
+ } else if (list->cursor_row >= list->start_row + height) {
+ list->start_row = list->cursor_row - height + 1;
+ }
+}
+
WERROR multilist_set_window(struct multilist *list, WINDOW *window)
{
int maxy, maxx;
@@ -421,10 +438,17 @@ WERROR multilist_set_window(struct multilist *list, WINDOW *window)
list->window = window;
list->window_width = maxx;
list->window_height = maxy;
+ list->start_row = 0;
if (rerender) {
- return multilist_set_data(list, list->data);
+ const void *row = multilist_get_current_row(list);
+ WERROR rv = multilist_set_data(list, list->data);
+ if (W_ERROR_IS_OK(rv) && row) {
+ multilist_set_current_row(list, row);
+ }
+ return rv;
} else {
put_header(list);
+ fix_start_row(list);
}
return WERR_OK;
@@ -449,23 +473,6 @@ void multilist_refresh(struct multilist *list)
false);
}
-static void fix_start_row(struct multilist *list)
-{
- int height;
-
- /* adjust start_row so that the cursor appears on the screen */
-
- height = list->window_height;
- if (list->cb->get_column_header) {
- height--;
- }
- if (list->cursor_row < list->start_row) {
- list->start_row = list->cursor_row;
- } else if (list->cursor_row >= list->start_row + height) {
- list->start_row = list->cursor_row - height + 1;
- }
-}
-
void multilist_driver(struct multilist *list, int c)
{
const void *tmp;