• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kdash-rs / kdash / 24912343985

24 Apr 2026 09:17PM UTC coverage: 74.478% (+1.2%) from 73.276%
24912343985

push

github

deepu105
feat: configurable cli info fix #452

187 of 321 new or added lines in 2 files covered. (58.26%)

137 existing lines in 5 files now uncovered.

10949 of 14701 relevant lines covered (74.48%)

130.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.3
/src/ui/utils.rs
1
use std::{borrow::Cow, collections::BTreeMap, io::Cursor, rc::Rc, sync::OnceLock};
2

3
use glob_match::glob_match;
4
use ratatui::{
5
  layout::{Constraint, Direction, Layout, Position, Rect},
6
  style::{Color, Modifier, Style},
7
  symbols,
8
  text::{Line, Span, Text},
9
  widgets::{Block, Borders, Paragraph, Row, Table, Wrap},
10
  Frame,
11
};
12

13
use super::HIGHLIGHT;
14
use crate::app::{
15
  key_binding::DEFAULT_KEYBINDING,
16
  models::{Named, StatefulTable},
17
  ActiveBlock, App,
18
};
19
use crate::event::Key;
20
use crate::ui::theme::override_color;
21
// Viewport width thresholds for responsive column display
22
pub const COMPACT_WIDTH_THRESHOLD: u16 = 120;
23
pub const WIDE_WIDTH_THRESHOLD: u16 = 180;
24

25
/// Which responsive tier the current view is in.
26
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
27
pub enum ViewTier {
28
  Compact,
29
  Standard,
30
  Wide,
31
}
32

33
impl ViewTier {
34
  pub fn from_width(area_width: u16, force_wide: bool) -> Self {
9✔
35
    if force_wide || area_width >= WIDE_WIDTH_THRESHOLD {
9✔
36
      Self::Wide
×
37
    } else if area_width >= COMPACT_WIDTH_THRESHOLD {
9✔
38
      Self::Standard
1✔
39
    } else {
40
      Self::Compact
8✔
41
    }
42
  }
9✔
43
}
44

45
/// Declarative column definition with per-tier width percentages.
46
/// A `None` width means the column is hidden at that tier.
47
pub struct ColumnDef {
48
  pub label: &'static str,
49
  pub compact: Option<u16>,
50
  pub standard: Option<u16>,
51
  pub wide: Option<u16>,
52
}
53

54
impl ColumnDef {
55
  /// Column visible at all tiers with different widths.
56
  pub const fn all(label: &'static str, compact: u16, standard: u16, wide: u16) -> Self {
×
57
    Self {
×
58
      label,
×
59
      compact: Some(compact),
×
60
      standard: Some(standard),
×
61
      wide: Some(wide),
×
62
    }
×
63
  }
×
64

65
  /// Column visible only at Standard and Wide tiers.
66
  pub const fn standard(label: &'static str, standard: u16, wide: u16) -> Self {
×
67
    Self {
×
68
      label,
×
69
      compact: None,
×
70
      standard: Some(standard),
×
71
      wide: Some(wide),
×
72
    }
×
73
  }
×
74

75
  /// Column visible only at Wide tier.
76
  pub const fn wide(label: &'static str, wide: u16) -> Self {
×
77
    Self {
×
78
      label,
×
79
      compact: None,
×
80
      standard: None,
×
81
      wide: Some(wide),
×
82
    }
×
83
  }
×
84
}
85

86
/// Given column definitions and a view tier, return the visible headers and widths.
87
pub fn responsive_columns(columns: &[ColumnDef], tier: ViewTier) -> (Vec<&str>, Vec<Constraint>) {
11✔
88
  columns
11✔
89
    .iter()
11✔
90
    .filter_map(|col| {
91✔
91
      let w = match tier {
91✔
92
        ViewTier::Wide => col.wide,
×
93
        ViewTier::Standard => col.standard,
8✔
94
        ViewTier::Compact => col.compact,
83✔
95
      };
96
      w.map(|w| (col.label, Constraint::Percentage(w)))
91✔
97
    })
91✔
98
    .unzip()
11✔
99
}
11✔
100

101
// Utils
102

103
#[derive(Clone, Debug, PartialEq, Eq)]
104
pub enum LinePart<'a> {
105
  Default(Cow<'a, str>),
106
  Help(Cow<'a, str>),
107
}
108

109
// Catppuccin Macchiato (dark)
110
pub const MACCHIATO_BASE: Color = Color::Rgb(36, 39, 58);
111
pub const MACCHIATO_BLUE: Color = Color::Rgb(138, 173, 244);
112
pub const MACCHIATO_GREEN: Color = Color::Rgb(166, 218, 149);
113
pub const MACCHIATO_RED: Color = Color::Rgb(237, 135, 150);
114
pub const MACCHIATO_YELLOW: Color = Color::Rgb(238, 212, 159);
115
pub const MACCHIATO_PEACH: Color = Color::Rgb(245, 169, 127);
116
pub const MACCHIATO_TEXT: Color = Color::Rgb(202, 211, 245);
117
pub const MACCHIATO_MAUVE: Color = Color::Rgb(198, 160, 246);
118
// Catppuccin Latte (light)
119
pub const LATTE_MAUVE: Color = Color::Rgb(136, 57, 239);
120
pub const LATTE_TEXT: Color = Color::Rgb(76, 79, 105);
121
pub const LATTE_BLUE: Color = Color::Rgb(30, 102, 245);
122
pub const LATTE_MAROON: Color = Color::Rgb(230, 69, 83);
123
pub const LATTE_GREEN: Color = Color::Rgb(64, 160, 43);
124
pub const LATTE_RED: Color = Color::Rgb(210, 15, 57);
125
pub const LATTE_PEACH: Color = Color::Rgb(254, 100, 11);
126
pub const LATTE_BASE: Color = Color::Rgb(239, 241, 245);
127
const CATPPUCCIN_MACCHIATO_THEME: &[u8] =
128
  include_bytes!("../../assets/themes/CatppuccinMacchiato.tmTheme");
129
const CATPPUCCIN_LATTE_THEME: &[u8] = include_bytes!("../../assets/themes/CatppuccinLatte.tmTheme");
130

131
/// Convert a syntect highlight segment into an owned ratatui Span.
132
fn syntect_to_ratatui_span_owned(
×
133
  (style, content): (syntect::highlighting::Style, &str),
×
134
) -> Option<Span<'static>> {
×
135
  use syntect::highlighting::FontStyle;
136
  let fg = if style.foreground.a > 0 {
×
137
    Some(Color::Rgb(
×
138
      style.foreground.r,
×
139
      style.foreground.g,
×
140
      style.foreground.b,
×
141
    ))
×
142
  } else {
143
    None
×
144
  };
145
  let bg = if style.background.a > 0 {
×
146
    Some(Color::Rgb(
×
147
      style.background.r,
×
148
      style.background.g,
×
149
      style.background.b,
×
150
    ))
×
151
  } else {
152
    None
×
153
  };
154
  let modifier = {
×
155
    let fs = style.font_style;
×
156
    let mut m = Modifier::empty();
×
157
    if fs.contains(FontStyle::BOLD) {
×
158
      m |= Modifier::BOLD;
×
159
    }
×
160
    if fs.contains(FontStyle::ITALIC) {
×
161
      m |= Modifier::ITALIC;
×
162
    }
×
163
    if fs.contains(FontStyle::UNDERLINE) {
×
164
      m |= Modifier::UNDERLINED;
×
165
    }
×
166
    m
×
167
  };
168
  let ratatui_style = Style::default()
×
169
    .fg(fg.unwrap_or_default())
×
170
    .bg(bg.unwrap_or_default())
×
171
    .add_modifier(modifier);
×
172
  Some(Span::styled(content.to_owned(), ratatui_style))
×
173
}
×
174

175
fn get_syntax_set() -> &'static syntect::parsing::SyntaxSet {
×
176
  static SYNTAX_SET: OnceLock<syntect::parsing::SyntaxSet> = OnceLock::new();
177
  SYNTAX_SET.get_or_init(syntect::parsing::SyntaxSet::load_defaults_newlines)
×
178
}
×
179

180
fn get_yaml_syntax_reference() -> &'static syntect::parsing::SyntaxReference {
×
181
  static YAML_SYNTAX_REFERENCE: OnceLock<syntect::parsing::SyntaxReference> = OnceLock::new();
182
  YAML_SYNTAX_REFERENCE.get_or_init(|| {
×
183
    get_syntax_set()
×
184
      .find_syntax_by_extension("yaml")
×
185
      .unwrap()
×
186
      .clone()
×
187
  })
×
188
}
×
189

190
struct YamlThemes {
191
  dark: syntect::highlighting::Theme,
192
  light: syntect::highlighting::Theme,
193
}
194

195
fn get_yaml_themes() -> &'static YamlThemes {
×
196
  static YAML_THEMES: OnceLock<YamlThemes> = OnceLock::new();
197
  YAML_THEMES.get_or_init(|| {
×
198
    let dark = load_embedded_theme(CATPPUCCIN_MACCHIATO_THEME);
×
199
    let light = load_embedded_theme(CATPPUCCIN_LATTE_THEME);
×
200
    YamlThemes { dark, light }
×
201
  })
×
202
}
×
203

204
fn load_embedded_theme(theme_bytes: &[u8]) -> syntect::highlighting::Theme {
×
205
  syntect::highlighting::ThemeSet::load_from_reader(&mut Cursor::new(theme_bytes))
×
206
    .expect("embedded theme should load")
×
207
}
×
208

