示例#1
0
文件: file_test.go 项目: wx13/sith
func TestInserChar(t *testing.T) {
	f := file.NewFile("", make(chan struct{}), nil)
	f.InsertChar('h')
	f.InsertChar('e')
	f.InsertChar('l')
	f.InsertChar('l')
	f.InsertChar('o')
	CheckBuffer(t, f, "hello", "InsertChar")
}
示例#2
0
文件: editor.go 项目: wx13/sith
// OpenFiles opens a set of specified files.
func (editor *Editor) OpenFiles(fileNames []string) {
	for _, name := range fileNames {
		editor.OpenFile(name)
	}
	if len(editor.files) == 0 {
		editor.files = append(editor.files, file.NewFile("", editor.flushChan, editor.screen))
	}
	editor.fileIdx = 0
	editor.fileIdxPrv = 0
	editor.file = editor.files[0]
}
示例#3
0
文件: file_test.go 项目: wx13/sith
func TestEditing(t *testing.T) {
	f := file.NewFile("", make(chan struct{}), nil)
	f.InsertChar('a')
	f.InsertChar('b')
	f.InsertChar('c')
	f.Newline()
	f.InsertChar('d')
	f.InsertChar('e')
	CheckBuffer(t, f, "abc\nde", "InsertChar")
	f.Backspace()
	CheckBuffer(t, f, "abc\nd", "Backspace")
	f.Backspace()
	f.Backspace()
	CheckBuffer(t, f, "abc", "Backspace (over newline)")
}
示例#4
0
文件: file_test.go 项目: wx13/sith
func TestNewFile(t *testing.T) {
	f := file.NewFile("", make(chan struct{}), nil)
	if f == nil {
		t.Error("bad")
	}
}
示例#5
0
文件: editor.go 项目: wx13/sith
// OpenFile opens a specified file.
func (editor *Editor) OpenFile(name string) {
	file := file.NewFile(name, editor.flushChan, editor.screen)
	file.SyntaxRules = syntaxcolor.NewSyntaxRules(name)
	editor.files = append(editor.files, file)
}