mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
document stuff; Thunk suffix -> prefix
This commit is contained in:
parent
f9f9051eb7
commit
9d250daa04
16 changed files with 162 additions and 125 deletions
|
|
@ -11,8 +11,8 @@ fn main () -> Usually<()> {
|
|||
#[derive(Debug)] pub struct Example(usize, Measure<TuiOut>);
|
||||
const KEYMAP: &str = "(:left prev) (:right next)";
|
||||
handle!(TuiIn: |self: Example, input|{
|
||||
let keymap = KeyMap::new(KEYMAP)?;
|
||||
let command = keymap.command::<_, ExampleCommand>(self, input);
|
||||
let keymap = SourceIter::new(KEYMAP);
|
||||
let command = keymap.command::<_, ExampleCommand, _>(self, input);
|
||||
if let Some(command) = command {
|
||||
command.execute(self)?;
|
||||
return Ok(Some(true))
|
||||
|
|
@ -46,22 +46,21 @@ const EXAMPLES: &'static [&'static str] = &[
|
|||
include_str!("edn13.edn"),
|
||||
];
|
||||
view!(TuiOut: |self: Example|{
|
||||
let title = Tui::bg(Color::Rgb(60,10,10),
|
||||
Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EXAMPLES.len(), &self.1.wh()))));
|
||||
let code = Tui::bg(Color::Rgb(10,60,10),
|
||||
Push::y(2, Align::n(format!("{}", EXAMPLES[self.0]))));
|
||||
let content = Tui::bg(Color::Rgb(10,10,60),
|
||||
AtomView::from_source(self, EXAMPLES[self.0]));
|
||||
let index = self.0 + 1;
|
||||
let wh = self.1.wh();
|
||||
let src = EXAMPLES[self.0];
|
||||
let heading = format!("Example {}/{} in {:?}", index, EXAMPLES.len(), &wh);
|
||||
let title = Tui::bg(Color::Rgb(60, 10, 10), Push::y(1, Align::n(heading)));
|
||||
let code = Tui::bg(Color::Rgb(10, 60, 10), Push::y(2, Align::n(format!("{}", src))));
|
||||
let content = Tui::bg(Color::Rgb(10, 10, 60), View(self, SourceIter::new(src)));
|
||||
self.1.of(Bsp::s(title, Bsp::n(""/*code*/, content)))
|
||||
}; {
|
||||
bool {};
|
||||
u16 {};
|
||||
usize {};
|
||||
Box<dyn Render<TuiOut> + 'a> {
|
||||
":title" => Tui::bg(Color::Rgb(60,10,10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EXAMPLES.len())))).boxed(),
|
||||
":code" => Tui::bg(Color::Rgb(10,60,10), Push::y(2, Align::n(format!("{}", EXAMPLES[self.0])))).boxed(),
|
||||
":hello" => Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed(),
|
||||
":world" => Tui::bg(Color::Rgb(100, 10, 10), "world").boxed(),
|
||||
":hello-world" => "Hello world!".boxed()
|
||||
}
|
||||
":title" => Tui::bg(Color::Rgb(60, 10, 10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EXAMPLES.len())))).boxed(),
|
||||
":code" => Tui::bg(Color::Rgb(10, 60, 10), Push::y(2, Align::n(format!("{}", EXAMPLES[self.0])))).boxed(),
|
||||
":hello" => Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed(),
|
||||
":world" => Tui::bg(Color::Rgb(100, 10, 10), "world").boxed(),
|
||||
":hello-world" => "Hello world!".boxed()
|
||||
});
|
||||
provide_bool!(bool: |self: Example| {});
|
||||
provide_num!(u16: |self: Example| {});
|
||||
provide_num!(usize: |self: Example| {});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
mod tui_buffer; pub use self::tui_buffer::*;
|
||||
mod tui_color; pub use self::tui_color::*;
|
||||
mod tui_buffer; pub use self::tui_buffer::*;
|
||||
mod tui_color; pub use self::tui_color::*;
|
||||
mod tui_content; pub use self::tui_content::*;
|
||||
mod tui_engine; pub use self::tui_engine::*;
|
||||
mod tui_file; pub use self::tui_file::*;
|
||||
mod tui_file; pub use self::tui_file::*;
|
||||
mod tui_input; pub use self::tui_input::*;
|
||||
mod tui_output; pub use self::tui_output::*;
|
||||
pub use ::tek_edn; pub(crate) use ::tek_edn::*;
|
||||
pub use ::tek_edn;// pub(crate) use ::tek_edn::*;
|
||||
pub use ::tek_time; pub(crate) use ::tek_time::*;
|
||||
pub use ::tek_input; pub(crate) use tek_input::*;
|
||||
pub use ::tek_output; pub(crate) use tek_output::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue