diff options
author | C. Davis <cd.rattan@gmail.com> | 2012-08-11 23:22:06 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-04-29 13:06:25 +0200 |
commit | dc119eb9b2881c0f3cf92a0c77fe71411a6a1a13 (patch) | |
tree | aabaf93701bd209520448268fea877ee4619d730 /source3/utils | |
parent | 485af4a785e16b9a219363be50e996e50bca8f77 (diff) | |
download | samba-dc119eb9b2881c0f3cf92a0c77fe71411a6a1a13.tar.gz |
regedit: Cut off the front of the path when screen width is too small.
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.c | 16 | ||||
-rw-r--r-- | source3/utils/regedit_treeview.c | 15 | ||||
-rw-r--r-- | source3/utils/regedit_treeview.h | 2 |
3 files changed, 24 insertions, 9 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 51528a8d11..efea07b89c 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -42,12 +42,14 @@ #define INFO_WIDTH (LINES) #define PATH_START_Y 0 #define PATH_START_X 6 -#define PATH_MAX_Y (COLS-1) +#define PATH_MAX_Y (COLS - 1) +#define PATH_WIDTH (COLS - 6) #define PATH_WIDTH_MAX 1024 struct regedit { WINDOW *main_window; WINDOW *path_label; + size_t path_len; struct value_list *vl; struct tree_view *keys; bool tree_input; @@ -57,13 +59,21 @@ 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, + int start_pad = 0; + int start_win = PATH_START_X; + + if (PATH_START_X + regedit->path_len > COLS) { + start_pad = 3 + PATH_START_X + regedit->path_len - COLS; + mvprintw(PATH_START_Y, start_win, "..."); + start_win += 3; + } + prefresh(regedit->path_label, 0, start_pad, PATH_START_Y, start_win, 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); + regedit->path_len = tree_node_print_path(regedit->path_label, node); } /* load all available hives */ diff --git a/source3/utils/regedit_treeview.c b/source3/utils/regedit_treeview.c index d19866e684..f0c3bd81f8 100644 --- a/source3/utils/regedit_treeview.c +++ b/source3/utils/regedit_treeview.c @@ -371,23 +371,28 @@ void tree_view_resize(struct tree_view *view, int nlines, int ncols, post_menu(view->menu); } -static void print_path_recursive(WINDOW *label, struct tree_node *node) +static void print_path_recursive(WINDOW *label, struct tree_node *node, size_t *len) { if (node->parent) - print_path_recursive(label, node->parent); + print_path_recursive(label, node->parent, len); wprintw(label, "%s/", node->name); + *len += 1 + strlen(node->name); } /* print the path of node to label */ -void tree_node_print_path(WINDOW *label, struct tree_node *node) +size_t tree_node_print_path(WINDOW *label, struct tree_node *node) { + size_t len = 1; + if (node == NULL) - return; + return 0; werase(label); wprintw(label, "/"); if (node->parent) - print_path_recursive(label, node->parent); + print_path_recursive(label, node->parent, &len); + + return len; } diff --git a/source3/utils/regedit_treeview.h b/source3/utils/regedit_treeview.h index 3008372452..39314418c6 100644 --- a/source3/utils/regedit_treeview.h +++ b/source3/utils/regedit_treeview.h @@ -57,7 +57,7 @@ struct tree_node *tree_node_first(struct tree_node *list); struct tree_node *tree_node_last(struct tree_node *list); 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); +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); |