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

Golang backend.View类代码示例

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

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



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

示例1: onNew

// Called when a new view is opened
func (f *frontend) onNew(bv *backend.View) {
	w := f.windows[bv.Window()]
	v := newView(bv)
	w.views[bv] = v
	if w.qw != nil {
		w.qw.Call("addTab", v.id, v)
		w.qw.Call("activateTab", v.id)
	}
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:10,代码来源:frontend.go


示例2: onLoad

// called when a view has loaded
func (f *frontend) onLoad(bv *backend.View) {
	w := f.windows[bv.Window()]
	v := w.views[bv]
	if v == nil {
		log.Error("Couldn't find loaded view")
		return
	}
	v.Title = bv.FileName()
	w.qw.Call("setTabTitle", v.id, v.Title)
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:11,代码来源:frontend.go


示例3: onClose

// called when a view is closed
func (f *frontend) onClose(bv *backend.View) {
	w := f.windows[bv.Window()]
	v := w.views[bv]
	if v == nil {
		log.Error("Couldn't find closed view...")
		return
	}
	w.qw.Call("removeTab", v.id)
	delete(w.views, bv)
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:11,代码来源:frontend.go


示例4: onStatusChanged

func (f *frontend) onStatusChanged(bv *backend.View) {
	w := f.windows[bv.Window()]
	v := w.views[bv]
	if v == nil {
		log.Error("Couldn't find status changed view")
		return
	}
	if v.qv == nil {
		return
	}
	v.qv.Call("onStatusChanged")
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:12,代码来源:frontend.go


示例5: onSelectionModified

func (f *frontend) onSelectionModified(bv *backend.View) {
	w := f.windows[bv.Window()]
	v := w.views[bv]
	if v == nil {
		log.Error("Couldn't find modified view")
		return
	}
	if v.qv == nil {
		return
	}
	v.qv.Call("onSelectionModified")
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:12,代码来源:frontend.go


示例6: VisibleRegion

func (t *tbfe) VisibleRegion(v *backend.View) Region {
	t.lock.Lock()
	r, ok := t.layout[v]
	t.lock.Unlock()
	if !ok || r.lastUpdate != v.ChangeCount() {
		t.Show(v, r.visible)
		t.lock.Lock()
		r = t.layout[v]
		t.lock.Unlock()
	}
	return r.visible
}
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:12,代码来源:main.go


示例7: Show

func (t *tbfe) Show(v *backend.View, r Region) {
	t.lock.Lock()
	l := t.layout[v]
	t.lock.Unlock()
	p := util.Prof.Enter("show")
	defer p.Exit()

	lv := l.visible

	s1, _ := v.RowCol(lv.Begin())
	e1, _ := v.RowCol(lv.End())
	s2, _ := v.RowCol(r.Begin())
	e2, _ := v.RowCol(r.End())

	r1 := Region{s1, e1}
	r2 := Region{s2, e2}

	r3 := r1.Cover(r2)
	diff := 0
	if d1, d2 := Abs(r1.Begin()-r3.Begin()), Abs(r1.End()-r3.End()); d1 > d2 {
		diff = r3.Begin() - r1.Begin()
	} else {
		diff = r3.End() - r1.End()
	}
	r3.A = r1.Begin() + diff
	r3.B = r1.End() + diff

	r3 = t.clip(v, r3.A, r3.B)
	l.visible = r3
	t.lock.Lock()
	t.layout[v] = l
	t.lock.Unlock()
	t.render()
}
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:34,代码来源:main.go


示例8: setupCallbacks

func (t *tbfe) setupCallbacks(view *backend.View) {
	// Ensure that the visible region currently presented is
	// inclusive of the insert/erase delta.
	view.AddObserver(&tbfeBufferDeltaObserver{t: t, view: view})

	backend.OnNew.Add(func(v *backend.View) {
		v.Settings().AddOnChange("lime.frontend.termbox.render", func(name string) { t.render() })
	})

	backend.OnModified.Add(func(v *backend.View) {
		t.render()
	})

	backend.OnSelectionModified.Add(func(v *backend.View) {
		t.render()
	})
}
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:17,代码来源:main.go


示例9: clip

func (t *tbfe) clip(v *backend.View, s, e int) Region {
	p := util.Prof.Enter("clip")
	defer p.Exit()
	t.lock.Lock()
	h := t.layout[v].height
	t.lock.Unlock()
	if e-s > h {
		e = s + h
	} else if e-s < h {
		s = e - h
	}
	if e2, _ := v.RowCol(v.TextPoint(e, 0)); e2 < e {
		e = e2
	}
	if s < 0 {
		s = 0
	}
	e = s + h
	r := Region{v.TextPoint(s, 0), v.TextPoint(e, 0)}
	return v.LineR(r)
}
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:21,代码来源:main.go


示例10: renderLStatus

func (t *tbfe) renderLStatus(v *backend.View, y int, fg, bg termbox.Attribute) {
	st := v.Status()
	sel := v.Sel()
	j := 0

	for k, v := range st {
		s := fmt.Sprintf("%s: %s, ", k, v)
		addString(j, y, s, fg, bg)
	}

	if sel.Len() == 0 {
		return
	} else if l := sel.Len(); l > 1 {
		s := fmt.Sprintf("%d selection regions", l)
		j = addString(j, y, s, fg, bg)
	} else if r := sel.Get(0); r.Size() == 0 {
		row, col := v.RowCol(r.A)
		s := fmt.Sprintf("Line %d, Column %d", row, col)
		j = addString(j, y, s, fg, bg)
	} else {
		ls := v.Lines(r)
		s := v.Substr(r)
		if len(ls) < 2 {
			s := fmt.Sprintf("%d characters selected", len(s))
			j = addString(j, y, s, fg, bg)
		} else {
			s := fmt.Sprintf("%d lines %d characters selected", len(ls), len(s))
			j = addString(j, y, s, fg, bg)
		}
	}

	if t.status_message != "" {
		s := fmt.Sprintf("; %s", t.status_message)
		addString(j, y, s, fg, bg)
	}
}
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:36,代码来源:main.go


示例11: VisibleRegion

func (f *frontend) VisibleRegion(bv *backend.View) Region {
	// TODO
	return Region{0, bv.Size()}
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:4,代码来源:frontend.go


示例12: newView

func newView(bv *backend.View) *view {
	v := &view{
		id:    int(bv.Id()),
		bv:    bv,
		Title: bv.FileName(),
	}
	if len(v.Title) == 0 {
		v.Title = "untitled"
	}
	bv.AddObserver(v)
	bv.Settings().AddOnChange("qml.view.syntax", v.onChange)
	bv.Settings().AddOnChange("qml.view.syntaxfile", func(name string) {
		if name != "syntax" {
			return
		}
		syn := bv.Settings().String("syntax", "Plain Text")
		syntax := backend.GetEditor().GetSyntax(syn)
		w := fe.windows[bv.Window()]
		w.qw.Call("setSyntaxStatus", syntax.Name())
	})
	bv.Settings().AddOnChange("qml.view.tabSize", func(name string) {
		if name != "tab_size" {
			return
		}
		ts := bv.Settings().Int("tab_size", 4)
		w := fe.windows[bv.Window()]
		w.qw.Call("setIndentStatus", strconv.Itoa(ts))
	})
	return v
}
开发者ID:rlugojr,项目名称:lime-qml,代码行数:30,代码来源:view.go


示例13: renderView

func (t *tbfe) renderView(v *backend.View, lay layout) {
	p := util.Prof.Enter("render")
	defer p.Exit()

	sx, sy, w, h := lay.x, lay.y, lay.width, lay.height
	vr := lay.visible
	runes := v.Substr(vr)
	x, y := sx, sy
	ex, ey := sx+w, sy+h

	style, _ := v.Settings().Get("caret_style", "underline").(string)
	inverse, _ := v.Settings().Get("inverse_caret_state", false).(bool)

	caretStyle := getCaretStyle(style, inverse)
	oldCaretStyle := caretStyle

	caretBlink, _ := v.Settings().Get("caret_blink", true).(bool)
	if caretBlink && blink {
		caretStyle = 0
	}

	tabSize := 4
	if i, ok := v.Settings().Get("tab_size", tabSize).(int); ok {
		tabSize = i
	}

	lineNumbers, _ := v.Settings().Get("line_numbers", true).(bool)

	recipe := v.Transform(vr).Transcribe()

	fg, bg := defaultFg, defaultBg
	sel := v.Sel()

	line, _ := v.RowCol(vr.Begin())
	eofline, _ := v.RowCol(v.Size())
	lineNumberRenderSize := len(intToRunes(eofline))

	for i, r := range runes {
		fg, bg = defaultFg, defaultBg

		if lineNumbers {
			renderLineNumber(&line, &x, y, lineNumberRenderSize, fg, bg)
		}

		curr := 0
		o := vr.Begin() + i

		for curr < len(recipe) && (o >= recipe[curr].Region.Begin()) {
			if o < recipe[curr].Region.End() {
				fg = palLut(render.Colour(recipe[curr].Flavour.Foreground))
				bg = palLut(render.Colour(recipe[curr].Flavour.Background))
			}
			curr++
		}

		iscursor := sel.Contains(Region{o, o})
		if iscursor {
			fg = fg | caretStyle
			termbox.SetCell(x, y, ' ', fg, bg)
		}

		if r == '\t' {
			add := (x + 1 + (tabSize - 1)) &^ (tabSize - 1)
			for ; x < add; x++ {
				if x < ex {
					termbox.SetCell(x, y, ' ', fg, bg)
				}
				// A long cursor looks weird
				fg = fg & ^(termbox.AttrUnderline | termbox.AttrReverse)
			}
			continue
		} else if r == '\n' {
			x = sx
			if y++; y > ey {
				break
			} else if lineNumbers {
				// This results in additional calls to renderLineNumber.
				// Maybe just accumulate positions needing line numbers, rendering them
				// after the loop?
				renderLineNumber(&line, &x, y, lineNumberRenderSize, defaultFg, defaultBg)
			}
			continue
		}
		if x < ex {
			termbox.SetCell(x, y, r, fg, bg)
		}
		x++
	}
	fg, bg = defaultFg, defaultBg
	// Need this if the cursor is at the end of the buffer
	o := vr.Begin() + len(runes)
	iscursor := sel.Contains(Region{o, o})
	if iscursor {
		fg = fg | caretStyle
		termbox.SetCell(x, y, ' ', fg, bg)
	}

	// restore original caretStyle before blink modification
	caretStyle = oldCaretStyle

//.........这里部分代码省略.........
开发者ID:Rixuel,项目名称:lime-termbox,代码行数:101,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang log.Debug函数代码示例发布时间:2022-05-23
下一篇:
Golang packet.Packet类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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