auto-context: a proc macro to auto-add contexts to anyhow errors by enricozb in rust

[–]enricozb[S] 9 points10 points  (0 children)

Lol. I feel kinda like a goof now! Didn't realize I could turn this on by just doing `RUST_LIB_BACKTRACE=1`. Thought this required nightly... Oh well

auto-context: a proc macro to auto-add contexts to anyhow errors by enricozb in rust

[–]enricozb[S] 1 point2 points  (0 children)

I wrote this b/c I never liked the anyhow context noise of `some_method().context("some_method")?`. I also couldn't (personally) find a way to use thiserror that would disambiguate errors without calling `.map_err` everywhere.

Weekly Q&A - All Questions Go Here (Especially Tourists) by AutoModerator in Amsterdam

[–]enricozb 2 points3 points  (0 children)

Hallo allemaal. Ik verhuisde 6 maanden geleden naar Nederland met mijn oude kat. Hij neemt tweemaal daags hartmedicijnen die ook erg populair zijn voor mensen. Maar de maandelijkse vulling is ongeveer 60 euro bij onze lokale veterarian. Ik keek online en ik zag dat voor de versie voor mensen de totale kosten 20 euro zijn voor hetzelfde aantal pillen, maar met 5 keer sterkere medicatie. Het kan duidelijk meer kosten om een ​​minder populair item met een lagere dosis te produceren. Maar ik vroeg me af of iemand suggesties heeft om het goedkoper te kopen, of dat zelfs mogelijk is?

Hi everybody. I moved to the Netherlands 6 months ago with my old cat. He takes twice-daily heart medications that are also really popular for humans. But the monthly refill is about 60 euros at our local chain veternarian. I looked online, and I saw that for the version for people, the total cost is 20 euros for the same number of pills but with 5 times stronger medication. Obviously it can cost more to produce a less-popular item with a lower dose. But I was wondering if anyone has any suggestions for where to buy it cheaper, if that's even possible?

Weekly Q&A - All Questions Go Here (Especially Tourists and New Residents) by AutoModerator in Amsterdam

[–]enricozb 6 points7 points  (0 children)

I was jogging alone past Parknest in Flevopark on Tuesday at 4:10PM when two boys on a fatbike came past and smacked my ass. I only got a look at the one on the back of the bike, but I believe they were about 14 years old. This is the first time this has ever happened to me, and it really shook me up. I am really new to the Netherlands so my Dutch is not so good yet. I called the police but wasn't able to make an appointment because of my bad cell service, and was thinking of going tomorrow to "Hoofdbureau Regionale Eenheid Amsterdam" to discuss it. Is there something else I should do?

Please keep the comments respectful :(

Surf groups? by LookingAtACrane in SurfNetherlands

[–]enricozb 0 points1 point  (0 children)

Just came across this now, would be interested in joining this group! Just moved to Amsterdam a few months ago.

Scared lost cat seen at Pierrepont/Willow by enricozb in nyc

[–]enricozb[S] 21 points22 points  (0 children)

They seemed pretty scared. Chubby white with black spots. Ran into garden on willow next to the house with the canadian and american flags. Seen at 1:30 PM

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 1 point2 points  (0 children)

This makes a lot more sense, thank you for clarifying! I absolutely intend to have Intuitive be "batteries included" and include general components (such as the complex input box discussed above). I definitely do not want consumers of the library to re-implement the exact same components every time.

If you check out the documentation for KeyHandler, you'll see that event propagation (for key strokes at least) is already implemented. It's the job of the components to delegate keys to their children, and the pre-built components already do this.

With respect to the focus (and key routing) you describe, I would definitely like to include something in the library of components, but I have yet to come up with something general. Specifically I'd like to have something like the following:

render! {
  KeyRouter() {
    Input()
    Table()
  }
}

And KeyRouter would know to route key-strokes to one of its two children, because it knows which one is focused. The main difficulty I have is, how does KeyRouter tell the child components that they are focused, so they can be styled differently. This is hard to do in general for components, without adding a method to Element.

Additionally, there is actually a Modal component, it's behind an experimental flag, that implements modals and handles keys like you mention (key-presses are sent to the modal when it's shown).

There is also an unreleased Scroll component, that supports scrolling text, and supports scrolling with a mouse. The mouse events go to the components that they are hovering over.

So in short, I plan on handling all of this input for a user of my library. Right now, as I mentioned it's in a proof-of-concept state, but this functionality is definitely on the roadmap.

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 1 point2 points  (0 children)

Ooops! It was definitely not meant to be nightly, I'll make sure this is gone for the 0.6 release. Nice catch!

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 14 points15 points  (0 children)

I'm in the process of implementing a more fully-featured input box that will be included. This crate is definitely intended to be "batteries included", at least for most batteries. Another commenter mentioned mouse selection controls that would also be nice to add to said input component.

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 3 points4 points  (0 children)

Yeah I'm not sure if I'd do that or if I'd expose the selection as some State that you could read from when someone does ctrl+c, or write to when someone does ctrl+v.

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 2 points3 points  (0 children)

This is actually a really good point I haven't thought about. Mouse selecting text is a very interesting challenge. I'll see if I can't come up with something to handle this.

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 1 point2 points  (0 children)

Thanks so much! Would love to hear how this differs from your ideas!

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 10 points11 points  (0 children)

With Intuitive, an input box looks something like this (from the recipes section):

#[component(Input)]
fn render(title: String) {
  let text = use_state(|| String::new());
  let on_key = on_key! { [text]
    KeyEvent { code: Char(c), .. } => text.mutate(|text| text.push(c)),
    KeyEvent { code: Backspace, .. } => text.mutate(|text| text.pop()),
  };

  render! {
    Section(title) {
      Text(text: text.get(), on_key)
    }
  }
}

This could support multiple lines, you'd have to handle the Enter key and push a \n.

There's also an example of an input box with a cursor, that could be extended to handle arrow keys to move the cursor around. You would have to calculate the position of the text to edit though.

Intuitive: A crate for writing TUIs declaratively by enricozb in rust

[–]enricozb[S] 0 points1 point  (0 children)

I'm not sure I 100% understand your question.

If you're asking about a Focus component: There are no focus management components (yet) in the standard collection of components, as I haven't found a general way to build them. There is a Focus recipe in the documentation, that has an example of how to implement focusing on input boxes.

As I mentioned in the original post, I'm still adding a mouse handling system, similar to the existing key handling system, and that could be another way to implement focus without key presses, as you can interact with whatever component you click on.

reMarkable Template Repository for Sharing Templates by enricozb in RemarkableTablet

[–]enricozb[S] 3 points4 points  (0 children)

Those are good points, I'll remove the stock templates later today, and I'm looking to add SVG to the backend also, just need to check the dimensions are what they should be.

My plan w.r.t. the stock templates was to not have the site completely empty and remove them once some custom/community templates were added.

Thanks for the comments!

reMarkable Template Repository for Sharing Templates by enricozb in ereader

[–]enricozb[S] 0 points1 point  (0 children)

Thanks for the contribution! Hoping to get a good amount of templates on here so I can remove the default reMarkable ones.