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

Unable to debug NcPlane::gradient #19

Closed
CyanideForBreakfast opened this issue Mar 19, 2022 · 4 comments
Closed

Unable to debug NcPlane::gradient #19

CyanideForBreakfast opened this issue Mar 19, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@CyanideForBreakfast
Copy link

I've been meaning to draw empty cells across a line, yet am unable to debug why gradient function is throwing error.
Here's a simple reproducible example.

use libnotcurses_sys::*;

fn main() -> NcResult<()> {
    let nc = unsafe { Nc::with_flags(NcOptions::SUPPRESS_BANNERS)? };
    let splane = unsafe { nc.stdplane() };

    let header_bg_channel = NcChannel::from_rgb8(
            57,
            100,
            200,
        );
    let header_fg_channel = NcChannel::from_rgb8(
            200,
            200, 
            200
        );

    let header_combined_channel = NcChannels::combine(header_fg_channel, header_bg_channel);
    splane.gradient(
        Some(0),
        Some(0),
        Some(1),
        None,
        " ",
        0,
        header_combined_channel,
        header_combined_channel,
        header_combined_channel,
        header_combined_channel,
    )?;
    nc.render()?;
    Ok(())
}

In some rare cases, it does render with garbage values filled in. Am I doing something wrong or making some invalid assumptions?

OS: Arch
Terminals: Xterm, Alacritty, Kitty

@joseluis
Copy link
Collaborator

Thanks for the bug report, I suspect this may be related to recent updates to the static channels functions in the C library. I'll try to update the Rust bindings and fix any related bugs.

@joseluis joseluis reopened this Mar 25, 2022
@joseluis
Copy link
Collaborator

It turns out it wasn't that.

The good news is that I've reproduced your issue, so it's an implementation bug. I'll investigate it further and will attempt to fix it soon.

BTW are you running an older version of the library? I've updated your code to the last version pointing the differences:

use libnotcurses_sys::*;

fn main() -> NcResult<()> {
    let nc = unsafe { Nc::with_flags(NcFlags::SuppressBanners))? }; // <=

    let splane = unsafe { nc.stdplane() };

    let header_bg_channel = NcChannel::from_rgb8(
            57,
            100,
            200,
        );
    let header_fg_channel = NcChannel::from_rgb8(
            200,
            200, 
            200
        );

    let header_combined_channel = NcChannels::combine(header_fg_channel, header_bg_channel);
    splane.gradient(
        Some(0),
        Some(0),
        Some(1),
        None,
        " ",
        NcStyle::None, // <=
        header_combined_channel,
        header_combined_channel,
        header_combined_channel,
        header_combined_channel,
    )?;
    nc.render()?;
    unsafe { nc.stop()?; } // <= notcurses must be stopped before exiting or it will leak
    Ok(())
}

@CyanideForBreakfast
Copy link
Author

CyanideForBreakfast commented Mar 26, 2022

Yes, I'm currently running on libnotcurses_sys = "= 3.1.2". The 3.2.0 version just wouldn't compile when I put it under [dependencies] in my Cargo.toml, spitting out a bunch of errors. On my local Arch system, I've already installed the notcurses-git AUR. I thought that there must be a version discrepancy between the AUR and the version 3.2.0 depends on that is causing the errors, so decided maybe I'll switch in the future. Is that related?

@joseluis joseluis added the bug Something isn't working label Mar 26, 2022
@joseluis joseluis self-assigned this Mar 26, 2022
@joseluis
Copy link
Collaborator

I've updated version 3.3.0 that should have the gradient problems fixed.

You'll have to update to the new syntax, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants