// befunge-93 X:"\\" / escape Q:"\"" / quote N:"0123456789" / numeric p:{[n;x](-n)#(&n),x} / left overtake, pad with 0 x:{[n;f]{v .(((-n)_ x),,f . p[n]x;y)}} / nary apply, append 1 y:{[n;f]{v .(((-n)_ x),f . p[n]x;y)}} / nary apply, append k z:{[d]{v .(x;@[y;1;:;d[]])}} / modify direction w:{[d]{v .(-1_ x;@[y;1;:;d@~*p[1]x])}} / modify direction conditional v:{(x;@[y;2;:;(+/y 1 2)!'^*y])} / vector B::"";b:{[f]if[~#B;B::0:`];r:f B;B::(#r)_ B;r} / input buffer O:+(("+" ;x[2;+]) / add ("-" ;x[2;-]) / sub ("*" ;x[2;*]) / mul ("/" ;x[2;_%]) / div ("%" ;x[2;!]) / mod ("!" ;x[1;~:]) / not ("`" ;x[2;>]) / more (">" ;z[0 1]) / right ("<" ;z[0 -1]) / left ("v" ;z[ 1 0]) / down ("^" ;z[-1 0]) / up ("?" ;z[(0 1;0 -1;1 0;-1 0)()_draw 4]) / randomize direction ("_" ;w[(0 -1;0 1)]) / if true left else right ("|" ;w[(-1 0;1 0)]) / if true up else down (Q ;{v .(x;@[y;3;:;1])}) / enter quote mode (":" ;y[1;{(x;x)}]) / dup (X ;y[2;{(y;x)}]) / swap ("$" ;y[1;{()}]) / pop ("." ;y[1;{`0:,$x;()}]) / pop val -> output ("," ;y[1;{`0:_ci x;()}]) / pop val -> char -> output ("#" ;{2(v .)/(x;y)}) / bridge (skip) ("g" ;{v .((-2_ x),_ic y[0].|p[2;x];y)}) / get ("p" ;{v .(-3_ x;.[y;0,|p[2;x];:;_ci p[3;x]0])}) / put ("&" ;{v .(x,0$b{(x?" ")#x};y)}) / input -> val ("~" ;{v . (x,_ic b(*:);y)}) / input -> char ("@" ;{(x;y)})) / stop / x = stack / y = (program;y-dir,x-dir;y,x;quote-mode) / apply - in normal mode: a:{t:y[0]. y 2;:[y 3;q;t _in N;{v .(x,0$y;z)};t _in*O;{O[1;O[0]?y][x;z]};{v .(x;z)}][x;t;y]} / apply - in quote mode: q:{v .:[y=X;(.[x;();,;_ic y];@[z;3;:;-1]);(1=z 3)&y=Q;(x;@[z;3;:;0]);(.[x;();,;_ic y];@[z;3;:;1])]} / gui engine: f:{m n F:::[@x;"";"."_in x;x;x,".bf"]} / file m:{(();({x,y#" "}'[x;80-#:'x:25#x,25#,""];0 1;0 0;0))} / normalize to 25 80 n:{:[#x;0:x;,""]} / file read r:{P::x;W.P::,:''+P[1;0];`show$`.k.W;} / evaluate k:{P::a . P;s[]} / step i:{P::(a .)/P;s[]} / run s:{W.P::,:''+P[1;0];W[`D`C`Q]:P[1;1 2 3];W.S::5:*P} / single j:{.t..t::[W.J;".k.k[]"];."\\t ",$W.J*.001} / timer l:{(5:y),":",("<>^v"(0 -1;0 1;-1 0;1 0)?x),":",$z} / label / gui display: W.P:80 25#,," " / program window W.P..bg:{:[_i~|P[1;2];999900;999999]} / yellow cell is current pointer W.P..e..d:".k.W.E" / edit toggle W.P..l..d:".k.F" / befunge program running W.P..t:"if[#_i;.[`.k.P;1 0,|_i;:;*_v ._i]]" / update program W.P..kr:".k.P[1;2]:|_i;.k.W.P::" / set pointer here W.S:"";W.S..e:0;W.S..f:-100$;W.S..l:"" / stack W.K:".k.k[]";W.K..c:`button;W.K..x:8;W.K..l..d:".k.l ..k.P[1;1 2 3]" / one instruction W.J:0;W.J..c:`check;W.J..l:`Step;W.J..t:".k.j[]" / step program W.I:0;W.I..c:`check;W.I..l:`Run;W.I..t:".k.i[]" / run program W.E:0;W.E..c:`check;W.E..l:`Edit / edit program W..a:(`P;`K`J`I`E`S);W..c:`form;W..l:"Befunge-93";W..y:29;W..x:100 / window attributes / start: r f@*_i / start on file _i 0