示例#1
0
文件: view.go 项目: rlugojr/lime-qml
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
}
示例#2
0
// 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)
}