()
| 281 | } |
| 282 | |
| 283 | func (buffer *Buffer) insertLine() { |
| 284 | |
| 285 | if !buffer.InScrollableRegion() { |
| 286 | pos := buffer.RawLine() |
| 287 | maxLines := buffer.GetMaxLines() |
| 288 | newLineCount := uint64(len(buffer.lines) + 1) |
| 289 | if newLineCount > maxLines { |
| 290 | newLineCount = maxLines |
| 291 | } |
| 292 | |
| 293 | out := make([]Line, newLineCount) |
| 294 | copy( |
| 295 | out[:pos-(uint64(len(buffer.lines))+1-newLineCount)], |
| 296 | buffer.lines[uint64(len(buffer.lines))+1-newLineCount:pos]) |
| 297 | out[pos] = newLine() |
| 298 | copy(out[pos+1:], buffer.lines[pos:]) |
| 299 | buffer.lines = out |
| 300 | } else { |
| 301 | topIndex := buffer.convertViewLineToRawLine(uint16(buffer.topMargin)) |
| 302 | bottomIndex := buffer.convertViewLineToRawLine(uint16(buffer.bottomMargin)) |
| 303 | before := buffer.lines[:topIndex] |
| 304 | after := buffer.lines[bottomIndex+1:] |
| 305 | out := make([]Line, len(buffer.lines)) |
| 306 | copy(out[0:], before) |
| 307 | |
| 308 | pos := buffer.RawLine() |
| 309 | for i := topIndex; i < bottomIndex; i++ { |
| 310 | if i < pos { |
| 311 | out[i] = buffer.lines[i] |
| 312 | } else { |
| 313 | out[i+1] = buffer.lines[i] |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | copy(out[bottomIndex+1:], after) |
| 318 | |
| 319 | out[pos] = newLine() |
| 320 | buffer.lines = out |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | func (buffer *Buffer) insertBlankCharacters(count int) { |
| 325 |
no test coverage detected