本文整理汇总了Golang中github.com/quarnster/util/text.Region.End方法的典型用法代码示例。如果您正苦于以下问题:Golang Region.End方法的具体用法?Golang Region.End怎么用?Golang Region.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quarnster/util/text.Region
的用法示例。
在下文中一共展示了Region.End方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}