Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt builder pattern #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ members = [
"shrs_vi",
"plugins/shrs_output_capture",
"plugins/shrs_cd_tools",
"plugins/shrs_prompt_builder",
]
15 changes: 15 additions & 0 deletions plugins/shrs_prompt_builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "shrs_prompt_builder"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["MrPicklePinosaur"]
description = "Builder pattern for shrs prompt"
repository = "https://github.com/MrPicklePinosaur/sh.rs"

[dependencies]
shrs = { path = "../../shrs" }
crossterm = "0.26"

derive_builder = "0.12"
thiserror = "1"
42 changes: 42 additions & 0 deletions plugins/shrs_prompt_builder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//! Builder pattern for prompt
//!
//!

#[macro_use]
extern crate derive_builder;

pub trait Section {
fn render(&self);
}

pub struct DerivePromptBuilder {
sections: Vec<Box<dyn Section>>,
}

impl DerivePromptBuilder {
pub fn new() -> Self {
DerivePromptBuilder {
sections: Vec::new(),
}
}

/// Display section conditionally
pub fn cond(&mut self, section: impl Section, pred: fn() -> bool) {}

/*
/// Insert a text section
pub fn text(&mut self, section: Section) {

}

/// Insert newline
pub fn newline(&mut self) {

}

/// Insert some spacing
pub fn spacer(&mut self, width: usize) {

}
*/
}