mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-28 16:14:16 +02:00
other: add a redraw event on resize (#926)
This commit is contained in:
parent
ac5e2ce4a2
commit
1920f4b2e1
@ -157,6 +157,9 @@ fn main() -> Result<()> {
|
|||||||
// TODO: Would be good to instead use a mix of is_terminated check + recv. Probably use a termination event instead.
|
// TODO: Would be good to instead use a mix of is_terminated check + recv. Probably use a termination event instead.
|
||||||
if let Ok(recv) = receiver.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
if let Ok(recv) = receiver.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
||||||
match recv {
|
match recv {
|
||||||
|
BottomEvent::Resize => {
|
||||||
|
try_drawing(&mut terminal, &mut app, &mut painter)?;
|
||||||
|
}
|
||||||
BottomEvent::KeyInput(event) => {
|
BottomEvent::KeyInput(event) => {
|
||||||
if handle_key_event_or_break(event, &mut app, &collection_thread_ctrl_sender) {
|
if handle_key_event_or_break(event, &mut app, &collection_thread_ctrl_sender) {
|
||||||
break;
|
break;
|
||||||
|
@ -71,6 +71,7 @@ pub type Pid = libc::pid_t;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BottomEvent {
|
pub enum BottomEvent {
|
||||||
|
Resize,
|
||||||
KeyInput(KeyEvent),
|
KeyInput(KeyEvent),
|
||||||
MouseInput(MouseEvent),
|
MouseInput(MouseEvent),
|
||||||
PasteEvent(String),
|
PasteEvent(String),
|
||||||
@ -431,6 +432,14 @@ pub fn create_input_thread(
|
|||||||
if let Ok(event) = read() {
|
if let Ok(event) = read() {
|
||||||
// FIXME: Handle all other event cases.
|
// FIXME: Handle all other event cases.
|
||||||
match event {
|
match event {
|
||||||
|
// TODO: Might want to debounce this in the future, or take into account the actual resize
|
||||||
|
// values. Maybe we want to keep the current implementation in case the resize event might
|
||||||
|
// not fire... not sure.
|
||||||
|
Event::Resize(_, _) => {
|
||||||
|
if sender.send(BottomEvent::Resize).is_err() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Event::Paste(paste) => {
|
Event::Paste(paste) => {
|
||||||
if sender.send(BottomEvent::PasteEvent(paste)).is_err() {
|
if sender.send(BottomEvent::PasteEvent(paste)).is_err() {
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user