mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-17 15:56:57 +02:00
add index to all iter helpers
This commit is contained in:
parent
2dc501c184
commit
29035d0b36
3 changed files with 14 additions and 10 deletions
|
|
@ -49,6 +49,11 @@ pub use self::screen::*;
|
||||||
pub trait Draw<T: Screen> {
|
pub trait Draw<T: Screen> {
|
||||||
fn draw (self, to: &mut T) -> Usually<XYWH<T::Unit>>;
|
fn draw (self, to: &mut T) -> Usually<XYWH<T::Unit>>;
|
||||||
}
|
}
|
||||||
|
impl<T: Screen> Draw<T> for () {
|
||||||
|
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
|
||||||
|
Ok(Default::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
impl<T: Screen, D: Draw<T>> Draw<T> for &D {
|
impl<T: Screen, D: Draw<T>> Draw<T> for &D {
|
||||||
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
|
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
|
||||||
|
|
@ -11,23 +11,23 @@ use super::*;
|
||||||
/// ].iter(), |x|x);
|
/// ].iter(), |x|x);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn iter <
|
pub fn iter <
|
||||||
S: Screen,
|
S: Screen, // Target screen
|
||||||
D: Draw<S>,
|
D, // Input doesn't need to be [Draw]able, output does
|
||||||
V: Fn()->I,
|
V: Fn()->I, // Function that returns the iterator
|
||||||
I: Iterator<Item = D>,
|
I: Iterator<Item = D>, // Type of the iterator
|
||||||
F: Fn(&D)->dyn Draw<S>,
|
F: Fn(&D, usize)->dyn Draw<S>, // Function that returns [Draw]able from iterator item
|
||||||
> (_items: V, _cb: F) -> impl Draw<S> {
|
> (_items: V, _cb: F) -> impl Draw<S> {
|
||||||
thunk(move|_to: &mut S|{ todo!() })
|
thunk(move|_to: &mut S|{ todo!() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_north <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
pub fn iter_north <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
||||||
_iter: impl Fn()->I, _draw: impl Fn(D)->U,
|
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
|
||||||
) -> impl Draw<S> {
|
) -> impl Draw<S> {
|
||||||
thunk(move|_to: &mut S|{ todo!() })
|
thunk(move|_to: &mut S|{ todo!() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_east <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
pub fn iter_east <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
||||||
_iter: impl Fn()->I, _draw: impl Fn(D)->U,
|
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
|
||||||
) -> impl Draw<S> {
|
) -> impl Draw<S> {
|
||||||
thunk(move|_to: &mut S|{ todo!() })
|
thunk(move|_to: &mut S|{ todo!() })
|
||||||
}
|
}
|
||||||
|
|
@ -39,8 +39,7 @@ pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_west <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
pub fn iter_west <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
|
||||||
_iter: impl Fn()->I, _draw: impl Fn(D)->U,
|
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
|
||||||
) -> impl Draw<S> {
|
) -> impl Draw<S> {
|
||||||
thunk(move|_to: &mut S|{ todo!() })
|
thunk(move|_to: &mut S|{ todo!() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use super::*;
|
||||||
/// ```
|
/// ```
|
||||||
/// /// TODO
|
/// /// TODO
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn border <T, S: BorderStyle> (on: bool, style: S, draw: impl Draw<Tui>) -> impl Draw<Tui> {
|
pub const fn border (on: bool, style: impl BorderStyle, draw: impl Draw<Tui>) -> impl Draw<Tui> {
|
||||||
let content = wh_pad(1, 1, draw);
|
let content = wh_pad(1, 1, draw);
|
||||||
let outline = when(on, thunk(move|to: &mut Tui|{
|
let outline = when(on, thunk(move|to: &mut Tui|{
|
||||||
let XYWH(x, y, w, h) = to.1;
|
let XYWH(x, y, w, h) = to.1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue