seems portal.runtime/session only contains the latest primary selection under :selection . would it be possible to also update for multi-select?
I find myself doing this:
;; click first arg
(def arg1 @session)
;; click second arg
(def arg2 @session)
(my-func arg1 arg2)
would be nice if I could alt click my arguments and do:
;; click first arg
;; alt-click second arg
(apply my-func @session)same goes for registered functions, seems they only get the primary selection
https://github.com/djblue/portal/blob/master/src/portal/ui/state.cljs#L306is the code responsible for syncing the selected values with the runtime. We could update it to send all selected values instead of just the first one. We would also need to update the https://github.com/djblue/portal/blob/master/src/portal/runtime/jvm/client.clj#L58 to only pull the first to preserve the existing API. How would you want to access all the selected values from a session? I could see adding a portal.api/selected function 🤔
portal.api/selected seems good for discoverability. We access portal from a dev ns so I'll probably roll my own.
Is this feature something you want take a crack at?
sure, I'll send a PR asap 👍
Is there a way of changing fonts/colors at run time via portal.api? Or at least pass a custom theme when creating a session - my use case is to provide an editor integration with emacs similar to VS Code - syncing colors and font sizes
I think I currently bake the themes into the UI, but that should be relatively easy to change. What kind of API are you thinking would be ideal here? I think defining themes should be independent of any particular session but selecting the default theme will be per session. You mention syncing, how would you expect to update a theme, put or patch?
I was thinking of something as simple as passing a map, rather than a keyword for a predefined theme - then you can do this as "simply" (😉 ) as:
(portal.api/open {:theme (merge (:portal.colors/nord-light portal.colors/theme) {:font-size 8})
I'm still toying with the Portal <-> Monroe (the nREPL client for Emacs) integration, and making slow progress - so passing current front size from Emacs when invoking the code above would be pretty straight forwardOhh, so you would want to be able to tweak existing themes slightly, not necessarily create a new theme?
With the above you can do both, either modify existing one, or provide a completely new one without shipping it with portal itself
"modify" in the sense that you're passing a custom theme based on an existing one
So with the above example, if the window has already been opened, how would you expect to sync the theme?
Ah, good question 🤔 I didn't think about what happens after, I never change font sizes or themes in my editor :D I'd guess it would have to be something that portal.api would have to expose too - something along the lines of (portal.api/set-theme :session-id {:some-theme :map})) (I'm very new to portal, so I'm a bit hazy on the details of using sessions etc - I always use just one)
I think that could work, but if we make it independent of sessions it might be easier to use. Something like:
(portal.api/set-theme ::my-theme (merge (:portal.colors/nord-light portal.colors/theme) {:font-size 8}))
(portal.api/open {:theme ::my-theme})
(portal.api/set-theme ::my-theme {:font-size 12}) ;; assuming set theme will merge?This way your emacs integration wouldn't have to worry about sessions at all
Indeed!
as an aside, I wish I used Portal earlier, I was aware of it but now that I'm using it in earnest it has super charged my workflow - I built a couple of utility functions to debug Postgres errors coming from JDBC, with SQL syntax formatting, dealing with the dreaded "Invalid query... postiion 10000" and stuff like that. Works amazingly when debugging queries generated via HoneySQL
That's awesome! I feel like enabling custom debug workflows is exactly how I wanted people to use Portal, I'm really glad it's serving you well.
If you feel like this is something others might find useful and feel like doing so, a new "Honey SQL" https://github.com/djblue/portal/tree/master/doc/guides in Portal would be amazing!
I need to tidy it up, it's quite messy right now - and it uses an external dependency to reformat the query string (HoneySQL's "pretty" formatting is really basic, understandably)
Gotcha, yeah getting things into a sharable state is always a challenge 👌
If you do get something together that is sharable before the 24th, I would be down to demo it in my "Portal Internals" talk
Would a screenshot be enough? :-)
Yeah, that would be great! Also, maybe some points on your workflow
no promises, but I'll try to jot something down 🤞
@djblue best I could do in such a short time :-) https://gist.github.com/lukaszkorecki/6031472de7514a27261c06f4d9ae865a - I think the code viewer can also do syntax highlighting but I didn't dig that deep