209
#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
210
pub enum Styles {
211
  Text,
212
  Failure,
213
  Warning,
214
  Success,
215
  Primary,
216
  Secondary,
217
  Help,
218
  Background,
219
}
220

221
pub fn theme_styles(light: bool) -> BTreeMap<Styles, Style> {
576✔
222
  let mut styles = if light {
576✔
223
    BTreeMap::from([
×
224
      (Styles::Text, Style::default().fg(LATTE_TEXT)),
×
225
      (Styles::Failure, Style::default().fg(LATTE_RED)),
×
226
      (Styles::Warning, Style::default().fg(LATTE_PEACH)),
×
227
      (Styles::Success, Style::default().fg(LATTE_GREEN)),
×
228
      (Styles::Primary, Style::default().fg(LATTE_MAUVE)),
×
229
      (Styles::Secondary, Style::default().fg(LATTE_MAROON)),
×
230
      (Styles::Help, Style::default().fg(LATTE_BLUE)),
×
231
      (
×
232
        Styles::Background,
×
233
        Style::default().bg(LATTE_BASE).fg(LATTE_TEXT),
×
234
      ),
×
235
    ])
×
236
  } else {
237
    BTreeMap::from([
576✔
238
      (Styles::Text, Style::default().fg(MACCHIATO_TEXT)),
576✔
239
      (Styles::Failure, Style::default().fg(MACCHIATO_RED)),
576✔
240
      (Styles::Warning, Style::default().fg(MACCHIATO_PEACH)),
576✔
241
      (Styles::Success, Style::default().fg(MACCHIATO_GREEN)),
576✔
242
      (Styles::Primary, Style::default().fg(MACCHIATO_MAUVE)),
576✔
243
      (Styles::Secondary, Style::default().fg(MACCHIATO_YELLOW)),
576✔
244
      (Styles::Help, Style::default().fg(MACCHIATO_BLUE)),
576✔
245
      (
576✔
246
        Styles::Background,
576✔
247
        Style::default().bg(MACCHIATO_BASE).fg(MACCHIATO_TEXT),
576✔
248
      ),
576✔
249
    ])
576✔
250
  };
251

252
  apply_theme_override(&mut styles, Styles::Text, "text", false, light);
576✔
253
  apply_theme_override(&mut styles, Styles::Failure, "failure", false, light);
576✔
254
  apply_theme_override(&mut styles, Styles::Warning, "warning", false, light);
576✔
255
  apply_theme_override(&mut styles, Styles::Success, "success", false, light);
576✔
256
  apply_theme_override(&mut styles, Styles::Primary, "primary", false, light);
576✔
257
  apply_theme_override(&mut styles, Styles::Secondary, "secondary", false, light);
576✔
258
  apply_theme_override(&mut styles, Styles::Help, "help", false, light);
576✔
259
  apply_theme_override(&mut styles, Styles::Background, "background", true, light);
576✔
260

261
  styles
576✔
262
}
576✔
263

264
pub fn title_style(txt: &str) -> Span<'_> {
13✔
265
  Span::styled(txt, style_bold())
13✔
266
}
13✔
267

268
pub fn default_part<'a, S: Into<Cow<'a, str>>>(text: S) -> LinePart<'a> {
157✔
269
  LinePart::Default(text.into())
157✔
270
}
157✔
271

272
pub fn help_part<'a, S: Into<Cow<'a, str>>>(text: S) -> LinePart<'a> {
239✔
273
  LinePart::Help(text.into())
239✔
274
}
239✔
275

276
pub fn style_header(light: bool) -> Style {
14✔
277
  style_primary(light).add_modifier(Modifier::REVERSED)
14✔
278
}
14✔
279

280
pub fn style_bold() -> Style {
13✔
281
  Style::default().add_modifier(Modifier::BOLD)
13✔
282
}
13✔
283

284
pub fn style_text(light: bool) -> Style {
165✔
285
  *theme_styles(light).get(&Styles::Text).unwrap()
165✔
286
}
165✔
287
pub fn style_logo(light: bool) -> Style {
3✔
288
  style_primary(light)
3✔
289
}
3✔
290
pub fn style_failure(light: bool) -> Style {
10✔
291
  *theme_styles(light).get(&Styles::Failure).unwrap()
10✔
292
}
10✔
293
pub fn style_warning(light: bool) -> Style {
2✔
294
  *theme_styles(light).get(&Styles::Warning).unwrap()
2✔
295
}
2✔
296
pub fn style_caution(light: bool) -> Style {
2✔
297
  style_warning(light)
2✔
298
}
2✔
299
pub fn style_success(light: bool) -> Style {
4✔
300
  *theme_styles(light).get(&Styles::Success).unwrap()
4✔
301
}
4✔
302
pub fn style_primary(light: bool) -> Style {
105✔
303
  *theme_styles(light).get(&Styles::Primary).unwrap()
105✔
304
}
105✔
305
pub fn style_help(light: bool) -> Style {
221✔
306
  *theme_styles(light).get(&Styles::Help).unwrap()
221✔
307
}
221✔
308

309
pub fn style_secondary(light: bool) -> Style {
62✔
310
  *theme_styles(light).get(&Styles::Secondary).unwrap()
62✔
311
}
62✔
312

313
pub fn style_main_background(light: bool) -> Style {
7✔
314
  *theme_styles(light).get(&Styles::Background).unwrap()
7✔
315
}
7✔
316

317
pub fn style_highlight() -> Style {
19✔
318
  Style::default().add_modifier(Modifier::REVERSED)
19✔
319
}
19✔
320

321
fn line_part_style(part: &LinePart<'_>, light: bool, bold: bool) -> Style {
373✔
322
  let style = match part {
373✔
323
    LinePart::Default(_) => style_text(light),
152✔
324
    LinePart::Help(_) => style_help(light),
221✔
325
  };
326
  if bold {
373✔
327
    style.add_modifier(Modifier::BOLD)
124✔
328
  } else {
329
    style
249✔
330
  }
331
}
373✔
332

333
fn apply_theme_override(
4,608✔
334
  styles: &mut BTreeMap<Styles, Style>,
4,608✔
335
  slot: Styles,
4,608✔
336
  config_key: &str,
4,608✔
337
  background: bool,
4,608✔
338
  light: bool,
4,608✔
339
) {
4,608✔
340
  if let Some(color) = override_color(config_key, light) {
4,608✔
341
    let style = styles.entry(slot).or_default();
×
342
    *style = if background {
×
343
      style.bg(color)
×
344
    } else {
345
      style.fg(color)
×
346
    };
347
  }
4,608✔
348
}
4,608✔
349

350
pub fn mixed_line<'a, I>(parts: I, light: bool) -> Line<'a>
128✔
351
where
128✔
352
  I: IntoIterator<Item = LinePart<'a>>,
128✔
353
{
354
  styled_line(parts, light, false)
128✔
355
}
128✔
356

357
pub fn mixed_bold_line<'a, I>(parts: I, light: bool) -> Line<'a>
58✔
358
where
58✔
359
  I: IntoIterator<Item = LinePart<'a>>,
58✔
360
{
361
  styled_line(parts, light, true)
58✔
362
}
58✔
363

364
pub fn help_bold_line<'a, S: Into<Cow<'a, str>>>(text: S, light: bool) -> Line<'a> {
15✔
365
  mixed_bold_line([help_part(text)], light)
15✔
366
}
15✔
367

368
pub fn key_hints(keys: &[Key]) -> String {
10✔
369
  keys
10✔
370
    .iter()
10✔
371
    .map(ToString::to_string)
10✔
372
    .collect::<Vec<_>>()
10✔
373
    .join("/")
10✔
374
}
10✔
375

376
pub fn action_hint(action: &str, key: Key) -> String {
104✔
377
  format!("{} {}", action, key)
104✔
378
}
104✔
379

380
pub fn describe_and_yaml_hint() -> String {
10✔
381
  format!(
10✔
382
    "{} | {} ",
383
    action_hint("describe", DEFAULT_KEYBINDING.describe_resource.key),
10✔
384
    action_hint("yaml", DEFAULT_KEYBINDING.resource_yaml.key)
10✔
385
  )
386
}
10✔
387

388
pub fn describe_yaml_and_logs_hint() -> String {
8✔
389
  format!(
8✔
390
    "{} | {} ",
391
    describe_and_yaml_hint().trim_end(),
8✔
392
    action_hint("logs", DEFAULT_KEYBINDING.aggregate_logs.key)
8✔
393
  )
394
}
8✔
395

396
pub fn describe_yaml_logs_and_esc_hint() -> String {
×
397
  format!(
×
398
    "{} | back {} ",
399
    describe_yaml_and_logs_hint().trim_end(),
×
400
    DEFAULT_KEYBINDING.esc.key
×
401
  )
402
}
×
403

404
pub fn describe_yaml_and_esc_hint() -> String {
×
405
  format!(
×
406
    "{} | back {} ",
407
    describe_and_yaml_hint().trim_end(),
×
408
    DEFAULT_KEYBINDING.esc.key
×
409
  )
410
}
×
411

412
pub fn describe_yaml_decode_and_esc_hint() -> String {
×
413
  format!(
×
414
    "{} | {} | back {} ",
415
    describe_and_yaml_hint().trim_end(),
×
416
    action_hint("decode", DEFAULT_KEYBINDING.decode_secret.key),
×
417
    DEFAULT_KEYBINDING.esc.key
×
418
  )
419
}
×
420

