From 316b332d4af4b6106cd4b0408d056840a8e8dcb9 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Wed, 11 Aug 2021 17:56:42 +0200 Subject: [PATCH] shell: add monstera --- shell/src/main.rs | 6 ++--- shell/src/monstera.rs | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 shell/src/monstera.rs diff --git a/shell/src/main.rs b/shell/src/main.rs index c12b2fc..544c290 100644 --- a/shell/src/main.rs +++ b/shell/src/main.rs @@ -1,5 +1,5 @@ -//mod monstera; +mod monstera; use{ std::sync::{Arc, RwLock}, @@ -287,11 +287,11 @@ write:: { compositor.write().unwrap().push(magic.offset(Vector2::new(40, 4))); //compositor.write().unwrap().push(magic.offset(Vector2::new(40, 20))); -/* + let monstera_port = monstera::make_monstera(); compositor.write().unwrap().push(monstera_port.clone()); compositor.write().unwrap().push(monstera_port.offset(Vector2::new(83,0))); -*/ + } /* diff --git a/shell/src/monstera.rs b/shell/src/monstera.rs new file mode 100644 index 0000000..3319b0e --- /dev/null +++ b/shell/src/monstera.rs @@ -0,0 +1,56 @@ + +use { + cgmath::Point2, + nested::{ + core::{ViewPort, OuterViewPort}, + vec::VecBuffer, + terminal::{ + TerminalStyle, TerminalView, make_label + }, + } +}; + +pub fn make_monstera() -> OuterViewPort { + let monstera_lines_port = ViewPort::new(); + let monstera_lines = VecBuffer::with_data( + vec![ + make_label(" |"), + make_label(" |"), + make_label(" _..._ | _..._"), + make_label(" .( \\|/ )."), + make_label(" ( | )"), + make_label(" .__>. <> | <> .<__."), + make_label(" / | \\"), + make_label(" | .___ _ | _ ___. |"), + make_label(" _./___>. / \\ | / \\ .<___\\._ "), + make_label(" / \\_/ | \\_/ \\"), + make_label(" ( .____. | .____. )"), + make_label(" ( /____ \\ _ | _ / ____\\ )"), + make_label(" _* \\.) / \\ | / \\ (./ *_"), + make_label(" / \\_/ | \\_/ \\"), + make_label(" ( .__. | .__. )"), + make_label(" ( / __ \\ | / __ \\ )"), + make_label(" * / \\.) O | O (./ \\ *"), + make_label(" / .___. | .___. \\"), + make_label(" ( / .---\\ | /---. \\ )"), + make_label(" *. ( | ) .*"), + make_label(" \\_ . | . _/"), + make_label(" \\ | /"), + make_label(" .") + ], + monstera_lines_port.inner() + ); + + monstera_lines_port.outer() + .to_sequence() + .to_index() + .map_key( + |idx| Point2::new(0 as i16, *idx as i16), + |pt| if pt.x == 0 { Some(pt.y as usize) } else { None } + ) + .flatten() + .map_item( + |p, at| at.add_style_back(TerminalStyle::fg_color((0,100,10))) + ) +} +