Beispiel #1
0
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
}
Beispiel #2
0
// 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)
	}
}
Beispiel #3
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)
}
Beispiel #4
0
// 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)
}
Beispiel #5
0
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")
}
Beispiel #6
0
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")
}