rustfmt
This commit is contained in:
@ -30,7 +30,7 @@ use crate::{
|
||||
action::Action,
|
||||
buffers::{Buffers, RoomBuffer},
|
||||
commands::RataCommands,
|
||||
components::{FpsCounter, Home, Component},
|
||||
components::{Component, FpsCounter, Home},
|
||||
config::Config,
|
||||
mode::Mode,
|
||||
tui,
|
||||
@ -151,7 +151,10 @@ impl App {
|
||||
|
||||
for client in &self.clients {
|
||||
for room in client.joined_rooms() {
|
||||
self.buffers.push(Box::new(RoomBuffer::new(vec![client.clone()], room.room_id().to_owned())));
|
||||
self.buffers.push(Box::new(RoomBuffer::new(
|
||||
vec![client.clone()],
|
||||
room.room_id().to_owned(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ impl Buffers {
|
||||
Self(Vec::new())
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item=&dyn Buffer> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &dyn Buffer> {
|
||||
self.0.iter().map(|buffer_box| &**buffer_box)
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use matrix_sdk::ruma::OwnedRoomId;
|
||||
use matrix_sdk::Client;
|
||||
use matrix_sdk::Room;
|
||||
use matrix_sdk::ruma::OwnedRoomId;
|
||||
|
||||
use super::Buffer;
|
||||
|
||||
|
@ -4,11 +4,7 @@ use ratatui::layout::Rect;
|
||||
use ratatui::Frame;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use crate::{
|
||||
action::Action,
|
||||
config::Config,
|
||||
tui::Event,
|
||||
};
|
||||
use crate::{action::Action, config::Config, tui::Event};
|
||||
|
||||
mod buflist;
|
||||
pub use buflist::Buflist;
|
||||
@ -126,5 +122,10 @@ pub trait Component {
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<()>` - An Ok result or an error.
|
||||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect, buffers: &crate::buffers::Buffers) -> Result<()>;
|
||||
fn draw(
|
||||
&mut self,
|
||||
f: &mut Frame<'_>,
|
||||
area: Rect,
|
||||
buffers: &crate::buffers::Buffers,
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
@ -57,9 +57,21 @@ impl Component for Buflist {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame<'_>, area: Rect, buffers: &crate::buffers::Buffers) -> Result<()> {
|
||||
fn draw(
|
||||
&mut self,
|
||||
frame: &mut Frame<'_>,
|
||||
area: Rect,
|
||||
buffers: &crate::buffers::Buffers,
|
||||
) -> Result<()> {
|
||||
frame.render_widget(
|
||||
Paragraph::new(buffers.iter().map(|buf| buf.short_name()).collect::<Vec<_>>().join("\n")).block(Block::new().borders(Borders::ALL)),
|
||||
Paragraph::new(
|
||||
buffers
|
||||
.iter()
|
||||
.map(|buf| buf.short_name())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n"),
|
||||
)
|
||||
.block(Block::new().borders(Borders::ALL)),
|
||||
area,
|
||||
);
|
||||
|
||||
|
@ -71,7 +71,12 @@ impl Component for FpsCounter {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, f: &mut Frame<'_>, rect: Rect, _buffers: &crate::buffers::Buffers) -> Result<()> {
|
||||
fn draw(
|
||||
&mut self,
|
||||
f: &mut Frame<'_>,
|
||||
rect: Rect,
|
||||
_buffers: &crate::buffers::Buffers,
|
||||
) -> Result<()> {
|
||||
let rects = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(vec![
|
||||
|
@ -51,13 +51,21 @@ impl Component for Home {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame<'_>, area: Rect, buffers: &crate::buffers::Buffers) -> Result<()> {
|
||||
fn draw(
|
||||
&mut self,
|
||||
frame: &mut Frame<'_>,
|
||||
area: Rect,
|
||||
buffers: &crate::buffers::Buffers,
|
||||
) -> Result<()> {
|
||||
let layout = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(vec![Constraint::Percentage(20), Constraint::Percentage(80)])
|
||||
.split(area);
|
||||
|
||||
self.buflist.draw(frame, layout[0], buffers).context("Error drawing buflist")?;
|
||||
self
|
||||
.buflist
|
||||
.draw(frame, layout[0], buffers)
|
||||
.context("Error drawing buflist")?;
|
||||
frame.render_widget(
|
||||
Paragraph::new("buffer goes here").block(Block::new().borders(Borders::ALL)),
|
||||
layout[1],
|
||||
|
Reference in New Issue
Block a user