# # unicron.icn - the Unicron client # link session link cve link world link user link commands # # Global variables for window environment # global x, y, vs, cwidth, wheight, wwidth, net, wwindow, User, Cmds, Lselect global server, port $define margin 3 # # Begin main procedure # procedure main(av) server := "unicon.cs.nmsu.edu" port := 4500 if av[1] == "-port" then port := integer(av[2]) win_init() #initialize client window Cmds := Commands() #server commands table & methods #user variables User := Session() camera() close(net) end # # handle_char(w,c) takes in characters from the user and # processes them in the correct half of the client window # procedure handle_char(w, S[]) local y_offset, c, pnum static xpos initial xpos := [margin, margin] pnum := 0 if not (&window === wwindow) then &window := wwindow while c := pop(S) do { if c == "\^d" then fail y_offset := (w - 1) * wheight/2 if c == ("\r"|"\n") | xpos[w] > wwidth then { ScrollUp(y_offset+1, wheight/2-1) xpos[w] := margin } if c == ("\r"|"\n") then next if c == "\b" then { if xpos[w] >= margin + cwidth then { EraseArea(xpos[w] - cwidth, y_offset+1+wheight/2-1-vs, cwidth, vs) xpos[w] -:= cwidth return } } DrawString(xpos[w], wheight/2 + y_offset - margin, c) xpos[w] +:= cwidth } return end # # ScrollUp(vpos,h) adjusts the client window to accept new text # procedure ScrollUp(vpos, h) CopyArea(0,vpos+vs,wwidth, h-vs,0,vpos) EraseArea(0,vpos+h-vs,wwidth, vs) end # # win_init() draws a client window with bottom half for client input # and top half for server input # procedure win_init() wwindow:=&window:= open("Command Window", "g", "size=600,250", "bg=white") | stop("can't open client window") wwidth := WAttrib("width") wheight := WAttrib("height") vs := WAttrib("fheight") cwidth := WAttrib("fwidth") DrawLine(0,wheight/2, wwidth, wheight/2) end