home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ccut!wakasato!epsongw!icphimiko!icphimiko!green
- From: green@icphimiko.ic.epson.co.jp (CAD M.Tanaka)
- Newsgroups: fj.lang.awk
- Subject: One line editor
- Message-ID: <GREEN.92Nov16195521@iccbrandy.icphimiko.ic.epson.co.jp>
- Date: 16 Nov 92 10:55:20 GMT
- Sender: news@icphimiko.hino.ic.epson.co.jp
- Distribution: fj
- Organization: SEIKO EPSON Corp., Nagano, Japan.
- Lines: 106
-
- $@$3$s$K$A$O!#EDCg!w%;(J$@%$%3!<%(%W%=%s$K$F$G$9!#(J
-
- $@8OLZ$b;3$NFx$N5(@a$H$$$&$3$H$G!"Fx$N$?$a$@$1$N(J awk $@%9%/%j%W%H$r$R$H$D!#(J
- ole $@$H$$$&L>A0$J$s$G$9$,!"J8;zNs$rJT=8$7$FI8=`=PNO$KEG$-$^$9!#$?$H$($P(J
-
- %ole bakayaro- $@$H%3%^%s%I$r$$$l(J$@$k$H(J
- bakayaro- $@$H%=!<%9$rI=<($9$k$N$G(J
- k b $@$HJ8;z$N2<$KCV49J8;z$rCV$/$H(J
- kabayaro- $@CV$-49$($FI=<((J$@$7$^$9!#(J
- $@2?$bF~$l$J$1$l$P!J#C!?#R$N$_!K(J
- kabayaro- $@$HI8=`=PNO$K=P$7$^$9!#(J
-
- $@A^F~!":o=|$J$s$+$O%3(J$@%a%s%H$r8+$F2<$5$$!#(J
- $@$3$l$O$b$H$b$H(J csh $@$N%3%^%s%IMzNr$NJT=8MQ$K:n$C$?$b$N$G$9!#(Jole $@$r;H$C(J
- $@$?<!$N(J csh $@$N(J alias $@$OD>A0$N%3%^%s%I$rJT=8$7$^$9!#!J$?$$$,$$<:GT$7$?;~(J
- $@$K;H$C$?$N$G(J ohno $@$H$$$&L>A0$G$9!#!K(J
-
- alias ohno 'ole "\!-1:q" >/tmp/ole$$;source -h /tmp/ole$$;source /tmp/ole$$;rm -f /tmp/ole$$'
-
- $@$=$l(J$@$+$i$3$l$OEPO?:Q$_$N(J alias $@$rJT=8$9$k$b$N$G$9!#!J!V(Jaliole $@%(%$%j(J
- $@%"%9L>!W$H$$$l$^$9!#!K(J
-
- alias aliole 'ole "`alias \!*`" >/tmp/ole$$;alias \!* `cat /tmp/ole$$`;rm -f /tmp/ole$$'
-
- $@$H$^$"!"$3$s$J$b$s$G$9(J$@$1$I!"(Jtcsh,zsh,ksh,bash $@$H$+$N%7%'%k$d(J ile $@$H(J
- $@$+$N%3%^%s%I%(%G%#%?$,=P2s$C$F$$$k8=:_$8$c$"!"$"$s$^$jMx(J$@MQ2ACM$O$J$$$G(J
- $@$9$M!#(J:- P
- $@:G6a!";w$?$h$&$J$N$r$U$?$D$P$+$jL\$K$7$^$7$F!"!V?M4V$N9M$($k$3$H$OF1(J
- $@$8$8(J$@$c!W$HL/$K46?4$7$F$7$^$$$^$7$?!#$3$3$K%]%9%H$9$k$N$O(JPDS$@$N%7%'%k(J rc
- $@$K$D$$$F$?$b$N$r;29M$K$7$F=q$-D>$7(J$@$?$b$N$G$9!#!J$=$s$J;~4V$J$$$N$K!#!#!K(J
- $@$G$O!"$I$&$>>P$C$F$d$C$F2<$5$$!#(J:-)
-
- --------- cut here ------------------------------------------------
- #!/bin/gawk -f
- # ole : The one line editor
- # v2.0 92/9/15 m.tanaka create
- #
- # usage : ole source_string
- #
- # any character
- # Replaces the character above.
- #
- # space or tab( at begining of line )
- # Skips over the above character(s).
- #
- # # Deletes one character.
- #
- # % Replaces one character with a space.
- #
- # ^ Inserts the rest of the typed line just before the
- # character.
- #
- # $ Deletes the rest of the line from that character on,
- # and replaces it with the rest of the typed line.
- #
- #
-
- BEGIN{
- print ARGV[1] > "/dev/tty"
- src = ARGV[1]
- ARGV[1] = "-"
-
- chgpat = "(\\^.*$|[^ #^%$]+|[#]+|[%]+|[$].*$)"
- }
- /^$/{
- exit
- }
- {
- gsub("\t"," ")
- src = sprintf("%-" length($0) "s",src)
- out = ""
- p = 1
- while( match(substr($0, p ), chgpat) ){
- out = out substr(src, p , RSTART - 1)
- p += (RSTART - 1)
- key = substr($0, p, 1)
- if(key == "%"){
- for(i=1; i <= RLENGTH; i++) {out = out " "}
- }
- else if(key == "^"){
- out = out substr($0, p+1)
- break
- }
- else if(key == "$"){
- p = -1
- break
- }
- else if(key != "#"){
- out = out substr($0, p, RLENGTH)
- }
- p += RLENGTH
- }
- src = out ((p > 0) ? substr(src,p) : "")
- print src > "/dev/tty"
- }
- END{
- print src
- exit
- }
- --------------- cut here -------------------------------
-
- --
- --
- $@EDCg(J $@L-(J $@%;%$%3!<%(%W%=%s3t<02q<R(J DAG CADT $@$K$F(J
- Tanaka Minoru
- green@iccbrandy.ic.epson.co.jp
-