~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to src/nvim/normal.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20160418214219-6lf1w0zadujghas7
Tags: upstream-0.1.3
ImportĀ upstreamĀ versionĀ 0.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1538
1538
        curbuf->b_visual_mode_eval = VIsual_mode;
1539
1539
      }
1540
1540
 
1541
 
      /* In Select mode, a linewise selection is operated upon like a
1542
 
       * characterwise selection. */
1543
 
      if (VIsual_select && VIsual_mode == 'V') {
 
1541
      // In Select mode, a linewise selection is operated upon like a
 
1542
      // characterwise selection.
 
1543
      // Special case: gH<Del> deletes the last line.
 
1544
      if (VIsual_select && VIsual_mode == 'V'
 
1545
          && cap->oap->op_type != OP_DELETE) {
1544
1546
        if (lt(VIsual, curwin->w_cursor)) {
1545
1547
          VIsual.col = 0;
1546
1548
          curwin->w_cursor.col =
1676
1678
            && (include_line_break || !virtual_op)
1677
1679
            ) {
1678
1680
          oap->inclusive = false;
1679
 
          /* Try to include the newline, unless it's an operator
1680
 
           * that works on lines only. */
1681
 
          if (*p_sel != 'o' && !op_on_lines(oap->op_type)) {
1682
 
            if (oap->end.lnum < curbuf->b_ml.ml_line_count) {
1683
 
              ++oap->end.lnum;
1684
 
              oap->end.col = 0;
1685
 
              oap->end.coladd = 0;
1686
 
              ++oap->line_count;
1687
 
            } else {
1688
 
              /* Cannot move below the last line, make the op
1689
 
               * inclusive to tell the operation to include the
1690
 
               * line break. */
1691
 
              oap->inclusive = true;
1692
 
            }
 
1681
          // Try to include the newline, unless it's an operator
 
1682
          // that works on lines only.
 
1683
          if (*p_sel != 'o'
 
1684
              && !op_on_lines(oap->op_type)
 
1685
              && oap->end.lnum < curbuf->b_ml.ml_line_count) {
 
1686
            oap->end.lnum++;
 
1687
            oap->end.col = 0;
 
1688
            oap->end.coladd = 0;
 
1689
            oap->line_count++;
1693
1690
          }
1694
1691
        }
1695
1692
      }
2347
2344
  if (mouse_row == 0 && firstwin->w_winrow > 0) {
2348
2345
    if (is_drag) {
2349
2346
      if (in_tab_line) {
2350
 
        tabpage_move(tab_page_click_defs[mouse_col].type == kStlClickTabClose
2351
 
                     ? 9999
2352
 
                     : tab_page_click_defs[mouse_col].tabnr - 1);
 
2347
        if (tab_page_click_defs[mouse_col].type == kStlClickTabClose) {
 
2348
          tabpage_move(9999);
 
2349
        } else {
 
2350
          int tabnr = tab_page_click_defs[mouse_col].tabnr;
 
2351
          tabpage_move(tabnr < tabpage_index(curtab) ? tabnr - 1 : tabnr);
 
2352
        }
2353
2353
      }
2354
2354
      return false;
2355
2355
    }
4099
4099
 
4100
4100
  case 't':   scroll_cursor_top(0, true);
4101
4101
    redraw_later(VALID);
 
4102
    set_fraction(curwin);
4102
4103
    break;
4103
4104
 
4104
4105
  /* "z." and "zz": put cursor in middle of screen */
4107
4108
 
4108
4109
  case 'z':   scroll_cursor_halfway(true);
4109
4110
    redraw_later(VALID);
 
4111
    set_fraction(curwin);
4110
4112
    break;
4111
4113
 
4112
4114
  /* "z^", "z-" and "zb": put cursor at bottom of screen */
4127
4129
 
4128
4130
  case 'b':   scroll_cursor_bot(0, true);
4129
4131
    redraw_later(VALID);
 
4132
    set_fraction(curwin);
4130
4133
    break;
4131
4134
 
4132
4135
  /* "zH" - scroll screen right half-page */
6955
6958
                       (cap->cmdchar == 'o' ? 1 : 0))
6956
6959
            )
6957
6960
        && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
6958
 
            has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM :
6959
 
            0, 0)) {
6960
 
      if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
 
6961
                     has_format_option(FO_OPEN_COMS)
 
6962
                     ? OPENLINE_DO_COM : 0,
 
6963
                     0)) {
 
6964
      if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) {
6961
6965
        update_single_line(curwin, oldline);
 
6966
      }
 
6967
      if (curwin->w_p_cul) {
 
6968
        // force redraw of cursorline
 
6969
        curwin->w_valid &= ~VALID_CROW;
 
6970
      }
6962
6971
      invoke_edit(cap, false, cap->cmdchar, true);
6963
6972
    }
6964
6973
  }
7742
7751
    if (was_visual) {
7743
7752
      curbuf->b_visual.vi_start = curbuf->b_op_start;
7744
7753
      curbuf->b_visual.vi_end = curbuf->b_op_end;
 
7754
      // need to adjust cursor position
 
7755
      if (*p_sel == 'e') {
 
7756
        inc(&curbuf->b_visual.vi_end);
 
7757
      }
7745
7758
    }
7746
7759
 
7747
7760
    /* When all lines were selected and deleted do_put() leaves an empty
7776
7789
    n_opencmd(cap);
7777
7790
}
7778
7791
 
7779
 
// calculate start/end virtual columns for operating in block mode
 
7792
// Calculate start/end virtual columns for operating in block mode.
7780
7793
static void get_op_vcol(
7781
7794
    oparg_T *oap,
7782
7795
    colnr_T redo_VIsual_vcol,
7786
7799
  colnr_T start;
7787
7800
  colnr_T end;
7788
7801
 
7789
 
  if (VIsual_mode != Ctrl_V) {
 
7802
  if (VIsual_mode != Ctrl_V
 
7803
      || (!initial && oap->end.col < curwin->w_width)) {
7790
7804
    return;
7791
7805
  }
7792
7806
 
7798
7812
  }
7799
7813
 
7800
7814
  getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
7801
 
  getvvcol(curwin, &(oap->end), &start, NULL, &end);
7802
 
 
7803
 
  if (start < oap->start_vcol) {
7804
 
    oap->start_vcol = start;
7805
 
  }
7806
 
  if (end > oap->end_vcol) {
7807
 
    if (initial && *p_sel == 'e'
7808
 
        && start >= 1
7809
 
        && start - 1 >= oap->end_vcol) {
7810
 
      oap->end_vcol = start - 1;
7811
 
    } else {
7812
 
      oap->end_vcol = end;
7813
 
    }
7814
 
  }
 
7815
  if (!redo_VIsual_busy) {
 
7816
    getvvcol(curwin, &(oap->end), &start, NULL, &end);
 
7817
 
 
7818
    if (start < oap->start_vcol) {
 
7819
      oap->start_vcol = start;
 
7820
    }
 
7821
    if (end > oap->end_vcol) {
 
7822
      if (initial && *p_sel == 'e'
 
7823
          && start >= 1
 
7824
          && start - 1 >= oap->end_vcol) {
 
7825
        oap->end_vcol = start - 1;
 
7826
      } else {
 
7827
        oap->end_vcol = end;
 
7828
      }
 
7829
    }
 
7830
  }
 
7831
 
7815
7832
  // if '$' was used, get oap->end_vcol from longest line
7816
7833
  if (curwin->w_curswant == MAXCOL) {
7817
7834
    curwin->w_cursor.col = MAXCOL;