reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
seancorfield 2020-12-04T00:24:16.286300Z

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

seancorfield 2020-12-04T19:26:57.291100Z

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

seancorfield 2020-12-04T19:28:11.291400Z

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

vlaaad 2020-12-04T19:29:00.291600Z

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

vlaaad 2020-12-04T19:29:55.292100Z

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

vlaaad 2020-12-04T19:31:26.292500Z

So newlines will be shown as single space

seancorfield 2020-12-04T19:38:27.293Z

That didn't work.

seancorfield 2020-12-04T19:38:44.293200Z

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

seancorfield 2020-12-04T19:39:32.293400Z

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

seancorfield 2020-12-04T19:41:48.293600Z

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/

seancorfield 2020-12-04T19:42:26.293800Z

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

seancorfield 2020-12-04T19:43:28.294Z

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

vlaaad 2020-12-05T07:14:39.294200Z

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

vlaaad 2020-12-05T07:16:23.294400Z

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

seancorfield 2020-12-05T07:51:23.294700Z

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

vlaaad 2020-12-05T20:27:41.298300Z

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

seancorfield 2020-12-05T20:45:55.298500Z

I just added code to automatically render <http://java.net|java.net>.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.

vlaaad 2020-12-05T20:54:17.299600Z

seeing it here https://github.com/seancorfield/dot-clojure/blob/develop/dev.clj#L66-L68 🙂

vlaaad 2020-12-04T07:27:46.286500Z

Yes, you can use nrepl middleware in cursive as well

vlaaad 2020-12-04T07:31:12.286700Z

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

wilkerlucio 2020-12-04T11:27:33.288900Z

how do I clear the buffer in the reveal window?

vlaaad 2020-12-04T14:17:37.289400Z

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

vlaaad 2020-12-04T15:41:31.289700Z

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

vlaaad 2020-12-04T15:42:38.289900Z

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

👍 1