diff options
author | Chris Davis <cd.rattan@gmail.com> | 2014-07-28 23:23:32 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-10-01 14:32:09 +0200 |
commit | 982c06f55a0ef8a80a0f87c9e77200ce952f85b3 (patch) | |
tree | 424bdb1bb5f547d4e575458f8d8482c8e399b0c4 /source3/utils/regedit_hexedit.c | |
parent | c272178ccc6bb2f3b4a6621ef463489741c7e040 (diff) | |
download | samba-982c06f55a0ef8a80a0f87c9e77200ce952f85b3.tar.gz |
regedit: don't use subwindows in hexedit
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/regedit_hexedit.c')
-rw-r--r-- | source3/utils/regedit_hexedit.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/source3/utils/regedit_hexedit.c b/source3/utils/regedit_hexedit.c index 847c5d888fb..bdc42556389 100644 --- a/source3/utils/regedit_hexedit.c +++ b/source3/utils/regedit_hexedit.c @@ -44,32 +44,19 @@ struct hexedit { int nibble; uint8_t *data; WINDOW *win; - WINDOW *status_line; }; static int max_rows(WINDOW *win) { - int maxy, maxx; + int maxy; - getmaxyx(win, maxy, maxx); + maxy = getmaxy(win); return maxy - 1; } -static int hexedit_free(struct hexedit *buf) -{ - if (buf->status_line) { - delwin(buf->status_line); - } - if (buf->win) { - delwin(buf->win); - } - - return 0; -} - -struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, int nlines, - int y, int x, const void *data, size_t sz) +struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, const void *data, + size_t sz) { WERROR rv; struct hexedit *buf; @@ -79,19 +66,7 @@ struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, int nlines, return NULL; } - talloc_set_destructor(buf, hexedit_free); - - buf->win = derwin(parent, nlines, LINE_WIDTH, y, x); - if (buf->win == NULL) { - goto fail; - } - - buf->status_line = derwin(buf->win, 1, LINE_WIDTH, max_rows(buf->win), - 0); - if (buf->status_line == NULL) { - goto fail; - } - wattron(buf->status_line, A_REVERSE | A_STANDOUT); + buf->win = parent; rv = hexedit_set_buf(buf, data, sz); if (!W_ERROR_IS_OK(rv)) { @@ -147,18 +122,20 @@ static size_t bytes_per_screen(WINDOW *win) void hexedit_set_cursor(struct hexedit *buf) { - werase(buf->status_line); + wmove(buf->win, max_rows(buf->win), 0); + wattron(buf->win, A_REVERSE | A_STANDOUT); + wclrtoeol(buf->win); if (buf->len) { - wprintw(buf->status_line, "Len:%lu Off:%lu Val:0x%X", buf->len, + wprintw(buf->win, "Len:%lu Off:%lu Val:0x%X", buf->len, buf->cursor_offset, buf->data[buf->cursor_offset]); } else { - wprintw(buf->status_line, "Len:%lu (empty)", buf->len); + wprintw(buf->win, "Len:%lu (empty)", buf->len); } + wattroff(buf->win, A_REVERSE | A_STANDOUT); wmove(buf->win, buf->cursor_y, buf->cursor_x); wcursyncup(buf->win); wsyncup(buf->win); untouchwin(buf->win); - wnoutrefresh(buf->status_line); } void hexedit_refresh(struct hexedit *buf) |