From e50f02f56aa38d87dbdc7cbb128a59aac5fabf2c Mon Sep 17 00:00:00 2001 From: andersendsa <199610634+andersendsa@users.noreply.github.com> Date: Fri, 26 Jun 2026 03:20:15 +0000 Subject: [PATCH 1/2] Fix address truncation in interactive histogram X-axis ruler The interactive horizontal histogram (`p==`) truncated the rightmost address offset on the X-axis ruler to a single character (e.g. `0` instead of `0x...`) because `max_room` for the last label tick was constrained to `data_cols - start_col`. This commit replaces the `max_room` calculation for the last tick so that it does not aggressively truncate the label, allowing the full address to be displayed correctly. --- librz/cons/histogram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librz/cons/histogram.c b/librz/cons/histogram.c index c0f91f376ad..eda67dcbd9f 100644 --- a/librz/cons/histogram.c +++ b/librz/cons/histogram.c @@ -733,7 +733,7 @@ static void render_visual_xaxis_ruler(RzStrBuf *buf, const RzHistogramInteractiv if (t + 1 < ticks) { max_room = tick_cols[t + 1] - start_col - 1; } else { - max_room = (int)data_cols - start_col; + max_room = sizeof(label); } if (max_room < 1) { max_room = 1; From 89bc19bead4a85714faa438ec02d7a39529a9310 Mon Sep 17 00:00:00 2001 From: andersendsa Date: Fri, 26 Jun 2026 16:13:03 +0530 Subject: [PATCH 2/2] fix ci failure --- librz/cons/histogram.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/librz/cons/histogram.c b/librz/cons/histogram.c index eda67dcbd9f..940ea37ba57 100644 --- a/librz/cons/histogram.c +++ b/librz/cons/histogram.c @@ -712,14 +712,12 @@ static void render_visual_xaxis_ruler(RzStrBuf *buf, const RzHistogramInteractiv int realj, max_room, wrote; ut64 off; char label[32] = { 0 }; - if ((int)c < start_col) { - rz_strbuf_appendf(buf, "%*s", start_col - (int)c, ""); - c = (ut32)start_col; - } + + // Calculate label value early to know its length before padding if (sizeofonebar > 1) { - realj = adder + (int)c / sizeofonebar; + realj = adder + start_col / sizeofonebar; } else { - realj = adder + (int)((ut64)c * histogramwidth / ((ut64)zoom * width)); + realj = adder + (int)((ut64)start_col * histogramwidth / ((ut64)zoom * width)); } if (realj < 0) { realj = 0; @@ -729,6 +727,26 @@ static void render_visual_xaxis_ruler(RzStrBuf *buf, const RzHistogramInteractiv off = opts->offpos + (ut64)realj * hist->blocksize; rz_strf(label, "0x%" PFMT64x, off); wrote = (int)strlen(label); + + // If this is the last tick, shift start_col to the left so the whole label fits + if (t + 1 == ticks && wrote > 0) { + int new_start = (int)data_cols - wrote; + if (new_start < 0) { + new_start = 0; + } + if (t > 0 && new_start <= tick_cols[t - 1]) { + new_start = tick_cols[t - 1] + 1; + } + if (new_start < start_col && (int)c <= new_start) { + start_col = new_start; + } + } + + if ((int)c < start_col) { + rz_strbuf_appendf(buf, "%*s", start_col - (int)c, ""); + c = (ut32)start_col; + } + // Truncate if the label would overflow into the next tick. if (t + 1 < ticks) { max_room = tick_cols[t + 1] - start_col - 1;