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