421
pub fn wide_hint() -> String {
9✔
422
  format!("wide {}", DEFAULT_KEYBINDING.toggle_wide_columns.key)
9✔
423
}
9✔
424

425
pub fn filter_cursor_position(area: Rect, prefix_width: usize, filter: &str) -> Position {
7✔
426
  Position {
7✔
427
    x: area.x
7✔
428
      + (prefix_width as u16 + 1 + filter.chars().count() as u16).min(area.width.saturating_sub(2)),
7✔
429
    y: area.y,
7✔
430
  }
7✔
431
}
7✔
432

433
fn styled_line<'a, I>(parts: I, light: bool, bold: bool) -> Line<'a>
186✔
434
where
186✔
435
  I: IntoIterator<Item = LinePart<'a>>,
186✔
436
{
437
  Line::from(
186✔
438
    parts
186✔
439
      .into_iter()
186✔
440
      .map(|part| {
373✔
441
        let style = line_part_style(&part, light, bold);
373✔
442
        match part {
373✔
443
          LinePart::Default(text) | LinePart::Help(text) => Span::styled(text, style),
373✔
444
        }
445
      })
373✔
446
      .collect::<Vec<_>>(),
186✔
447
  )
448
}
186✔
449

450
pub fn get_gauge_symbol(enhanced_graphics: bool) -> &'static str {
12✔
451
  if enhanced_graphics {
12✔
452
    symbols::line::THICK_HORIZONTAL
4✔
453
  } else {
454
    symbols::line::HORIZONTAL
8✔
455
  }
456
}
12✔
457

458
pub fn table_header_style(cells: Vec<&str>, light: bool) -> Row<'_> {
10✔
459
  Row::new(cells).style(style_text(light)).bottom_margin(0)
10✔
460
}
10✔
461

462
pub fn horizontal_chunks(constraints: Vec<Constraint>, size: Rect) -> Rc<[Rect]> {
3✔
463
  Layout::default()
3✔
464
    .constraints(<Vec<Constraint> as AsRef<[Constraint]>>::as_ref(
3✔
465
      &constraints,
3✔
466
    ))
3✔
467
    .direction(Direction::Horizontal)
3✔
468
    .split(size)
3✔
469
}
3✔
470

471
pub fn horizontal_chunks_with_margin(
7✔
472
  constraints: Vec<Constraint>,
7✔
473
  size: Rect,
7✔
474
  margin: u16,
7✔
475
) -> Rc<[Rect]> {
7✔
476
  Layout::default()
7✔
477
    .constraints(<Vec<Constraint> as AsRef<[Constraint]>>::as_ref(
7✔
478
      &constraints,
7✔
479
    ))
7✔
480
    .direction(Direction::Horizontal)
7✔
481
    .margin(margin)
7✔
482
    .split(size)
7✔
483
}
7✔
484

485
pub fn vertical_chunks(constraints: Vec<Constraint>, size: Rect) -> Rc<[Rect]> {
12✔
486
  Layout::default()
12✔
487
    .constraints(<Vec<Constraint> as AsRef<[Constraint]>>::as_ref(
12✔
488
      &constraints,
12✔
489
    ))
12✔
490
    .direction(Direction::Vertical)
12✔
491
    .split(size)
12✔
492
}
12✔
493

494
pub fn vertical_chunks_with_margin(
13✔
495
  constraints: Vec<Constraint>,
13✔
496
  size: Rect,
13✔
497
  margin: u16,
13✔
498
) -> Rc<[Rect]> {
13✔
499
  Layout::default()
13✔
500
    .constraints(<Vec<Constraint> as AsRef<[Constraint]>>::as_ref(
13✔
501
      &constraints,
13✔
502
    ))
13✔
503
    .direction(Direction::Vertical)
13✔
504
    .margin(margin)
13✔
505
    .split(size)
13✔
506
}
13✔
507

508
pub fn layout_block(title: Span<'_>) -> Block<'_> {
13✔
509
  Block::default().borders(Borders::ALL).title(title)
13✔
510
}
13✔
511

512
pub fn layout_block_default(title: &str) -> Block<'_> {
13✔
513
  layout_block(title_style(title))
13✔
514
}
13✔
515

516
pub fn layout_block_default_line(title: Line<'_>) -> Block<'_> {
14✔
517
  Block::default().borders(Borders::ALL).title(title)
14✔
518
}
14✔
519

520
pub fn layout_block_active_line(title: Line<'_>, light: bool) -> Block<'_> {
5✔
521
  Block::default()
5✔
522
    .borders(Borders::ALL)
5✔
523
    .title(title)
5✔
524
    .style(style_secondary(light))
5✔
525
}
5✔
526

527
pub fn layout_block_active_span(title: Line<'_>, light: bool) -> Block<'_> {
2✔
528
  layout_block_active_line(title, light)
2✔
529
}
2✔
530

531
pub fn layout_block_top_border(title: Line<'_>) -> Block<'_> {
14✔
532
  Block::default().borders(Borders::TOP).title(title)
14✔
533
}
14✔
534

535
enum FilterDisplayState<'a> {
536
  Inactive,
537
  EditingEmpty,
538
  Value { filter: &'a str, active: bool },
539
}
540

541
fn filter_display_state(filter: &str, active: bool) -> FilterDisplayState<'_> {
24✔
542
  if active && filter.is_empty() {
24✔
543
    FilterDisplayState::EditingEmpty
×
544
  } else if !filter.is_empty() {
24✔
545
    FilterDisplayState::Value { filter, active }
7✔
546
  } else {
547
    FilterDisplayState::Inactive
17✔
548
  }
549
}
24✔
550

551
fn filter_display_parts(filter: &str, active: bool) -> Vec<LinePart<'_>> {
24✔
552
  let state = filter_display_state(filter, active);
24✔
553
  let inactive_text = action_hint("filter", DEFAULT_KEYBINDING.filter.key);
24✔
554
  let clear_suffix = format!(" | clear {} ", DEFAULT_KEYBINDING.esc.key);
24✔
555
  let edit_suffix = format!(" | edit {} ", DEFAULT_KEYBINDING.filter.key);
24✔
556

557
  match state {
24✔
558
    FilterDisplayState::Inactive => vec![help_part(inactive_text)],
17✔
559
    FilterDisplayState::EditingEmpty => {
560
      vec![help_part("[type to filter]"), help_part(clear_suffix)]
×
561
    }
562
    FilterDisplayState::Value {
563
      filter,
4✔
564
      active: true,
565
    } => vec![
4✔
566
      default_part(format!("[{}]", filter)),
4✔
567
      help_part(clear_suffix),
4✔
568
    ],
569
    FilterDisplayState::Value {
570
      filter,
3✔
571
      active: false,
572
    } => vec![
3✔
573
      default_part(format!("[{}]", filter)),
3✔
574
      help_part(edit_suffix),
3✔
575
    ],
576
  }
577
}
24✔
578

579
pub fn filter_status_parts(filter: &str, active: bool) -> Vec<LinePart<'_>> {
6✔
580
  filter_display_parts(filter, active)
6✔
581
}
6✔
582

583
pub fn owned_filter_status_parts(filter: &str, active: bool) -> Vec<LinePart<'static>> {
18✔
584
  filter_display_parts(filter, active)
18✔
585
    .into_iter()
18✔
586
    .map(|part| match part {
23✔
587
      LinePart::Default(text) => default_part(text.into_owned()),
5✔
588
      LinePart::Help(text) => help_part(text.into_owned()),
18✔
589
    })
23✔
590
    .collect()
18✔
591
}
18✔
592

593
pub fn title_with_dual_style<'a>(part_1: String, part_2: Line<'a>, light: bool) -> Line<'a> {
16✔
594
  let mut spans = vec![Span::styled(
16✔
595
    part_1,
16✔
596
    style_secondary(light).add_modifier(Modifier::BOLD),
16✔
597
  )];
598
  spans.extend(part_2.spans);
16✔
599
  Line::from(spans)
16✔
600
}
16✔
601

602
pub fn copy_and_escape_title_line<'a, S: Into<Cow<'a, str>>>(_target: S, light: bool) -> Line<'a> {
×
603
  mixed_bold_line(
×
604
    [
×
605
      help_part(format!(
×
606
        "{} | ",
×
607
        action_hint("copy", DEFAULT_KEYBINDING.copy_to_clipboard.key)
×
608
      )),
×
609
      help_part(format!("back {} ", DEFAULT_KEYBINDING.esc.key)),
×
610
    ],
×
611
    light,
×
612
  )
613
}
×
614

615
pub fn copy_scroll_and_escape_title_line<'a, S: Into<Cow<'a, str>>>(
×
616
  _target: S,
×
617
  auto_scroll: bool,
×
618
  light: bool,
×
619
) -> Line<'a> {
×
620
  let auto_scroll_action = if auto_scroll {
×
621
    "pause scroll"
×
622
  } else {
623
    "resume scroll"
×
624
  };
625
  mixed_bold_line(
×
626
    [
×
627
      help_part(format!(
×
628
        "{} | {} | ",
×
629
        action_hint("copy", DEFAULT_KEYBINDING.copy_to_clipboard.key),
×
630
        action_hint(auto_scroll_action, DEFAULT_KEYBINDING.log_auto_scroll.key)
×
631
      )),
×
632
      help_part(format!("back {} ", DEFAULT_KEYBINDING.esc.key)),
×
633
    ],
×
634
    light,
×
635
  )
