1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

regedit: Uese a pad for path label.

This makes it easier scale the label on resize.

Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
C. Davis 2012-08-11 22:10:51 -07:00 committed by Michael Adam
parent a857475501
commit 485af4a785
2 changed files with 28 additions and 16 deletions

View File

@ -32,12 +32,18 @@
#define KEY_START_X 0 #define KEY_START_X 0
#define KEY_START_Y 3 #define KEY_START_Y 3
#define KEY_WIDTH (COLS / 4) #define KEY_WIDTH (COLS / 4)
#define KEY_HEIGHT (LINES - KEY_START_Y) #define KEY_HEIGHT (LINES - KEY_START_Y - 1)
#define VAL_START_X KEY_WIDTH #define VAL_START_X KEY_WIDTH
#define VAL_START_Y 3 #define VAL_START_Y 3
#define VAL_WIDTH (COLS - KEY_WIDTH) #define VAL_WIDTH (COLS - KEY_WIDTH)
#define VAL_HEIGHT (LINES - VAL_START_Y) #define VAL_HEIGHT (LINES - VAL_START_Y - 1)
#define HEADING_START_Y KEY_START_Y - 1 #define HEADING_START_Y (KEY_START_Y - 1)
#define INFO_START_Y (LINES - 1)
#define INFO_WIDTH (LINES)
#define PATH_START_Y 0
#define PATH_START_X 6
#define PATH_MAX_Y (COLS-1)
#define PATH_WIDTH_MAX 1024
struct regedit { struct regedit {
WINDOW *main_window; WINDOW *main_window;
@ -49,6 +55,17 @@ struct regedit {
static struct regedit *regedit_main = NULL; static struct regedit *regedit_main = NULL;
static void show_path(struct regedit *regedit)
{
prefresh(regedit->path_label, 0, 0, PATH_START_Y, PATH_START_X,
PATH_START_Y, PATH_MAX_Y);
}
static void print_path(struct regedit *regedit, struct tree_node *node)
{
tree_node_print_path(regedit->path_label, node);
}
/* load all available hives */ /* load all available hives */
static struct tree_node *load_hives(TALLOC_CTX *mem_ctx, static struct tree_node *load_hives(TALLOC_CTX *mem_ctx,
struct registry_context *ctx) struct registry_context *ctx)
@ -193,8 +210,7 @@ static void handle_tree_input(struct regedit *regedit, int c)
node = item_userptr(current_item(regedit->keys->menu)); node = item_userptr(current_item(regedit->keys->menu));
if (node && tree_node_has_children(node)) { if (node && tree_node_has_children(node)) {
tree_node_load_children(node); tree_node_load_children(node);
tree_node_print_path(regedit->path_label, print_path(regedit, node->child_head);
node->child_head);
tree_view_update(regedit->keys, node->child_head); tree_view_update(regedit->keys, node->child_head);
value_list_load(regedit->vl, node->child_head->key); value_list_load(regedit->vl, node->child_head->key);
} }
@ -202,7 +218,7 @@ static void handle_tree_input(struct regedit *regedit, int c)
case KEY_LEFT: case KEY_LEFT:
node = item_userptr(current_item(regedit->keys->menu)); node = item_userptr(current_item(regedit->keys->menu));
if (node && node->parent) { if (node && node->parent) {
tree_node_print_path(regedit->path_label, node->parent); print_path(regedit, node->parent);
node = tree_node_first(node->parent); node = tree_node_first(node->parent);
tree_view_update(regedit->keys, node); tree_view_update(regedit->keys, node);
value_list_load(regedit->vl, node->key); value_list_load(regedit->vl, node->key);
@ -243,8 +259,7 @@ static void handle_tree_input(struct regedit *regedit, int c)
node = parent->child_head; node = parent->child_head;
if (node == NULL) { if (node == NULL) {
node = tree_node_first(parent); node = tree_node_first(parent);
tree_node_print_path(regedit->path_label, print_path(regedit, node);
node);
} }
tree_view_update(regedit->keys, node); tree_view_update(regedit->keys, node);
value_list_load(regedit->vl, node->key); value_list_load(regedit->vl, node->key);
@ -344,7 +359,6 @@ int regedit_getch(void)
SMB_ASSERT(regedit_main); SMB_ASSERT(regedit_main);
c = getch(); c = getch();
if (c == KEY_RESIZE) { if (c == KEY_RESIZE) {
tree_view_resize(regedit_main->keys, KEY_HEIGHT, KEY_WIDTH, tree_view_resize(regedit_main->keys, KEY_HEIGHT, KEY_WIDTH,
KEY_START_Y, KEY_START_X); KEY_START_Y, KEY_START_X);
@ -375,7 +389,8 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
keypad(regedit->main_window, TRUE); keypad(regedit->main_window, TRUE);
mvwprintw(regedit->main_window, 0, 0, "Path: "); mvwprintw(regedit->main_window, 0, 0, "Path: ");
regedit->path_label = derwin(regedit->main_window, 1, COLS - 6, 0, 6); regedit->path_label = newpad(1, PATH_WIDTH_MAX);
SMB_ASSERT(regedit->path_label);
wprintw(regedit->path_label, "/"); wprintw(regedit->path_label, "/");
root = load_hives(regedit, ctx); root = load_hives(regedit, ctx);
@ -397,6 +412,7 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
update_panels(); update_panels();
doupdate(); doupdate();
show_path(regedit_main);
while (1) { while (1) {
c = regedit_getch(); c = regedit_getch();
if (c == 'q' || c == 'Q') { if (c == 'q' || c == 'Q') {
@ -405,6 +421,7 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
handle_main_input(regedit, c); handle_main_input(regedit, c);
update_panels(); update_panels();
doupdate(); doupdate();
show_path(regedit_main);
} }
endwin(); endwin();

View File

@ -385,14 +385,9 @@ void tree_node_print_path(WINDOW *label, struct tree_node *node)
if (node == NULL) if (node == NULL)
return; return;
wmove(label, 0, 0); werase(label);
wclrtoeol(label);
wprintw(label, "/"); wprintw(label, "/");
wmove(label, 0, 1);
if (node->parent) if (node->parent)
print_path_recursive(label, node->parent); print_path_recursive(label, node->parent);
wnoutrefresh(label);
wrefresh(label);
} }