Commit Graph

10 Commits

Author SHA1 Message Date
Ted Blackman
844386076f %base: symlinks; some -test tests fail 2021-08-30 20:39:37 +03:00
fang
f285c7954e
sole: add %bye effect for closing the session
This lets applications suggest to the client that they should gracefully
unsubscribe from the session.

Arguably this might be accomplished by %kick-ing the client and then
crashing on their subsequent resubscribe, but this requires tracking
their sole session id and has less semantic clarity on what's happening.
2020-12-15 16:56:47 +01:00
fang
a539d986a7
various: move away from {type} syntax
In favor of [type] syntax.
Turns a bunch of ++ into +$ along the way.
2020-11-26 17:43:26 +01:00
fang
44fb0cc19d
various: move away from face/type syntax
In favor of face=type.
2020-11-26 17:38:00 +01:00
fang
a6e7af38d5
various: move away from $constant type syntax 2020-11-26 17:31:06 +01:00
Isaac Visintainer
51d61e4d49 static gall: convert soto 2019-11-22 12:57:58 -08:00
Philip Monk
9487481128
dojo, drum: change %tab sole-effect to use tanks
It should be general-purpose for tab-completing things in other apps,
types are inappropriate.
2019-10-31 15:14:41 -07:00
Philip Monk
4482997a16
dojo, drum: give tab completion as true output
This stops slogging the tab completion and intead adds a +sole-effect
for tab completion output.  This is morally correct, and it lets dojo
clients show tab completions how they want.  For example, web dojo could
implement this as a drop-down box.

Another advantage is that this puts the rendering logic in drum, which
knows the width of the terminal.  Thus, we can make sure each match
takes no more than one line by truncating with ellipses.  If there's
only one match and it's already fully typed, then we display the whole
type.
2019-10-31 14:36:14 -07:00
Philip Monk
76b917f426
dojo: add tab completion
This is initial support for type-aware tab completion.  When you hit tab, it tries to complete the word you're in the middle of using a face or arm in the subject at that point in the code.  It also shows all possible matches and their associated types.  It's nearly instantaneous.  Notes:

- It advances to the longest common prefix, so if you hit tab on `ab` and the only possible results are `abcde` and `abcdz`, then it'll write `abcd` and print both out (with their types).

- If there are fewer than ten matches, it prints the type along with the face.  Printing types is too slow to use all the time, but with 10 it's essentially instantaneous.

- The match closest in the subject to you (i.e. smallest axis number) is displayed lowest (closest to your focus).

Examples below, where `<TAB>` represents me hitting tab while my cursor is at that position (the line with the `<TAB>` is not preserved in the actual output).

```
~zod:dojo> eth<TAB>
-----
ethereum        #t/<11.qcl {<3.ltb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141> <21.yeb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141>}>
ethereum-types  #t/<3.ltb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141>
~zod:dojo> ethereum
~zod:dojo> |=  zong=@ud  z<TAB>
-----
zing  #t/<1.dqs {* <126.xjf 41.mac 1.ane $141>}>
zap   #t/<1.iot {tub/{p/{p/@ud q/@ud} q/""} <1.rff {daf/@t <247.ows 51.mvt 126.xjf 41.mac 1.ane $141>}>}>
zuse  #t/$309
zong  #t/@ud
~zod:dojo> |=  zong=@ud  zo<TAB>
-----
zong  #t/@ud
~zod:dojo> |=  zong=@ud  zong
~zod:dojo> <TAB>
hoon-version
trel
quip
pole
unit
qual
lone
... about 600 more lines ...
unity
html
zuse
eny
now
our
~zod:dojo>
```

Functionally, this is in a state where I'd be comfortable shipping it.  It doesn't interfere with anything if you don't press tab, and it's perfectly OTA-able.  I do think its output is a little verbose, but that can be tuned over time as people try it and determine what feels good in practice.

Additional notes:

- There are plenty of similar systems for other languages, but my most direct inspiration is Idris's editor tools.  This is implemented for the dojo, but I actually want it in my editor, which is why the meat is all defind in a library.  I've only tested on dojo one-liners, so I don't know the performance on large blocks of code.

- The default type printer isn't great for this use case.  In particular,
	- Cores should not print anything about their context
  - The `#t/` should go away
  - If it looks like a gate, we should print its return value
  - Maybe special handling for molds, but if the above is done, then for example `bone` is  `* -> @ud`.

- The worst part about our wing ordering is that it really screws up tab completion.  You want to do `point.owner-address` instead of `owner-address.point` because that lets you type `point.ow<TAB>`.  I weakly prefer reading it how we do it now, but it's really not great.  You could do an (dojo-specific?) alternate syntax of `point;owner-address`; this is a simple transformation.

- Regardless of the above, this should handle the case where we're in the middle of defining a wing; it doesn't right now.

- When a variable is shadowed, we show both of them.  We should probably show the shadowed one with a `^`.

- We probably shouldn't print out hundreds of results.  Maybe just the closest 50 with ellipses.

- This gets you any face in your subject, regardless of whether its type is reasonable.  We could limit that some by copying the `gol` logic in mint, so that if the pseudo-backward-inference engine happens to know what type it should be, you can filter the tab results according to if they nest in that type.  This would be "strongly type-aware".
2019-10-30 23:19:25 -07:00
Jared Tobin
b3901ab42f Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8'
git-subtree-dir: pkg/arvo
git-subtree-mainline: 9c8f40bf6c
git-subtree-split: c20e2a185f
2019-06-28 12:48:05 +08:00