/ k client nick host port X:80 Y:10 Beep:0 Beep..c:`check Nick:Room:Out.s0:"" Out.s0.:.+(`l`y`e;`,Y,0) Out.[`c`a`l]:`form`s0` In:1000#"" In..t:"in In" In..l..d:".k.Pri" Colors:"`show$`Color;" Up:"up[]";Down:"down[]" Top:"top[]";Bottom:"bottom[]" Who:"`show$`Nicks" Who..c:Up..c:Down..c:Top..c:Bottom..c:Colors..c:`button nbg:{:[Pri~_v ._i;707070]} nk:{Pri:::[Pri~n:Nicks x;"";n];Nicks::} Nicks:() Nicks.[`e`x`k`bg`t]:(0;20;"nk@*_i";nbg;"if[~Pri _in Nicks;Pri:0#Pri]") Pri:"" \d Color Codes:.(`white,999999 `black,0 `gray,808080 `red,990000 `green,9900 `blue,99 `cyan,9999 `magenta,990099 `yellow,999900) Fg:`black;Bg:`gray Fg.[`o`c]:Bg.[`o`c]:(!Codes;`radio) Fx..d:"Codes Fg" Bx..d:"Codes Bg" Fx..l:Bx..l:` Colors:"foreground on background" Colors.[`e`l]:0,` Colors..fg..d:".k.Color.Fx" Colors..bg..d:".k.Color.Bx" \d ^ Color..a:((`Fg`Fx;`Bg`Bx);`Colors) in:{In::1000#0#In;send x} code:{:[1=4:x;x;Color.Codes x]} send:{ if[~&/x=" " if[">"=*x;t:1_'(0,x?" ")_ x;p:Pri;Pri::*t;_f t 1;Pri::p;:_n] if["\\"=*x;:(Host;Port)3:(`msg;((1_ x;. 1_ x;att 1_ x);Color.Fx;Color.Bx;Pri))] (Host;Port)3:(`msg;(x;Color.Fx;Color.Bx;Pri))] } msg:{[x;y;z;n] if[Beep;`0:_ci 7] if[0=4:x;:obj[x;y;z]n] l:last[] if[1=#x:wrap[X]x;x*:] Out[v:`$"s",$#!Out]:x if[v _in!`.k;Out[~v;`kl]:".k.detach _v"] Out[~v;`l`fg`bg`e`y]:(n;code y;code z;0;lines x) if[l;arr[|:]@!Out] } obj:{[x;y;z;n] .[`.k;v:`$"s",$#!Out;:;x 1] .[`.k;~v;:;@[x 2;`l`kl;:;(($v),":",*x;".k.In:\"\\\\",($v),"\"")]] msg[*x;y;z]n } arr:{ Out.s0..y::0 a:x((+\Out[~x y;`y])_bin Y)#x y if[Y>h:+/Out[~a _dv`s0;`y];if[~`s0 _in a;a:`s0,a];Out.s0..y::Y-h] Out..a::a } att:{:[&/name'undot x;. x,"."]} A:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" name:{(x[0]_in A)&&/(1_ x)_lin A,"0123456789_"} undot:{1_'(&n=".")_ n::["."=*x;x;".",x]} detach:{`show$`$".k.",(1+#$_d)_$_v} up:{if[~first[];arr[|:](d?*1_ Out..a)#d:!Out;if[first[];top[]]]} down:{if[~last[];arr[::](1+d?*|1_ Out..a)_ d:!Out;if[last[];bottom[]]]} top:{arr[::]@!Out} bottom:{arr[|:]@!Out} first:{(!Out)[1]~Out..a 1} last:{(*|!Out)=*|Out..a} lines:{:[-3=4:x;1;2+#x]} wrap:{(b -1_(-1+b _binl x+b:0,1+&" "=y)\0)_ y,:" "} .k.[`c`a`y`kl]:(`form;(`Who`Colors`Up`Down`Top`Bottom`Beep;`Out;`In);Y+7;"`show$`.k.Help") .k..l..d:".k.Room,\":\",.k.Nick" Nick::[1>#_i;$_u;*_i] Host::[2>#_i;`;`$_i 1] Port::[3>#_i;1234;0$_i 2] .m.c:"reconnect[]" \d .t. T:S:() A:{[t;s]@[`.t.;`T`S;{(x#y),(,z),x _ y}[.t..T _bin 1+t];(t;s)];} t:"while[~t<*t..T,2000000;t..Z:*.t..S;@[`t.;`T`S;1_];:[4:t..Z;. t..Z;.[.;t..Z]]]" \t 1 \d .k reconnect:{In..e::0;.t..A[1+_t]".k.connect[]"} connect:{ if[*r:.[4:;((Host;Port);(`hi;,Nick));:];msg["trying to connect ...";`black;`gray]"";:reconnect[]] Nick::r[1;0];Room::r[1;1];Nicks::r[1;2];{`.k[x]. y}.'r[1;3];In..e::1 } Help:("Instant is an instant messaging system written in pure k" "" "type messages, commands, and expressions into the input box" "messages which are too wide are wrapped and boxed" "" "square brackets are metasyntactic:" "" " [msg] to send a message" " /nick [newname] to change your nickname" " /me [verb-phrase] to use indirect speech" " \\[expr] to evaluate expr and send the result" " >[name] [msg|expr] to send a private message to [name]" "" "click on a name in the Who list to default to private" "click on a selected name in the Who list to reset to public" "select fg and bg colors in Colors, or mix rgb custom colors" "use Up, Down, Top, and Bottom to scroll the list of messages" "check Beep to signal message arrival" "click on the label of a listed object to detach it" "click on the label of a detached object to send it") Help.[`e`x]:0 70 `show$`.k reconnect[]