reveal 2020-12-04

@vlaaad Is there a way to get Reveal to display a string value laid out with newlines and tabs etc?

Awesome, I love it! For every evaluation you automatically see value's meta and, if appropriate, documentation!

I just added code to automatically render .URL's inline as web views -- like REBL does -- so that I can use ctrl-; j and ctrl-; ? (from my Atom/Chlorine or VS Code/Clover setup) and have Javadocs or Clojuredocs displayed automatically for types or symbols, respectively.

There is example action in the readme:

(rx/defaction ::unescape [x]
  (when (string? x)
    #(rx/stream-as-is 
       (rx/as x (rx/raw-string x {:fill :string})))))

@vlaaad Thanks. How would that look in place of something like this:

{:fx/type rx-table-view
                      :items [x']
                      :v-box/vgrow :always
                      :columns [{:fn identity :header 'value}]}

i.e., if x' is a string and I wanted to display it as a raw string?

(if (string? x') (rx/stream-as-is ...) x')

I think table view forces its items to be a single row

So newlines will be shown as single space

That didn't work.

Oh, wait, I think I have a typo...

Hmm... "class clojure.lang.AFunction$1 cannot be cast to class clojure.lang.IPersistentMap (clojure.lang.AFunction$1 and clojure.lang.IPersistentMap are in unnamed module of loader 'app')"

Here's the full context:

(rx-stream-as-is
       (rx-as
        {:fx/type rx-obs-view
         :ref last-tap
         :fn (fn [x]
               (let [x' (if (var? x) (deref x) x)]
                 {:fx/type :v-box
                  :children
                  [{:fx/type rx-value-view
                    :v-box/vgrow :always
                    :value (assoc (meta x)
                                  :_meta (meta x')
                                  :_class (class x'))}
                   (cond
                     (string? x')
                     (rx-stream-as-is (rx-as x' (rx-raw-string x' {:fill :string})))
                     (or (nil? x') (not (seqable? x')))
                     {:fx/type rx-table-view
                      :items [x']
                      :v-box/vgrow :always
                      :columns [{:fn identity :header 'value}]}
                     :else ...
I have these dynamically resolved so rx- means rx/

The above gives me "class vlaaad.reveal.stream$_EQ__GT_$fn__3596 cannot be cast to class clojure.lang.IPersistentMap (vlaaad.reveal.stream$_EQ__GT_$fn__3596 is in unnamed module of loader clojure.lang.DynamicClassLoader @19d27c27; clojure.lang.IPersistentMap is in unnamed module of loader 'app')"

If I remove the stream-as-is wrapper in that string? cond clause, I get the AFunction$1 cast exception above.

Ah, you don't want string IN the table, you want it INSTEAD OF the table

Then you should use {:fx/type rx/value-view :value (rx/stream-as-is ...)}

Argh! Somehow that was about the only combination I hadn't tried! Perfect! Checkout https://github.com/seancorfield/dot-clojure/blob/develop/dev.clj#L25-L27

how do I clear the buffer in the reveal window?

It's not implemented yet, but it's planned and it's coming in the future

The most popular request btw, I even already received a PR for that. Holding it off just because I want to make a general solution for such user actions, since the discoverability for such commands is very lacking