Fork me on GitHub
#reveal
<
2020-12-04
>
seancorfield00:12:16

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

vlaaad07:12:12

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})))))

seancorfield19:12:57

@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}]}

seancorfield19:12:11

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

vlaaad19:12:00

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

vlaaad19:12:55

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

vlaaad19:12:26

So newlines will be shown as single space

seancorfield19:12:27

That didn't work.

seancorfield19:12:44

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

seancorfield19:12:32

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')"

seancorfield19:12:48

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/

seancorfield19:12:26

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')"

seancorfield19:12:28

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

vlaaad07:12:39

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

vlaaad07:12:23

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

seancorfield07:12:23

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

vlaaad20:12:41

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

seancorfield20:12:55

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.

wilkerlucio11:12:33

how do I clear the buffer in the reveal window?

vlaaad14:12:37

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

vlaaad15:12:31

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

vlaaad15:12:38

Some more discussion on that: https://github.com/vlaaad/reveal/pull/14

👍 3