func gocov_update(ir *gothic.Interpreter) { ir.Eval(` .f2.funcs delete [.f2.funcs children {}] `) ir.EvalAs(&xsourceview, ".f1.sourceview xview") ir.EvalAs(&ysourceview, ".f1.sourceview yview") gocov_test(ir) }
func gocov_selection(ir *gothic.Interpreter) { var selection string ir.EvalAs(&selection, ".f2.funcs selection") var pi, fi int _, err := fmt.Sscanf(selection, "f_%d_%d", &pi, &fi) if err != nil { panic(err) } f := current[pi].Functions[fi] prevsel = fmt.Sprintf("%s.%s", current[pi].Name, f.Name) data, err := ioutil.ReadFile(f.File) if err != nil { panic(err) } ir.Set("source", string(data[f.Start:f.End])) ir.Eval(` .f1.sourceview configure -state normal .f1.sourceview delete 1.0 end .f1.sourceview insert end $source .f1.sourceview configure -state disabled `) for _, s := range f.Statements { if s.Reached != 0 { continue } ls, le := s.Start-f.Start, s.End-f.Start ir.Eval(`.f1.sourceview tag add red {1.0 +`, ls, `chars} {1.0 +`, le, `chars}`) } if xsourceview != "" { ir.Eval(".f1.sourceview xview moveto [lindex {", xsourceview, "} 0]") ir.Eval(".f1.sourceview yview moveto [lindex {", ysourceview, "} 0]") xsourceview = "" ysourceview = "" } }
func applyOp(op string, ir *gothic.Interpreter) { var num string ir.EvalAs(&num, "set calcText") if args[0] == nil { if op != "=" { args[0] = big.NewInt(0) args[0].SetString(num, 10) } } else { args[1] = big.NewInt(0) args[1].SetString(num, 10) } afterOp = true if args[1] == nil { lastOp = op return } switch lastOp { case "+": args[0] = args[0].Add(args[0], args[1]) case "-": args[0] = args[0].Sub(args[0], args[1]) case "/": args[0] = args[0].Div(args[0], args[1]) case "*": args[0] = args[0].Mul(args[0], args[1]) } lastOp = op args[1] = nil ir.Eval("set calcText ", args[0]) if op == "=" { args[0] = nil } }