636
}
×
637

638
pub fn split_hint_suffix(text: &str) -> (&str, Option<&str>) {
138✔
639
  if let Some(pos) = text.rfind(" <") {
138✔
640
    (&text[..pos], Some(&text[(pos + 1)..]))
138✔
641
  } else {
642
    (text, None)
×
643
  }
644
}
138✔
645

646
/// helper function to create a centered rect using up
647
/// certain percentage of the available rect `r`
648
pub fn centered_rect(width: u16, height: u16, r: Rect) -> Rect {
7✔
649
  let Rect {
650
    width: grid_width,
7✔
651
    height: grid_height,
7✔
652
    ..
653
  } = r;
7✔
654
  let outer_height = (grid_height / 2).saturating_sub(height / 2);
7✔
655

656
  let popup_layout = Layout::default()
7✔
657
    .direction(Direction::Vertical)
7✔
658
    .constraints(
7✔
659
      [
7✔
660
        Constraint::Length(outer_height),
7✔
661
        Constraint::Length(height),
7✔
662
        Constraint::Length(outer_height),
7✔
663
      ]
7✔
664
      .as_ref(),
7✔
665
    )
7✔
666
    .split(r);
7✔
667

668
  let outer_width = (grid_width / 2).saturating_sub(width / 2);
7✔
669

670
  Layout::default()
7✔
671
    .direction(Direction::Horizontal)
7✔
672
    .constraints(
7✔
673
      [
7✔
674
        Constraint::Length(outer_width),
7✔
675
        Constraint::Length(width),
7✔
676
        Constraint::Length(outer_width),
7✔
677
      ]
7✔
678
      .as_ref(),
7✔
679
    )
7✔
680
    .split(popup_layout[1])[1]
7✔
681
}
7✔
682

683
pub fn loading(f: &mut Frame<'_>, block: Block<'_>, area: Rect, is_loading: bool, light: bool) {
13✔
684
  if is_loading {
13✔
685
    let text = "\n\n Loading ...\n\n".to_owned();
×
686
    let text = Text::from(text);
×
687
    let text = text.patch_style(style_secondary(light));
×
688

×
689
    // Contains the text
×
690
    let paragraph = Paragraph::new(text)
×
691
      .style(style_secondary(light))
×
692
      .block(block);
×
693
    f.render_widget(paragraph, area);
×
694
  } else {
×
695
    f.render_widget(block, area)
13✔
696
  }
697
}
13✔
698

699
// using a macro to reuse code as generics will make handling lifetimes a PITA
700
#[macro_export]
701
macro_rules! draw_resource_tab {
702
  ($title:expr, $block:expr, $f:expr, $app:expr, $area:expr, $fn1:expr, $fn2:expr, $res:expr) => {
703
    match $block {
704
      ActiveBlock::Describe => draw_describe_block(
705
        $f,
706
        $app,
707
        $area,
708
        title_with_dual_style(
709
          get_resource_title($app, $title, get_describe_active($block), $res.items.len()),
710
          $crate::ui::utils::copy_and_escape_title_line($title, $app.light_theme),
711
          $app.light_theme,
712
        ),
713
      ),
714
      ActiveBlock::Yaml => draw_yaml_block(
715
        $f,
716
        $app,
717
        $area,
718
        title_with_dual_style(
719
          get_resource_title($app, $title, get_describe_active($block), $res.items.len()),
720
          $crate::ui::utils::copy_and_escape_title_line($title, $app.light_theme),
721
          $app.light_theme,
722
        ),
723
      ),
724
      ActiveBlock::Pods => $crate::app::pods::draw_block_as_sub($f, $app, $area),
725
      ActiveBlock::Containers => $crate::app::pods::draw_containers_block($f, $app, $area),
726
      ActiveBlock::Logs => $crate::app::pods::draw_logs_block($f, $app, $area),
727
      ActiveBlock::Namespaces => $fn1($app.get_prev_route().active_block, $f, $app, $area),
728
      _ => $fn2($f, $app, $area),
729
    };
730
  };
731
}
732

733
pub struct ResourceTableProps<'a, T> {
734
  pub title: String,
735
  pub inline_help: Line<'a>,
736
  pub resource: &'a mut StatefulTable<T>,
737
  pub table_headers: Vec<&'a str>,
738
  pub column_widths: Vec<Constraint>,
739
}
740
/// common for all resources
741
pub fn draw_describe_block(f: &mut Frame<'_>, app: &mut App, area: Rect, title: Line<'_>) {
×
742
  draw_yaml_block(f, app, area, title);
×
743
}
×
744

745
/// Refreshes the syntax-highlight cache when empty or the theme changed.
746
/// Returns `false` when there is no content to highlight.
747
fn ensure_highlight_cache(app: &mut App) -> bool {
×
748
  if app.data.describe_out.get_txt().is_empty() {
×
749
    return false;
×
750
  }
×
751
  if app.data.describe_out.highlighted_lines.is_empty()
×
752
    || app.data.describe_out.highlight_light_theme != app.light_theme
×
753
  {
754
    let ss = get_syntax_set();
×
755
    let syntax = get_yaml_syntax_reference();
×
756
    let theme = if app.light_theme {
×
757
      &get_yaml_themes().light
×
758
    } else {
759
      &get_yaml_themes().dark
×
760
    };
761
    let mut h = syntect::easy::HighlightLines::new(syntax, theme);
×
762
    let txt = app.data.describe_out.get_txt();
×
763
    let lines: Vec<_> = syntect::util::LinesWithEndings::from(txt)
×
764
      .filter_map(|line| match h.highlight_line(line, ss) {
×
765
        Ok(segments) => {
×
766
          let line_spans: Vec<_> = segments
×
767
            .into_iter()
×
768
            .filter_map(syntect_to_ratatui_span_owned)
×
769
            .collect();
×
770
          Some(ratatui::text::Line::from(line_spans))
×
771
        }
772
        Err(_) => None,
×
773
      })
×
774
      .collect();
×
775
    app.data.describe_out.highlighted_lines = lines;
×
776
    app.data.describe_out.highlight_light_theme = app.light_theme;
×
777
  }
×
778
  true
×
779
}
×
780

781
/// Compute the (start, end, scroll-within-slice) window into a buffer of
782
/// `total` highlighted lines for the given `offset` and visible row count.
783
/// Clamps `offset` to a valid index and ensures `start <= end <= total`.
784
fn highlight_window(offset: usize, total: usize, view_h: usize) -> (usize, usize, u16) {
5✔
785
  // Caller guarantees total > 0; clamp here defensively too.
786
  let view_h = view_h.max(1);
5✔
787
  let effective_offset = offset.min(total.saturating_sub(1));
5✔
788
  let slice_start = effective_offset.saturating_sub(view_h);
5✔
789
  let slice_end = total.min(effective_offset + view_h * 3);
5✔
790
  let adjusted_offset = (effective_offset - slice_start).min(u16::MAX as usize) as u16;
5✔
791
  (slice_start, slice_end, adjusted_offset)
5✔
792
}
5✔
793

794
/// common for all resources
795
pub fn draw_yaml_block(f: &mut Frame<'_>, app: &mut App, area: Rect, title: Line<'_>) {
×
796
  let block = layout_block_top_border(title);
×
797
  if ensure_highlight_cache(app) {
×
798
    let total = app.data.describe_out.highlighted_lines.len();
×
799
    if total == 0 {
×
800
      loading(f, block, area, app.is_loading(), app.light_theme);
×
801
      return;
×
802
    }
×
803
    let offset = app.data.describe_out.offset;
×
804
    // Subtract 2 for the top-border of the block; clamp to >=1 so a tiny
805
    // terminal doesn't degenerate into an empty slice.
806
    let view_h = (area.height.saturating_sub(2) as usize).max(1);
×
807
    let (slice_start, slice_end, adjusted_offset) = highlight_window(offset, total, view_h);
×
808
    let visible_lines = app.data.describe_out.highlighted_lines[slice_start..slice_end].to_vec();
×
809
    let paragraph = Paragraph::new(visible_lines)
×
810
      .block(block)
×
811
      .wrap(Wrap { trim: false })
×
812
      .scroll((adjusted_offset, 0));
×
813
    f.render_widget(paragraph, area);
×
814
  } else {
×
815
    loading(f, block, area, app.is_loading(), app.light_theme);
×
816
  }
×
817
}
×
818

819
fn draw_resource_table<'a, T: Named, F>(
15✔
820
  f: &mut Frame<'_>,
15✔
821
  area: Rect,
15✔
822
  table_props: ResourceTableProps<'a, T>,
15✔
823
  row_cell_mapper: F,
15✔
824
  light_theme: bool,
15✔
825
  is_loading: bool,
15✔
826
  block: Block<'a>,
15✔
827
) where
15✔
828
  F: Fn(&T) -> Row<'a>,
