reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
flowthing 2020-09-17T06:58:24.032800Z

So this might be more of a tools.deps question, but I can’t figure out how to quote things properly. I’d like to put this in my ~/.clojure/deps.edn:

:jvm-opts ["-Dvlaaad.reveal.prefs='{:font-family \"Fira Code\" :font-size 20}'"]
But that’s not correct. Any ideas on how to properly quote “Fira Code”?

flowthing 2020-09-17T07:00:11.033200Z

Oh, this might actually also be a comma/space thing…

flowthing 2020-09-17T07:10:15.033700Z

Well, this is a workaround, but it works:

:jvm-opts ["-Dvlaaad.reveal.prefs={:font-family,\"<https://github.com/tonsky/FiraCode/raw/master/distr/ttf/FiraCode-Retina.ttf>\",:font-size,20}"]

seancorfield 2020-09-17T07:27:54.034600Z

@flowthing Yup, in deps.edn you need , instead of space in :jvm-opts and :main-opts

seancorfield 2020-09-17T07:28:30.035200Z

(I've gotten so used to it that I also tend to use , on the command-line inside options 🙂

flowthing 2020-09-17T07:30:53.036500Z

Yeah, using a comma solves the issue otherwise, except the "Fira Code" part, because I can’t use a comma there.

dharrigan 2020-09-17T07:34:01.036800Z

I just use it as a property in my clj alias...

dharrigan 2020-09-17T07:34:17.037Z

clojure -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.core.async.go-checking=true -J-Dvlaaad.reveal.prefs='{:font-family "JetBrains Mono Medium" :font-size 20}' -A:rebel:base:test

dharrigan 2020-09-17T07:34:24.037200Z

works grand 🙂

flowthing 2020-09-17T07:35:00.037600Z

Yeah, that’ll work — I’d rather not alias clj, though. 🙂

dharrigan 2020-09-17T07:35:05.037800Z

meh

dharrigan 2020-09-17T07:35:06.038Z

🙂

dharrigan 2020-09-17T07:35:48.038200Z

my full command is this

dharrigan 2020-09-17T07:35:55.038400Z

clj () {
	if [[ -z $@ ]]
	then
		command clojure -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.core.async.go-checking=true -J-Dvlaaad.reveal.prefs='{:font-family "JetBrains Mono Medium" :font-size 20}' -A:rebel:base:test
	else
		command clj -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.core.async.go-checking=true $@
	fi
}

seancorfield 2020-09-17T07:37:53.038900Z

Ah, good point on commas in an actual font name 😞

dharrigan 2020-09-17T07:38:22.039400Z

Not tried, but you may be able to use the alternative name

dharrigan 2020-09-17T07:38:23.039600Z

i.e.,

dharrigan 2020-09-17T07:38:29.039900Z

JetBrains Mono Medium (JetBrainsMono-Medium)

dharrigan 2020-09-17T07:38:34.040300Z

so either are valid

flowthing 2020-09-17T07:38:57.040800Z

Yeah, that’s worth a try.

dharrigan 2020-09-17T07:39:09.041100Z

Fira Code Medium (FiraCode-Medium)

dharrigan 2020-09-17T07:39:45.041900Z

caveat, I'm on Arch Linux, not mac 🙂

seancorfield 2020-09-17T07:39:48.042Z

This sort of stuff is also why we have a build shell script wrapped around clojure/`clj` so it can a) run multiple clojure commands from a single invocation and b) add JVM options via the command-line as needed 🙂

dharrigan 2020-09-17T07:40:13.042400Z

indeed, something I perfer, hence my tiny simple alias 🙂

flowthing 2020-09-17T07:40:44.043600Z

No dice:

Execution error - invalid arguments to vlaaad.reveal.prefs/fn at (prefs.clj:38).
"FiraCode-Medium" - failed: valid-url? at: [:font-family :url-string] spec: :vlaaad.reveal.prefs/font-family
"FiraCode-Medium" - failed: system-font? at: [:font-family :system-font] spec: :vlaaad.reveal.prefs/font-family

dharrigan 2020-09-17T07:40:44.043800Z

For complex things, I have a bin dir in my project folder, usually with a build or prompt something

