Skip to content

Commit be965f3

Browse files
committed
[all] Drop macro crate (archive it), introduce new_style! and tui_color!
The CHANGELOG has all the details. The summary is: - Drop the macro crate as the proc macro for tui_style! is replaced with a decl macro new_style! Instead of working with TuiStyle, using this macro is strongly encouraged and used in the entire codebase. - TUI color! macro is now rewritten and enhanced as tui_color! Instead of working with TuiColor directly, using this macro is strongly encouraged and is used in the entire codebase.
1 parent d2fb681 commit be965f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1120
-2228
lines changed

.vscode/bookmarks.json

-24
This file was deleted.

CHANGELOG.md

+55-44
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,9 @@ idioms and design patterns are used in this release.
895895
- A new telemetry API is also in this release, which makes it easy to measure and report
896896
performance metrics in a memory access and CPU performant way. This is built for the
897897
`r3bl_tui` main event loop (which is a very hot loop).
898+
- `new_style!` (decl macro) replaces `tui_style!` (proc macro). `tui_color!` also replaces
899+
`color!`. You are not expected to work with `TuiStyle` or `TuiColor` directly. Instead,
900+
you are expected to work with these decl macros.
898901

899902
These videos have been an inspiration for many of these changes:
900903
- [Data oriented design](https://youtu.be/WwkuAqObplU)
@@ -921,6 +924,9 @@ Removed:
921924
like `ch()`, `usize()`, `f64()`, etc.
922925

923926
Changed:
927+
- In `decl_macros/macros.rs` change the semantics of the `with!` macro, so that the
928+
`$id` is only contained to the `run` block and doesn't get added to the caller's scope
929+
/ block.
924930
- Add new declarative macros to mimic `.join(..)` method on `Vec` and `String`. This
925931
makes it easier to join a collection of items into a string, or a collection of
926932
strings into a string with (`join!` & `join_with_index!`) or without allocations
@@ -968,6 +974,14 @@ Changed:
968974
- Replace the use of `bool` with meaningful enums to enhance code readability.
969975

970976
- Added:
977+
- [Archive](#archived-2025-03-11) the `tui_style!` proc macro. Replace it with an easier
978+
to use decl macro `new_style!`. This allows the `r3bl_macro` crate to be removed from
979+
the workspace, and all the crates in it. `new_style!` makes it a breeze to work with
980+
`TuiStyle` struct, so there is no need to manipulate it directly except if you need
981+
to.
982+
- Expand the functionality of `tui_color!` and rename it from `color!`. This macro makes
983+
it trivial to create different variants of `TuiColor` without having to work with the
984+
complex variants of the struct.
971985
- Add a new test fixture `temp_dir::create_temp_dir()` to make it easy to create
972986
temporary directories for tests. Any temporary directories created are automatically
973987
cleaned up after the test is done. The `TempDir` struct implements many traits that
@@ -1112,50 +1126,6 @@ in the real world.
11121126
- Added:
11131127
- Initial support structs for use by `r3bl-base` and `r3bl-cmdr`.
11141128

1115-
## `r3bl_macro`
1116-
1117-
### v_next_release_r3bl_macro
1118-
1119-
This release contains changes that are part of optimizing memory allocation to increase
1120-
performance, and ensure that performance is stable over time. `ch_unit.rs` is also heavily
1121-
refactored and the entire codebase updated so that a the more ergonomic `ChUnit` API is
1122-
now used throughout the codebase. No new functionality is added in this release.
1123-
1124-
- Updated:
1125-
- Use the latest Rust 2024 edition.
1126-
1127-
- Changed:
1128-
- Change the semantics of the `with!` macro, so that the `$id` is only contained to the `run` block and doesn't
1129-
get added to the caller's scope / block.
1130-
1131-
### v0.10.0 (2024-10-20)
1132-
1133-
This is a major release that does not include any new functionality, but is a radical
1134-
reorganization & rename of the crate, it used to be
1135-
[`r3bl_rs_utils_macro`](#rename-to-r3bl_macro).
1136-
1137-
The `r3bl-open-core` repo was started in `2022-02-23`, about 1 year, 7 months, and 11 days
1138-
ago, (which you can get using `curl https://api.github.com/repos/r3bl-org/r3bl-open-core |
1139-
jq .created_at`). We have learned many lessons since then after writing about 125K lines
1140-
of Rust code.
1141-
1142-
And it is time to pay down the accrued technical debt, to ensure that the codebase is
1143-
easier to maintain and understand, and easier to add new features to in the future. The
1144-
separation of concerns is now much clearer, and they reflect how the functionality is used
1145-
in the real world.
1146-
1147-
This [PR](https://github.com/r3bl-org/r3bl-open-core/pull/360) contains all the changes.
1148-
1149-
Changed:
1150-
- The name of this repo used to be [`r3bl_rs_utils_macro`](#rename-to-r3bl_macro).
1151-
- The modules and functions in this crate which are used (by other crates in this monorepo)
1152-
are left unchanged. Only the unused modules and functions are moved to the
1153-
[`r3bl-open-core-archive`](https://github.com/r3bl-open-core-archive) repo.
1154-
1155-
Deleted:
1156-
- Move all the unused modules and functions to the
1157-
[`r3bl-open-core-archive`](https://github.com/r3bl-open-core-archive) repo.
1158-
11591129
## `r3bl_test_fixtures`
11601130

11611131
### v_next_release_r3bl_test_fixtures
@@ -1732,6 +1702,47 @@ the `ok!()` macro.
17321702

17331703
<!-- Archived section -->
17341704

1705+
## `r3bl_macro`
1706+
1707+
### Archived (2025-03-11)
1708+
1709+
The only purpose for having this crate is the requirements for Rust to have procedural
1710+
macros be in a separate crate. Proc macros also increase the build time. For this reason
1711+
we have rewritten the `tui_style!` macro as a declarative macro in the `r3bl_core` crate
1712+
called `new_style!`. And are archiving this crate.
1713+
1714+
This crate used to be called `r3bl_rs_utils_macro`. It was renamed to `r3bl_macro` in
1715+
late 2024. And in early 2025, it is being archived.
1716+
1717+
### v0.10.0 (2024-10-20)
1718+
1719+
This is a major release that does not include any new functionality, but is a radical
1720+
reorganization & rename of the crate, it used to be
1721+
[`r3bl_rs_utils_macro`](#rename-to-r3bl_macro).
1722+
1723+
The `r3bl-open-core` repo was started in `2022-02-23`, about 1 year, 7 months, and 11 days
1724+
ago, (which you can get using `curl https://api.github.com/repos/r3bl-org/r3bl-open-core |
1725+
jq .created_at`). We have learned many lessons since then after writing about 125K lines
1726+
of Rust code.
1727+
1728+
And it is time to pay down the accrued technical debt, to ensure that the codebase is
1729+
easier to maintain and understand, and easier to add new features to in the future. The
1730+
separation of concerns is now much clearer, and they reflect how the functionality is used
1731+
in the real world.
1732+
1733+
This [PR](https://github.com/r3bl-org/r3bl-open-core/pull/360) contains all the changes.
1734+
1735+
Changed:
1736+
- The name of this repo used to be [`r3bl_rs_utils_macro`](#rename-to-r3bl_macro).
1737+
- The modules and functions in this crate which are used (by other crates in this monorepo)
1738+
are left unchanged. Only the unused modules and functions are moved to the
1739+
[`r3bl-open-core-archive`](https://github.com/r3bl-open-core-archive) repo.
1740+
1741+
Deleted:
1742+
- Move all the unused modules and functions to the
1743+
[`r3bl-open-core-archive`](https://github.com/r3bl-open-core-archive) repo.
1744+
1745+
17351746
## `r3bl_simple_logger`
17361747

17371748
### Archived (2024-09-27)

Cargo.lock

-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ members = [
55
"ansi_color",
66
"cmdr",
77
"core",
8-
"macro",
98
"terminal_async",
109
"test_fixtures",
1110
"tui",

cmdr/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ path = "src/lib.rs"
4545
# R3BL crates (from this mono repo).
4646
r3bl_ansi_color = { path = "../ansi_color", version = "0.7.0" } # version is required to publish to crates.io
4747
r3bl_core = { path = "../core", version = "0.10.0" } # version is required to publish to crates.io
48-
r3bl_macro = { path = "../macro", version = "0.10.0" } # version is required to publish to crates.io
4948
r3bl_tui = { path = "../tui", version = "0.6.0" } # version is required to publish to crates.io
5049
r3bl_tuify = { path = "../tuify", version = "0.2.0" } # version is required to publish to crates.io
5150
r3bl_analytics_schema = { path = "../analytics_schema", version = "0.0.2" } # version is required to publish to crates.io

cmdr/src/edi/app_main.rs

+33-37
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
use crossterm::style::Stylize;
19-
use r3bl_core::{ANSIBasicColor,
20-
Ansi256GradientIndex,
18+
use r3bl_core::{Ansi256GradientIndex,
2119
ColorWheel,
2220
ColorWheelConfig,
2321
ColorWheelSpeed,
@@ -28,22 +26,22 @@ use r3bl_core::{ANSIBasicColor,
2826
GradientGenerationPolicy,
2927
StringStorage,
3028
TextColorizationPolicy,
31-
TuiColor,
3229
TuiStyledTexts,
3330
TuiStylesheet,
3431
call_if_true,
3532
col,
3633
get_tui_style,
3734
glyphs,
3835
height,
36+
new_style,
3937
req_size_pc,
4038
row,
4139
send_signal,
4240
throws,
4341
throws_with_return,
42+
tui_color,
4443
tui_styled_text,
4544
tui_stylesheet};
46-
use r3bl_macro::tui_style;
4745
use r3bl_tui::{App,
4846
BoxedSafeApp,
4947
ComponentRegistry,
@@ -635,37 +633,37 @@ mod stylesheet {
635633
pub fn create_stylesheet() -> CommonResult<TuiStylesheet> {
636634
throws_with_return!({
637635
tui_stylesheet! {
638-
tui_style! {
639-
id: Id::StyleEditorDefault
640-
padding: 1
636+
new_style!(
637+
id: {Id::StyleEditorDefault}
638+
padding: {1}
641639
// These are ignored due to syntax highlighting.
642640
// attrib: [bold]
643641
// color_fg: TuiColor::Blue
644-
},
645-
tui_style! {
646-
id: Id::StyleDialogTitle
647-
lolcat: true
642+
),
643+
new_style!(
644+
id: {Id::StyleDialogTitle}
645+
lolcat
648646
// These are ignored due to lolcat: true.
649647
// attrib: [bold]
650648
// color_fg: TuiColor::Yellow
651-
},
652-
tui_style! {
653-
id: Id::StyleDialogBorder
654-
lolcat: true
649+
),
650+
new_style!(
651+
id: {Id::StyleDialogBorder}
652+
lolcat
655653
// These are ignored due to lolcat: true.
656654
// attrib: [dim]
657655
// color_fg: TuiColor::Green
658-
},
659-
tui_style! {
660-
id: Id::StyleDialogEditor
661-
attrib: [bold]
662-
color_fg: TuiColor::Basic(ANSIBasicColor::Magenta)
663-
},
664-
tui_style! {
665-
id: Id::StyleDialogResultsPanel
666-
// attrib: [bold]
667-
color_fg: TuiColor::Basic(ANSIBasicColor::Blue)
668-
}
656+
),
657+
new_style!(
658+
id: {Id::StyleDialogEditor}
659+
bold
660+
color_fg: {tui_color!(magenta)}
661+
),
662+
new_style!(
663+
id: {Id::StyleDialogResultsPanel}
664+
// bold
665+
color_fg: {tui_color!(blue)}
666+
)
669667
}
670668
})
671669
}
@@ -676,10 +674,7 @@ mod status_bar {
676674

677675
/// Shows helpful messages at the bottom row of the screen.
678676
pub fn render_status_bar(pipeline: &mut RenderPipeline, size: Dim) {
679-
let separator_style = tui_style!(
680-
attrib: [dim]
681-
color_fg: TuiColor::Basic(ANSIBasicColor::DarkGrey)
682-
);
677+
let separator_style = new_style!(dim color_fg: {tui_color!(dark_grey)});
683678

684679
let app_text = "edi 🦜 ✶early access✶";
685680

@@ -706,14 +701,15 @@ mod status_bar {
706701
let mut it = Default::default();
707702
it += app_text_styled_texts;
708703
it += tui_styled_text! { @style: separator_style , @text: " │ "};
709-
it += tui_styled_text! { @style: tui_style!(attrib: [dim]) , @text: "Save: Ctrl+S "};
710-
it += tui_styled_text! { @style: tui_style!() , @text: "💾"};
704+
it += tui_styled_text! { @style: new_style!(dim) , @text: "Save: Ctrl+S "};
705+
it += tui_styled_text! { @style: new_style!() , @text: "💾"};
711706
it += tui_styled_text! { @style: separator_style , @text: " │ "};
712-
it += tui_styled_text! { @style: tui_style!(attrib: [dim]) , @text: "Feedback: Ctrl+K "};
713-
it += tui_styled_text! { @style: tui_style!() , @text: "💭"};
707+
it +=
708+
tui_styled_text! { @style: new_style!(dim) , @text: "Feedback: Ctrl+K "};
709+
it += tui_styled_text! { @style: new_style!() , @text: "💭"};
714710
it += tui_styled_text! { @style: separator_style , @text: " │ "};
715-
it += tui_styled_text! { @style: tui_style!(attrib: [dim]) , @text: "Exit: Ctrl+Q "};
716-
it += tui_styled_text! { @style: tui_style!() , @text: "🖖"};
711+
it += tui_styled_text! { @style: new_style!(dim) , @text: "Exit: Ctrl+Q "};
712+
it += tui_styled_text! { @style: new_style!() , @text: "🖖"};
717713
it
718714
};
719715

0 commit comments

Comments
 (0)