15✔
829
{
830
  if !table_props.resource.items.is_empty() {
15✔
831
    let filter = table_props.resource.filter.to_lowercase();
8✔
832
    let has_filter = !filter.is_empty();
8✔
833
    let mut filtered_indices: Vec<usize> = Vec::new();
8✔
834
    let mut filtered_items: Vec<&T> = Vec::new();
8✔
835
    for (idx, item) in table_props.resource.items.iter().enumerate() {
33✔
836
      if !has_filter || filter_by_name(&filter, item) {
33✔
837
        if has_filter {
30✔
838
          filtered_indices.push(idx);
5✔
839
        }
25✔
840
        filtered_items.push(item);
30✔
841
      }
3✔
842
    }
843

844
    if has_filter {
8✔
845
      let max = filtered_items.len().saturating_sub(1);
4✔
846
      if let Some(sel) = table_props.resource.state.selected() {
4✔
847
        if sel > max {
4✔
UNCOV
848
          table_props.resource.state.select(Some(max));
×
849
        }
4✔
UNCOV
850
      }
×
851
    }
4✔
852
    table_props.resource.filtered_indices = filtered_indices;
8✔
853

854
    // Skip row_cell_mapper for off-screen items: ratatui's Table only paints
855
    // rows intersecting the visible area, so we can hand it cheap empty Rows
856
    // outside the window. The window must bracket the legal range of
857
    // state.offset() (which ratatui keeps within `selected ± view_h`),
858
    // hence `selected.saturating_sub(view_h)` and `selected + view_h * 2`.
859
    // view_h is clamped to >=1 so a tiny terminal still renders one row.
860
    let selected = table_props.resource.state.selected().unwrap_or(0);
8✔
861
    let view_h = (area.height.saturating_sub(3) as usize).max(1);
8✔
862
    let visible_start = selected.saturating_sub(view_h);
8✔
863
    let visible_end = (selected + view_h * 2).min(filtered_items.len());
8✔
864

865
    let rows: Vec<Row<'a>> = filtered_items
8✔
866
      .iter()
8✔
867
      .enumerate()
8✔
868
      .map(|(fi, item)| {
30✔
869
        if fi >= visible_start && fi < visible_end {
30✔
870
          row_cell_mapper(item)
30✔
871
        } else {
UNCOV
872
          Row::default()
×
873
        }
874
      })
30✔
875
      .collect();
8✔
876

877
    let table = Table::new(rows, &table_props.column_widths)
8✔
878
      .header(table_header_style(table_props.table_headers, light_theme))
8✔
879
      .block(block)
8✔
880
      .row_highlight_style(style_highlight())
8✔
881
      .highlight_symbol(HIGHLIGHT);
8✔
882

883
    f.render_stateful_widget(table, area, &mut table_props.resource.state);
8✔
884
  } else {
7✔
885
    loading(f, block, area, is_loading, light_theme);
7✔
886
  }
7✔
887
}
15✔
888

889
/// Builds the help `Line` for a resource block title, weaving filter status
890
/// into any existing inline help (placing it after a "containers" prefix when present).
891
fn build_resource_help_line(
16✔
892
  inline_help: Line<'_>,
16✔
893
  filter: &str,
16✔
894
  filter_active: bool,
16✔
895
  light_theme: bool,
16✔
896
) -> Line<'static> {
16✔
897
  let inline_help_text = inline_help
16✔
898
    .spans
16✔
899
    .iter()
16✔
900
    .map(|span| span.content.as_ref())
16✔
901
    .collect::<String>();
16✔
902
  let containers_prefix = format!(
16✔
903
    "{} | ",
904
    action_hint("containers", DEFAULT_KEYBINDING.submit.key)
16✔
905
  );
906
  let mut help_parts: Vec<LinePart<'static>> = Vec::new();
16✔
907
  if let Some(rest) = inline_help_text.strip_prefix(&containers_prefix) {
16✔
908
    help_parts.push(help_part(containers_prefix));
5✔
909
    help_parts.extend(owned_filter_status_parts(filter, filter_active));
5✔
910
    if !rest.is_empty() {
5✔
911
      help_parts.push(help_part(" | ".to_string()));
4✔
912
      help_parts.push(help_part(rest.to_string()));
4✔
913
    }
4✔
914
  } else {
915
    help_parts.extend(owned_filter_status_parts(filter, filter_active));
11✔
916
    if !inline_help_text.is_empty() {
11✔
917
      help_parts.push(help_part(" | ".to_string()));
9✔
918
      help_parts.push(help_part(inline_help_text));
9✔
919
    }
9✔
920
  }
921
  mixed_bold_line(help_parts, light_theme)
16✔
922
}
16✔
923

924
/// Draw a kubernetes resource overview tab
925
pub fn draw_resource_block<'a, T: Named, F>(
14✔
926
  f: &mut Frame<'_>,
14✔
927
  area: Rect,
14✔
928
  table_props: ResourceTableProps<'a, T>,
14✔
929
  row_cell_mapper: F,
14✔
930
  light_theme: bool,
14✔
931
  is_loading: bool,
14✔
932
) where
14✔
933
  F: Fn(&T) -> Row<'a>,
14✔
934
{
935
  let ResourceTableProps {
936
    title,
14✔
937
    inline_help,
14✔
938
    resource,
14✔
939
    table_headers,
14✔
940
    column_widths,
14✔
941
  } = table_props;
14✔
942
  let filter = resource.filter.clone();
14✔
943
  let filter_active = resource.filter_active;
14✔
944
  if filter_active {
14✔
945
    let title_width = title.chars().count();
2✔
946
    let title = title_with_dual_style(
2✔
947
      title,
2✔
948
      mixed_bold_line(owned_filter_status_parts(&filter, true), light_theme),
2✔
949
      light_theme,
2✔
950
    );
951
    let block = layout_block_top_border(title);
2✔
952
    draw_resource_table(
2✔
953
      f,
2✔
954
      area,
2✔
955
      ResourceTableProps {
2✔
956
        title: String::new(),
2✔
957
        inline_help: Line::default(),
2✔
958
        resource,
2✔
959
        table_headers,
2✔
960
        column_widths,
2✔
961
      },
2✔
962
      row_cell_mapper,
2✔
963
      light_theme,
2✔
964
      is_loading,
2✔
965
      block,
2✔
966
    );
967
    f.set_cursor_position(filter_cursor_position(area, title_width, &filter));
2✔
968
    return;
2✔
969
  }
12✔
970

971
  let help_line = build_resource_help_line(inline_help, &filter, filter_active, light_theme);
12✔
972
  let title = title_with_dual_style(title, help_line, light_theme);
12✔
973
  let block = layout_block_top_border(title);
12✔
974
  draw_resource_table(
12✔
975
    f,
12✔
976
    area,
12✔
977
    ResourceTableProps {
12✔
978
      title: String::new(),
12✔
979
      inline_help: Line::default(),
12✔
980
      resource,
12✔
981
      table_headers,
12✔
982
      column_widths,
12✔
983
    },
12✔
984
    row_cell_mapper,
12✔
985
    light_theme,
12✔
986
    is_loading,
12✔
987
    block,
12✔
988
  );
989
}
14✔
990

991
pub fn draw_route_resource_block<'a, T: Named, F>(
1✔
992
  f: &mut Frame<'_>,
1✔
993
  area: Rect,
1✔
994
  table_props: ResourceTableProps<'a, T>,
1✔
995
  row_cell_mapper: F,
1✔
996
  light_theme: bool,
1✔
997
  is_loading: bool,
1✔
998
) where
1✔
999
  F: Fn(&T) -> Row<'a>,
1✔
1000
{
1001
  let ResourceTableProps {
1002
    title,
1✔
1003
    inline_help,
1✔
1004
    resource,
1✔
1005
    table_headers,
1✔
1006
    column_widths,
1✔
1007
  } = table_props;
1✔
1008
  let filter = resource.filter.clone();
1✔
1009
  let filter_active = resource.filter_active;
1✔
1010
  if filter_active {
1✔
UNCOV
1011
    let title_width = title.chars().count();
×
UNCOV
1012
    let title = title_with_dual_style(
×
1013
      title,
×
1014
      mixed_bold_line(owned_filter_status_parts(&filter, true), light_theme),
×
1015
      light_theme,
×
1016
    );
1017
    let block = layout_block_active_span(title, light_theme);
×
UNCOV
1018
    draw_resource_table(
×
1019
      f,
×
1020
      area,
×
1021
      ResourceTableProps {
×
1022
        title: String::new(),
×
1023
        inline_help: Line::default(),
×
1024
        resource,
×
1025
        table_headers,
×
1026
        column_widths,
×
1027
      },
×
1028
      row_cell_mapper,
×
1029
      light_theme,
×
1030
      is_loading,
×
1031
      block,
×
1032
    );
1033
    f.set_cursor_position(filter_cursor_position(area, title_width, &filter));
×
UNCOV
1034
    return;
×
1035
  }
1✔
1036

1037
  let title = title_with_dual_style(title, inline_help, light_theme);
1✔
1038
  let block = layout_block_active_span(title, light_theme);
1✔
1039
  draw_resource_table(
1✔
1040
    f,
1✔
1041
    area,
1✔
1042
    ResourceTableProps {
1✔
1043
      title: String::new(),
1✔
1044
      inline_help: Line::default(),
1✔
1045
      resource,
1✔
1046
      table_headers,
1✔
1047
      column_widths,
1✔
1048
    },
1✔
1049
    row_cell_mapper,
1✔
1050
    light_theme,
1✔
1051
    is_loading,
1✔
1052
    block,
1✔
1053
  );
1054
}
1✔
1055

1056
pub fn filter_by_resource_name<T: Named>(
7✔
1057
  filter: &str,
7✔
1058
  res: &T,
7✔
1059
  row_cell_mapper: Row<'static>,
7✔
1060
) -> Option<Row<'static>> {
7✔
1061
  if filter.is_empty() || filter_by_name(filter, res) {
7✔
1062
    Some(row_cell_mapper)
7✔
1063
  } else {
UNCOV
1064
    None
×
1065
  }
