当前位置: 首页>>代码示例>>Golang>>正文


Golang text.Region类代码示例

本文整理汇总了Golang中github.com/limetext/text.Region的典型用法代码示例。如果您正苦于以下问题:Golang Region类的具体用法?Golang Region怎么用?Golang Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Region类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Py_substr

func (o *View) Py_substr(tu *py.Tuple) (py.Object, error) {
	var (
		arg1 text.Region
	)
	v, err := tu.GetItem(0)
	if err != nil {
		return nil, err
	}
	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 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
}
开发者ID:ericcapricorn,项目名称:lime,代码行数:29,代码来源:view_manual.go

示例2: Cull

// Removes any regions that are outside of the given viewport,
// and clips the regions that are intersecting it so that
// all regions remaining are fully contained inside of the viewport.
func (vr *ViewRegions) Cull(viewport text.Region) {
	pe := util.Prof.Enter("render.vr.Cull")
	defer pe.Exit()
	nr := []text.Region{}
	for _, r := range vr.Regions.Regions() {
		if viewport.Intersects(r) {
			in := viewport.Intersection(r)
			if in.Size() != 0 {
				nr = append(nr, in)
			}
		}
	}
	vr.Regions.Clear()
	vr.Regions.AddAll(nr)
}
开发者ID:ericcapricorn,项目名称:lime,代码行数:18,代码来源:view.go

示例3: Py_expand_by_class

func (o *View) Py_expand_by_class(tu *py.Tuple, kw *py.Dict) (py.Object, error) {
	var (
		arg1 text.Region
		arg2 int
	)

	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 backend.View.ExpandByClass() arg1, not %s", v.Type())
			} else {
				arg1.A = int(v2.Int64())
				arg1.B = arg1.A + 1
			}
		} else {
			arg1 = v2.data
		}
	}

	if v, err := tu.GetItem(1); err != nil {
		return nil, err
	} else {
		if v3, err2 := fromPython(v); err2 != nil {
			return nil, err2
		} else {
			if v2, ok := v3.(int); !ok {
				return nil, fmt.Errorf("Expected type int for backend.View.ExpandByClass() arg2, not %s", v.Type())
			} else {
				arg2 = v2
			}
		}
	}

	ret := o.data.ExpandByClass(arg1, arg2)
	var err error
	var pyret py.Object

	pyret, err = toPython(ret)
	if err != nil {
		return nil, err
	}
	return pyret, err
}
开发者ID:ericcapricorn,项目名称:lime,代码行数:45,代码来源:view_manual.go

示例4: Py_show

func (view *View) Py_show(tu *py.Tuple, kw *py.Dict) (py.Object, error) {
	var (
		arg1 text.Region
	)
	v, err := tu.GetItem(0)
	if err != nil {
		return nil, err
	}
	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(view.data, arg1)
	return toPython(nil)
}
开发者ID:ericcapricorn,项目名称:lime,代码行数:21,代码来源:view_manual.go


注:本文中的github.com/limetext/text.Region类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。