Esempio n. 1
0
func TestSetBufferTwice(t *testing.T) {
	var w Window

	v := newView(&w)
	defer func() {
		v.SetScratch(true)
		v.Close()
	}()

	b1 := text.NewBuffer()
	b1.SetName("test1")

	_ = v.setBuffer(b1)

	b2 := text.NewBuffer()
	b2.SetName("test2")

	err := v.setBuffer(b2)

	if err == nil {
		t.Errorf("Expected setting the second buffer to cause an error, but it didn't.")
	}

	if v.buffer.Name() != b1.Name() {
		t.Errorf("Expected buffer called %s, but got %s", b1.Name(), v.buffer.Name())
	}
}
Esempio n. 2
0
func TestSetBuffer(t *testing.T) {
	var w Window

	v := newView(&w)
	defer func() {
		v.SetScratch(true)
		v.Close()
	}()

	b := text.NewBuffer()
	b.SetName("test")

	_ = v.setBuffer(b)

	if v.buffer.Name() != b.Name() {
		t.Errorf("Expected buffer called %s, but got %s", b.Name(), v.buffer.Name())
	}
}
Esempio n. 3
0
func (w *Window) NewFile() *View {
	w.lock.Lock()
	defer w.lock.Unlock()

	w.views = append(w.views, newView(w))
	v := w.views[len(w.views)-1]

	v.Settings().SetParent(w)
	v.setBuffer(text.NewBuffer())
	v.selection.Clear()
	v.selection.Add(text.Region{A: 0, B: 0})
	v.buffer.Settings().Set("lime.last_save_change_count", v.buffer.ChangeCount())

	OnNew.Call(v)
	w.SetActiveView(v)

	return v
}