Example #1
0
func TestMCClear(t *testing.T) {
	mc := cursor.MakeMultiCursor()

	mc.Snapshot()
	mc.Snapshot()
	if mc.Length() != 3 {
		t.Error("Wrong MC length:", mc.Length())
	}

	mc.Clear()
	if mc.Length() != 1 {
		t.Error("Wrong MC length:", mc.Length())
	}

	mc.Snapshot()
	mc.Snapshot()
	mc.Snapshot()
	mc.Snapshot()
	mc.OuterMost()
	if mc.Length() != 2 {
		t.Error("Outermost failed:", mc.Length())
	}

	mc.Clear()
	mc.Set(5, 10, 10)
	mc.Append(cursor.MakeCursor(10, 12))
	mc.SetColumn()
	if mc.Length() != 6 {
		t.Error("SetColumn() failed:", mc.Length())
	}
}
Example #2
0
File: file.go Project: wx13/sith
func NewFile(name string, flushChan chan struct{}, screen *terminal.Screen) *File {
	file := &File{
		Name:        name,
		screen:      screen,
		fileMode:    os.FileMode(int(0644)),
		buffer:      buffer.MakeBuffer([]string{""}),
		savedBuffer: buffer.MakeBuffer([]string{""}),
		MultiCursor: cursor.MakeMultiCursor(),
		flushChan:   flushChan,
		saveChan:    make(chan struct{}, 1),
		SyntaxRules: syntaxcolor.NewSyntaxRules(""),
		autoIndent:  true,
		autoTab:     true,
		tabString:   "\t",
		newline:     "\n",
		tabHealth:   true,
		timer:       MakeTimer(),
		maxRate:     100.0,
		statusMutex: &sync.Mutex{},
	}
	file.buffHist = NewBufferHist(file.buffer, file.MultiCursor)
	go file.processSaveRequests()
	go file.ReadFile(name)
	switch path.Ext(name) {
	case ".md", ".txt", ".csv", ".C":
		file.autoIndent = false
	}
	return file
}