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

Adds a buffer before the backend #786

Merged
merged 8 commits into from
Jun 4, 2024
Merged

Adds a buffer before the backend #786

merged 8 commits into from
Jun 4, 2024

Conversation

gyscos
Copy link
Owner

@gyscos gyscos commented Jun 4, 2024

This accumulates print operations in a draw cycle, and flushes the result out to the backend at the end.
It also computes a delta and only flushes the changes, reducing the amount of IO, and improving performance for the termion and crossterm backends (the ncurses/pancurses backend was already doing that internally).

@gyscos gyscos merged commit fda429a into main Jun 4, 2024
1 check passed
@correabuscar

This comment was marked as resolved.

@correabuscar

This comment was marked as outdated.

@correabuscar

This comment was marked as off-topic.

match width {
1 => CellWidth::Single,
2 => CellWidth::Double,
_ => panic!("expected width of 1 or 2 only."),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can that be this:

+            n => panic!("expected width of 1 or 2 only, got {n}."),

It shows got 0. in case of \0(nuls) in string.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Indeed, I'm now skipping zero-width graphemes entirely.

correabuscar added a commit to correabuscar/cursive that referenced this pull request Jun 5, 2024
correabuscar added a commit to correabuscar/cursive that referenced this pull request Jun 5, 2024
@correabuscar

This comment was marked as outdated.

correabuscar added a commit to correabuscar/sandbox that referenced this pull request Jun 5, 2024
@gyscos
Copy link
Owner Author

gyscos commented Jun 5, 2024

Looks like this file: https://github.com/gyscos/cursive/blob/main/.github/workflows/rust.yml might be in need of some more tests like: cargo test cargo test --all-targets which would've caught the other tests failing.

Just realized it was running the tests from the cursive directory, which probably predates when I added a workspace at the top level. Now running from the top, and everything runs (and passes!).

correabuscar added a commit to correabuscar/cursive that referenced this pull request Jun 5, 2024
correabuscar added a commit to correabuscar/cursive that referenced this pull request Jun 5, 2024
@correabuscar
Copy link
Contributor

This is amazing work.

Just realized it was running the tests from the cursive directory, which probably predates when I added a workspace at the top level. Now running from the top, and everything runs (and passes!).

I feel like it's worth noting that some tests will be missed, but maybe this is intentional? that's why I suggested more than 1 command(but maybe they can be merged, didn't look into it)

For example:

$ cargo test --features "toml markdown ansi termion-backend crossterm-backend" --no-default-features --verbose |& grep displays
$ cargo test --all-targets |& grep  displays
test tests::displays ... ok
$ cargo test --features "toml markdown ansi termion-backend crossterm-backend" --no-default-features | grep displays
    Finished test [unoptimized + debuginfo] target(s) in 0.06s
     Running unittests src/lib.rs (target/debug/deps/cursive-6d59192ef8182ae1)
     Running unittests src/lib.rs (target/debug/deps/cursive_macros-cb1bb8127866da3a)
     Running unittests src/lib.rs (target/debug/deps/cursive_syntect-d1cdede76caa67d2)
     Running unittests src/lib.rs (target/debug/deps/cursive_core-7a35f5e2196d3f5b)
   Doc-tests cursive
   Doc-tests cursive-macros
   Doc-tests cursive-syntect
   Doc-tests cursive_core
$ cargo test --all-targets | grep  displays
    Finished test [unoptimized + debuginfo] target(s) in 0.05s
     Running unittests src/lib.rs (target/debug/deps/cursive-36eb433902f80600)
     Running unittests examples/advanced_user_data.rs (target/debug/examples/advanced_user_data-284ee3d5ed90ea5c)
     Running unittests examples/autocomplete.rs (target/debug/examples/autocomplete-9ef323c34c3656cd)
     Running unittests examples/colors.rs (target/debug/examples/colors-b93866a3181132ba)
     Running unittests examples/ctrl_c.rs (target/debug/examples/ctrl_c-f6df7796c59bb329)
     Running unittests examples/debug_console.rs (target/debug/examples/debug_console-08bdfaf2b2aa04e8)
     Running unittests examples/dialog.rs (target/debug/examples/dialog-e80b10c1dcad574d)
     Running unittests examples/edit.rs (target/debug/examples/edit-5e1708ce0bf90952)
     Running unittests examples/fixed_layout.rs (target/debug/examples/fixed_layout-0176d20532141002)
     Running unittests examples/focus.rs (target/debug/examples/focus-aaae9b548336bd8e)
     Running unittests examples/hello_world.rs (target/debug/examples/hello_world-84f70169dd96d0d2)
     Running unittests examples/key_codes.rs (target/debug/examples/key_codes-a863c62aaa823db7)
     Running unittests examples/linear.rs (target/debug/examples/linear-f749da98f8c49e1c)
     Running unittests examples/list_view.rs (target/debug/examples/list_view-6c0e1f6ca0013a5a)
     Running unittests examples/logs.rs (target/debug/examples/logs-3c48f33e409c6f5f)
     Running unittests examples/lorem.rs (target/debug/examples/lorem-2aa6de63399e2c0b)
     Running unittests examples/markup.rs (target/debug/examples/markup-9f015ae2efe5ae2e)
     Running unittests examples/menubar.rs (target/debug/examples/menubar-f80eea203addcd74)
     Running unittests examples/menubar_styles.rs (target/debug/examples/menubar_styles-fd8da694ee6c8c46)
     Running unittests examples/mines/main.rs (target/debug/examples/mines-7a2592301c981ed2)
     Running unittests examples/mutation.rs (target/debug/examples/mutation-1b31aec50795ef4d)
     Running unittests examples/panels.rs (target/debug/examples/panels-831d76dfe94d340a)
     Running unittests examples/pause.rs (target/debug/examples/pause-5aa774dad7554457)
     Running unittests examples/position.rs (target/debug/examples/position-799ff01d054b78c7)
     Running unittests examples/progress.rs (target/debug/examples/progress-d170ca5e6f3b58ed)
     Running unittests examples/radio.rs (target/debug/examples/radio-4aa523868f740a01)
     Running unittests examples/refcell_view.rs (target/debug/examples/refcell_view-4933d1c1f0efd12a)
     Running unittests examples/scroll.rs (target/debug/examples/scroll-9b0d913b49b048f0)
     Running unittests examples/select.rs (target/debug/examples/select-997d102f5841794c)
     Running unittests examples/select_test.rs (target/debug/examples/select_test-ed58e29b04026e5f)
test tests::displays ... ok
     Running unittests examples/slider.rs (target/debug/examples/slider-e08c1e5f50e5aefc)
     Running unittests examples/status.rs (target/debug/examples/status-34fa01bfd9a29a4c)
     Running unittests examples/status_bar_ext.rs (target/debug/examples/status_bar_ext-1c5f3cb423e57f70)
     Running unittests examples/stopwatch.rs (target/debug/examples/stopwatch-cc166955428bc89e)
     Running unittests examples/tcp_server.rs (target/debug/examples/tcp_server-646d8100e60bced6)
     Running unittests examples/terminal_default.rs (target/debug/examples/terminal_default-ec937226ffa5c62f)
     Running unittests examples/text_area.rs (target/debug/examples/text_area-d77345664ca2a2b7)
     Running unittests examples/theme_editor.rs (target/debug/examples/theme_editor-552d832521b384d1)
     Running unittests examples/theme_manual.rs (target/debug/examples/theme_manual-fd3cf067e069f742)
     Running unittests examples/themed_view.rs (target/debug/examples/themed_view-27b1e4ffe8eb05bc)
     Running unittests examples/user_data.rs (target/debug/examples/user_data-3d83386b2b40753f)
     Running unittests examples/vpv.rs (target/debug/examples/vpv-9210142970b6df0c)
     Running unittests examples/window_title.rs (target/debug/examples/window_title-2db86d5b5974a859)
     Running unittests src/lib.rs (target/debug/deps/cursive_macros-cb1bb8127866da3a)
     Running unittests src/lib.rs (target/debug/deps/cursive_syntect-b185255a9d44cd55)
     Running unittests examples/parse.rs (target/debug/examples/parse-2196759276f652f9)
     Running unittests src/lib.rs (target/debug/deps/cursive_core-6dd9eaa1e8719442)

@gyscos
Copy link
Owner Author

gyscos commented Jun 5, 2024

Interesting... the difference seems to be that it looks for unit tests in the examples?

Running cargo test at the root already checks the examples themselves (maybe not any #[test] in there though).

Is there any error the first command would not catch?

@correabuscar
Copy link
Contributor

Is there any error the first command would not catch?

no errors currently, but I figured maybe it's worth not skipping those extra tests, there are at least(apparently the only?) these 2 that the first one is missing:

$ cargo test --example select_test
    Finished test [unoptimized + debuginfo] target(s) in 0.04s
     Running unittests examples/select_test.rs (target/debug/examples/select_test-ed58e29b04026e5f)

running 2 tests
test tests::displays ... ok
test tests::interacts ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

So there are far less tests that are missing that I initially thought, 2 out of 28, the rest are overlapping with cargo test now that it's doing it outside of cursive subdir.

@gyscos
Copy link
Owner Author

gyscos commented Jun 5, 2024

Oh ha ha I completely forgot we had this select_test.rs example here. I guess it's indeed an example for how to write tests!

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.

2 participants