1066
}
7✔
1067

1068
pub fn text_matches_filter(filter: &str, value: &str) -> bool {
202✔
1069
  let filter = filter.to_lowercase();
202✔
1070
  let value = value.to_lowercase();
202✔
1071
  filter.is_empty() || glob_match(&filter, &value) || value.contains(&filter)
202✔
1072
}
202✔
1073

1074
fn filter_by_name<T: Named>(ft: &str, res: &T) -> bool {
9✔
1075
  text_matches_filter(ft, res.get_name())
9✔
1076
}
9✔
1077

1078
pub fn get_cluster_wide_resource_title<S: AsRef<str>>(
2✔
1079
  title: S,
2✔
1080
  items_len: usize,
2✔
1081
  suffix: S,
2✔
1082
) -> String {
2✔
1083
  format!(" {} [{}] {}", title.as_ref(), items_len, suffix.as_ref())
2✔
1084
}
2✔
1085

1086
pub fn get_resource_title<S: AsRef<str>>(
14✔
1087
  app: &App,
14✔
1088
  title: S,
14✔
1089
  suffix: S,
14✔
1090
  items_len: usize,
14✔
1091
) -> String {
14✔
1092
  format!(
14✔
1093
    " {} {}",
1094
    title_with_ns(
14✔
1095
      title.as_ref(),
14✔
1096
      app
14✔
1097
        .data
14✔
1098
        .selected
14✔
1099
        .ns
14✔
1100
        .as_ref()
14✔
1101
        .unwrap_or(&String::from("all")),
14✔
1102
      items_len
14✔
1103
    ),
1104
    suffix.as_ref(),
14✔
1105
  )
1106
}
14✔
1107

1108
static DESCRIBE_ACTIVE: &str = "-> Describe ";
1109
static YAML_ACTIVE: &str = "-> YAML ";
1110

UNCOV
1111
pub fn get_describe_active<'a>(block: ActiveBlock) -> &'a str {
×
UNCOV
1112
  match block {
×
1113
    ActiveBlock::Describe => DESCRIBE_ACTIVE,
×
1114
    _ => YAML_ACTIVE,
×
1115
  }
1116
}
×
1117

1118
pub fn title_with_ns(title: &str, ns: &str, length: usize) -> String {
15✔
1119
  format!("{} (ns: {}) [{}]", title, ns, length)
15✔
1120
}
15✔
1121

1122
#[cfg(test)]
1123
mod tests {
1124
  use ratatui::{
1125
    backend::TestBackend, buffer::Buffer, layout::Position, style::Modifier, widgets::Cell,
1126
    Terminal,
1127
  };
1128

1129
  use super::*;
1130
  use crate::ui::utils::{MACCHIATO_BLUE, MACCHIATO_MAUVE, MACCHIATO_TEXT, MACCHIATO_YELLOW};
1131

1132
  #[test]
1133
  fn test_draw_resource_block() {
1✔
1134
    let backend = TestBackend::new(100, 6);
1✔
1135
    let mut terminal = Terminal::new(backend).unwrap();
1✔
1136

1137
    struct RenderTest {
1138
      pub name: String,
1139
      pub namespace: String,
1140
      pub data: i32,
1141
      pub age: String,
1142
    }
1143

1144
    impl Named for RenderTest {
UNCOV
1145
      fn get_name(&self) -> &String {
×
UNCOV
1146
        &self.name
×
1147
      }
×
1148
    }
1149
    terminal
1✔
1150
      .draw(|f| {
1✔
1151
        let size = f.area();
1✔
1152
        let mut resource: StatefulTable<RenderTest> = StatefulTable::new();
1✔
1153
        resource.set_items(vec![
1✔
1154
          RenderTest {
1✔
1155
            name: "Test 1".into(),
1✔
1156
            namespace: "Test ns".into(),
1✔
1157
            age: "65h3m".into(),
1✔
1158
            data: 5,
1✔
1159
          },
1✔
1160
          RenderTest {
1✔
1161
            name: "Test long name that should be truncated from view".into(),
1✔
1162
            namespace: "Test ns".into(),
1✔
1163
            age: "65h3m".into(),
1✔
1164
            data: 3,
1✔
1165
          },
1✔
1166
          RenderTest {
1✔
1167
            name: "test_long_name_that_should_be_truncated_from_view".into(),
1✔
1168
            namespace: "Test ns long value check that should be truncated".into(),
1✔
1169
            age: "65h3m".into(),
1✔
1170
            data: 6,
1✔
1171
          },
1✔
1172
        ]);
1173
        draw_resource_block(
1✔
1174
          f,
1✔
1175
          size,
1✔
1176
          ResourceTableProps {
1✔
1177
            title: "Test".into(),
1✔
1178
            inline_help: help_bold_line("-> yaml <y>", false),
1✔
1179
            resource: &mut resource,
1✔
1180
            table_headers: vec!["Namespace", "Name", "Data", "Age"],
1✔
1181
            column_widths: vec![
1✔
1182
              Constraint::Percentage(30),
1✔
1183
              Constraint::Percentage(40),
1✔
1184
              Constraint::Percentage(15),
1✔
1185
              Constraint::Percentage(15),
1✔
1186
            ],
1✔
1187
          },
1✔
1188
          |c| {
3✔
1189
            Row::new(vec![
3✔
1190
              Cell::from(c.namespace.to_owned()),
3✔
1191
              Cell::from(c.name.to_owned()),
3✔
1192
              Cell::from(c.data.to_string()),
3✔
1193
              Cell::from(c.age.to_owned()),
3✔
1194
            ])
1195
            .style(style_primary(false))
3✔
1196
          },
3✔
1197
          false,
1198
          false,
1199
        );
1200
      })
1✔
1201
      .unwrap();
1✔
1202

1203
    let mut expected = Buffer::with_lines(vec![
1✔
1204
        "Testfilter </> | -> yaml <y>────────────────────────────────────────────────────────────────────────",
1205
        "   Namespace                     Name                                 Data           Age            ",
1✔
1206
        "=> Test ns                       Test 1                               5              65h3m          ",
1✔
1207
        "   Test ns                       Test long name that should be trunca 3              65h3m          ",
1✔
1208
        "   Test ns long value check that test_long_name_that_should_be_trunca 6              65h3m          ",
1✔
1209
        "                                                                                                    ",
1✔
1210
      ]);
1211
    // set row styles
1212
    // First row heading style
1213
    for col in 0..=99 {
100✔
1214
      match col {
100✔
1215
        0..=3 => {
100✔
1216
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
4✔
1217
            Style::default()
4✔
1218
              .fg(MACCHIATO_YELLOW)
4✔
1219
              .add_modifier(Modifier::BOLD),
4✔
1220
          );
4✔
1221
        }
4✔
1222
        4..=27 => {
96✔
1223
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
24✔
1224
            Style::default()
24✔
1225
              .fg(MACCHIATO_BLUE)
24✔
1226
              .add_modifier(Modifier::BOLD),
24✔
1227
          );
24✔
1228
        }
24✔
1229
        _ => {}
72✔
1230
      }
1231
    }
1232

1233
    // Second row table header style
1234
    for col in 0..=99 {
100✔
1235
      expected
100✔
1236
        .cell_mut(Position::new(col, 1))
100✔
1237
        .unwrap()
100✔
1238
        .set_style(Style::default().fg(MACCHIATO_TEXT));
100✔
1239
    }
100✔
1240
    // first table data row style
1241
    for col in 0..=99 {
100✔
1242
      expected.cell_mut(Position::new(col, 2)).unwrap().set_style(
100✔
1243
        Style::default()
100✔
1244
          .fg(MACCHIATO_MAUVE)
100✔
1245
          .add_modifier(Modifier::REVERSED),
100✔
1246
      );
100✔
1247
    }
100✔
1248
    // remaining table data row style
1249
    for row in 3..=4 {
2✔
1250
      for col in 0..=99 {
200✔
1251
        expected
200✔
1252
          .cell_mut(Position::new(col, row))
200✔
1253
          .unwrap()
200✔
1254
          .set_style(Style::default().fg(MACCHIATO_MAUVE));
200✔
1255
      }
200✔
1256
    }
1257

1258
    terminal.backend().assert_buffer(&expected);
1✔
1259
  }
1✔
1260

1261
  #[test]