flowthing 2020-09-17T07:40:49.044Z

Well, the URL works, so it’s not a big deal.

seancorfield 2020-09-17T07:41:02.044200Z

(we're getting off-topic for Reveal 🙂 )

dharrigan 2020-09-17T07:41:06.044400Z

indeed 🙂

seancorfield 2020-09-17T07:57:08.046900Z

Some feedback for @vlaaad: being able to nav around the output panel in larger jumps would be really helpful. If I've eval'ing lots of stuff into Reveal, the cursor stays where it last was instead of moving to the end of the buffer, when is a pain when I've eval several giant maps. I can fn-down to page down but the cursor stays put instead of following the fn-down action so I then have to mouse-click somewhere in the visible area to get the cursor to move.

seancorfield 2020-09-17T07:57:34.047900Z

Being able to jump between matching () {} and [] would greatly ease that too.

seancorfield 2020-09-17T07:58:24.050Z

I notice that alt/opt-up/down seem to jump multiple words, which is about the fastest way to navigate with the keyboard right now.

flowthing 2020-09-17T07:58:42.050800Z

Also, is there a way to clear the output panel?

seancorfield 2020-09-17T07:59:01.051700Z

Not yet @flowthing He mentioned that he's had requests for that.

✅ 2
practicalli-john 2020-09-17T07:59:02.051800Z

@vlaaad is there a Java .properties file that reveal will check for, in which we could put theme configuration? This would save putting it on an alias or command line and having to manage spaces. Thanks

seancorfield 2020-09-17T08:01:07.053400Z

I definitely miss being able to datafy things (there's only a nav option, and it does the datafy thing behind the scenes automatically on the enclosing data structure). And I'm already missing REBL's automatic "display as table" when possible for hash map and vector results.

vlaaad 2020-09-17T08:01:26.053600Z

Morning yall!

1
vlaaad 2020-09-17T08:01:54.053900Z

at least here it’s morning…

vlaaad 2020-09-17T08:02:49.054700Z

"FiraCode-Medium" - failed: system-font? at: [:font-family :system-font] spec: :vlaaad.reveal.prefs/font-family means system font uses a different name

seancorfield 2020-09-17T08:02:51.054900Z

Welcome to Thursday! 🙂

vlaaad 2020-09-17T08:04:53.055Z

Thank you for feedback! I think I just got used to that, but now that you brought my attention to it, I agree — cursor should follow the navigation more. I’ll think about that

1
vlaaad 2020-09-17T08:05:12.055200Z

Yes, structural navigation is the next thing I’m planning to work on

2
vlaaad 2020-09-17T08:06:25.055500Z

Good point about troubles with escaping in jvm-opts, I’ll investigate other ways to supply configuration

vlaaad 2020-09-17T08:07:46.055700Z

there is datafy action available for objects if their datafication is different from the initial object (e.g. vars)

seancorfield 2020-09-17T08:20:15.055900Z

How does it detect "different"? I'm not getting the right result from Reveal's datafy for a JDBC Connection object -- it seems to do object reflection, whereas if I explicitly call datafy on it, I get the right thing (the protocol implementation from next.jdbc.datafy).

seancorfield 2020-09-17T08:21:35.056100Z

https://www.dropbox.com/s/g4hzw157mojyv00/Screen%20Shot%202020-09-17%20at%201.20.26%20AM.png?dl=0 If I use Reveal's datafy option, I get the result panel shown but if I call datafy directly, I get the hash map with :schema, :closed etc (shown in the output panel, below the connection object).

seancorfield 2020-09-17T08:23:21.056600Z

As a follow-up, here's a screen cap of the inline results in Atom, showing the two evals that were tap&gt;'d into Reveal for the screenshot above: https://www.dropbox.com/s/7rgswf2118weo2t/Screen%20Shot%202020-09-17%20at%201.22.38%20AM.png?dl=0

vlaaad 2020-09-17T08:32:37.056900Z

You are datafying a class in a first screenshot

vlaaad 2020-09-17T08:33:19.057100Z

select #object[

seancorfield 2020-09-17T08:33:22.057300Z

I'm datafying a class explicitly for the hash map result shown tho'

seancorfield 2020-09-17T08:33:47.057500Z

Oh... OK, let me try. It seemed to jump over that...

seancorfield 2020-09-17T08:34:26.057700Z

Bingo! OK, that works. I'll have to watch for that...

seancorfield 2020-09-17T08:35:29.057900Z

If I have the cursor as shown here https://www.dropbox.com/s/oczgayt1tho9j9z/Screen%20Shot%202020-09-17%20at%201.34.51%20AM.png?dl=0 and I cursor down, I end up on the classname, not the object which was confusing.

seancorfield 2020-09-17T08:36:14.058200Z

If, instead, I use cursor right, I end up on tap&gt; which seems kind of pointless, then cursor right and I end up on #object[ and then I can datafy it.

vlaaad 2020-09-17T08:37:02.058600Z

Yeah, I really should start working on structural navigation ASAP...

seancorfield 2020-09-17T08:37:24.058800Z

I'd probably be a lot less confused with that 🙂

seancorfield 2020-09-17T08:38:50.059Z

What about the second half of my comment -- about automatically displaying a result as a table if applicable without needing to switch from the editor to Reveal, navigate to the last tap&gt;'d value, pressing space, selecting view:table, and pressing return, and then switching back to the editor?

seancorfield 2020-09-17T08:39:26.059200Z

(it would need to be a transient result tab that was updated with each new tap&gt;'d result)

seancorfield 2020-09-17T08:51:25.059700Z

@vlaaad I'm getting a lot of these warnings, BTW:

WARNING: Illegal reflective access by vlaaad.reveal.action$eval3927$fn__3928$fn__3929$fn__3933 to field java.lang.Class.enumConstants
WARNING: Illegal reflective access by vlaaad.reveal.action$eval3927$fn__3928$fn__3929$fn__3933 to field java.lang.Class.enumConstantDirectory
WARNING: Illegal reflective access by vlaaad.reveal.action$eval3927$fn__3928$fn__3929$fn__3933 to field java.lang.Class.annotationData
WARNING: Illegal reflective access by vlaaad.reveal.action$eval3927$fn__3928$fn__3929$fn__3933 to field java.lang.Class.annotationType
WARNING: Illegal reflective access by vlaaad.reveal.action$eval3927$fn__3928$fn__3929$fn__3933 to field java.lang.Class.classValueMap

seancorfield 2020-09-17T08:51:30.059900Z

(Java 14)

vlaaad 2020-09-17T09:00:32.060Z

what do you mean by showing results as table? the table that gets a new row on every tap&gt;?

vlaaad 2020-09-17T09:00:54.060200Z

or replace the whole table contents with rows/columns from the latest tapped value?

seancorfield 2020-09-17T09:05:17.060400Z

I mean a shortcut that basically does view:table automatically (if applicable) for every new result.

seancorfield 2020-09-17T09:05:26.060600Z

Which is what REBL does, essentially.

seancorfield 2020-09-17T09:06:09.060900Z

But it would be a temporary tab that would go away as soon as the next result came along. Which in turn would create a new tab for view:table if it was applicable.

vlaaad 2020-09-17T09:06:10.061100Z

In java-bean action I assume? I’ll have a look if there is a good way to avoid these warnings without compromising the ability to inspect objects…

seancorfield 2020-09-17T09:07:16.061300Z

In other words, for every result that could have view:table applied, do it automatically. It could be a mode selected via a JVM option -- it wouldn't have to be the default. Maybe :auto-table true in the prefs?

seancorfield 2020-09-17T09:07:57.061500Z

And the new tab created with the table view would automatically close (or just be replaced) as each new result came in.

vlaaad 2020-09-17T09:08:21.061800Z

hmm, good idea, I’ll think about that!

1
seancorfield 2020-09-17T09:08:37.062Z

I haven't been using java-bean in the drop-down so I'm not sure what is causing it.

vlaaad 2020-09-17T09:09:06.062300Z

many thanks for your feedback!

seancorfield 2020-09-17T09:09:12.062500Z

That's probably the #1 usability issue for me, coming from REBL.

vlaaad 2020-09-17T09:09:43.062700Z

and your need applies to tap only, or to everything submitted to reveal?

seancorfield 2020-09-17T09:11:19.062900Z

I think "everything submitted to Reveal" makes sense -- since REBL does this for REPL values as well as submitted values.

seancorfield 2020-09-17T09:12:21.063100Z

I just confirmed datafy on namespaces is very usable. Slightly more work than REBL (again, the auto-table view thing) but acceptable.

seancorfield 2020-09-17T09:14:15.063300Z

(ok, I'm off to bed)

vlaaad 2020-09-17T09:14:33.063500Z

I hear you 🙂 I agree, Reveal requires more work to use than REBL because of it’s approach to inspection as an open set of actions, and some sort of automation would benefit it.

vlaaad 2020-09-17T09:14:37.063700Z

Good night!

vlaaad 2020-09-17T09:15:09.063900Z

ah, that’s interesting…

vlaaad 2020-09-17T18:44:42.064500Z

@seancorfield I made a new release — 1.0.130 — that fixes a bug with reveal's table view that I found while prototyping something that might be useful to you. With that version, you can evaluate the following:

(require '[vlaaad.reveal.ext :as rx])

(let [last-tap (atom nil)]
  (add-tap #(reset! last-tap %))
  (rx/view-as-is
    {:fx/type rx/observable-view
     :ref last-tap
     :fn (fn [x]
           (if (or (nil? x) (string? x) (not (seqable? x)))
             {:fx/type rx/table-view
              :items [x]
              :columns [{:fn identity :header 'value}]}
             (let [head (first x)]
               {:fx/type rx/table-view
                :items x
                :columns (cond
                           (map? head) (for [k (keys head)] {:header k :fn #(get % k)})
                           (map-entry? head) [{:header 'key :fn key} {:header 'val :fn val}]
                           (indexed? head) (for [i (range (count head))] {:header i :fn #(nth % i)})
                           :else [{:header 'item :fn identity}])})))}))
This snippet will return an object with a view action that will always show last tapped value in a table. What do you think of that? 🙂

seancorfield 2020-09-17T19:06:49.064700Z

How do I use it?

seancorfield 2020-09-17T19:07:20.064900Z

(i.e., after eval'ing that expression, what do I do with the view?)

vlaaad 2020-09-17T19:08:48.065100Z

after you eval it, there will be an #object[blah blah blag] in the output. Select #object[ and choose view action

vlaaad 2020-09-17T19:09:38.065300Z

then try tap&gt; -ing stuff 🙂

seancorfield 2020-09-17T19:11:15.065500Z

Got it! Oh, that is very nice. Yes, that's pretty much exactly what I was thinking of with the "auto-table" preference!

seancorfield 2020-09-17T19:12:10.065700Z

Yeah!!! That's much more REBL-like! Thank you!

vlaaad 2020-09-17T19:12:21.065900Z

...and it's possible today using default extensibility mechanisms 🙂

seancorfield 2020-09-17T19:13:46.066100Z

And how would I automate that so it always got eval'd and "view"'d on startup of Reveal?

vlaaad 2020-09-17T19:14:03.066300Z

and that is a story for another time 🙂

vlaaad 2020-09-17T19:15:24.066500Z

I agree, some sort of automation with regards to preferred views will improve Reveal, I'm not giving up on that

seancorfield 2020-09-17T19:20:16.066700Z

Is the view option in the drop-down, something that can be called in code? (I would assume so, but don't know where to start looking for that)

vlaaad 2020-09-17T19:31:34.066900Z

do you want to trigger that action from code?

vlaaad 2020-09-17T19:34:06.067100Z

I'm not sure this is possible from the repl. You need to get a reference to the ui function and then reflectively reach event handler, and then dispatch :vlaaad.reveal.ui/execute-action event

vlaaad 2020-09-17T19:34:16.067300Z

that's, like, super implementation details 🙂

seancorfield 2020-09-17T19:35:48.067500Z

Ah, OK. Then I guess I'll wait for this to get built-in as a pref that can be triggered 🙂

seancorfield 2020-09-17T19:36:01.067700Z

(and, meanwhile, do some of it manually)

seancorfield 2020-09-17T19:41:34.067900Z

I've pasted that code into my dev.repl ns at work so at least I have it easily to hand if I restart my REPL.

👍 1