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 }
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() }) }