1262
  fn test_draw_resource_block_filter() {
1✔
1263
    let backend = TestBackend::new(100, 6);
1✔
1264
    let mut terminal = Terminal::new(backend).unwrap();
1✔
1265

1266
    struct RenderTest {
1267
      pub name: String,
1268
      pub namespace: String,
1269
      pub data: i32,
1270
      pub age: String,
1271
    }
1272
    impl Named for RenderTest {
1273
      fn get_name(&self) -> &String {
3✔
1274
        &self.name
3✔
1275
      }
3✔
1276
    }
1277

1278
    terminal
1✔
1279
      .draw(|f| {
1✔
1280
        let size = f.area();
1✔
1281
        let mut resource: StatefulTable<RenderTest> = StatefulTable::new();
1✔
1282
        resource.set_items(vec![
1✔
1283
          RenderTest {
1✔
1284
            name: "Test 1".into(),
1✔
1285
            namespace: "Test ns".into(),
1✔
1286
            age: "65h3m".into(),
1✔
1287
            data: 5,
1✔
1288
          },
1✔
1289
          RenderTest {
1✔
1290
            name: "Test long name that should be truncated from view".into(),
1✔
1291
            namespace: "Test ns".into(),
1✔
1292
            age: "65h3m".into(),
1✔
1293
            data: 3,
1✔
1294
          },
1✔
1295
          RenderTest {
1✔
1296
            name: "test_long_name_that_should_be_truncated_from_view".into(),
1✔
1297
            namespace: "Test ns long value check that should be truncated".into(),
1✔
1298
            age: "65h3m".into(),
1✔
1299
            data: 6,
1✔
1300
          },
1✔
1301
        ]);
1302
        resource.filter = "truncated".to_string();
1✔
1303
        draw_resource_block(
1✔
1304
          f,
1✔
1305
          size,
1✔
1306
          ResourceTableProps {
1✔
1307
            title: "Test".into(),
1✔
1308
            inline_help: help_bold_line("-> yaml <y>", false),
1✔
1309
            resource: &mut resource,
1✔
1310
            table_headers: vec!["Namespace", "Name", "Data", "Age"],
1✔
1311
            column_widths: vec![
1✔
1312
              Constraint::Percentage(30),
1✔
1313
              Constraint::Percentage(40),
1✔
1314
              Constraint::Percentage(15),
1✔
1315
              Constraint::Percentage(15),
1✔
1316
            ],
1✔
1317
          },
1✔
1318
          |c| {
2✔
1319
            Row::new(vec![
2✔
1320
              Cell::from(c.namespace.to_owned()),
2✔
1321
              Cell::from(c.name.to_owned()),
2✔
1322
              Cell::from(c.data.to_string()),
2✔
1323
              Cell::from(c.age.to_owned()),
2✔
1324
            ])
1325
            .style(style_primary(false))
2✔
1326
          },
2✔
1327
          false,
1328
          false,
1329
        );
1330
      })
1✔
1331
      .unwrap();
1✔
1332

1333
    let mut expected = Buffer::with_lines(vec![
1✔
1334
        "Test[truncated] | edit </>  | -> yaml <y>───────────────────────────────────────────────────────────",
1335
        "   Namespace                     Name                                 Data           Age            ",
1✔
1336
        "=> Test ns                       Test long name that should be trunca 3              65h3m          ",
1✔
1337
        "   Test ns long value check that test_long_name_that_should_be_trunca 6              65h3m          ",
1✔
1338
        "                                                                                                    ",
1✔
1339
        "                                                                                                    ",
1✔
1340
      ]);
1341
    // set row styles
1342
    // First row heading style
1343
    for col in 0..=99 {
100✔
1344
      match col {
100✔
1345
        0..=3 => {
100✔
1346
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
4✔
1347
            Style::default()
4✔
1348
              .fg(MACCHIATO_YELLOW)
4✔
1349
              .add_modifier(Modifier::BOLD),
4✔
1350
          );
4✔
1351
        }
4✔
1352
        4..=14 => {
96✔
1353
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
11✔
1354
            Style::default()
11✔
1355
              .fg(MACCHIATO_TEXT)
11✔
1356
              .add_modifier(Modifier::BOLD),
11✔
1357
          );
11✔
1358
        }
11✔
1359
        15..=40 => {
85✔
1360
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
26✔
1361
            Style::default()
26✔
1362
              .fg(MACCHIATO_BLUE)
26✔
1363
              .add_modifier(Modifier::BOLD),
26✔
1364
          );
26✔
1365
        }
26✔
1366
        _ => {}
59✔
1367
      }
1368
    }
1369

1370
    // Second row table header style
1371
    for col in 0..=99 {
100✔
1372
      expected
100✔
1373
        .cell_mut(Position::new(col, 1))
100✔
1374
        .unwrap()
100✔
1375
        .set_style(Style::default().fg(MACCHIATO_TEXT));
100✔
1376
    }
100✔
1377
    // first table data row style
1378
    for col in 0..=99 {
100✔
1379
      expected.cell_mut(Position::new(col, 2)).unwrap().set_style(
100✔
1380
        Style::default()
100✔
1381
          .fg(MACCHIATO_MAUVE)
100✔
1382
          .add_modifier(Modifier::REVERSED),
100✔
1383
      );
100✔
1384
    }
100✔
1385
    // remaining table data row style
1386
    for row in 3..=3 {
1✔
1387
      for col in 0..=99 {
100✔
1388
        expected
100✔
1389
          .cell_mut(Position::new(col, row))
100✔
1390
          .unwrap()
100✔
1391
          .set_style(Style::default().fg(MACCHIATO_MAUVE));
100✔
1392
      }
100✔
1393
    }
1394

1395
    terminal.backend().assert_buffer(&expected);
1✔
1396
  }
1✔
1397

1398
  #[test]
1399
  fn test_draw_resource_block_filter_glob() {
1✔
1400
    let backend = TestBackend::new(100, 6);
1✔
1401
    let mut terminal = Terminal::new(backend).unwrap();
1✔
1402

1403
    struct RenderTest {
1404
      pub name: String,
1405
      pub namespace: String,
1406
      pub data: i32,
1407
      pub age: String,
1408
    }
1409
    impl Named for RenderTest {
1410
      fn get_name(&self) -> &String {
3✔
1411
        &self.name
3✔
1412
      }
3✔
1413
    }
1414

1415
    terminal
1✔
1416
      .draw(|f| {
1✔
1417
        let size = f.area();
1✔
1418
        let mut resource: StatefulTable<RenderTest> = StatefulTable::new();
1✔
1419
        resource.set_items(vec![
1✔
1420
          RenderTest {
1✔
1421
            name: "Test 1".into(),
1✔
1422
            namespace: "Test ns".into(),
1✔
1423
            age: "65h3m".into(),
1✔
1424
            data: 5,
1✔
1425
          },
1✔
1426
          RenderTest {
1✔
1427
            name: "Test long name that should be truncated from view".into(),
1✔
1428
            namespace: "Test ns".into(),
1✔
1429
            age: "65h3m".into(),
1✔
1430
            data: 3,
1✔
1431
          },
1✔
1432
          RenderTest {
1✔
1433
            name: "test_long_name_that_should_be_truncated_from_view".into(),
1✔
1434
            namespace: "Test ns long value check that should be truncated".into(),
1✔
1435
            age: "65h3m".into(),
1✔
1436
            data: 6,
1✔
1437
          },
1✔
1438
        ]);
1439
        resource.filter = "*long*truncated*".to_string();
1✔
1440
        draw_resource_block(
1✔
1441
          f,
1✔
1442
          size,
1✔
1443
          ResourceTableProps {
1✔
1444
            title: "Test".into(),
1✔
1445
            inline_help: help_bold_line("-> yaml <y>", false),
1✔
1446
            resource: &mut resource,
1✔
1447
            table_headers: vec!["Namespace", "Name", "Data", "Age"],
1✔
1448
            column_widths: vec![
1✔
1449
              Constraint::Percentage(30),
1✔
1450
              Constraint::Percentage(40),
1✔
1451
              Constraint::Percentage(15),
1✔
1452
              Constraint::Percentage(15),
1✔
1453
            ],
1✔
1454
          },
1✔
1455
          |c| {
2✔
1456
            Row::new(vec![
2✔
1457
              Cell::from(c.namespace.to_owned()),
2✔
1458
              Cell::from(c.name.to_owned()),
2✔
1459
              Cell::from(c.data.to_string()),
2✔
1460
              Cell::from(c.age.to_owned()),
2✔
1461
            ])
1462
            .style(style_primary(false))
2✔
1463
          },
2✔
1464
          false,
1465
          false,
1466
        );
1467
      })
1✔
1468
      .unwrap();
1✔
1469

1470
    let mut expected = Buffer::with_lines(vec![
1✔
1471
        "Test[*long*truncated*] | edit </>  | -> yaml <y>────────────────────────────────────────────────────",
1472
        "   Namespace                     Name                                 Data           Age            ",
1✔
1473
        "=> Test ns                       Test long name that should be trunca 3              65h3m          ",
1✔
1474
        "   Test ns long value check that test_long_name_that_should_be_trunca 6              65h3m          ",
1✔
1475
        "                                                                                                    ",
1✔
1476
        "                                                                                                    ",
1✔
1477
      ]);
1478
    // set row styles
1479
    // First row heading style
1480
    for col in 0..=99 {
100✔
1481
      match col {
100✔
1482
        0..=3 => {
100✔
1483
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
4✔
1484
            Style::default()
4✔
1485
              .fg(MACCHIATO_YELLOW)
4✔
1486
              .add_modifier(Modifier::BOLD),
4✔
1487
          );
4✔
1488
        }
4✔
1489
        4..=21 => {
96✔
1490
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
18✔
1491
            Style::default()
18✔
1492
              .fg(MACCHIATO_TEXT)
18✔
1493
              .add_modifier(Modifier::BOLD),
18✔
1494
          );
18✔
1495
        }
18✔
1496
        22..=47 => {
78✔
1497
          expected.cell_mut(Position::new(col, 0)).unwrap().set_style(
26✔
1498
            Style::default()
26✔
1499
              .fg(MACCHIATO_BLUE)
26✔
1500
              .add_modifier(Modifier::BOLD),
26✔
1501
          );
26✔
1502
        }
26✔
1503
        _ => {}
52✔
1504
      }
