mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-03-13 12:10:44 +01:00
it's a song!
This commit is contained in:
parent
0d8503cc05
commit
5d0dc40fdc
11 changed files with 846 additions and 828 deletions
|
|
@ -270,15 +270,11 @@ impl<O: Out, D: Draw<O>> Draw<O> for Option<D> {
|
|||
//}
|
||||
|
||||
impl<O: Out, T: Content<O>, F: Fn()->T> Lazy<O, T, F> {
|
||||
pub const fn new (thunk: F) -> Self {
|
||||
Self(thunk, PhantomData)
|
||||
}
|
||||
pub const fn new (thunk: F) -> Self { Self(thunk, PhantomData) }
|
||||
}
|
||||
|
||||
impl<O: Out, F: Fn(&mut O)> Thunk<O, F> {
|
||||
pub const fn new (draw: F) -> Self {
|
||||
Self(PhantomData, draw)
|
||||
}
|
||||
pub const fn new (draw: F) -> Self { Self(PhantomData, draw) }
|
||||
}
|
||||
|
||||
impl<O: Out, F: Fn(&mut O)> Layout<O> for Thunk<O, F> {}
|
||||
|
|
@ -672,57 +668,15 @@ impl<Head, Tail> Bsp<Head, Tail> {
|
|||
|
||||
impl<O: Out, Head: Content<O>, Tail: Content<O>> Draw<O> for Bsp<Head, Tail> {
|
||||
fn draw (&self, to: &mut O) {
|
||||
match self.0 {
|
||||
North => { // FIXME
|
||||
let area_1 = self.1.layout(to.area());
|
||||
let area_2 = self.2.layout(XYWH(
|
||||
to.area().x(), to.area().y().plus(area_1.h()),
|
||||
to.area().w(), to.area().h().minus(area_1.h())
|
||||
));
|
||||
to.place_at(area_1, &self.1);
|
||||
to.place_at(area_2, &self.2);
|
||||
},
|
||||
South => {
|
||||
let area_1 = self.1.layout(to.area());
|
||||
let area_2 = self.2.layout(XYWH(
|
||||
to.area().x(), to.area().y().plus(area_1.h()),
|
||||
to.area().w(), to.area().h().minus(area_1.h())
|
||||
));
|
||||
to.place_at(area_1, &self.1);
|
||||
to.place_at(area_2, &self.2);
|
||||
},
|
||||
East => {
|
||||
let area_1 = self.1.layout(to.area());
|
||||
let area_2 = self.2.layout(XYWH(
|
||||
to.area().x().plus(area_1.w()), to.area().y(),
|
||||
to.area().w().minus(area_1.w()), to.area().h()
|
||||
));
|
||||
to.place_at(area_1, &self.1);
|
||||
to.place_at(area_2, &self.2);
|
||||
},
|
||||
Above => {
|
||||
let area_1 = self.1.layout(to.area());
|
||||
let area_2 = self.2.layout(to.area());
|
||||
to.place_at(area_2, &self.2);
|
||||
to.place_at(area_1, &self.1);
|
||||
},
|
||||
Below => {
|
||||
let area_1 = self.1.layout(to.area());
|
||||
let area_2 = self.2.layout(to.area());
|
||||
to.place_at(area_1, &self.1);
|
||||
to.place_at(area_2, &self.2);
|
||||
},
|
||||
_ => todo!("{:?}", self.0)
|
||||
}
|
||||
//let [a, b, _] = bsp_areas(to.area(), self.0, &self.1, &self.2);
|
||||
let [a, b, _] = bsp_areas(to.area(), self.0, &self.1, &self.2);
|
||||
//panic!("{a:?} {b:?}");
|
||||
//if self.0 == Below {
|
||||
//to.place_at(a, &self.1);
|
||||
//to.place_at(b, &self.2);
|
||||
//} else {
|
||||
//to.place_at(b, &self.2);
|
||||
//to.place_at(a, &self.1);
|
||||
//}
|
||||
if self.0 == Below {
|
||||
to.place_at(a, &self.1);
|
||||
to.place_at(b, &self.2);
|
||||
} else {
|
||||
to.place_at(b, &self.2);
|
||||
to.place_at(a, &self.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1011,7 +965,7 @@ impl PerfModel {
|
|||
}
|
||||
|
||||
impl Tui {
|
||||
pub fn new (output: Stdout) -> Usually<Self> {
|
||||
pub fn new (output: Box<dyn Write + Send + Sync>) -> Usually<Self> {
|
||||
let backend = CrosstermBackend::new(output);
|
||||
let Size { width, height } = backend.size()?;
|
||||
Ok(Self {
|
||||
|
|
@ -1061,6 +1015,8 @@ impl Input for TuiIn {
|
|||
type Event = TuiEvent;
|
||||
type Handled = bool;
|
||||
fn event (&self) -> &TuiEvent { &self.event }
|
||||
}
|
||||
impl Done for TuiIn {
|
||||
fn done (&self) { self.exited.store(true, Relaxed); }
|
||||
fn is_done (&self) -> bool { self.exited.fetch_and(true, Relaxed) }
|
||||
}
|
||||
|
|
@ -1076,6 +1032,11 @@ impl TuiEvent {
|
|||
Ok(TuiKey::from_dsl(dsl)?.to_crossterm().map(Self))
|
||||
}
|
||||
}
|
||||
impl From<Event> for TuiEvent {
|
||||
fn from (e: Event) -> Self {
|
||||
Self(e)
|
||||
}
|
||||
}
|
||||
impl From<char> for TuiEvent {
|
||||
fn from (c: char) -> Self {
|
||||
Self(Event::Key(KeyEvent::new(KeyCode::Char(c), KeyModifiers::NONE)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue