src/nvim/screen.c
/// insert lines on the screen and move the existing lines down
/// 'line_count' is the number of lines to be inserted.
/// 'end' is the line after the scrolled part. Normally it is Rows.
/// 'col' is the column from with we start inserting.
//
/// 'row', 'col' and 'end' are relative to the start of the region.
insert lines on the screen and move the existing lines down
'line_count' is the number of lines to be inserted.
'end' is the line after the scrolled part. Normally it is Rows.
'col' is the column from with we start inserting.


insert lines on the screen and move the existing lines down ' line_count ' is the number of lines to be inserted . ' end ' is the line after the scrolled part . Normally it is Rows . ' col ' is the column from with we start inserting .
void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
                    int width)
{
  int i;
  int j;
  unsigned temp;
  int row_off = 0;
  screen_adjust_grid(&grid, &row_off, &col);
  row += row_off;
  end += row_off;
  if (line_count <= 0) {
    return;
  }
  for (i = 0; i < line_count; i++) {
    if (width != grid->Columns) {
      j = end - 1 - i;
      while ((j -= line_count) >= row) {
        linecopy(grid, j + line_count, j, col, width);
      }
      j += line_count;
      grid_clear_line(grid, grid->line_offset[j] + col, width, false);
      grid->line_wraps[j] = false;
    } else {
      j = end - 1 - i;
      temp = grid->line_offset[j];
      while ((j -= line_count) >= row) {
        grid->line_offset[j + line_count] = grid->line_offset[j];
        grid->line_wraps[j + line_count] = grid->line_wraps[j];
      }
      grid->line_offset[j + line_count] = temp;
      grid->line_wraps[j + line_count] = false;
      grid_clear_line(grid, temp, (int)grid->Columns, false);
    }
  }
  if (!grid->throttled) {
    ui_call_grid_scroll(grid->handle, row, end, col, col+width, -line_count, 0);
  }
  return;
}
void grid_ins_lines ( ScreenGrid * grid , int row , int line_count , int end , int col , int width ) { int i ; int j ; unsigned temp ; int row_off = 0 ; screen_adjust_grid ( & grid , & row_off , & col ) ; row += row_off ; end += row_off ; if ( line_count <= 0 ) { return ; } for ( i = 0 ; i < line_count ; i ++ ) { if ( width != grid -> Columns ) { j = end - 1 - i ; while ( ( j -= line_count ) >= row ) { linecopy ( grid , j + line_count , j , col , width ) ; } j += line_count ; grid_clear_line ( grid , grid -> line_offset [ j ] + col , width , false ) ; grid -> line_wraps [ j ] = false ; } else { j = end - 1 - i ; temp = grid -> line_offset [ j ] ; while ( ( j -= line_count ) >= row ) { grid -> line_offset [ j + line_count ] = grid -> line_offset [ j ] ; grid -> line_wraps [ j + line_count ] = grid -> line_wraps [ j ] ; } grid -> line_offset [ j + line_count ] = temp ; grid -> line_wraps [ j + line_count ] = false ; grid_clear_line ( grid , temp , ( int ) grid -> Columns , false ) ; } } if ( ! grid -> throttled ) { ui_call_grid_scroll ( grid -> handle , row , end , col , col + width , - line_count , 0 ) ; } return ; }
insert lines on the screen and move the existing lines down
'line_count' is the number of lines to be inserted.
insert lines on the screen and move the existing lines down ' line_count ' is the number of lines to be inserted .
// Shift line_offset[] line_count down to reflect the inserted lines. // Clear the inserted lines. // need to copy part of a line