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 executable blocks #17

Merged
merged 4 commits into from
Oct 21, 2023
Merged

Add executable blocks #17

merged 4 commits into from
Oct 21, 2023

Conversation

mfontanini
Copy link
Owner

This adds code execution for shell blocks (e.g. bash, sh, shell, etc) when pressing control+e. For this to work you need to annotate the code block with +exec(e.g.bash +exec`) so that you agree to allow presenterm to run the code.

I also made this so that you can still change slides as the code is being rendered. Not sure if that's necessary but I think it was simpler to do it this way.

@baduhai would you like to test this and let me know if it works for you? Thanks!

asciicast

Closes #4

@mfontanini
Copy link
Owner Author

I'm curious actually how do you expect this to work if the output overflows the screen. I'd like to avoid implementing scrolling if possible, so I guess the alternatives are a) let it overflow and b) truncate and get the last N lines. Thoughts?

@mfontanini
Copy link
Owner Author

@baduhai I'm merging this because I want to change other stuff and I'll start having conflicts. Let me know if something's off

@mfontanini mfontanini merged commit c33b588 into master Oct 21, 2023
6 checks passed
@mfontanini mfontanini deleted the executable-blocks branch October 21, 2023 13:03
@baduhai
Copy link

baduhai commented Oct 21, 2023

You merged just as I was testing :)

I'm getting a failed test when compiling, currently:

test render::layout::test::layout::case_17_center_margin_and_size_overflows ... ok
test render::properties::test::shrink ... ok
test style::test::color_serde ... ok
test builder::test::preformatted_blocks_account_for_unicode_widths ... ok
test theme::test::validate_themes ... ok

failures:

---- execute::test::shell_code_execution stdout ----
thread 'execute::test::shell_code_execution' panicked at 'execution failed: SpawnProcess(Os { code: 2, kind: NotFound, message: "No such file or directory" })', src/execute.rs:166:51
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    execute::test::shell_code_execution

test result: FAILED. 96 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Gonna try to skip tests to see how it runs.

@baduhai
Copy link

baduhai commented Oct 21, 2023

Interesting, I think I did something wrong on my end before. cargo test works just fine when I cloned the entire source, I guess the nix derivation I wrote for this is just missing something.

It works wonderfully, thank you so much for this feature!

@mfontanini
Copy link
Owner Author

Phew you scared me. Awesome, let me know if you find any issues/need any features!

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.

Allow code execution
2 participants