From 33bd5366cc2b8ecd33235b07ba51b22c91a88247 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 7 Apr 2015 16:07:10 -0700 Subject: [PATCH 1/5] hook/door/dill-belt/mar --- arvo/dill.hoon | 8 +++--- main/app/reload/core.hook | 2 +- main/app/sole/core.hook | 4 +-- main/mar/dill-belt/door.hook | 54 ++++++++++++++++++++++++++++++++++++ main/sur/sole/core.hook | 4 +-- 5 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 main/mar/dill-belt/door.hook diff --git a/arvo/dill.hoon b/arvo/dill.hoon index ef98b32eb3..009934a623 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -37,9 +37,9 @@ $% [%aro p=?(%d %l %r %u)] :: arrow key [%bac ~] :: true backspace [%cru p=@tas q=(list tank)] :: echo error - [%ctl p=@ud] :: control-key + [%ctl p=@c] :: control-key [%del ~] :: true delete - [%met p=@ud] :: meta-key + [%met p=@c] :: meta-key [%ret ~] :: return [%rez p=@ud q=@ud] :: resize, cols, rows [%txt p=(list ,@c)] :: utf32 text @@ -78,9 +78,9 @@ ++ belt :: raw console input $% [%aro p=?(%d %l %r %u)] :: arrow key [%bac ~] :: true backspace - [%ctl p=@ud] :: control-key + [%ctl p=@c] :: control-key [%del ~] :: true delete - [%met p=@ud] :: meta-key + [%met p=@c] :: meta-key [%ret ~] :: return [%txt p=(list ,@c)] :: utf32 text == :: diff --git a/main/app/reload/core.hook b/main/app/reload/core.hook index c12947d80a..3b9cbd7da0 100644 --- a/main/app/reload/core.hook +++ b/main/app/reload/core.hook @@ -11,7 +11,7 @@ ++ poke--args %^ add-output . rush/tang/[leaf/"done"]~ - %+ args-into-resp . + %+ args-into-resp . |= all=(list ,@tas) %+ turn all =+ ark=(arch .^(%cy /(scot %p our.hid)/arvo/(scot %da lat.hid))) diff --git a/main/app/sole/core.hook b/main/app/sole/core.hook index c88c1c723a..39b6ed6223 100644 --- a/main/app/sole/core.hook +++ b/main/app/sole/core.hook @@ -356,7 +356,7 @@ (ta-hom(pos.inp pre) %del pre) :: ++ ta-ctl :: hear control - |= key=@ud + |= key=@c ^+ +> ?+ key ta-bel %a +>(pos.inp 0) @@ -477,7 +477,7 @@ +> :: ++ ta-met :: meta key - |= key=@ud + |= key=@c ~& [%ta-met key] +> :: diff --git a/main/mar/dill-belt/door.hook b/main/mar/dill-belt/door.hook new file mode 100644 index 0000000000..43c924c463 --- /dev/null +++ b/main/mar/dill-belt/door.hook @@ -0,0 +1,54 @@ +:: +:::: /hook/door/dill-belt/mar + :: +/? 314 +/- kyev,*sole +!: +:::: + :: +|_ dill-belt +:: +++ grab :: convert from + |% + ++ json + =< (cork . kyev) + |= jon=^json ^- ^kyev + %- need + %. jon => jo %- ot + :~ mod/(cu ^sa (ar (su (perk ~[%ctrl %shift %alt %meta])))) + :- %key + %+ cu |*(a=$%([%str @t] [%act @]) ?+(-.a a %str +.a)) + =- (of str/so act/(su (perk -)) ~) + :~ %ctrl %shift %alt %meta %entr %esc %caps %uncap + %pgup %pgdn %home %end %baxp %del %ins + %up %down %left %right + == == + ++ kyev + |= kev=^kyev ^- dill-belt + ~| dill-belt-incomplete/kev + ?: ?=([%act ?(%ctrl %shift %alt %meta)] q.kev) + [%txt ~] :: ignore + =+ mod=(~(del in p.kev) %shift) + ?^ mod + ?^ q.kev !! :: only accept strings + =+ cha=(tuba (trip q.kev)) + ?> ?=([@ ~] cha) :: of a single character + ?+ mod !! :: modified by one buckykey + [%ctrl ~ ~] [%ctl i.cha] + [%alt ~ ~] [%met i.cha] + == + ?@ q.kev + [%txt (tuba (trip q.kev))] + ?+ +.q.kev !! + %del [%del ~] + %baxp [%bac ~] + %entr [%ret ~] + %up [%aro %u] + %down [%aro %d] + %left [%aro %l] + %right [%aro %r] + == :: %yow, %rez? + :: + ++ noun dill-belt :: clam from %noun + -- +-- diff --git a/main/sur/sole/core.hook b/main/sur/sole/core.hook index ef1eedbc27..dec63fcec4 100644 --- a/main/sur/sole/core.hook +++ b/main/sur/sole/core.hook @@ -93,9 +93,9 @@ $% [%aro p=?(%d %l %r %u)] :: arrow key [%bac ~] :: true backspace [%cru p=@tas q=(list tank)] :: echo error - [%ctl p=@ud] :: control-key + [%ctl p=@c] :: control-key [%del ~] :: true delete - [%met p=@ud] :: meta-key + [%met p=@c] :: meta-key [%ret ~] :: return [%rez p=@ud q=@ud] :: resize, cols, rows [%txt p=(list ,@c)] :: utf32 text From fcb46d2cef74f54d61a84ca6fbfb9016b5715825 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 7 Apr 2015 17:13:46 -0700 Subject: [PATCH 2/5] stopped urb.js %mean retry --- main/lib/urb.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/lib/urb.js b/main/lib/urb.js index 4d22ad515e..197378ad3f 100644 --- a/main/lib/urb.js +++ b/main/lib/urb.js @@ -103,11 +103,12 @@ window.urb.poll = function(params) { return document.location.reload() // XX check autoreload case "rush": case "mean": + var err2 = err if(res.data.type == "mean") - err = res.data.data + err2 = res.data.data var fn = $this.gsig(res.data.from) if($this.cabs[fn]) - $this.cabs[fn].call(this,err, + $this.cabs[fn].call(this,err2, {status: res.status, data: res.data.data.json}) // XX non-json break; default: From 3c2762a9d1387612528d54293a31f01db50b6076 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 7 Apr 2015 18:08:48 -0700 Subject: [PATCH 3/5] :helm+sync syd her sud --- main/app/helm/core.hook | 22 ++++++++++++++++++++-- main/cat/helm/sync/gate.hook | 12 ++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 main/cat/helm/sync/gate.hook diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 50e55aa921..aa1adb99d4 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -24,6 +24,7 @@ %verb :: verbose mode == :: $% [%reload p=(list term)] :: reload vanes + [%sync p=@tas q=@p r=@tas ~] :: == :: ++ dill-flog :: sent to %dill $% [%veer p=@ta q=path r=@t] :: install vane @@ -46,8 +47,12 @@ ++ note-dill :: system command $% [%flog p=dill-flog] :: == :: + ++ note-clay :: filesystem command + $% [%font p=@p q=@tas r=@p s=@tas] :: + == :: ++ note :: out request $-> - $% [%d note-dill] :: + $% [%c note-clay] :: + [%d note-dill] :: [%g note-gall] :: == :: -- :: @@ -88,7 +93,7 @@ =+ txt=((hard ,@) .^(%cx (welp pax /hoon))) [ost %pass /reset %d %flog %veer p pax txt] :: - ++ he-wish-reload + ++ he-wish-reload |= all=(list term) %_ +>.$ moz @@ -116,6 +121,14 @@ == == :: + ++ he-wish-sync + |= [syd=@tas her=@p sud=@tas ~] + %_ . + moz + :_ moz + [ost %pass /sync %c %font our.hid syd her sud] + == + :: ++ he-wish-verb %_ . moz @@ -144,6 +157,11 @@ ~& %poke-helm-reload he-abet:(he-wish-reload:(hake ost her) all) :: +++ poke-helm-sync + |= [ost=bone her=ship all=[@tas @p @tas ~]] + ~& %poke-helm-sync + he-abet:(he-wish-sync:(hake ost her) all) +:: ++ poke-helm-begin |= [ost=bone you=ship begs] ~& %poke-helm-begin diff --git a/main/cat/helm/sync/gate.hook b/main/cat/helm/sync/gate.hook new file mode 100644 index 0000000000..078680fcab --- /dev/null +++ b/main/cat/helm/sync/gate.hook @@ -0,0 +1,12 @@ +:: +:::: /hook/gate/sync/helm/cat + :: +/? 314 +:: +:::: + !: +|= $: [now=@da eny=@uvI bec=beak] + [arg=[syd=@tas her=@p sud=@tas ~] ~] + == +:- %helm-sync +arg From d76b5d43c754c40f7b389fac27a9e519abfcd473 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 8 Apr 2015 15:01:47 -0700 Subject: [PATCH 4/5] New url stuff on test branch. --- main/app/talk/core.hook | 23 ++++++++++++++++------- main/mar/talk-command/door.hook | 1 + main/mar/talk-report/door.hook | 1 + main/sur/talk/core.hook | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 1627c2c37c..a91015fafa 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -135,6 +135,7 @@ |_ $: coz=(list command) :: talk actions she=shell == + ++ sh-purl (ifix [gay gay] auri:urlp) :: url with spaces ++ sh-scad :: command parser =+ vag=(vang | [&1:% &2:% '0' |3:%]) =< work @@ -739,8 +740,8 @@ (fix inx '?' lit) ?: &((gte i.buf 'A') (lte i.buf 'Z')) (fix inx (add 32 i.buf) lit) - :: ?: &(=('/' i.buf) ?=([47 *] t.buf)) - :: (fix inx '\\' lit) + ?: &(=('/' i.buf) ?=([47 *] t.buf)) + (fix inx '\\' lit) lit :: ++ sh-sane-rule :: sanitize by rule @@ -754,10 +755,13 @@ |= [inv=sole-edit buf=(list ,@c)] ^- (list sole-edit) ?~ buf ~ - ?: =(';' i.buf) - ((sh-sane-rule sh-scad) inv (tufa t.buf)) + =+ txt=(tufa buf) + ?: =(';' -.txt) + ((sh-sane-rule sh-scad) inv +.txt) ?: =('@' i.buf) (sh-sane-chat +.buf) + =+ ryv=(rose txt sh-purl) + ?: -.ryv ~ (sh-sane-chat buf) :: ++ sh-slug :: edit to sanity @@ -780,10 +784,13 @@ ++ sh-pork :: parse work ^- (unit work) ?~ buf.say.she ~ - ?: =(';' -.buf.say.she) - (rust (tufa +.buf.say.she) sh-scad) + =+ txt=(tufa buf.say.she) + ?: =(';' -.txt) + (rust +.txt sh-scad) ?: =('@' -.buf.say.she) `[%say %lin | (crip (tufa +.buf.say.she))] + =+ rul=(rust txt sh-purl) + ?^ rul `[%say %url u.rul] `[%say %lin & (crip (tufa buf.say.she))] :: ++ sh-lame :: send error @@ -821,7 +828,8 @@ ++ activate :: from %number |= gam=telegram ^+ +>+>+> - ~& [%activate gam] + =. +>+>+> ?. ?=(%url -.r.r.q.gam) +>+>+> + (sh-fact %txt (earn p.r.r.q.gam)) sh-prod(active.she `~(tr-pals tr man.she gam)) :: ++ join :: %join @@ -1729,6 +1737,7 @@ |= oug=? ^- tape ?+ -.sep "" + %url (weld ": " (scag 62 (earn p.sep))) %lin =+ txt=(trip q.sep) ?: p.sep diff --git a/main/mar/talk-command/door.hook b/main/mar/talk-command/door.hook index afdde5288d..da2a3e94a3 100644 --- a/main/mar/talk-command/door.hook +++ b/main/mar/talk-command/door.hook @@ -72,6 +72,7 @@ ^- $+(json (unit statement)) =- (ot date/di bouquet/(as (ar so)) speech/(of -) ~) :~ lin/(ot say/bo txt/so ~) + :: url/(su auri:urlp) :: exp/(cu |=(a=cord [a ~]) so) :: inv/(ot ship/(su fed:ag) party/(su urs:ab) ~) == diff --git a/main/mar/talk-report/door.hook b/main/mar/talk-report/door.hook index 0caf6de4bf..bc35013e52 100644 --- a/main/mar/talk-report/door.hook +++ b/main/mar/talk-report/door.hook @@ -88,6 +88,7 @@ %+ joba -.a ?+ -.a !! %lin (jobe say/[%b p.a] txt/[%s q.a] ~) + %url (jobe url/[%s (crip (earn p.a))] ~) %exp (jobe code/[%s p.a] ~) :: %inv (jobe ship/(jope p.a) party/[%s q.a] ~) == diff --git a/main/sur/talk/core.hook b/main/sur/talk/core.hook index 120855b4a4..987125efb3 100644 --- a/main/sur/talk/core.hook +++ b/main/sur/talk/core.hook @@ -59,7 +59,7 @@ [%ext p=@tas q=*] :: extended action [%fat p=torso q=speech] :: attachment :: [%inv p=station] :: invite to station - :: [%url p=purl] + [%url p=purl] :: parsed url [%ire p=serial q=speech] :: in-reply-to [%lin p=? q=@t] :: no=@, text line [%mor p=(list speech)] :: multiplex From 886bbe9aca19cd6295f6296348d2d9f896524c51 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 8 Apr 2015 18:35:17 -0700 Subject: [PATCH 5/5] Matrix frontend v1 --- arvo/eyre.hoon | 13 ++- main/app/dojo/core.hook | 2 +- main/app/matrix/hymn.hook | 165 +++++++++++++++++++++++++++++++++++ main/mar/dill-belt/door.hook | 4 + main/mar/dill-blit/door.hook | 23 +++++ 5 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 main/app/matrix/hymn.hook create mode 100644 main/mar/dill-blit/door.hook diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index d2f7522a12..050669806f 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -518,9 +518,12 @@ [?(%on %ay) *] ~|(e/ford/lost/-.tee !!) [%of ^] ?~ q.tee ~|(e/ford/lost/tee !!) + ?: ?=(%| -.q.sih) + (print-tang p.q.sih) %+ get-rush:(ire-ix p.tee) q.tee - ?> ?=([%& %json ^] q.sih) :: XX others - ((hard json) |3.q.sih) + =* cay p.q.sih + ?> ?=(%json p.cay) :: XX others + ((hard json) q.q.cay) :: [%to ^] ?: ?=(%| -.q.sih) @@ -558,6 +561,12 @@ (fail 500 0v0 >%exit< p.mul) :: ++ ire-ix |=(ire=ixor ~(. ix ire (~(got by wix) ire))) + ++ print-tang + |= a=tang ^+ +> + ?~ a +> + ~> %slog.`i.a + $(a t.a) + :: ++ ses-authed |= ses=hole =+ sap=(~(get by sop) ses) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 3b425f3e6c..f3ee5d4f9a 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -233,7 +233,7 @@ ++ dp-server-cat (stag 0 (stag %cat dp-device)) :: ++dojo-server ++ dp-server-dog (stag 0 (stag %dog dp-device)) :: ++dojo-server ++ dp-server-pig (stag 0 (stag %pig dp-device)) :: ++dojo-server - ++ dp-twig wide:(vang & ~) :: ++twig + ++ dp-twig wide:(vang | ~) :: ++twig ++ dp-device (most fas sym) :: ++dojo-device ++ dp-value :: ++dojo-source %+ cook |=(a=dojo-source a) diff --git a/main/app/matrix/hymn.hook b/main/app/matrix/hymn.hook new file mode 100644 index 0000000000..317482d6b3 --- /dev/null +++ b/main/app/matrix/hymn.hook @@ -0,0 +1,165 @@ +:: Matrix GUI +:: +:::: /hook/hymn/matr/app + :: +/? 310 +|% +++ cdnj |=(a=tape ;script(src "//cdnjs.cloudflare.com/ajax/libs/{a}");) +-- +:: +:::: + :: +^- manx +;html + ;head + ;title: Matrix + ;* %- turn :_ cdnj ^- wall + :~ "jquery/2.1.1/jquery.min.js" + "mousetrap/1.4.6/mousetrap.js" + "react/0.11.0/react.js" + == + ;script(src "/~/at/main/lib/urb.js"); + ;script: urb.appl = 'sole' + ;style:''' + #term { + width: 100%; + } + #term * { + margin: 0px; + } + ''' + == + ;body + ;div#err; + ;div#term:"" + ;script(type "text/coffeescript") ;- %- trip + ''' + [DOM,recl,rend] = [React.DOM, React.createClass, React.renderComponent] + [div, pre] = [DOM.div, DOM.pre] + Matr = recl render: -> + [pro,cur] = [@props.prompt + " ", @props.cursor + 1] + prompt = "#{pro.slice(0,cur)}\u0332#{pro.slice(cur)}" + lines = [prompt, @props.rows...] + div {}, lines.slice().reverse().map (lin)-> + pre {}, lin + + $ -> + termRev = 0 + pressed = [] + deltim = null + + met = $('
').text('m').css(display: 'none').appendTo(term).width()
+        subs = ""
+        # $(window).resize -> 
+        #   window.termWif = ($(term).width() / met).toFixed()
+        #   path =  "/new/#{termWif}"
+        #   if path is subs
+        #     return
+        #   if subs
+        #     urb.unsubscribe {path:subs}
+        #   subs = path
+        #   urb.subscribe {path}, (err,dat)->
+        #       if err or dat.data.ok
+        #         return;
+        #       syncRev = dat.data.rev
+        #       unless termRev > syncRev
+        #         termRev = syncRev
+        #         matr.setProps rows: dat.data.stak
+        #         document.title = "Matrix"  # XX  debug
+        # $(window).resize()
+
+        matr = rend (Matr rows:[], prompt:"", cursor:1), term
+        flash = ($el, background)->
+          $el.css {background}
+          if background
+            setTimeout (()-> flash $el,''), 50
+        
+        peer = (ruh) ->
+          switch false
+            when !ruh.map then ruh.map peer
+            when !ruh.pro then matr.setProps prompt: ruh.pro
+            when !ruh.hop then matr.setProps cursor: ruh.hop
+            when !ruh.out 
+              matr.setProps rows: [ruh.out, matr.props.rows...]
+            when !ruh.act then switch ruh.act
+              when 'clr' then matr.setProps rows:[]
+              when 'bel' then flash ($ 'body'), 'black'
+              else throw "Unknown "+(JSON.stringify ruh)
+            else console.log ruh
+        
+        urb.bind "", (err,d)->
+          if d.data then peer d.data
+
+        #later = (data)->
+        #  if data
+        #    pressed.push data
+        #  clearTimeout deltim
+        #  setTimeout (->
+        #    if urb.reqq.length > 0 
+        #      return deltim = later()
+        #    urb.send data: pressed
+        #    pressed = []
+        #  ), 500
+
+        Mousetrap.handleKey = (char, mod, e)->
+          norm = {
+            capslock:  'caps'
+            pageup:    'pgup'
+            pagedown:  'pgdn'
+            backspace: 'baxp'
+            enter:     'entr'
+          }
+          key = 
+            if char.length is 1
+              if e.type is 'keypress'
+                str: char
+            else if e.type is 'keydown'
+              if char isnt 'space'
+                act: norm[char] ? char
+            else if e.type is 'keyup' and norm[key] is 'caps'
+              act: 'uncap'
+          if key
+            e.preventDefault()
+            urb.send mark: 'dill-belt', data: {mod,key}
+            
+            # amod = (arr)->
+            #   for i in arr
+            #     unless mod.indexOf(i) < 0
+            #       return yes
+            #   no
+            # if key.str or key.act is 'baxp' or key.act is 'entr'
+            #   termRev++
+            #   [bot, rest...] = old = matr.props.rows
+            #   matr.setProps rows:(
+            #     switch  key.act 
+            #       when 'baxp'
+            #         if amod ['ctrl', 'meta']
+            #           ['', rest...]
+            #         else if amod ['alt']
+            #           [(bot.replace /\ *[^ ]*$/, ''), rest...]
+            #         else if bot and bot.length 
+            #           [bot.slice(0, -1), rest...]
+            #         else if rest[0] and rest[0].length
+            #           res = rest.slice()
+            #           res[0] = res[0].slice(0, -1)
+            #           res
+            #         else rest
+            #       when 'entr'
+            #         ['', old...]
+            #       when undefined
+            #         if mod.length > 1 or (mod.length and !amod ['shift'])
+            #           old
+            #         else unless old and bot isnt null
+            #           [key.str]
+            #         #else if bot.length is termWif
+            #         #  [key.str, old...]
+            #         else [bot + key.str, rest...]
+            #   )
+            #   document.title = "Matri"  # XX  debug
+            # later {mod, key}
+
+
+      '''
+    ==
+    ;+  (cdnj "coffee-script/1.7.1/coffee-script.min.js")
+==  ==
diff --git a/main/mar/dill-belt/door.hook b/main/mar/dill-belt/door.hook
index 43c924c463..b21f81b8bc 100644
--- a/main/mar/dill-belt/door.hook
+++ b/main/mar/dill-belt/door.hook
@@ -31,6 +31,10 @@
     =+  mod=(~(del in p.kev) %shift)
     ?^  mod
       ?^  q.kev  !!                   ::  only accept strings
+      =.  q.kev
+        ?.  (~(has in p.kev) %ctrl)
+          q.kev
+        (con 96 q.kev)                ::  ctrl key decoding
       =+  cha=(tuba (trip q.kev))
       ?>  ?=([@ ~] cha)               ::  of a single character
       ?+  mod  !!                     ::  modified by one buckykey
diff --git a/main/mar/dill-blit/door.hook b/main/mar/dill-blit/door.hook
new file mode 100644
index 0000000000..eecb0e505c
--- /dev/null
+++ b/main/mar/dill-blit/door.hook
@@ -0,0 +1,23 @@
+::
+::::  /hook/door/dill-blit/mar
+  ::
+/?    314
+/-    *sole
+|_  dib=dill-blit
+::
+++  grab                                                ::  convert from
+  |%
+  ++  noun  dill-blit                                       ::  clam from %noun
+  --
+++  grow
+  |%
+  ++  json
+    ^-  ^json
+    ?+  -.dib  ~|(unsupported-blit/-.dib !!)
+      %mor  [%a (turn p.dib |=(a=dill-blit json(dib a)))]
+      %hop  (joba %hop (jone p.dib))
+      ?(%pro %out)  (joba -.dib (jape (tufa p.dib)))
+      ?(%bel %clr)  (joba %act %s -.dib)
+    ==
+  --
+--