summaryrefslogtreecommitdiffstats
path: root/source3/utils
diff options
context:
space:
mode:
authorChris Davis <cd.rattan@gmail.com>2014-05-20 16:17:42 -0700
committerMichael Adam <obnox@samba.org>2014-10-01 14:32:08 +0200
commitc79837c215de59fa07b665bb79149058f36828d7 (patch)
treeee99d68d82b77d32ae2a11780c95d3c98115ce7b /source3/utils
parentb48f081dc681a0a769165da43668b356c71fdb35 (diff)
regedit: add borders around key and value lists, and change headings
Signed-off-by: Chris Davis <cd.rattan@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/regedit.c25
-rw-r--r--source3/utils/regedit_treeview.c32
-rw-r--r--source3/utils/regedit_treeview.h2
-rw-r--r--source3/utils/regedit_valuelist.c29
-rw-r--r--source3/utils/regedit_valuelist.h2
5 files changed, 70 insertions, 20 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c
index 5e6db7e629..86983c2f08 100644
--- a/source3/utils/regedit.c
+++ b/source3/utils/regedit.c
@@ -30,14 +30,14 @@
#include <panel.h>
#define KEY_START_X 0
-#define KEY_START_Y 3
+#define KEY_START_Y 1
#define KEY_WIDTH (COLS / 4)
#define KEY_HEIGHT (LINES - KEY_START_Y - 2)
#define VAL_START_X KEY_WIDTH
-#define VAL_START_Y 3
+#define VAL_START_Y 1
#define VAL_WIDTH (COLS - KEY_WIDTH)
#define VAL_HEIGHT (LINES - VAL_START_Y - 2)
-#define HEADING_START_Y (KEY_START_Y - 1)
+
#define HELP1_START_Y (LINES - 2)
#define HELP1_START_X 0
#define HELP1_WIDTH (LINES)
@@ -164,24 +164,13 @@ static void print_help(struct regedit *regedit)
static void print_heading(struct regedit *regedit)
{
- 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);
+ tree_view_set_selected(regedit->keys, true);
+ value_list_set_selected(regedit->vl, false);
} else {
- attroff(A_REVERSE);
+ tree_view_set_selected(regedit->keys, false);
+ value_list_set_selected(regedit->vl, true);
}
- mvprintw(HEADING_START_Y, VAL_START_X, "Value");
- attroff(A_REVERSE);
print_help(regedit);
}
diff --git a/source3/utils/regedit_treeview.c b/source3/utils/regedit_treeview.c
index 1f2354ad35..f2241e65f4 100644
--- a/source3/utils/regedit_treeview.c
+++ b/source3/utils/regedit_treeview.c
@@ -20,6 +20,8 @@
#include "regedit_treeview.h"
#include "lib/registry/registry.h"
+#define HEADING_X 3
+
struct tree_node *tree_node_new(TALLOC_CTX *ctx, struct tree_node *parent,
const char *name, struct registry_key *key)
{
@@ -284,6 +286,16 @@ fail:
return WERR_NOMEM;
}
+void tree_view_set_selected(struct tree_view *view, bool select)
+{
+ attr_t attr = A_NORMAL;
+
+ if (select) {
+ attr = A_REVERSE;
+ }
+ mvwchgat(view->window, 0, HEADING_X, 3, attr, 0, NULL);
+}
+
void tree_view_show(struct tree_view *view)
{
post_menu(view->menu);
@@ -301,6 +313,9 @@ static int tree_view_free(struct tree_view *view)
if (view->panel) {
del_panel(view->panel);
}
+ if (view->sub) {
+ delwin(view->sub);
+ }
if (view->window) {
delwin(view->window);
}
@@ -332,6 +347,14 @@ struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
if (view->window == NULL) {
goto fail;
}
+ view->sub = subwin(view->window, nlines - 2, ncols - 2,
+ begin_y + 1, begin_x + 1);
+ if (view->sub == NULL) {
+ goto fail;
+ }
+ box(view->window, 0, 0);
+ mvwprintw(view->window, 0, HEADING_X, "Key");
+
view->panel = new_panel(view->window);
if (view->panel == NULL) {
goto fail;
@@ -344,6 +367,7 @@ 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);
menu_opts_off(view->menu, O_SHOWDESC);
set_menu_mark(view->menu, "* ");
@@ -360,15 +384,21 @@ fail:
void tree_view_resize(struct tree_view *view, int nlines, int ncols,
int begin_y, int begin_x)
{
- WINDOW *nwin;
+ WINDOW *nwin, *nsub;
unpost_menu(view->menu);
nwin = newwin(nlines, ncols, begin_y, begin_x);
+ nsub = subwin(nwin, nlines - 2, ncols - 2, begin_y + 1, begin_x + 1);
replace_panel(view->panel, nwin);
+ delwin(view->sub);
delwin(view->window);
view->window = nwin;
+ view->sub = nsub;
+ box(view->window, 0, 0);
+ mvwprintw(view->window, 0, HEADING_X, "Key");
set_menu_format(view->menu, nlines, 1);
set_menu_win(view->menu, view->window);
+ set_menu_sub(view->menu, view->sub);
post_menu(view->menu);
}
diff --git a/source3/utils/regedit_treeview.h b/source3/utils/regedit_treeview.h
index 39314418c6..66e692eb0f 100644
--- a/source3/utils/regedit_treeview.h
+++ b/source3/utils/regedit_treeview.h
@@ -43,6 +43,7 @@ struct tree_view {
struct tree_node *root;
WINDOW *window;
+ WINDOW *sub;
PANEL *panel;
MENU *menu;
ITEM **current_items;
@@ -61,6 +62,7 @@ size_t tree_node_print_path(WINDOW *label, struct tree_node *node);
struct tree_view *tree_view_new(TALLOC_CTX *ctx, struct tree_node *root,
int nlines, int ncols,
int begin_y, int begin_x);
+void tree_view_set_selected(struct tree_view *view, bool select);
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);
diff --git a/source3/utils/regedit_valuelist.c b/source3/utils/regedit_valuelist.c
index b135159ed9..4d56fa6336 100644
--- a/source3/utils/regedit_valuelist.c
+++ b/source3/utils/regedit_valuelist.c
@@ -20,6 +20,8 @@
#include "regedit_valuelist.h"
#include "lib/registry/registry.h"
+#define HEADING_X 3
+
static void value_list_free_items(ITEM **items)
{
size_t i;
@@ -87,6 +89,14 @@ struct value_list *value_list_new(TALLOC_CTX *ctx, int nlines, int ncols,
if (vl->window == NULL) {
goto fail;
}
+ vl->sub = subwin(vl->window, nlines - 2, ncols - 2,
+ begin_y + 1, begin_x + 1);
+ if (vl->sub == NULL) {
+ goto fail;
+ }
+ box(vl->window, 0, 0);
+ mvwprintw(vl->window, 0, HEADING_X, "Value");
+
vl->panel = new_panel(vl->window);
if (vl->panel == NULL) {
goto fail;
@@ -99,6 +109,7 @@ struct value_list *value_list_new(TALLOC_CTX *ctx, int nlines, int ncols,
set_menu_format(vl->menu, nlines, 1);
set_menu_win(vl->menu, vl->window);
+ set_menu_sub(vl->menu, vl->sub);
menu_opts_on(vl->menu, O_SHOWDESC);
set_menu_mark(vl->menu, "* ");
@@ -111,18 +122,34 @@ fail:
return NULL;
}
+void value_list_set_selected(struct value_list *vl, bool select)
+{
+ attr_t attr = A_NORMAL;
+
+ if (select) {
+ attr = A_REVERSE;
+ }
+ mvwchgat(vl->window, 0, HEADING_X, 5, attr, 0, NULL);
+}
+
void value_list_resize(struct value_list *vl, int nlines, int ncols,
int begin_y, int begin_x)
{
- WINDOW *nwin;
+ WINDOW *nwin, *nsub;
unpost_menu(vl->menu);
nwin = newwin(nlines, ncols, begin_y, begin_x);
+ nsub = subwin(nwin, nlines - 2, ncols - 2, begin_y + 1, begin_x + 1);
replace_panel(vl->panel, nwin);
+ delwin(vl->sub);
delwin(vl->window);
vl->window = nwin;
+ vl->sub = nsub;
+ box(vl->window, 0, 0);
+ mvwprintw(vl->window, 0, HEADING_X, "Value");
set_menu_format(vl->menu, nlines, 1);
set_menu_win(vl->menu, vl->window);
+ set_menu_sub(vl->menu, vl->sub);
post_menu(vl->menu);
}
diff --git a/source3/utils/regedit_valuelist.h b/source3/utils/regedit_valuelist.h
index d01db51be2..16b0d502b7 100644
--- a/source3/utils/regedit_valuelist.h
+++ b/source3/utils/regedit_valuelist.h
@@ -37,6 +37,7 @@ struct value_item {
struct value_list {
WINDOW *window;
+ WINDOW *sub;
PANEL *panel;
MENU *menu;
ITEM **items;
@@ -46,6 +47,7 @@ struct value_list {
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);
+void value_list_set_selected(struct value_list *vl, bool select);
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);