Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Alexandre Bury
    @gyscos
    If you can recreate it then you can just use pop_layer, and only have a single layer in the stack view.
    It sounds like you'd want a view that display one of its children (here the last one) and lets you remove some easily - i don't think we have that built in yet.
    Workarounds for now include using pop_layer, storing the returned view, and adding that back when you want to go back.
    Or updating the stackview to only draw the last view, not the whole stack.
    Or, as you hinted, add 2 layers everytime: a fullscreen view with a "background" color, then the actual view.
    Note that add_fullscreen_view is a bit misleading; it doesn't force the view to be fullscreen but just omits the usual margin and shadow that go with regular layers. To actually be fullscreen you also need to wrap it in a ResizedView using .full_screen() for example.
    Alexandre Bury
    @gyscos
    As for the "screens", yeah right now they're not removable, but that wouldn't even be that hard to add.
    Artie Fuffkin
    @smallB007
    Hi there, I'm working on a file explorer using cursive and I have a question. Can I make buttons not react (without disabling them) to a Tab events? That is, imagine file explorer ala Norton Commander and those two main panels, left and right and under them row of buttons, like remove del etc. I'd like the Tab event to only switch between left and right panel, but at the moment it goes to the buttons as well. Is this possible to not react to Tab events where buttons are concerned?
    Alexander Gavrilov
    @agavrilov
    @gyscos Is it possible to release a new version with a fixed version of 'enumset' as dependency instead of 'wasmer_enumset'?
    Alexandre Bury
    @gyscos
    @agavrilov Arf right, it's going to be another (small) breaking change :(
    I think re-exporting 3rd party crates that are part of the public API could help ease the transition - so users don't have to include and update their own enumset, they can rely on cursive::enumset (at least when dealing with the types in the cursive API). It's still strictly speaking a semver-breaking change, but it should reduce the actual risk of breakage.
    @smallB007 It's easy to disable a button by wrapping it in an OnEventView, and giving a no-op "pre-event" callback.
    In your case the button already ignore the "tab" button, but the parent vertical LinearLayout is the one that listens to it, and changes the focus. This is what you'll want to wrap in the OnEventView.
    Alexandre Bury
    @gyscos
    If you have a horizontal layout with only left and right panels, then wrapping that in a circularFocus may work
    (It depends on your layout: if you have a vertical layout with buttons on the bottom, and a horizontal layout with the two panels on top, then use CircularFocus.
    If you have a horizontal layout with two vertical layouts, each with a panel on top and buttons on the bottom, then disable Tab on the vertical layouts.)
    Alexander Gavrilov
    @agavrilov
    @gyscos is there any ETA for a new version with 'enumset'?
    Fabian Schlager
    @ghtyrant
    Hey there! I have a quick question about cursive: Is there a way to handle a view losing focus, e.g. using events? I have a TextArea and I want to save its contents as soon as it loses focus. How would I do that?
    Alexandre Bury
    @gyscos
    Hi! Unfortunately right now there's no such event or notification
    I think I had a reason not to, but I forgot about it, so I'll check if we could add that.
    srevinsaju
    @srevinsaju:matrix.org
    [m]
    Hey, I wanted to know if its possible to set "no background" in the custom styles.toml file
    I see that some work has been done here gyscos/cursive#526, but I wasn't really sure of how to put it into the styles toml file.
    Jonatan Magnusson
    @jomag
    Newbie question: I have a TextView with a custom background color, and it's placed in a ResizedWidget in a LinearLayout to occupy the full width of the screen. But the background color is applied to the actual text content. I've fixed this by instead adding the TextView and ResizedWidget to a StackedView with a colored fullscreen Layer. Is there any better way to achieve this basic styling?
    The text view is used to display keyboard shortcuts on the bottom row, as is very common.
    Alexandre Bury
    @gyscos
    @srevinsaju:matrix.org Hi! Right now styles.toml (or the theme's palette in general) lets you redefine individual colors from the palette. Such a color must always exist.
    The ticket you linked is at another level - for views to say "I don't want to specify a color here, just use whatever we were using before". When used for the background, the result can be interpreted as "no background" since it just blends in the parent background.
    What are you trying to achieve? There may still be a way
    @jomag You'll want to wrap the TextView in a Layer
    By default TextViews only write their text content, and don't fill the full space they occupy. Layer on the other hand always write the View color from the palette to the full area.
    Instead of specifying a custom color to the TextView, you may wrap the Layer<TextView> in a ThemedView (not released yet, only on git for now). This will let you apply a custom theme to the view subtree, redefining the View color from the palette (and maybe the Primary color for the text).
    srevinsaju
    @srevinsaju:matrix.org
    [m]
    @gyscos thanks, I resolved the problem by manually specifying the colors (I.e. not on styles.toml, but within code)
    liushuyu
    @liushuyu
    Hi there, I have a design question: I need to do some heavy computation and show a progress dialog with a status message and a progress bar. Currently, all the examples and cursive-async-view do not update status messages to the view. I wonder if it's possible to do this in a non-hacky way?
    Alexandre Bury
    @gyscos
    @liushuyu Hi! To communicate with the main thread from the worker thread, you can either:
    • Give a clone of Cursive::cb_sink() to the worker thread, from which you can send "callbacks" that can change some text message.
    • Use your own communication method, for example sharing a Arc<Mutex<String>> or something similar between the worker thread and a view. For example, TextView has a get_shared_content() method returning you a TextContent you can use to update the content from another thread. You can also implement your own view with a similar mechanism if you need something slightly different.
    liushuyu
    @liushuyu

    @liushuyu Hi! To communicate with the main thread from the worker thread, you can either:

    • Give a clone of Cursive::cb_sink() to the worker thread, from which you can send "callbacks" that can change some text message.
    • Use your own communication method, for example sharing a Arc<Mutex<String>> or something similar between the worker thread and a view. For example, TextView has a get_shared_content() method returning you a TextContent you can use to update the content from another thread. You can also implement your own view with a similar mechanism if you need something slightly different.

    Thank you very much for your reply!

    Thomas Hatzopoulos
    @thatzopoulos
    Hello,
    Is there a way to use Cursive's dump and restore commands to dump the current state of the Cursive root to a file that can be read back in when the program is launched at a later time? I do not seem to have the correct permissions for the fields of Dump to do something like this
    Alexandre Bury
    @gyscos
    Hi! No, the current state of cursive is not in general serializable - you cannot save it to a file and load it in another process. That's (among other things) because the "state" of cursive includes callbacks, which are not easy to serialize. Especially since these may include, for example, channels connected to another thread. How would you load the cursive state in this case?
    That's why the dump/restore mechanism is currently limited to the same process, mostly for cases where you need to run some cursive app, then run something else, then come back to the cursive app.
    At first it was required because as long as the Cursive object was not dropped, the terminal was not cleared. So running another app like vim would conflict with cursive itself. The solution was then to create a dump, drop the Cursiveobject itself (so the terminal is cleared), run the cursive-less part, then create a new cursive object and restore it.
    Alexandre Bury
    @gyscos
    But now the same thing can be done using separate runs of the same Cursive object
    So effectively the dump/restore process is redundant; I think I'll deprecate it soon.
    Thomas Hatzopoulos
    @thatzopoulos
    Thanks for the quick answer!
    Darrell Plank
    @darrellp

    Trying to run Cursive with pancurses backend. I've got all the features turned on in Cargo.toml that are required. The code is from the Cursive example:
    let mut siv = Cursive::default();
    siv.add_global_callback('q', |s| s.quit());
    siv.add_layer(TextView::new("Hello cursive! Press <q> to quit."));
    siv.run();

    but Rust says "no method named run found for struct Cursive in the current scope". EVERY piece of code I can find says you should call run() but I can't. I wonder if I should be using run_with() which is supposed to "initialize the backend" but I can't figure out how to set up the argument and since every piece of code uses run() here I can't locate an example to work off of. So confused!

    Alexandre Bury
    @gyscos
    Hi!
    You may want to use cursive:: default rather than Cursive::default
    It returns a CursiveRunnable configured to use the default backend (pancurses in your case) in its run method.
    Alexandre Bury
    @gyscos
    Cursive::default returns a Cursive object, which is backend-agnostic. If you want, you don't need the CursiveRunnable, and you can instead manually run the pancurses backend with siv.try_run_with(cursive::backends::curses::pan::Backend::init).
    Darrell Plank
    @darrellp
    Ah - thanks to you all. I actually got it to work by using CursiveExt. I didn't really understand what CursiveExt is and why it worked and still don't but the REAL problem was, as you pointed out, "cursive" vs "Cursive". It didn't help that "Cursive" worked fine for everything but "run" so lulled me into thinking it was correct.
    Alexandre Bury
    @gyscos
    Yeah - the main issue is that Cursive is defined in cursive_core, which does not know any backend. The cursive crate re-exports it and brings backend-aware functions, as well as a CursiveExt trait to make it look like these functions are on the Cursive object itself.
    To be honest CursiveExt is mostly here to bring backward compatibility with minimal changes.
    Filip Szczepański
    @FreeFull
    In a vertical LinearLayout, is there a way to align buttons inside it to the right, instead of having them aligned to the middle?
    Filip Szczepański
    @FreeFull
    I'd also like some way to swap the position of two elements in a SelectView
    Filip Szczepański
    @FreeFull
    Ended up deciding maybe a LinearLayout of custom widgets will be better for what I want, anyway