Comments (7)
This commit 9072d962a9e643cdf868803a23bbbe01dac57ae2 is the first step towards assembling the "React JSX"-like syntax from scratch. It makes the following changes.
Associated commit in r3bl-org/r3bl-cmdr@9072d962a9e643cdf868803a23bbbe01dac57ae2
Original code:
tw_surface.box_start(TWBoxProps {
styles: tw_surface.stylesheet.find_styles_by_ids(vec!["style1"]),
id: COL_1_ID.into(),
dir: Direction::Vertical,
req_size: (50, 100).try_into()?,
})?;
Next, use the box_props!
macro:
tw_surface.box_start(box_props! {
COL_1_ID,
Direction::Vertical,
(50, 100).try_into()?,
get_styles! { from: tw_surface.stylesheet => ["style1", "style2"] }
})?;
Finally, use the box_start!
macro:
box_start! {
in: tw_surface,
COL_1_ID,
Direction::Vertical,
(50, 100).try_into()?,
["style1", "style2"]
};
from r3bl-open-core.
This commit de38450 adds the following functionality.
Associated commit in r3bl-org/r3bl-cmdr@8024029e4d5ead398c61ae5f6f1ed31188943929
Use render_component
macro to simplify this:
if let Some(shared_component) = self.component_registry.get(COL_2_ID) {
let current_box = tw_surface.current_box()?;
let queue = shared_component
.write()
.await
.render(&self.has_focus, current_box, state, shared_store)
.await?;
tw_surface.render_buffer += queue;
}
into this:
render_component! {
in: tw_surface,
from: self.component_registry,
id: COL_1_ID,
has_focus: self.has_focus,
state: state,
shared_store: shared_store
};
from r3bl-open-core.
This commit f65dc6e moves all the JSX-like syntax stuff into RSX module:
https://github.com/r3bl-org/r3bl-rs-utils/blob/main/src/tui/rsx
from r3bl-open-core.
These commits: [ 1d50f2e and r3bl-org/r3bl-cmdr@590e749788da1afeb46340823782c9e619d68357 ] introduce the make_box!
macro. This is the start of the RSX declarative style of syntax for creating layout.
This macro is possible due to TT munching in declarative macros: https://veykril.github.io/tlborm/decl-macros/patterns/tt-muncher.html
Here's the new code.
make_box! {
in: tw_surface,
id: COL_1_ID,
dir: Direction::Vertical,
size: (50, 100).try_into()?,
style: ["style1", "style2"],
render: {
from: self.component_registry,
component_id: COL_1_ID,
has_focus: self.has_focus,
state: state,
shared_store: shared_store
}
}
Here's the old code it replaces:
box_start! {
in: tw_surface,
COL_1_ID,
Direction::Vertical,
(50, 100).try_into()?,
["style1", "style2"]
};
render_component! {
in: tw_surface,
from: self.component_registry,
id: COL_1_ID,
has_focus: self.has_focus,
state: state,
shared_store: shared_store
};
tw_surface.box_end()?;
And here's the original code w/out macros:
tw_surface.box_start(TWBoxProps {
styles: tw_surface.stylesheet.find_styles_by_ids(vec!["style2"]),
id: COL_2_ID.to_string(),
dir: Direction::Vertical,
req_size: (50, 100).try_into()?,
})?;
// OPTIMIZE: macro?
if let Some(shared_component) = self.component_registry.get(COL_2_ID) {
let current_box = tw_surface.current_box()?;
let queue = shared_component
.write()
.await
.render(&self.has_focus, current_box, state, shared_store)
.await?;
tw_surface.render_buffer += queue;
}
tw_surface.box_end()?;
from r3bl-open-core.
The box_start!
macro is further simplified by 0a560d8 and r3bl-org/r3bl-cmdr@5b13bde38a4377ed6a72d7efe81698231642b2dd.
make_box! {
in: tw_surface,
id: COL_1_ID,
dir: Direction::Vertical,
size: (50, 100).try_into()?,
style: ["style1"],
render: {
from: self.component_registry,
has_focus: self.has_focus,
state: state,
shared_store: shared_store
}
}
from r3bl-open-core.
All the macros are now cleaned up so they all have clearly identified fields. So in:
, id:
, dir:
, etc. are all consistently passed thru.
from r3bl-open-core.
Add a new macro surface_start
to make it a little easier to work w/ Surface
. Rename TWSurface
-> Surface
. Drop the TW
prefix on all names; except for when they collide w/ other common names like Box
and Command
.
let mut surface = surface_start! {
stylesheet: style_helpers::create_stylesheet()?,
pos: (0, 0).into(),
size: (window_size.cols, window_size.rows - 1).into(), // Leave row at bottom for message.
};
self
.create_main_container(&mut surface, state, shared_store)
.await?;
surface.surface_end()?;
status_bar_helpers::render(&mut surface.render_buffer, window_size);
surface.render_buffer
✅ The following commits add this functionality:
- b30e686
r3bl-org/r3bl-cmdr@12238df194ed8032f7ce28205a28f51029e4d5d5 - 16a1ebe r3b-org/r3bl-cmdr@7bc1499349dca61f3412cc79129386cf508f4b2b
from r3bl-open-core.
Related Issues (20)
- [tuify][giti][docs] Create `giti branch checkout` UX HOT 1
- [giti][docs] Create `giti commit` user flows
- [tuify][giti][docs] Create `giti branch new` user flow HOT 1
- [giti] `giti branch delete`: If user deleted current branch, switch them to main development branch
- [giti] `giti branch delete`: Handle user deleting current branch which is main development branch
- [giti] `giti branch delete`: Handle user trying to delete all the branches
- [giti] `giti branch delete`: Prefix relevant branches with "(current) " and "(merged) "
- [giti] `giti branch checkout`: Create a user experience for switching to another branch
- [giti] `giti branch new`: Create a user experience for creating a new branch HOT 1
- [giti] `git log search`: Create a user experience for searching git log
- [giti] Move giti.rs into cmdr folder (r3bl-cmdr repo). Do the same for edi.rs
- [giti] Update giti to use `select_from_list_with_multi_line_header` component HOT 1
- [edi][giti] update readme before launching them
- [giti][edi] Copy to clipboard upgrade command
- [giti] Add an option to checkout a branch by typing the name HOT 1
- [tuify] Fix tuify multiselect component up and down navigation issue
- Update all the r3bl-open-core README.md
- [giti] Display the git command(s) we run for giti workflow
- [tui][edi] editor component MD parser problem with block quotes
- [tui][edi] editor component upgrades
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r3bl-open-core.