Example #1
0
func TestMakeSplitBuffer(t *testing.T) {
	str := "This is not a very long line, but it is long enough."
	buf := buffer.MakeSplitBuffer(str, 40)
	if buf.Length() != 2 {
		t.Error("SplitBuffer error:", buf.Length())
	}
	buf = buffer.MakeSplitBuffer(str, 20)
	if buf.Length() != 3 {
		t.Error("SplitBuffer error:", buf.Length())
	}
}
Example #2
0
File: edit.go Project: wx13/sith
// Justify justifies the marked text.
func (file *File) Justify(lineLen int) {
	minRow, maxRow := file.MultiCursor.MinMaxRow()
	bigString := file.buffer.InclSlice(minRow, maxRow).ToString(" ")
	splitBuf := buffer.MakeSplitBuffer(bigString, lineLen)
	file.buffer.ReplaceLines(splitBuf.Lines(), minRow, maxRow)
	file.MultiCursor.Clear()
	file.Snapshot()
}