mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
cargo fmt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
use drk::tui::{App, HBox, VBox, Widget};
|
||||
use drk::Result;
|
||||
use drk::{
|
||||
tui::{App, HBox, VBox, Widget},
|
||||
Result,
|
||||
};
|
||||
|
||||
async fn start() -> Result<()> {
|
||||
let wv1 = vec![Widget::new("V1".into())?];
|
||||
|
||||
@@ -8,8 +8,8 @@ use termion::{
|
||||
raw::{IntoRawMode, RawTerminal},
|
||||
};
|
||||
|
||||
use crate::Result;
|
||||
use super::Layout;
|
||||
use crate::Result;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct App {
|
||||
@@ -25,11 +25,7 @@ impl App {
|
||||
let stdout = std::io::stdout();
|
||||
let stdout = stdout.into_raw_mode()?;
|
||||
|
||||
Ok(Self {
|
||||
stdin,
|
||||
stdout,
|
||||
layouts: vec![],
|
||||
})
|
||||
Ok(Self { stdin, stdout, layouts: vec![] })
|
||||
}
|
||||
|
||||
fn clear(&mut self) -> Result<()> {
|
||||
@@ -93,7 +89,7 @@ impl App {
|
||||
if terminal_width > box_x {
|
||||
terminal_width -= box_x;
|
||||
} else {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +98,7 @@ impl App {
|
||||
if terminal_height > box_y {
|
||||
terminal_height -= box_y;
|
||||
} else {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
pub mod widget;
|
||||
pub mod app;
|
||||
pub mod widget;
|
||||
|
||||
pub use widget::{HBox, VBox, Widget, Layout};
|
||||
pub use app::App;
|
||||
|
||||
pub use widget::{HBox, Layout, VBox, Widget};
|
||||
|
||||
@@ -15,13 +15,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
pub fn new(title: String) -> Result<Widget> {
|
||||
Ok(Widget {
|
||||
width: 0,
|
||||
height: 0,
|
||||
x: 0,
|
||||
y: 0,
|
||||
title,
|
||||
})
|
||||
Ok(Widget { width: 0, height: 0, x: 0, y: 0, title })
|
||||
}
|
||||
|
||||
pub fn print(
|
||||
@@ -31,12 +25,7 @@ impl Widget {
|
||||
y: usize,
|
||||
text: &str,
|
||||
) -> Result<()> {
|
||||
write!(
|
||||
stdout,
|
||||
"{}{}",
|
||||
cursor::Goto(1 + x as u16, 1 + y as u16),
|
||||
text
|
||||
)?;
|
||||
write!(stdout, "{}{}", cursor::Goto(1 + x as u16, 1 + y as u16), text)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -82,12 +71,7 @@ impl Widget {
|
||||
|
||||
pub fn draw(&self, stdout: &mut RawTerminal<Stdout>) -> Result<()> {
|
||||
self.print_border(stdout)?;
|
||||
self.print(
|
||||
stdout,
|
||||
self.x + 3,
|
||||
self.y,
|
||||
&format!(" {} ", &self.title.clone()),
|
||||
)?;
|
||||
self.print(stdout, self.x + 3, self.y, &format!(" {} ", &self.title.clone()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -159,13 +143,12 @@ impl Layout for HBox {
|
||||
layout_width: usize,
|
||||
layout_height: usize,
|
||||
) -> Result<(usize, usize)> {
|
||||
|
||||
let len = self.widgets.len();
|
||||
|
||||
let widget_height = layout_height / self.height;
|
||||
|
||||
for (i, widget) in self.widgets.iter_mut().enumerate() {
|
||||
widget.width = layout_width / len - 1;
|
||||
widget.width = layout_width / len - 1;
|
||||
widget.height = widget_height - 1;
|
||||
widget.x = (widget.width + 1) * i + x;
|
||||
widget.y = y;
|
||||
|
||||
Reference in New Issue
Block a user