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

Add proc macros for compile time parsing #50

Merged
merged 47 commits into from
May 11, 2024
Merged

Add proc macros for compile time parsing #50

merged 47 commits into from
May 11, 2024

Conversation

lampsitter
Copy link
Owner

@lampsitter lampsitter commented May 11, 2024

Closes #49

Example

commonmark!("n1", ui, &mut self.cache, "# Hello, world");

Generates the following

    {
        let ui: &mut egui::Ui = ui;
        ::egui_commonmark_backend::prepare_show(&mut self.cache, ui.ctx());
        let options = ::egui_commonmark_backend::CommonMarkOptions::default();
        let max_width = options.max_width(ui);
        let layout = egui::Layout::left_to_right(egui::Align::BOTTOM).with_main_wrap(true);
        ui.allocate_ui_with_layout(egui::vec2(max_width, 0.0), layout, |ui| {
            ui.spacing_mut().item_spacing.x = 0.0;
            let height = ui.text_style_height(&egui::TextStyle::Body);
            ui.set_row_height(height);
            ::egui_commonmark_backend::newline(ui);
            ui.label(egui::RichText::new("Hello, world").strong().heading());
            ::egui_commonmark_backend::newline(ui);
        })
    }

lampsitter added 30 commits May 9, 2024 12:35
This has all the fundamental building blocks in place.
A lot more work is needed, but it appears to be moving in the correct
direction.
Pulldown is the only backend used by macro crate
Ideally the macros should be exported through the egui_commonmark as
that would allow egui_commonmark to also reexport the code that the
generated code depends on. The code can't stay in egui_commonmark as
that would cause a cyclic dependency.
Added back Alert and AlertBundle.
Hid implementation details that should not be exposed
lampsitter added 11 commits May 10, 2024 18:08
egui_commonmark_backend gives more information about it's purpose
It would unnecessarily insert two extra ui.end_row() at the end of tables.
To figure out quirks about releasing two new crates and check if
everything is working correctly.
@lampsitter lampsitter marked this pull request as draft May 11, 2024 09:16
Forgot to remove them after a massive refactor
This is the correct function to call
Macros had to use a separate impl so there is no reason for this to be
in the backend crate when only egui_commonmark uses it.
@lampsitter lampsitter marked this pull request as ready for review May 11, 2024 14:06
@lampsitter lampsitter merged commit 17336ca into master May 11, 2024
1 check passed
@lampsitter lampsitter deleted the macro branch May 11, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile time parsing
1 participant