mirror of
https://github.com/ratatui/ratatui.git
synced 2025-10-02 07:21:24 +00:00
fix(examples/scrollbar): title wasn't displayed because of background reset (#795)
This commit is contained in:
parent
2b4aa46a6a
commit
50b81c9d4e
@ -100,9 +100,6 @@ fn ui(f: &mut Frame, app: &mut App) {
|
|||||||
let mut long_line = s.repeat(usize::from(size.width) / s.len() + 4);
|
let mut long_line = s.repeat(usize::from(size.width) / s.len() + 4);
|
||||||
long_line.push('\n');
|
long_line.push('\n');
|
||||||
|
|
||||||
let block = Block::default().black();
|
|
||||||
f.render_widget(block, size);
|
|
||||||
|
|
||||||
let chunks = Layout::vertical([
|
let chunks = Layout::vertical([
|
||||||
Constraint::Min(1),
|
Constraint::Min(1),
|
||||||
Constraint::Percentage(25),
|
Constraint::Percentage(25),
|
||||||
@ -143,18 +140,10 @@ fn ui(f: &mut Frame, app: &mut App) {
|
|||||||
app.vertical_scroll_state = app.vertical_scroll_state.content_length(text.len());
|
app.vertical_scroll_state = app.vertical_scroll_state.content_length(text.len());
|
||||||
app.horizontal_scroll_state = app.horizontal_scroll_state.content_length(long_line.len());
|
app.horizontal_scroll_state = app.horizontal_scroll_state.content_length(long_line.len());
|
||||||
|
|
||||||
let create_block = |title| {
|
let create_block = |title: &'static str| Block::bordered().gray().title(title.bold());
|
||||||
Block::default()
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.gray()
|
|
||||||
.title(Span::styled(
|
|
||||||
title,
|
|
||||||
Style::default().add_modifier(Modifier::BOLD),
|
|
||||||
))
|
|
||||||
};
|
|
||||||
|
|
||||||
let title = Block::default()
|
let title = Block::default()
|
||||||
.title("Use h j k l to scroll ◄ ▲ ▼ ►")
|
.title("Use h j k l or ◄ ▲ ▼ ► to scroll ".bold())
|
||||||
.title_alignment(Alignment::Center);
|
.title_alignment(Alignment::Center);
|
||||||
f.render_widget(title, chunks[0]);
|
f.render_widget(title, chunks[0]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user