summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/regedit.c77
-rw-r--r--source3/utils/regedit_dialog.c4
-rw-r--r--source3/utils/regedit_treeview.c35
-rw-r--r--source3/utils/regedit_treeview.h7
-rw-r--r--source3/utils/regedit_valuelist.c37
-rw-r--r--source3/utils/regedit_valuelist.h9
6 files changed, 116 insertions, 53 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c
index 59fb86fc8c..e862ab3da6 100644
--- a/source3/utils/regedit.c
+++ b/source3/utils/regedit.c
@@ -29,12 +29,19 @@
#include <menu.h>
#include <panel.h>
+#define KEY_START_X 0
+#define KEY_START_Y 3
+#define KEY_WIDTH (COLS / 4)
+#define KEY_HEIGHT (LINES - KEY_START_Y)
+#define VAL_START_X KEY_WIDTH
+#define VAL_START_Y 3
+#define VAL_WIDTH (COLS - KEY_WIDTH)
+#define VAL_HEIGHT (LINES - VAL_START_Y)
+#define HEADING_START_Y KEY_START_Y - 1
+
struct regedit {
WINDOW *main_window;
- PANEL *main_panel;
WINDOW *path_label;
- WINDOW *key_label;
- WINDOW *value_label;
struct value_list *vl;
struct tree_view *keys;
bool tree_input;
@@ -87,18 +94,26 @@ static struct tree_node *load_hives(TALLOC_CTX *mem_ctx,
return root;
}
-static void print_heading(WINDOW *win, bool selected, const char *str)
+static void print_heading(struct regedit *regedit)
{
- if (selected) {
- wattron(win, A_REVERSE);
+ move(HEADING_START_Y, 0);
+ clrtoeol();
+
+ if (regedit->tree_input) {
+ attron(A_REVERSE);
+ } else {
+ attroff(A_REVERSE);
+ }
+ mvprintw(HEADING_START_Y, KEY_START_X, "Key");
+ attroff(A_REVERSE);
+
+ if (!regedit->tree_input) {
+ attron(A_REVERSE);
} else {
- wattroff(win, A_REVERSE);
+ attroff(A_REVERSE);
}
- wmove(win, 0, 0);
- wclrtoeol(win);
- waddstr(win, str);
- wnoutrefresh(win);
- wrefresh(win);
+ mvprintw(HEADING_START_Y, VAL_START_X, "Value");
+ attroff(A_REVERSE);
}
static void add_reg_key(struct regedit *regedit, struct tree_node *node,
@@ -303,8 +318,6 @@ static void handle_value_input(struct regedit *regedit, int c)
vitem->value_name);
value_list_load(regedit->vl, node->key);
}
-
-
}
break;
}
@@ -317,10 +330,7 @@ static void handle_main_input(struct regedit *regedit, int c)
switch (c) {
case '\t':
regedit->tree_input = !regedit->tree_input;
- print_heading(regedit->key_label, regedit->tree_input == true,
- "Keys");
- print_heading(regedit->value_label, regedit->tree_input == false,
- "Values");
+ print_heading(regedit);
break;
default:
if (regedit->tree_input) {
@@ -343,47 +353,44 @@ static void display_test_window(TALLOC_CTX *mem_ctx,
start_color();
cbreak();
noecho();
- keypad(stdscr, TRUE);
regedit = talloc_zero(mem_ctx, struct regedit);
SMB_ASSERT(regedit != NULL);
- regedit->main_window = newwin(25, 80, 0, 0);
- SMB_ASSERT(regedit->main_window != NULL);
-
+ regedit->main_window = stdscr;
keypad(regedit->main_window, TRUE);
mvwprintw(regedit->main_window, 0, 0, "Path: ");
- regedit->path_label = derwin(regedit->main_window, 1, 65, 0, 6);
+ regedit->path_label = derwin(regedit->main_window, 1, COLS - 6, 0, 6);
wprintw(regedit->path_label, "/");
root = load_hives(regedit, ctx);
SMB_ASSERT(root != NULL);
- regedit->key_label = derwin(regedit->main_window, 1, 10, 2, 0);
- regedit->value_label = derwin(regedit->main_window, 1, 10, 2, 25);
-
- print_heading(regedit->key_label, true, "Keys");
- regedit->keys = tree_view_new(regedit, root, regedit->main_window,
- 15, 24, 3, 0);
+ regedit->keys = tree_view_new(regedit, root, KEY_HEIGHT, KEY_WIDTH,
+ KEY_START_Y, KEY_START_X);
SMB_ASSERT(regedit->keys != NULL);
- print_heading(regedit->value_label, false, "Values");
- regedit->vl = value_list_new(regedit, regedit->main_window,
- 15, 40, 3, 25);
+ regedit->vl = value_list_new(regedit, VAL_HEIGHT, VAL_WIDTH,
+ VAL_START_Y, VAL_START_X);
SMB_ASSERT(regedit->vl != NULL);
regedit->tree_input = true;
+ print_heading(regedit);
tree_view_show(regedit->keys);
value_list_show(regedit->vl);
- regedit->main_panel = new_panel(regedit->main_window);
- SMB_ASSERT(regedit->main_panel != NULL);
-
update_panels();
doupdate();
while ((c = wgetch(regedit->main_window)) != 'q') {
+ if (c == KEY_RESIZE) {
+ tree_view_resize(regedit->keys, KEY_HEIGHT, KEY_WIDTH,
+ KEY_START_Y, KEY_START_X);
+ value_list_resize(regedit->vl, VAL_HEIGHT, VAL_WIDTH,
+ VAL_START_Y, VAL_START_X);
+ print_heading(regedit);
+ }
handle_main_input(regedit, c);
update_panels();
doupdate();
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c
index e7808e1495..802e6a806e 100644
--- a/source3/utils/regedit_dialog.c
+++ b/source3/utils/regedit_dialog.c
@@ -138,10 +138,10 @@ static void center_dialog_above_window(WINDOW *below, int *nlines, int *ncols,
}
if (*nlines < centery) {
- *y = centery - *nlines;
+ *y = centery - *nlines / 2;
}
if (*ncols < centerx) {
- *x = centerx - *ncols;
+ *x = centerx - *ncols / 2;
}
}
diff --git a/source3/utils/regedit_treeview.c b/source3/utils/regedit_treeview.c
index fb6247faac..8d677c8a14 100644
--- a/source3/utils/regedit_treeview.c
+++ b/source3/utils/regedit_treeview.c
@@ -297,6 +297,12 @@ static int tree_view_free(struct tree_view *view)
if (view->empty[0]) {
free_item(view->empty[0]);
}
+ if (view->panel) {
+ del_panel(view->panel);
+ }
+ if (view->window) {
+ delwin(view->window);
+ }
tree_view_free_current_items(view->current_items);
tree_node_free_recursive(view->root);
@@ -304,8 +310,8 @@ static int tree_view_free(struct tree_view *view)
}
struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
- WINDOW *orig, int nlines, int ncols,
- int begin_y, int begin_x)
+ int nlines, int ncols, int begin_y,
+ int begin_x)
{
struct tree_view *view;
static const char *dummy = "(empty)";
@@ -321,9 +327,12 @@ struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
if (view->empty[0] == NULL) {
goto fail;
}
- view->window = orig;
- view->sub_window = derwin(orig, nlines, ncols, begin_y, begin_x);
- if (view->sub_window == NULL) {
+ view->window = newwin(nlines, ncols, begin_y, begin_x);
+ if (view->window == NULL) {
+ goto fail;
+ }
+ view->panel = new_panel(view->window);
+ if (view->panel == NULL) {
goto fail;
}
view->root = root;
@@ -334,7 +343,6 @@ struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
}
set_menu_format(view->menu, nlines, 1);
set_menu_win(view->menu, view->window);
- set_menu_sub(view->menu, view->sub_window);
menu_opts_off(view->menu, O_SHOWDESC);
set_menu_mark(view->menu, "* ");
@@ -348,6 +356,21 @@ fail:
return NULL;
}
+void tree_view_resize(struct tree_view *view, int nlines, int ncols,
+ int begin_y, int begin_x)
+{
+ WINDOW *nwin;
+
+ unpost_menu(view->menu);
+ nwin = newwin(nlines, ncols, begin_y, begin_x);
+ replace_panel(view->panel, nwin);
+ delwin(view->window);
+ view->window = nwin;
+ set_menu_format(view->menu, nlines, 1);
+ set_menu_win(view->menu, view->window);
+ post_menu(view->menu);
+}
+
static void print_path_recursive(WINDOW *label, struct tree_node *node)
{
if (node->parent)
diff --git a/source3/utils/regedit_treeview.h b/source3/utils/regedit_treeview.h
index 52b64da5f8..3008372452 100644
--- a/source3/utils/regedit_treeview.h
+++ b/source3/utils/regedit_treeview.h
@@ -23,6 +23,7 @@
#include "includes.h"
#include <ncurses.h>
#include <menu.h>
+#include <panel.h>
struct registry_key;
@@ -42,7 +43,7 @@ struct tree_view {
struct tree_node *root;
WINDOW *window;
- WINDOW *sub_window;
+ PANEL *panel;
MENU *menu;
ITEM **current_items;
ITEM *empty[2];
@@ -58,8 +59,10 @@ void tree_node_append_last(struct tree_node *list, struct tree_node *node);
void tree_node_free_recursive(struct tree_node *list);
void tree_node_print_path(WINDOW *label, struct tree_node *node);
struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
- WINDOW *orig, int nlines, int ncols,
+ int nlines, int ncols,
int begin_y, int begin_x);
+void tree_view_resize(struct tree_view *view, int nlines, int ncols,
+ int begin_y, int begin_x);
void tree_view_show(struct tree_view *view);
void tree_view_clear(struct tree_view *view);
WERROR tree_view_update(struct tree_view *view, struct tree_node *list);
diff --git a/source3/utils/regedit_valuelist.c b/source3/utils/regedit_valuelist.c
index 644375283d..6a02858918 100644
--- a/source3/utils/regedit_valuelist.c
+++ b/source3/utils/regedit_valuelist.c
@@ -49,13 +49,19 @@ static int value_list_free(struct value_list *vl)
if (vl->empty && vl->empty[0]) {
free_item(vl->empty[0]);
}
+ if (vl->panel) {
+ del_panel(vl->panel);
+ }
+ if (vl->window) {
+ delwin(vl->window);
+ }
value_list_free_items(vl->items);
return 0;
}
-struct value_list *value_list_new(TALLOC_CTX *ctx, WINDOW *orig, int nlines,
- int ncols, int begin_y, int begin_x)
+struct value_list *value_list_new(TALLOC_CTX *ctx, int nlines, int ncols,
+ int begin_y, int begin_x)
{
static const char *empty = "(no values)";
static const char *empty_desc = "";
@@ -77,8 +83,14 @@ struct value_list *value_list_new(TALLOC_CTX *ctx, WINDOW *orig, int nlines,
goto fail;
}
- vl->window = orig;
- vl->sub_window = derwin(orig, nlines, ncols, begin_y, begin_x);
+ vl->window = newwin(nlines, ncols, begin_y, begin_x);
+ if (vl->window == NULL) {
+ goto fail;
+ }
+ vl->panel = new_panel(vl->window);
+ if (vl->panel == NULL) {
+ goto fail;
+ }
vl->menu = new_menu(vl->empty);
if (vl->menu == NULL) {
@@ -87,7 +99,7 @@ struct value_list *value_list_new(TALLOC_CTX *ctx, WINDOW *orig, int nlines,
set_menu_format(vl->menu, nlines, 1);
set_menu_win(vl->menu, vl->window);
- set_menu_sub(vl->menu, vl->sub_window);
+
menu_opts_on(vl->menu, O_SHOWDESC);
set_menu_mark(vl->menu, "* ");
@@ -99,6 +111,21 @@ fail:
return NULL;
}
+void value_list_resize(struct value_list *vl, int nlines, int ncols,
+ int begin_y, int begin_x)
+{
+ WINDOW *nwin;
+
+ unpost_menu(vl->menu);
+ nwin = newwin(nlines, ncols, begin_y, begin_x);
+ replace_panel(vl->panel, nwin);
+ delwin(vl->window);
+ vl->window = nwin;
+ set_menu_format(vl->menu, nlines, 1);
+ set_menu_win(vl->menu, vl->window);
+ post_menu(vl->menu);
+}
+
static uint32_t get_num_values(TALLOC_CTX *ctx, const struct registry_key *key)
{
const char *classname;
diff --git a/source3/utils/regedit_valuelist.h b/source3/utils/regedit_valuelist.h
index 5d5399905c..2923e98964 100644
--- a/source3/utils/regedit_valuelist.h
+++ b/source3/utils/regedit_valuelist.h
@@ -23,6 +23,7 @@
#include "includes.h"
#include <ncurses.h>
#include <menu.h>
+#include <panel.h>
struct registry_key;
@@ -35,15 +36,17 @@ struct value_item {
struct value_list {
WINDOW *window;
- WINDOW *sub_window;
+ PANEL *panel;
MENU *menu;
ITEM **items;
ITEM **empty;
}
;
-struct value_list *value_list_new(TALLOC_CTX *ctx, WINDOW *orig, int nlines,
- int ncols, int begin_y, int begin_x);
+struct value_list *value_list_new(TALLOC_CTX *ctx, int nlines, int ncols,
+ int begin_y, int begin_x);
void value_list_show(struct value_list *vl);
WERROR value_list_load(struct value_list *vl, struct registry_key *key);
+void value_list_resize(struct value_list *vl, int nlines, int ncols,
+ int begin_y, int begin_x);
#endif