• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang text.Region类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Region类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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:kiawin,项目名称:lime,代码行数:29,代码来源:view_manual.go


示例2: Cull

func (vr *ViewRegions) Cull(viewport text.Region) {
	nr := []text.Region{}
	for _, r := range vr.Regions.Regions() {
		if viewport.Intersects(r) {
			nr = append(nr, viewport.Intersection(r))
		}
	}
	vr.Regions.Clear()
	vr.Regions.AddAll(nr)
}
开发者ID:networkpku,项目名称:lime,代码行数:10,代码来源:view.go


示例3: Transform

// Transform takes a ColourScheme, a ViewRegionMap and a viewport as input.
//
// The viewport would be the text.Region of the current buffer that is visible to the user
// and any ViewRegions outside of this area are not forwarded for further processing.
//
// The remaining ViewRegions are then passed on to the ColourScheme for determining the exact Flavour
// for which that RegionSet should be styled, adding Regions of the same Flavour to the same RegionSet.
//
// Typically there are more ViewRegions available in a text buffer than there are unique Flavours in
// a ColourScheme, so this operation can be viewed as reducing the number of state changes required to
// display the text to the user.
//
// The final output, the Recipe, contains a mapping of all unique Flavours and that Flavour's
// associated RegionSet.
func Transform(scheme ColourScheme, data ViewRegionMap, viewport text.Region) Recipe {
	// TODO:
	// 	caret_blink := true
	// if b, ok := v.Settings().Get("caret_blink", true).(bool); ok {
	// 	caret_blink = b
	// }
	//
	// highlight_line := false
	// if b, ok := v.Settings().Get("highlight_line", highlight_line).(bool); ok {
	// 	highlight_line = b
	// }
	//	if b, ok := v.Settings().Get("inverse_caret_state", false).(bool); !b && ok {
	// 	if caret_style == termbox.AttrReverse {
	// 		caret_style = termbox.AttrUnderline
	// 	} else {
	// 		caret_style = termbox.AttrReverse
	// 	}
	// }
	// caret_style := termbox.AttrUnderline
	// if b, ok := v.Settings().Get("caret_style", "underline").(string); ok {
	// 	if b == "block" {
	// 		caret_style = termbox.AttrReverse
	// 	}
	// }

	data.Cull(viewport)
	recipe := make(Recipe)
	for _, v := range data {
		k := scheme.Spice(&v)
		rs := recipe[k]
		rs.AddAll(v.Regions.Regions())

		if rs.HasNonEmpty() {
			var rs2 text.RegionSet
			var last text.Region
			for i, r := range rs.Regions() {
				if i > 0 && r.Begin() == last.End() {
					rs2.Add(r.Cover(last))
				} else {
					rs2.Add(r)
				}
				last = r
			}
			recipe[k] = rs2
		}
	}
	return recipe
}
开发者ID:haofree,项目名称:lime,代码行数:62,代码来源:renderer.go


示例4: 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:joushou,项目名称:lime,代码行数:45,代码来源:view_manual.go


示例5: 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:kiawin,项目名称:lime,代码行数:21,代码来源:view_manual.go


示例6: newQLimeView

func newQLimeView(v *backend.View) *QLimeView {
	log4go.Debug("new_QLimeView entered")
	defer log4go.Debug("new_QLimeView exited")
	var ret QLimeView
	ret.Widget = qt5.NewWidget()
	ret.v = v
	ret.Widget.OnPaintEvent(func(ev *qt5.PaintEvent) {
		p := qt5.NewPainter()
		defer p.Close()
		p.Begin(ret)
		b := v.Buffer()
		ps := p.Font().PointSize()

		pen := qt5.NewPen()
		p.SetPen(pen)
		brush := qt5.NewBrush()
		brush.SetStyle(qt5.SolidPattern)
		def := scheme.Settings[0]
		p.SetBrush(brush)
		f := p.Font()
		f.SetFixedPitch(true)
		p.SetFont(f)

		brush.SetColor(color.RGBA(def.Settings["background"]))
		p.DrawRect(ev.Rect())
		is_widget, ok := v.Settings().Get("is_widget", false).(bool)
		is_widget = ok && is_widget
		pen.SetColor(color.RGBA(def.Settings["background"]))
		p.SetPen(pen)

		for y := 0; y < 20; y++ {
			pos := b.TextPoint(y, 0)
			line := b.Line(pos)

			if is_widget {
				p.DrawText(qt5.Point{0, (y + 1) * (ps + 2)}, b.Substr(line))
			} else {
				for line.Contains(pos) {
					scope := text.Region{pos, pos}
					sn := v.ScopeName(pos)
					for line.Contains(pos) {
						pos++
						if v.ScopeName(pos) != sn {
							scope.B = pos
							break
						}
					}
					is := line.Intersection(scope)
					c := color.RGBA(def.Settings["foreground"])
					s := scheme.ClosestMatchingSetting(sn)
					if v, ok := s.Settings["foreground"]; ok {
						c = color.RGBA(v)
					}
					pen.SetColor(c)
					p.SetPen(pen)
					_, col := b.RowCol(line.A)
					p.DrawText(qt5.Point{col * ps / 2, (y + 1) * (ps + 2)}, b.Substr(is))
					line.A = is.End()
				}
			}
		}
	})
	ret.Widget.OnResizeEvent(func(ev *qt5.ResizeEvent) {
		if w, ok := v.Settings().Get("is_widget", false).(bool); ok && !w {
			ret.Widget.SetMinimumSize(qt5.Size{600, 100})
		}
	})
	v.Settings().Set("lime.qt.widget", &ret)
	return &ret
}
开发者ID:nadavvin,项目名称:lime,代码行数:70,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang buildfile.Buildfile类代码示例发布时间:2022-05-28
下一篇:
Golang binary.BinaryReader类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap