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 | |
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')
-rw-r--r-- | source3/utils/regedit_dialog.c | 4 | ||||
-rw-r--r-- | source3/utils/regedit_hexedit.c | 45 | ||||
-rw-r--r-- | source3/utils/regedit_hexedit.h | 4 |
3 files changed, 15 insertions, 38 deletions
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c index d8ffa9f7506..3c577737280 100644 --- a/source3/utils/regedit_dialog.c +++ b/source3/utils/regedit_dialog.c @@ -1037,8 +1037,8 @@ static WERROR hexedit_create(struct dialog *dia, struct dialog_section_hexedit *hexedit = talloc_get_type_abort(section, struct dialog_section_hexedit); - hexedit->buf = hexedit_new(dia, section->window, section->nlines, - 0, 0, NULL, HEXEDIT_MIN_SIZE); + hexedit->buf = hexedit_new(dia, section->window, NULL, + HEXEDIT_MIN_SIZE); if (hexedit->buf == NULL) { return WERR_NOMEM; } 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) diff --git a/source3/utils/regedit_hexedit.h b/source3/utils/regedit_hexedit.h index af2432a05ae..dc13c21194f 100644 --- a/source3/utils/regedit_hexedit.h +++ b/source3/utils/regedit_hexedit.h @@ -34,8 +34,8 @@ enum { #define LINE_WIDTH 44 struct hexedit; -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 hexedit_set_buf(struct hexedit *buf, const void *data, size_t sz); const void *hexedit_get_buf(struct hexedit *buf); size_t hexedit_get_buf_len(struct hexedit *buf); |