1505
    }
1506

1507
    // Second row table header style
1508
    for col in 0..=99 {
100✔
1509
      expected
100✔
1510
        .cell_mut(Position::new(col, 1))
100✔
1511
        .unwrap()
100✔
1512
        .set_style(Style::default().fg(MACCHIATO_TEXT));
100✔
1513
    }
100✔
1514
    // first table data row style
1515
    for col in 0..=99 {
100✔
1516
      expected.cell_mut(Position::new(col, 2)).unwrap().set_style(
100✔
1517
        Style::default()
100✔
1518
          .fg(MACCHIATO_MAUVE)
100✔
1519
          .add_modifier(Modifier::REVERSED),
100✔
1520
      );
100✔
1521
    }
100✔
1522
    // remaining table data row style
1523
    for row in 3..=3 {
1✔
1524
      for col in 0..=99 {
100✔
1525
        expected
100✔
1526
          .cell_mut(Position::new(col, row))
100✔
1527
          .unwrap()
100✔
1528
          .set_style(Style::default().fg(MACCHIATO_MAUVE));
100✔
1529
      }
100✔
1530
    }
1531

1532
    terminal.backend().assert_buffer(&expected);
1✔
1533
  }
1✔
1534

1535
  #[test]
1536
  fn test_get_resource_title() {
1✔
1537
    let app = App::default();
1✔
1538
    assert_eq!(
1✔
1539
      get_resource_title(&app, "Title", "-> hello", 5),
1✔
1540
      " Title (ns: all) [5] -> hello"
1541
    );
1542
  }
1✔
1543

1544
  #[test]
1545
  fn test_draw_resource_block_filter_hides_other_hints_when_active() {
1✔
1546
    let backend = TestBackend::new(100, 4);
1✔
1547
    let mut terminal = Terminal::new(backend).unwrap();
1✔
1548

1549
    struct RenderTest {
1550
      pub name: String,
1551
    }
1552

1553
    impl Named for RenderTest {
1554
      fn get_name(&self) -> &String {
1✔
1555
        &self.name
1✔
1556
      }
1✔
1557
    }
1558

1559
    terminal
1✔
1560
      .draw(|f| {
1✔
1561
        let size = f.area();
1✔
1562
        let mut resource: StatefulTable<RenderTest> = StatefulTable::new();
1✔
1563
        resource.set_items(vec![RenderTest {
1✔
1564
          name: "test".into(),
1✔
1565
        }]);
1✔
1566
        resource.filter = "pod".into();
1✔
1567
        resource.filter_active = true;
1✔
1568
        draw_resource_block(
1✔
1569
          f,
1✔
1570
          size,
1✔
1571
          ResourceTableProps {
1✔
1572
            title: "Test".into(),
1✔
1573
            inline_help: help_bold_line("describe <d> | back <Esc>", false),
1✔
1574
            resource: &mut resource,
1✔
1575
            table_headers: vec!["Name"],
1✔
1576
            column_widths: vec![Constraint::Percentage(100)],
1✔
1577
          },
1✔
UNCOV
1578
          |c| Row::new(vec![Cell::from(c.name.to_owned())]).style(style_primary(false)),
×
1579
          false,
1580
          false,
1581
        );
1582
      })
1✔
1583
      .unwrap();
1✔
1584

1585
    let first_line = (0..terminal.backend().buffer().area.width)
1✔
1586
      .map(|col| terminal.backend().buffer()[(col, 0)].symbol())
100✔
1587
      .collect::<String>();
1✔
1588
    assert!(first_line.contains("[pod]"));
1✔
1589
    assert!(first_line.contains("clear <Esc>"));
1✔
1590
    assert!(!first_line.contains("describe <d>"));
1✔
1591
    assert!(!first_line.contains("back <Esc>"));
1✔
1592
  }
1✔
1593

1594
  #[test]
1595
  fn test_title_with_ns() {
1✔
1596
    assert_eq!(title_with_ns("Title", "hello", 3), "Title (ns: hello) [3]");
1✔
1597
  }
1✔
1598

1599
  #[test]
1600
  fn test_get_cluster_wide_resource_title() {
1✔
1601
    assert_eq!(
1✔
1602
      get_cluster_wide_resource_title("Cluster Resource", 3, ""),
1✔
1603
      " Cluster Resource [3] "
1604
    );
1605
    assert_eq!(
1✔
1606
      get_cluster_wide_resource_title("Nodes", 10, "-> hello"),
1✔
1607
      " Nodes [10] -> hello"
1608
    );
1609
  }
1✔
1610

1611
  #[test]
1612
  fn test_build_resource_help_line() {
1✔
1613
    // Case 1: Empty inline_help, empty filter, filter_active=false
1614
    // -> line text should contain the inactive "filter <key>" action hint
1615
    let line = build_resource_help_line(Line::default(), "", false, false);
1✔
1616
    let text: String = line.spans.iter().map(|s| s.content.as_ref()).collect();
1✔
1617
    let expected_filter_hint = action_hint("filter", DEFAULT_KEYBINDING.filter.key);
1✔
1618
    assert!(
1✔
1619
      text.contains(&expected_filter_hint),
1✔
1620
      "Case 1: expected '{text}' to contain '{expected_filter_hint}'"
1621
    );
1622

1623
    // Case 2: Non-empty inline_help, empty filter, filter_active=false
1624
    // -> line text should contain the inline help hint after " | "
1625
    let line2 = build_resource_help_line(help_bold_line("-> yaml <y>", false), "", false, false);
1✔
1626
    let text2: String = line2.spans.iter().map(|s| s.content.as_ref()).collect();
3✔
1627
    assert!(
1✔
1628
      text2.contains("-> yaml <y>"),
1✔
1629
      "Case 2: expected '{text2}' to contain '-> yaml <y>'"
1630
    );
1631

1632
    // Case 3: inline_help starting with the containers prefix
1633
    // -> line text should start with the containers hint
1634
    let containers_prefix_str = format!(
1✔
1635
      "{} | ",
1636
      action_hint("containers", DEFAULT_KEYBINDING.submit.key)
1✔
1637
    );
1638
    let line3 = build_resource_help_line(
1✔
1639
      help_bold_line(containers_prefix_str.as_str(), false),
1✔
1640
      "",
1✔
1641
      false,
1642
      false,
1643
    );
1644
    let text3: String = line3.spans.iter().map(|s| s.content.as_ref()).collect();
2✔
1645
    let containers_hint = action_hint("containers", DEFAULT_KEYBINDING.submit.key);
1✔
1646
    assert!(
1✔
1647
      text3.starts_with(&containers_hint),
1✔
1648
      "Case 3: expected '{text3}' to start with '{containers_hint}'"
1649
    );
1650

1651
    // Case 4: Empty inline_help, filter="foo", filter_active=false
1652
    // -> line text should contain "[foo]"
1653
    let line4 = build_resource_help_line(Line::default(), "foo", false, false);
1✔
1654
    let text4: String = line4.spans.iter().map(|s| s.content.as_ref()).collect();
2✔
1655
    assert!(
1✔
1656
      text4.contains("[foo]"),
1✔
1657
      "Case 4: expected '{text4}' to contain '[foo]'"
1658
    );
1659
  }
1✔
1660

1661
  #[test]
1662
  fn test_highlight_window_offset_within_bounds() {
1✔
1663
    // total=100, view_h=10, offset=50 → window straddles the offset.
1664
    let (start, end, scroll) = highlight_window(50, 100, 10);
1✔
1665
    assert_eq!(start, 40);
1✔
1666
    assert_eq!(end, 80);
1✔
1667
    assert_eq!(scroll, 10);
1✔
1668
    assert!(start <= end && end <= 100);
1✔
1669
  }
1✔
1670

1671
  #[test]
1672
  fn test_highlight_window_offset_at_zero() {
1✔
1673
    let (start, end, scroll) = highlight_window(0, 100, 10);
1✔
1674
    assert_eq!(start, 0);
1✔
1675
    assert_eq!(end, 30);
1✔
1676
    assert_eq!(scroll, 0);
1✔
1677
  }
1✔
1678

1679
  #[test]
1680
  fn test_highlight_window_offset_exceeds_total_does_not_panic() {
1✔
1681
    // Regression: items.len() can exceed highlighted_lines.len() when
1682
    // some lines fail to highlight, leaving offset stale relative to total.
1683
    // The slice [start..end] must remain valid.
1684
    let (start, end, _) = highlight_window(50, 5, 10);
1✔
1685
    assert!(start <= end, "start {start} must not exceed end {end}");
1✔
1686
    assert!(end <= 5, "end {end} must not exceed total");
1✔
1687
  }
1✔
1688

1689
  #[test]
1690
  fn test_highlight_window_view_h_zero_clamps_to_one() {
1✔
1691
    // A view height of 0 should not collapse the window to empty.
1692
    let (start, end, _) = highlight_window(2, 10, 0);
1✔
1693
    assert!(start < end, "window must not be empty when content exists");
1✔
1694
  }
1✔
1695

1696
  #[test]
1697
  fn test_highlight_window_total_one() {
1✔
1698
    // Single-line buffer must produce a non-empty window.
1699
    let (start, end, scroll) = highlight_window(0, 1, 5);
1✔
1700
    assert_eq!(start, 0);
1✔
1701
    assert_eq!(end, 1);
1✔
1702
    assert_eq!(scroll, 0);
1✔
1703
  }
1✔
1704
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc