vlaaad / reveal

Read Eval Visualize Loop for Clojure

Home Page:https://vlaaad.github.io/reveal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for Zooming or changing the font size?

didibus opened this issue · comments

It be nice to be able to zoom or change the font size.

Indeed it would :)

Currently changing the font size is possible only with prefs system property that requires JVM restart.

I also wanted to reload prefs without restart, and this works for me (I did a quick search for namespaces which require vlaaad.reveal.prefs:

(require '[vlaaad.reveal.prefs :as rp])

(defn set-prefs
  "`(set-prefs {...})` to reset reveal prefs without restarting your repl"
  [prefs]
  (tap>
   (do (alter-var-root #'rp/prefs (constantly (delay prefs)))
       (require '[vlaaad.reveal.style]
                '[vlaaad.reveal.font] :reload))))

(comment
  (set-prefs {:font-size 20, :theme :dark})
  ,)

The tap> is only needed because the updated settings are only reflected when the next value is send to reveal.

That seems very unreliable, I'm surprised it worked :D

Me too, tbh. I wanted to try rewriting prefs, style, and font to use functions instead of delays, but this is working for now 🤷‍♂️

I don't quite remember why I used delays everywhere, probably wanted to make reveal AOT-compatible, and loading prefs should happen in runtime and not during compilation

Ah, I assumed it was for performance.

In that case, I might try rewrite vlaaad.reveal.prefs/prefs and bits which refer to it as functions.

What do you think?

I'd prefer to keep the delay for now, since a lot of reveal code currently relies on prefs being effectively constant.

I see :)

You could leverage re-delay (or your custom version of it).

https://github.com/aroemers/redelay

Which let's you selectively invalidate the delay (and in the case of re-delay the delay dependencies as well and safely do so).

I do think in general it is best to avoid side-effect at load-time.