mirror of
https://github.com/youwen5/iamb.git
synced 2025-08-04 11:38:28 -07:00
Support sending and displaying formatted messages (#10)
This commit is contained in:
parent
8966644f6e
commit
4f2261e66f
11 changed files with 1770 additions and 233 deletions
14
src/main.rs
14
src/main.rs
|
@ -42,6 +42,7 @@ mod commands;
|
|||
mod config;
|
||||
mod keybindings;
|
||||
mod message;
|
||||
mod util;
|
||||
mod windows;
|
||||
mod worker;
|
||||
|
||||
|
@ -99,6 +100,14 @@ use modalkit::{
|
|||
},
|
||||
};
|
||||
|
||||
const MIN_MSG_LOAD: u32 = 50;
|
||||
|
||||
fn msg_load_req(area: Rect) -> u32 {
|
||||
let n = area.height as u32;
|
||||
|
||||
n.max(MIN_MSG_LOAD)
|
||||
}
|
||||
|
||||
struct Application {
|
||||
store: AsyncProgramStore,
|
||||
worker: Requester,
|
||||
|
@ -176,7 +185,7 @@ impl Application {
|
|||
f.set_cursor(cx, cy);
|
||||
}
|
||||
|
||||
store.application.load_older(area.height as u32);
|
||||
store.application.load_older(msg_load_req(area));
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
@ -186,7 +195,8 @@ impl Application {
|
|||
loop {
|
||||
self.redraw(false, self.store.clone().lock().await.deref_mut())?;
|
||||
|
||||
if !poll(Duration::from_millis(500))? {
|
||||
if !poll(Duration::from_secs(1))? {
|
||||
// Redraw in case there's new messages to show.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue