diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-25 15:02:26 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-25 15:02:26 +0000 |
commit | f1c57085607bbc64c55438595c583f885aa086c3 (patch) | |
tree | efb3074d101d5017c36dbf51ecd8b43946a4a0e5 /usr.bin | |
parent | d319a08799295a67e35256e2d64747c66d1ae575 (diff) |
Make some data types consistent.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/format.c | 37 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 10 | ||||
-rw-r--r-- | usr.bin/tmux/utf8.c | 12 |
3 files changed, 42 insertions, 17 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 1b33b71f9bd..92e0ac81587 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.255 2020/05/16 16:02:24 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.256 2020/05/25 15:02:25 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -761,22 +761,46 @@ format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe) struct window_pane *wp = ft->wp; struct grid *gd; struct grid_line *gl; - unsigned long long size; + size_t size = 0; u_int i; if (wp == NULL) return; gd = wp->base.grid; - size = 0; - for (i = 0; i < gd->hsize; i++) { + for (i = 0; i < gd->hsize + gd->sy; i++) { gl = grid_get_line(gd, i); size += gl->cellsize * sizeof *gl->celldata; size += gl->extdsize * sizeof *gl->extddata; } - size += gd->hsize * sizeof *gl; + size += (gd->hsize + gd->sy) * sizeof *gl; - xasprintf(&fe->value, "%llu", size); + xasprintf(&fe->value, "%zu", size); +} + +/* Callback for history_all_bytes. */ +static void +format_cb_history_all_bytes(struct format_tree *ft, struct format_entry *fe) +{ + struct window_pane *wp = ft->wp; + struct grid *gd; + struct grid_line *gl; + u_int i, lines, cells = 0, extended_cells = 0; + + if (wp == NULL) + return; + gd = wp->base.grid; + + lines = gd->hsize + gd->sy; + for (i = 0; i < lines; i++) { + gl = grid_get_line(gd, i); + cells += gl->cellsize; + extended_cells += gl->extdsize; + } + + xasprintf(&fe->value, "%u,%zu,%u,%zu,%u,%zu", lines, + lines * sizeof *gl, cells, cells * sizeof *gl->celldata, + extended_cells, extended_cells * sizeof *gl->extddata); } /* Callback for pane_tabs. */ @@ -2823,6 +2847,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp) format_add(ft, "history_size", "%u", gd->hsize); format_add(ft, "history_limit", "%u", gd->hlimit); format_add_cb(ft, "history_bytes", format_cb_history_bytes); + format_add_cb(ft, "history_all_bytes", format_cb_history_all_bytes); format_add(ft, "pane_written", "%zu", wp->written); format_add(ft, "pane_skipped", "%zu", wp->skipped); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index eca2e1c85dc..636cb64346f 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1053 2020/05/25 09:32:10 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1054 2020/05/25 15:02:25 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -673,7 +673,7 @@ struct grid_cell { /* Grid extended cell entry. */ struct grid_extd_entry { - uint32_t data; + u_int data; u_short attr; u_char flags; int fg; @@ -2889,9 +2889,9 @@ u_int session_group_attached_count(struct session_group *); void session_renumber_windows(struct session *); /* utf8.c */ -uint32_t utf8_set_big(char, u_int); -uint32_t utf8_map_big(const struct utf8_data *); -void utf8_get_big(uint32_t, struct utf8_data *); +u_int utf8_set_big(char, u_int); +u_int utf8_map_big(const struct utf8_data *); +void utf8_get_big(u_int, struct utf8_data *); void utf8_set(struct utf8_data *, u_char); void utf8_copy(struct utf8_data *, const struct utf8_data *); enum utf8_state utf8_open(struct utf8_data *, u_char); diff --git a/usr.bin/tmux/utf8.c b/usr.bin/tmux/utf8.c index 95981b8b689..76e44472384 100644 --- a/usr.bin/tmux/utf8.c +++ b/usr.bin/tmux/utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utf8.c,v 1.45 2020/05/25 09:32:10 nicm Exp $ */ +/* $OpenBSD: utf8.c,v 1.46 2020/05/25 15:02:25 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -55,7 +55,7 @@ static u_int utf8_big_list_size; static u_int utf8_big_list_used; union utf8_big_map { - uint32_t value; + u_int value; struct { u_char flags; #define UTF8_BIG_SIZE 0x1f @@ -125,7 +125,7 @@ utf8_put_big_item(const char *data, size_t size, u_int *index) } /* Get UTF-8 as index into buffer. */ -uint32_t +u_int utf8_map_big(const struct utf8_data *ud) { union utf8_big_map m = { .value = 0 }; @@ -165,7 +165,7 @@ fail: /* Get UTF-8 from index into buffer. */ void -utf8_get_big(uint32_t v, struct utf8_data *ud) +utf8_get_big(u_int v, struct utf8_data *ud) { union utf8_big_map m = { .value = v }; struct utf8_big_item *bi; @@ -183,7 +183,7 @@ utf8_get_big(uint32_t v, struct utf8_data *ud) return; } - o = ((uint32_t)m.data[2] << 16)|((uint32_t)m.data[1] << 8)|m.data[0]; + o = ((u_int)m.data[2] << 16)|((u_int)m.data[1] << 8)|m.data[0]; if (o >= utf8_big_list_used) memset(ud->data, ' ', ud->size); else { @@ -193,7 +193,7 @@ utf8_get_big(uint32_t v, struct utf8_data *ud) } /* Get big value for UTF-8 single character. */ -uint32_t +u_int utf8_set_big(char c, u_int width) { union utf8_big_map m = { .flags = 1, .data[0] = c }; |