mirror of
https://github.com/alexpasmantier/television.git
synced 2025-07-29 06:11:37 +00:00

## 📺 PR Description this allows changing (or removing) the border styles tv 0.12.3: <img width="773" height="407" alt="image" src="https://github.com/user-attachments/assets/8b74fc2f-7abc-4bb8-b645-c6243f40230c" /> this PR with ```toml [ui.input_bar] border_type = 'none' [ui.results_panel] border_type = 'none' [ui.preview_panel] border_type = 'plain' ``` <img width="778" height="407" alt="image" src="https://github.com/user-attachments/assets/481fd0fa-a90a-4be8-bbe8-6e0ee5b002e3" /> see #638 ## Checklist - [ ] my commits **and PR title** follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format - [x] if this is a new feature, I have added tests to consolidate the feature and prevent regressions - [ ] if this is a bug fix, I have added a test that reproduces the bug (if applicable) - [x] I have added a reasonable amount of documentation to the code where appropriate --------- Co-authored-by: alexandre pasmantier <alex.pasmant@gmail.com>
71 lines
2.1 KiB
Rust
71 lines
2.1 KiB
Rust
use crate::{
|
|
channels::entry::Entry,
|
|
config::ui::ResultsPanelConfig,
|
|
screen::{colors::Colorscheme, layout::InputPosition, result_item},
|
|
};
|
|
use anyhow::Result;
|
|
use ratatui::{
|
|
Frame,
|
|
layout::{Alignment, Rect},
|
|
prelude::Style,
|
|
text::Line,
|
|
widgets::{Block, Borders, ListState, Padding},
|
|
};
|
|
use rustc_hash::FxHashSet;
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
pub fn draw_results_list(
|
|
f: &mut Frame,
|
|
rect: Rect,
|
|
entries: &[Entry],
|
|
selected_entries: &FxHashSet<Entry>,
|
|
relative_picker_state: &mut ListState,
|
|
input_bar_position: InputPosition,
|
|
use_nerd_font_icons: bool,
|
|
colorscheme: &Colorscheme,
|
|
results_panel_config: &ResultsPanelConfig,
|
|
) -> Result<()> {
|
|
let mut results_block = Block::default()
|
|
.title_top(Line::from(" Results ").alignment(Alignment::Center))
|
|
.style(
|
|
Style::default()
|
|
.bg(colorscheme.general.background.unwrap_or_default()),
|
|
)
|
|
.padding(Padding::from(results_panel_config.padding));
|
|
if let Some(border_type) =
|
|
results_panel_config.border_type.to_ratatui_border_type()
|
|
{
|
|
results_block = results_block
|
|
.borders(Borders::ALL)
|
|
.border_type(border_type)
|
|
.border_style(Style::default().fg(colorscheme.general.border_fg));
|
|
}
|
|
|
|
let list_direction = match input_bar_position {
|
|
InputPosition::Bottom => ratatui::widgets::ListDirection::BottomToTop,
|
|
InputPosition::Top => ratatui::widgets::ListDirection::TopToBottom,
|
|
};
|
|
|
|
let has_multi_select = !selected_entries.is_empty();
|
|
|
|
let results_list = result_item::build_results_list(
|
|
results_block,
|
|
entries,
|
|
relative_picker_state,
|
|
list_direction,
|
|
use_nerd_font_icons,
|
|
&colorscheme.results,
|
|
rect.width - 1, // right padding
|
|
|entry| {
|
|
if has_multi_select {
|
|
Some(selected_entries.contains(entry))
|
|
} else {
|
|
None
|
|
}
|
|
},
|
|
);
|
|
|
|
f.render_stateful_widget(results_list, rect, relative_picker_state);
|
|
Ok(())
|
|
}
|