mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 05:39:52 -07:00
Support sending and displaying typing notifications (#9)
This commit is contained in:
parent
c744d74e42
commit
d038da6844
12 changed files with 348 additions and 30 deletions
|
@ -1125,6 +1125,9 @@ impl<'a> StatefulWidget for Scrollback<'a> {
|
|||
type State = ScrollbackState;
|
||||
|
||||
fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
|
||||
let info = self.store.application.rooms.entry(state.room_id.clone()).or_default();
|
||||
let area = info.render_typing(area, buf, &self.store.application.settings);
|
||||
|
||||
state.set_term_info(area);
|
||||
|
||||
let height = state.viewctx.get_height();
|
||||
|
@ -1137,8 +1140,6 @@ impl<'a> StatefulWidget for Scrollback<'a> {
|
|||
state.viewctx.corner = state.cursor.clone();
|
||||
}
|
||||
|
||||
let info = self.store.application.get_room_info(state.room_id.clone());
|
||||
|
||||
let cursor = &state.cursor;
|
||||
let cursor_key = if let Some(k) = cursor.to_key(info) {
|
||||
k
|
||||
|
@ -1297,6 +1298,9 @@ mod tests {
|
|||
let prev = MoveDir2D::Up;
|
||||
let next = MoveDir2D::Down;
|
||||
|
||||
// Skip rendering typing notices.
|
||||
store.application.settings.tunables.typing_notice_display = false;
|
||||
|
||||
assert_eq!(scrollback.cursor, MessageCursor::latest());
|
||||
assert_eq!(scrollback.viewctx.dimensions, (0, 0));
|
||||
assert_eq!(scrollback.viewctx.corner, MessageCursor::latest());
|
||||
|
@ -1425,6 +1429,9 @@ mod tests {
|
|||
let mut scrollback = ScrollbackState::new(TEST_ROOM1_ID.clone());
|
||||
let ctx = ProgramContext::default();
|
||||
|
||||
// Skip rendering typing notices.
|
||||
store.application.settings.tunables.typing_notice_display = false;
|
||||
|
||||
// Set a terminal width of 60, and height of 3, rendering in scrollback as:
|
||||
//
|
||||
// |------------------------------------------------------------|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue