From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <36493baa15b236661ef0f0225656755c@debpi> To: 9fans@9fans.net From: trebol55555@yandex.ru Date: Tue, 31 May 2016 02:34:57 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [9fans] Chords, ^, _, ^B and scroll with mouse wheel in p9p sam Topicbox-Message-UUID: 962be1de-ead9-11e9-9d60-3106f5b1d025 I posted wrong code for Plan 9 by error. The E script: ----------------- #!/bin/rc files=3D() dest=3D() if(~ $#* 0){ echo usage: E file ... >[1=3D2] exit usage } for(i) switch($i){ case /* files =3D ( $files $i ) case * files =3D ( $files `{cleanname `{pwd}^/$i} ) } if(test -f /mnt/term/srv/sam.$user) dest =3D /mnt/term/srv/sam.$user if not if(test -f /srv/sam.$user) dest =3D /srv/sam.$user if not { switch($files){ case *:* for(i in $files){ fi =3D `{echo $i | sed 's/(.*):[^:]*/\1/'} ad =3D `{echo $i | sed 's/.*:([^:]*)/\1/'} plumb -d edit -a 'addr=3D'$"ad'' $fi } case * plumb -d edit $files } exit } switch($files){ case *:* for(i in $files) echo $i | sed 's/^/B /;s/:(.*)$/\n\1/g' >> $dest case * echo B $files >> $dest } ----------------- The plumb rules: ----------------- # existing files, possibly tagged by line number, go to editor type is text data matches '([.a-zA-Z=C2=A1-=EF=BF=BF0-9_/+\-]*[a-zA-Z=C2=A1-=EF=BF=BF0= -9_/+\-])('$addr')?' arg isfile $1 plumb start E $file:$3 ## man index entries are synthesized type is text data matches '([a-zA-Z=C3=80-=CA=A8=C2=A1-=EF=BF=BF0-9_-./+\-]+)\(([1-8])= \)' plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =3D /mnt/term= /srv/sam.$user; if not if(test -f /srv/sam.$user) dest =3D /srv/sam.$user= ; if not {man '$2' '$1' >[2=3D1] | plumb -i -d edit -a ''action=3Dshowdat= a filename=3D/man/'$1'('$2')''; exit}; {echo ''{}''; echo ''B ~~'$1'('$2'= )~~''; echo ''[2=3D1]''} >>$dest' # poor man's sam file browser type is text data matches '([.a-zA-Z=C2=A1-=EF=BF=BF0-9_/\-;&$,'']+)' arg isdir $0 plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =3D /mnt/term= /srv/sam.$user; if not if(test -f /srv/sam.$user) dest =3D /srv/sam.$user= ; if not {plumb -d edit '$dir'; exit}; cd '$dir'; DIR =3D `{pwd}; {echo '= '{}''; echo B $DIR/~~samdir~~; echo '',>/srv/sam.$user' ## poor man's sam exec in current file's cwd type is text data matches '(=C2=A4)([a-zA-Z=C3=80-=CA=A8=C2=A1-=EF=BF=BF0-9_\-./\+^,()= $:|#%<>*&'' ]+)' plumb start rc -c 'if(test -f /mnt/term/srv/sam.$user) dest =3D /mnt/term= /srv/sam.$user; if not if(test -f /srv/sam.$user) dest =3D /srv/sam.$user= ; if not {echo can''''t find sam server file >[1=3D2]; exit open}; {cd '$= wdir'; {echo '$wdir' =C2=A4'''$2'''; echo; {'$2'}; echo} >/tmp/sam_ecfcwd= _$pid >[2=3D1]; {echo ''{}''; echo B '$wdir'^/~~cmd~~; echo ''$''; echo '= '>$dest}= ' ----------------- I've tested it in 9front, and all works good. Of course you can delete all the acme part if you don't use it. Remember that you have to edit samterm/io.c to create always the pipe [...] hoststart(); plumbstart(); extstart(); } And in P9P you need to set the shell to rc in sam/unix.c #define SHNAME "rc" #define SHPATHNAME "/usr/local/plan9/bin/rc" =09 Or adapt the rules for sh... trebol.