Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Alexandre Bury
    @gyscos
    So you can either:
    • Directly attach the name to the EditView, give that a fixed width
    • Look for a ResizedView<EditView> in the button callback
    Alexandre Bury
    @gyscos
    To debug this kind of things, you can try Cursive::debug_name
    You give it a name, and it tries to return the type name of the view with this name.
    Shriphani Palakodety
    @shriphani
    ah I se
    cool thanks
    Steven Luu
    @stnluu_twitter
    Hey all, I'm new to cursive. What I'm trying to achieve is that, every time i add a layer (e.g. add a dialog) to the default stackview, only that new view (the dialog in this case) is visible.
    Meaning, i want the behavior to basically draw a full screen background first, and then draw the view.
    What's the best way to achieve that?
    I tried playing around with add_fullscreen_layer but seems like that just means the view starts at (0, 0), and the "background" is still transparent
    One way that i was able to do that is basically add a new screen every time i add a new view, but i don't see any way to remove a screen so i assume that's quite expensive?
    Alexandre Bury
    @gyscos
    Hi! When you add a new view, do you want to keep the previous one around to come back to it, or do you want to get rid of it, amd recreate it if you need it again?
    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.
    Alexandre Bury
    @gyscos
    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.
    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!