How to create a status bar? #677
-
How can I create a status bar like this one? It's always at the bottom and always top most. Can I use cursive to achieve this? Or must I have to use a lower level lib like crossterm? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, and thanks for the question! To create a status bar, you can add a transparent full-screen layer at the back of your StackView, which only draws something at the bottom. use cursive::traits::{Nameable, Resizable};
use cursive::view::View;
use cursive::views::{FixedLayout, Layer, OnLayoutView, TextView};
use cursive::{Rect, Vec2};
fn main() {
let mut siv = cursive::default();
siv.screen_mut().add_transparent_layer(
OnLayoutView::new(
FixedLayout::new().child(
Rect::from_point(Vec2::zero()),
Layer::new(TextView::new("Status").with_name("status"))
.full_width(),
),
|layout, size| {
layout.set_child_position(
0,
Rect::from_size((0, size.y - 1), (size.x, 1)),
);
layout.layout(size);
},
)
.full_screen(),
);
siv.run();
} (Using a |
Beta Was this translation helpful? Give feedback.
Hi, and thanks for the question!
To create a status bar, you can add a transparent full-screen layer at the back of your StackView, which only draws something at the bottom.
For example, you can use a
FixedLayout
to manually specify the location of aTextView
, and useOnLayoutView
to update this location when the terminal is resized: