// calc.go package main import ( "os"; "fmt"; "bufio"; "time"; "strconv";) var gfisnum=false; var gdisplaystr=""; var gbinop="+"; var gax=0.0; var gbx=1.0; var MAXDISP=24; var gfnotexit=true var acolor[4]int = [4]int{2628095,1015567,986895,12632256} var kbdchars[20]string = [20]string{"Off","C"," 0 ) { if ( len(gdisplaystr) == 1 ) { displaystr( "0", 6052991 ) } gdisplaystr = gdisplaystr[2:len(gdisplaystr)-1] if ( len( gdisplaystr ) > 0 ) { displaystr( gdisplaystr, 6052991 ) } } } else if ( (rowcol == 18 ) && ( len( gdisplaystr ) > 0 ) ) { if ( gdisplaystr[1] == '-' ) { gdisplaystr = gdisplaystr[2:] } else if len(gdisplaystr) < ( MAXDISP - 1 ) { gdisplaystr = "-"+gdisplaystr } displaystr( gdisplaystr, 6052991 ) } else if ( rowcol == 3) || (rowcol == 7) || ( rowcol == 11) || ( rowcol == 15 ) { gbinop = kbdchars[rowcol] gax,_ = strconv.ParseFloat(gdisplaystr,64) gfisnum = false } else if ( rowcol == 19 ) { if ( gfisnum ) { gbx,_ = strconv.ParseFloat(gdisplaystr,64) gfisnum = false } if ( gbinop == "*" ) { gax = gax * gbx } else if ( gbinop == "/" ) { gax = gax / gbx } else if ( gbinop == "+" ) { gax = gax + gbx } else if (gbinop == "-" ) { gax = gax - gbx } gdisplaystr = fmt.Sprintf("%.16g", gax); displaystr( gdisplaystr, 6052991 ) } } func main() { var button,x,y,i,row,col int var line string scanner := bufio.NewScanner(os.Stdin) for gfnotexit { if scanner.Scan() { line = scanner.Text() if ( line == "drawapp" ) { fmt.Print("Fo 0 611 3\nFo 2 140 3\nF 0 16777215\nFR 0 0 0 10000 10000\nZ \n");displaystr( "0", 6052991 ) fmt.Print("B 0 12632256\n") for i = 0; i < len(kbdcolor); i++ { fmt.Print( "F 0 10526880\nFR 0 ",(i%4)*2000+220," ",int(i/4)*1200+1220," ",(i%4)*2000+2080," ",int(i/4)*1200+2280,"\n") fmt.Print( "F 0 986895\nR 0 ",(i%4)*2000+200," ",int(i/4)*1200+1200," ",(i%4)*2000+2100," ",int(i/4)*1200+2300,"\n") fmt.Print( "F 0 ",kbdcolor[i],"\n") fmt.Print( "C$ 0 ",(i%4)*2000+1100," ",int(i/4)*1200+1700,"\"",kbdchars[i],"\"\n") } fmt.Print( "F 0 16711935\nC$ 0 5000 800 \"Go(Lang) cloud app\"\n") fmt.Print( "F 2 255\n" ); fmt.Print( "C$ 2 5000 7200\"Corrie Zucker Technologies LLC.\"\n" ); fmt.Print( "C$ 2 5000 7340\"d/b/a CZ Technologies\"\nZ \n" ) } else if ( line == "QUERY_REMOTE" ) { fmt.Print( "Rz 1200 900\n") } else { _,_ = fmt.Sscanf(line,"%d %d %d", &button, &x, &y) if ( x >= 0 ) { row = int((y-1200)/1200) col = int((x-200)/2000) if ( row >= 0 ) && ( row < 5 ) && ( col >= 0 ) && ( col < 4 ) { keytoexe(row*4+col) } } else if ( x == -2 ) { keytoexe( chartorowcol[button] ) } else if ( x == -4 ) { fmt.Print( "Rz ",button," ",y,"\n") } else if ( x == -5 ) { fmt.Print( "Mv ",button," ",y,"\n") } else if ( x == -98 ) { time.Sleep(time.Duration(2*y)*time.Millisecond) fmt.Fprintf(os.Stderr, "watermark %d\n", 2*y ) } } } else { gfnotexit = false } } }