mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
Merge 9a9d35bca3
into e3688e9b3d
This commit is contained in:
commit
d94aebb8a3
|
@ -30,6 +30,7 @@ pub struct FloatingText {
|
||||||
v_scroll: usize,
|
v_scroll: usize,
|
||||||
h_scroll: usize,
|
h_scroll: usize,
|
||||||
mode_title: String,
|
mode_title: String,
|
||||||
|
frame_height: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! style {
|
macro_rules! style {
|
||||||
|
@ -137,6 +138,7 @@ impl FloatingText {
|
||||||
max_line_width,
|
max_line_width,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
|
frame_height: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +169,13 @@ impl FloatingText {
|
||||||
max_line_width,
|
max_line_width,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
|
frame_height: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_down(&mut self) {
|
fn scroll_down(&mut self) {
|
||||||
if self.v_scroll + 1 < self.src.len() {
|
let visible_lines = self.frame_height.saturating_sub(2);
|
||||||
|
if self.v_scroll + visible_lines < self.src.len() {
|
||||||
self.v_scroll += 1;
|
self.v_scroll += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,6 +201,8 @@ impl FloatingText {
|
||||||
|
|
||||||
impl FloatContent for FloatingText {
|
impl FloatContent for FloatingText {
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) {
|
||||||
|
self.frame_height = area.height as usize;
|
||||||
|
|
||||||
// Define the Block with a border and background color
|
// Define the Block with a border and background color
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user