func (o *View) Py_substr(tu *py.Tuple) (py.Object, error) { var ( arg1 primitives.Region ) if v, err := tu.GetItem(0); err != nil { return nil, err } else { if v2, ok := v.(*Region); !ok { if v2, ok := v.(*py.Long); !ok { return nil, fmt.Errorf("Expected type *Region or *Int for primitives.Buffer.Substr() arg1, not %s", v.Type()) } else { arg1.A = int(v2.Int64()) arg1.B = arg1.A + 1 } } else { arg1 = v2.data } } ret0 := o.data.Buffer().Substr(arg1) var err error var pyret0 py.Object pyret0, err = py.NewUnicode(ret0) if err != nil { // TODO: do the py objs need to be freed? return nil, err } return pyret0, err }
func (v *View) Py_show(tu *py.Tuple, kw *py.Dict) (py.Object, error) { var ( arg1 primitives.Region ) if v, err := tu.GetItem(0); err != nil { return nil, err } else { if v2, ok := v.(*Region); !ok { if v2, ok := v.(*py.Long); !ok { return nil, fmt.Errorf("Expected type *Region or *Int for primitives.Buffer.Substr() arg1, not %s", v.Type()) } else { arg1.A = int(v2.Int64()) arg1.B = arg1.A + 1 } } else { arg1 = v2.data } } backend.GetEditor().Frontend().Show(v.data, arg1) return toPython(nil) }
func (t *tbfe) clip(v *backend.View, r primitives.Region) primitives.Region { s, _ := v.Buffer().RowCol(r.Begin()) e, _ := v.Buffer().RowCol(r.End()) _, h := termbox.Size() h -= console_height if e-s > h { e = s + h } if e2, _ := v.Buffer().RowCol(v.Buffer().TextPoint(e, 1)); e2 < e { e = e2 } if e-s < h { s = e - h } if s < 1 { s = 1 } r.A = v.Buffer().Line(v.Buffer().TextPoint(s, 1)).A r.B = v.Buffer().Line(v.Buffer().TextPoint(e, 1)).B return r }