summaryrefslogtreecommitdiffstats
path: root/src/client/ui.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 23:31:54 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 23:31:54 +0100
commit7d18a268547734daf19a740b6533e9c1697baf1a (patch)
tree789f519a19b053b8ad0ff41d2828fe22c06fb21a /src/client/ui.rs
parentv1.2.0: show the symbol paytable on the slots board (diff)
downloadzagan-bet-7d18a268547734daf19a740b6533e9c1697baf1a.tar.gz
zagan-bet-7d18a268547734daf19a740b6533e9c1697baf1a.zip
v1.2.1: track wrapped board lines and split the paytable
Diffstat (limited to 'src/client/ui.rs')
-rw-r--r--src/client/ui.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/client/ui.rs b/src/client/ui.rs
index 493f660..11cedc7 100644
--- a/src/client/ui.rs
+++ b/src/client/ui.rs
@@ -257,6 +257,23 @@ pub fn input_cursor_column(prompt_len: usize, input_len: usize) -> u16 {
257 .min(u16::MAX as usize) as u16 257 .min(u16::MAX as usize) as u16
258} 258}
259 259
260/// Number of terminal rows a block of logical lines occupies after wrapping.
261/// Empty lines still occupy one row.
262pub fn visual_line_count(lines: &[String], width: usize) -> usize {
263 let width = width.max(1);
264 lines
265 .iter()
266 .map(|line| {
267 let columns = display_width(line);
268 if columns == 0 {
269 1
270 } else {
271 columns.div_ceil(width)
272 }
273 })
274 .sum()
275}
276
260/// Format a ping round-trip time with one decimal place. 277/// Format a ping round-trip time with one decimal place.
261pub fn format_pong(elapsed: std::time::Duration) -> String { 278pub fn format_pong(elapsed: std::time::Duration) -> String {
262 format!("Pong ({:.1}ms)", elapsed.as_secs_f64() * 1000.0) 279 format!("Pong ({:.1}ms)", elapsed.as_secs_f64() * 1000.0)