home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.228 < prev    next >
Encoding:
Internet Message Format  |  2002-02-16  |  26.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.228
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.228
  11. Problem:    After putting text in Visual mode the '] mark is not at the end of
  12.         the put text.
  13.         Undo doesn't work properly when putting a word into a Visual
  14.         selection that spans more than one line.
  15. Solution:   Correct the '] mark for the deleting the Visually selected text.
  16.         #ifdef code that depends on FEAT_VISUAL properly.
  17.         Also fix that "d" crossing line boundary puts '[ just before
  18.         deleted text.
  19.         Fix undo by saving all deleted lines at once.
  20. Files:        src/ex_docmd.c, src/globals.h, src/normal.c, src/ops.c,
  21.         src/structs.h, src/vim.h
  22. *** ../vim60.227/src/ex_docmd.c    Sun Feb 17 13:55:07 2002
  23. --- src/ex_docmd.c    Sun Feb 17 20:22:06 2002
  24. ***************
  25. *** 6276,6282 ****
  26.       eap->forceit = TRUE;
  27.       }
  28.       curwin->w_cursor.lnum = eap->line2;
  29. !     do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, -1L, 0);
  30.   }
  31.   
  32.   /*
  33. --- 6276,6282 ----
  34.       eap->forceit = TRUE;
  35.       }
  36.       curwin->w_cursor.lnum = eap->line2;
  37. !     do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, PUT_LINE);
  38.   }
  39.   
  40.   /*
  41. *** ../vim60.227/src/globals.h    Sun Feb  3 12:42:13 2002
  42. --- src/globals.h    Sun Feb 17 16:23:37 2002
  43. ***************
  44. *** 446,451 ****
  45. --- 447,453 ----
  46.   
  47.   EXTERN int    redo_VIsual_busy INIT(= FALSE);
  48.                   /* TRUE when redoing Visual */
  49. + EXTERN int    did_visual_put INIT(= FALSE); /* TRUE after Visual mode "p" */
  50.   #endif
  51.   
  52.   #ifdef FEAT_MOUSE
  53. *** ../vim60.227/src/normal.c    Sat Feb 16 22:55:56 2002
  54. --- src/normal.c    Sun Feb 17 21:04:42 2002
  55. ***************
  56. *** 1130,1135 ****
  57. --- 1130,1138 ----
  58.   normal_end:
  59.   
  60.       msg_nowait = FALSE;
  61. + #ifdef FEAT_VISUAL
  62. +     did_visual_put = FALSE;
  63. + #endif
  64.   
  65.       /* Reset finish_op, in case it was set */
  66.   #ifdef CURSOR_SHAPE
  67. ***************
  68. *** 1888,1894 ****
  69. --- 1891,1899 ----
  70.       {
  71.           curwin->w_cursor = old_cursor;
  72.       }
  73. + #ifdef FEAT_VISUAL
  74.       oap->block_mode = FALSE;
  75. + #endif
  76.       oap->regname = 0;
  77.       oap->motion_force = NUL;
  78.       }
  79. ***************
  80. *** 7180,7185 ****
  81. --- 7185,7191 ----
  82.   
  83.   /*
  84.    * Handle an operator command.
  85. +  * The actual work is done by do_pending_operator().
  86.    */
  87.       static void
  88.   nv_operator(cap)
  89. ***************
  90. *** 7842,7852 ****
  91. --- 7848,7862 ----
  92.       colnr_T    left, right;
  93.   #endif
  94.       int        dir;
  95. +     int        flags = 0;
  96.   
  97.       if (cap->oap->op_type != OP_NOP)
  98.       clearopbeep(cap->oap);
  99.       else
  100.       {
  101. +     dir = (cap->cmdchar == 'P'
  102. +         || (cap->cmdchar == 'g' && cap->nchar == 'P'))
  103. +                              ? BACKWARD : FORWARD;
  104.   #ifdef FEAT_VISUAL
  105.       if (VIsual_active)
  106.       {
  107. ***************
  108. *** 7866,7881 ****
  109.           if (VIsual_mode == 'v' && *p_sel == 'e')
  110.           dir = BACKWARD;
  111.           else
  112.           dir = FORWARD;
  113.       }
  114. -     else
  115.   #endif
  116. -         dir = (cap->cmdchar == 'P'
  117. -             || (cap->cmdchar == 'g' && cap->nchar == 'P'))
  118. -                              ? BACKWARD : FORWARD;
  119.       prep_redo_cmd(cap);
  120. !     do_put(cap->oap->regname, dir,
  121. !               cap->count1, cap->cmdchar == 'g' ? PUT_CURSEND : 0);
  122.   
  123.   #ifdef FEAT_VISUAL
  124.       if (VIsual_active)
  125. --- 7876,7896 ----
  126.           if (VIsual_mode == 'v' && *p_sel == 'e')
  127.           dir = BACKWARD;
  128.           else
  129. +         {
  130. +         if (dir == BACKWARD)
  131. +             flags |= PUT_LINE_BACKWARD;
  132.           dir = FORWARD;
  133. +         }
  134. +         /* When deleting a linewise Visual area, must put the register as
  135. +          * lines to avoid it being deleted. */
  136. +         if (VIsual_mode == 'V')
  137. +         flags |= PUT_LINE;
  138.       }
  139.   #endif
  140.       prep_redo_cmd(cap);
  141. !     if (cap->cmdchar == 'g')
  142. !         flags |= PUT_CURSEND;
  143. !     do_put(cap->oap->regname, dir, cap->count1, flags);
  144.   
  145.   #ifdef FEAT_VISUAL
  146.       if (VIsual_active)
  147. ***************
  148. *** 7886,7891 ****
  149. --- 7901,7907 ----
  150.           cap->oap->regname = NUL;
  151.           curwin->w_cursor = curpos;
  152.           nv_operator(cap);
  153. +         did_visual_put = TRUE;  /* tell op_delete() to correct '] mark */
  154.       }
  155.   #endif
  156.       }
  157. *** ../vim60.227/src/ops.c    Tue Feb 12 12:14:36 2002
  158. --- src/ops.c    Sun Feb 17 21:07:29 2002
  159. ***************
  160. *** 50,56 ****
  161. --- 50,58 ----
  162.       char_u    **y_array;    /* pointer to array of line pointers */
  163.       linenr_T    y_size;        /* number of lines in y_array */
  164.       char_u    y_type;        /* MLINE, MCHAR or MBLOCK */
  165. + #ifdef FEAT_VISUAL
  166.       colnr_T    y_width;    /* only set if y_type == MBLOCK */
  167. + #endif
  168.   } y_regs[NUM_REGISTERS];
  169.   
  170.   static struct yankreg    *y_current;        /* ptr to current yankreg */
  171. ***************
  172. *** 99,108 ****
  173. --- 101,113 ----
  174.   #endif
  175.   static void    free_yank __ARGS((long));
  176.   static void    free_yank_all __ARGS((void));
  177. + static int    yank_copy_line __ARGS((struct block_def *bd, long y_idx));
  178.   #ifdef FEAT_CLIPBOARD
  179.   static void    copy_yank_reg __ARGS((struct yankreg *reg));
  180.   #endif
  181. + #ifdef FEAT_VISUAL
  182.   static void    block_prep __ARGS((oparg_T *oap, struct block_def *, linenr_T, int));
  183. + #endif
  184.   #if defined(FEAT_CLIPBOARD) || defined(FEAT_EVAL)
  185.   static void    str_to_reg __ARGS((struct yankreg *y_ptr, int type, char_u *str, long len));
  186.   #endif
  187. ***************
  188. *** 213,227 ****
  189.   {
  190.       long        i;
  191.       int            first_char;
  192. -     int            block_col = 0;
  193.       char_u        *s;
  194.   
  195.       if (u_save((linenr_T)(oap->start.lnum - 1),
  196.                          (linenr_T)(oap->end.lnum + 1)) == FAIL)
  197.       return;
  198.   
  199.       if (oap->block_mode)
  200.       block_col = curwin->w_cursor.col;
  201.   
  202.       for (i = oap->line_count; --i >= 0; )
  203.       {
  204. --- 218,236 ----
  205.   {
  206.       long        i;
  207.       int            first_char;
  208.       char_u        *s;
  209. + #ifdef FEAT_VISUAL
  210. +     int            block_col = 0;
  211. + #endif
  212.   
  213.       if (u_save((linenr_T)(oap->start.lnum - 1),
  214.                          (linenr_T)(oap->end.lnum + 1)) == FAIL)
  215.       return;
  216.   
  217. + #ifdef FEAT_VISUAL
  218.       if (oap->block_mode)
  219.       block_col = curwin->w_cursor.col;
  220. + #endif
  221.   
  222.       for (i = oap->line_count; --i >= 0; )
  223.       {
  224. ***************
  225. *** 246,257 ****
  226.   
  227.       changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
  228.   
  229.       if (oap->block_mode)
  230.       {
  231.       curwin->w_cursor.lnum = oap->start.lnum;
  232.       curwin->w_cursor.col = block_col;
  233.       }
  234. !     else if (curs_top)        /* put cursor on first line, for ">>" */
  235.       {
  236.       curwin->w_cursor.lnum = oap->start.lnum;
  237.       beginline(BL_SOL | BL_FIX);   /* shift_line() may have set cursor.col */
  238. --- 255,269 ----
  239.   
  240.       changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
  241.   
  242. + #ifdef FEAT_VISUAL
  243.       if (oap->block_mode)
  244.       {
  245.       curwin->w_cursor.lnum = oap->start.lnum;
  246.       curwin->w_cursor.col = block_col;
  247.       }
  248. !     else
  249. ! #endif
  250. !     if (curs_top)        /* put cursor on first line, for ">>" */
  251.       {
  252.       curwin->w_cursor.lnum = oap->start.lnum;
  253.       beginline(BL_SOL | BL_FIX);   /* shift_line() may have set cursor.col */
  254. ***************
  255. *** 1402,1411 ****
  256.       int            n;
  257.       linenr_T        lnum;
  258.       char_u        *ptr;
  259.       char_u        *newp, *oldp;
  260.       linenr_T        old_lcount = curbuf->b_ml.ml_line_count;
  261.       int            did_yank = FALSE;
  262. -     struct block_def    bd;
  263.   
  264.       if (curbuf->b_ml.ml_flags & ML_EMPTY)        /* nothing to do */
  265.       return OK;
  266. --- 1414,1425 ----
  267.       int            n;
  268.       linenr_T        lnum;
  269.       char_u        *ptr;
  270. + #ifdef FEAT_VISUAL
  271.       char_u        *newp, *oldp;
  272. +     struct block_def    bd;
  273. + #endif
  274.       linenr_T        old_lcount = curbuf->b_ml.ml_line_count;
  275.       int            did_yank = FALSE;
  276.   
  277.       if (curbuf->b_ml.ml_flags & ML_EMPTY)        /* nothing to do */
  278.       return OK;
  279. ***************
  280. *** 1538,1543 ****
  281. --- 1552,1558 ----
  282.       }
  283.       }
  284.   
  285. + #ifdef FEAT_VISUAL
  286.   /*
  287.    * block mode delete
  288.    */
  289. ***************
  290. *** 1584,1590 ****
  291.                                  oap->end.lnum + 1, 0L);
  292.       oap->line_count = 0;        /* no lines deleted */
  293.       }
  294. !     else if (oap->motion_type == MLINE)
  295.       {
  296.       if (oap->op_type == OP_CHANGE)
  297.       {
  298. --- 1599,1607 ----
  299.                                  oap->end.lnum + 1, 0L);
  300.       oap->line_count = 0;        /* no lines deleted */
  301.       }
  302. !     else
  303. ! #endif
  304. !     if (oap->motion_type == MLINE)
  305.       {
  306.       if (oap->op_type == OP_CHANGE)
  307.       {
  308. ***************
  309. *** 1623,1631 ****
  310.       }
  311.       else
  312.       {
  313. -     if (u_save_cursor() == FAIL)    /* save first line for undo */
  314. -         return FAIL;
  315.   #ifdef FEAT_VIRTUALEDIT
  316.       if (virtual_active())
  317.       {
  318. --- 1640,1645 ----
  319. ***************
  320. *** 1634,1639 ****
  321. --- 1648,1655 ----
  322.           /* For virtualedit: break the tabs that are partly included. */
  323.           if (gchar_pos(&oap->start) == '\t')
  324.           {
  325. +         if (u_save_cursor() == FAIL)    /* save first line for undo */
  326. +             return FAIL;
  327.           if (oap->line_count == 1)
  328.               endcol = getviscol2(oap->end.col, oap->end.coladd);
  329.           coladvance_force(getviscol2(oap->start.col, oap->start.coladd));
  330. ***************
  331. *** 1649,1654 ****
  332. --- 1665,1675 ----
  333.   
  334.           if (gchar_pos(&oap->end) == '\t')
  335.           {
  336. +         /* save last line for undo if it's not also the first line */
  337. +         if (oap->end.lnum != curwin->w_cursor.lnum
  338. +             && u_save((linenr_T)(oap->end.lnum - 1),
  339. +                        (linenr_T)(oap->end.lnum + 1)) == FAIL)
  340. +             return FAIL;
  341.           curwin->w_cursor = oap->end;
  342.           coladvance_force(getviscol2(oap->end.col, oap->end.coladd));
  343.           oap->end = curwin->w_cursor;
  344. ***************
  345. *** 1659,1664 ****
  346. --- 1680,1688 ----
  347.   
  348.       if (oap->line_count == 1)    /* delete characters within one line */
  349.       {
  350. +         if (u_save_cursor() == FAIL)    /* save line for undo */
  351. +         return FAIL;
  352.           /* if 'cpoptions' contains '$', display '$' at end of change */
  353.           if (       vim_strchr(p_cpo, CPO_DOLLAR) != NULL
  354.               && oap->op_type == OP_CHANGE
  355. ***************
  356. *** 1697,1717 ****
  357.       }
  358.       else                /* delete characters between lines */
  359.       {
  360.           truncate_line(TRUE);    /* delete from cursor to end of line */
  361.   
  362. !         oap->start = curwin->w_cursor;    /* remember curwin->w_cursor */
  363.           ++curwin->w_cursor.lnum;
  364. !                         /* includes save for undo */
  365. !         del_lines((long)(oap->line_count - 2), TRUE);
  366.   
  367. -         if (u_save_cursor() == FAIL)    /* save last line for undo */
  368. -         return FAIL;
  369. -         u_clearline();            /* "U" not possible now */
  370.           /* delete from start of line until op_end */
  371.           curwin->w_cursor.col = 0;
  372.           (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
  373.                       restart_edit == NUL && !virtual_active());
  374. !         curwin->w_cursor = oap->start;    /* restore curwin->w_cursor */
  375.   
  376.           (void)do_join(FALSE);
  377.       }
  378. --- 1721,1744 ----
  379.       }
  380.       else                /* delete characters between lines */
  381.       {
  382. +         pos_T   curpos;
  383. +         /* save deleted and changed lines for undo */
  384. +         if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
  385. +          (linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
  386. +         return FAIL;
  387.           truncate_line(TRUE);    /* delete from cursor to end of line */
  388.   
  389. !         curpos = curwin->w_cursor;    /* remember curwin->w_cursor */
  390.           ++curwin->w_cursor.lnum;
  391. !         del_lines((long)(oap->line_count - 2), FALSE);
  392.   
  393.           /* delete from start of line until op_end */
  394.           curwin->w_cursor.col = 0;
  395.           (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
  396.                       restart_edit == NUL && !virtual_active());
  397. !         curwin->w_cursor = curpos;        /* restore curwin->w_cursor */
  398.   
  399.           (void)do_join(FALSE);
  400.       }
  401. ***************
  402. *** 1719,1735 ****
  403.   
  404.       msgmore(curbuf->b_ml.ml_line_count - old_lcount);
  405.   
  406.       /*
  407.        * Set "'[" and "']" marks.
  408.        */
  409. !     curbuf->b_op_start = oap->start;
  410. !     if (oap->block_mode)
  411.       {
  412. !     curbuf->b_op_end.lnum = oap->end.lnum;
  413. !     curbuf->b_op_end.col = oap->start.col;
  414.       }
  415.       else
  416. !     curbuf->b_op_end = oap->start;
  417.   
  418.       return OK;
  419.   }
  420. --- 1746,1793 ----
  421.   
  422.       msgmore(curbuf->b_ml.ml_line_count - old_lcount);
  423.   
  424. + #ifdef FEAT_VISUAL
  425.       /*
  426.        * Set "'[" and "']" marks.
  427.        */
  428. !     if (did_visual_put)
  429.       {
  430. !     /* "p" in Visual mode: The '] mark is at the end of the inserted text,
  431. !      * correct it for the deleted text. */
  432. !     if (oap->block_mode)
  433. !     {
  434. !         if (curbuf->b_op_end.lnum <= oap->end.lnum)
  435. !         curbuf->b_op_end.col -= bd.textlen
  436. !                           - bd.startspaces - bd.endspaces;
  437. !     }
  438. !     else if (oap->motion_type == MLINE)
  439. !         curbuf->b_op_end.lnum -= oap->line_count;
  440. !     else
  441. !     {
  442. !         if (curbuf->b_op_end.lnum == curbuf->b_op_start.lnum)
  443. !         {
  444. !         if (oap->line_count == 1)
  445. !             curbuf->b_op_end.col -= oap->end.col - oap->start.col + 1;
  446. !         else
  447. !             curbuf->b_op_end.col -= oap->end.col - 1;
  448. !         }
  449. !         curbuf->b_op_end.lnum -= oap->line_count - 1;
  450. !     }
  451.       }
  452.       else
  453. ! #endif
  454. !     {
  455. ! #ifdef FEAT_VISUAL
  456. !     if (oap->block_mode)
  457. !     {
  458. !         curbuf->b_op_end.lnum = oap->end.lnum;
  459. !         curbuf->b_op_end.col = oap->start.col;
  460. !     }
  461. !     else
  462. ! #endif
  463. !         curbuf->b_op_end = oap->start;
  464. !     }
  465. !     curbuf->b_op_start = oap->start;
  466.   
  467.       return OK;
  468.   }
  469. ***************
  470. *** 1952,1958 ****
  471. --- 2010,2018 ----
  472.       oparg_T    *oap;
  473.   {
  474.       pos_T        pos;
  475. + #ifdef FEAT_VISUAL
  476.       struct block_def    bd;
  477. + #endif
  478.       int            did_change = 0;
  479.   
  480.       if (u_save((linenr_T)(oap->start.lnum - 1),
  481. ***************
  482. *** 1960,1965 ****
  483. --- 2020,2026 ----
  484.       return;
  485.   
  486.       pos = oap->start;
  487. + #ifdef FEAT_VISUAL
  488.       if (oap->block_mode)            /* Visual block mode */
  489.       {
  490.       for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
  491. ***************
  492. *** 1977,1982 ****
  493. --- 2038,2044 ----
  494.           changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
  495.       }
  496.       else                    /* not block mode */
  497. + #endif
  498.       {
  499.       if (oap->motion_type == MLINE)
  500.       {
  501. ***************
  502. *** 2470,2476 ****
  503. --- 2532,2540 ----
  504.   
  505.       y_current->y_size = yanklines;
  506.       y_current->y_type = yanktype;   /* set the yank register type */
  507. + #ifdef FEAT_VISUAL
  508.       y_current->y_width = 0;
  509. + #endif
  510.       y_current->y_array = (char_u **)lalloc_clear((long_u)(sizeof(char_u *) *
  511.                                   yanklines), TRUE);
  512.   
  513. ***************
  514. *** 2483,2488 ****
  515. --- 2547,2553 ----
  516.       y_idx = 0;
  517.       lnum = oap->start.lnum;
  518.   
  519. + #ifdef FEAT_VISUAL
  520.       if (oap->block_mode)
  521.       {
  522.       /* Visual block mode */
  523. ***************
  524. *** 2492,2522 ****
  525.       if (curwin->w_curswant == MAXCOL && y_current->y_width > 0)
  526.           y_current->y_width--;
  527.       }
  528.   
  529.       for ( ; lnum <= yankendlnum; lnum++, y_idx++)
  530.       {
  531.       switch (y_current->y_type)
  532.       {
  533.           case MBLOCK:
  534.           block_prep(oap, &bd, lnum, FALSE);
  535. ! copyline:
  536. !         if ((pnew = alloc(bd.startspaces + bd.endspaces
  537. !                            + bd.textlen + 1)) == NULL)
  538. !         {
  539. ! fail:             /* free the allocated lines */
  540. !             free_yank(y_idx + 1);
  541. !             y_current = curr;
  542. !             return FAIL;
  543. !         }
  544. !         y_current->y_array[y_idx] = pnew;
  545. !         copy_spaces(pnew, (size_t)bd.startspaces);
  546. !         pnew += bd.startspaces;
  547. !         mch_memmove(pnew, bd.textstart, (size_t)bd.textlen);
  548. !         pnew += bd.textlen;
  549. !         copy_spaces(pnew, (size_t)bd.endspaces);
  550. !         pnew += bd.endspaces;
  551. !         *pnew = NUL;
  552.           break;
  553.   
  554.           case MLINE:
  555.           if ((y_current->y_array[y_idx] =
  556. --- 2557,2575 ----
  557.       if (curwin->w_curswant == MAXCOL && y_current->y_width > 0)
  558.           y_current->y_width--;
  559.       }
  560. + #endif
  561.   
  562.       for ( ; lnum <= yankendlnum; lnum++, y_idx++)
  563.       {
  564.       switch (y_current->y_type)
  565.       {
  566. + #ifdef FEAT_VISUAL
  567.           case MBLOCK:
  568.           block_prep(oap, &bd, lnum, FALSE);
  569. !         if (yank_copy_line(&bd, y_idx) == FAIL)
  570. !             goto fail;
  571.           break;
  572. + #endif
  573.   
  574.           case MLINE:
  575.           if ((y_current->y_array[y_idx] =
  576. ***************
  577. *** 2595,2601 ****
  578.               bd.textlen = endcol - startcol + oap->inclusive;
  579.               }
  580.               bd.textstart = p + startcol;
  581. !             goto copyline;
  582.           }
  583.           /* NOTREACHED */
  584.       }
  585. --- 2648,2656 ----
  586.               bd.textlen = endcol - startcol + oap->inclusive;
  587.               }
  588.               bd.textstart = p + startcol;
  589. !             if (yank_copy_line(&bd, y_idx) == FAIL)
  590. !             goto fail;
  591. !             break;
  592.           }
  593.           /* NOTREACHED */
  594.       }
  595. ***************
  596. *** 2623,2630 ****
  597.                     + STRLEN(y_current->y_array[0]) + 1), TRUE);
  598.           if (pnew == NULL)
  599.           {
  600. !             y_idx = y_current->y_size - 1;
  601. !             goto fail;
  602.           }
  603.           STRCPY(pnew, curr->y_array[--j]);
  604.           STRCAT(pnew, y_current->y_array[0]);
  605. --- 2678,2685 ----
  606.                     + STRLEN(y_current->y_array[0]) + 1), TRUE);
  607.           if (pnew == NULL)
  608.           {
  609. !         y_idx = y_current->y_size - 1;
  610. !         goto fail;
  611.           }
  612.           STRCPY(pnew, curr->y_array[--j]);
  613.           STRCAT(pnew, y_current->y_array[0]);
  614. ***************
  615. *** 2643,2649 ****
  616.       }
  617.       if (mess)            /* Display message about yank? */
  618.       {
  619. !     if (yanktype == MCHAR && !oap->block_mode && yanklines == 1)
  620.           yanklines = 0;
  621.       /* Some versions of Vi use ">=" here, some don't...  */
  622.       if (yanklines > p_report)
  623. --- 2698,2708 ----
  624.       }
  625.       if (mess)            /* Display message about yank? */
  626.       {
  627. !     if (yanktype == MCHAR
  628. ! #ifdef FEAT_VISUAL
  629. !         && !oap->block_mode
  630. ! #endif
  631. !         && yanklines == 1)
  632.           yanklines = 0;
  633.       /* Some versions of Vi use ">=" here, some don't...  */
  634.       if (yanklines > p_report)
  635. ***************
  636. *** 2660,2667 ****
  637.       /*
  638.        * Set "'[" and "']" marks.
  639.        */
  640. !     curbuf->b_op_start = oap->start;
  641. !     curbuf->b_op_end = oap->end;
  642.   
  643.   #ifdef FEAT_CLIPBOARD
  644.       /*
  645. --- 2719,2731 ----
  646.       /*
  647.        * Set "'[" and "']" marks.
  648.        */
  649. ! #ifdef FEAT_VISUAL
  650. !     if (!did_visual_put)
  651. ! #endif
  652. !     {
  653. !     curbuf->b_op_start = oap->start;
  654. !     curbuf->b_op_end = oap->end;
  655. !     }
  656.   
  657.   #ifdef FEAT_CLIPBOARD
  658.       /*
  659. ***************
  660. *** 2702,2707 ****
  661. --- 2766,2797 ----
  662.   #endif
  663.   
  664.       return OK;
  665. + fail:        /* free the allocated lines */
  666. +     free_yank(y_idx + 1);
  667. +     y_current = curr;
  668. +     return FAIL;
  669. + }
  670. +     static int
  671. + yank_copy_line(bd, y_idx)
  672. +     struct block_def    *bd;
  673. +     long        y_idx;
  674. + {
  675. +     char_u    *pnew;
  676. +     if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1))
  677. +                                       == NULL)
  678. +     return FAIL;
  679. +     y_current->y_array[y_idx] = pnew;
  680. +     copy_spaces(pnew, (size_t)bd->startspaces);
  681. +     pnew += bd->startspaces;
  682. +     mch_memmove(pnew, bd->textstart, (size_t)bd->textlen);
  683. +     pnew += bd->textlen;
  684. +     copy_spaces(pnew, (size_t)bd->endspaces);
  685. +     pnew += bd->endspaces;
  686. +     *pnew = NUL;
  687. +     return OK;
  688.   }
  689.   
  690.   #ifdef FEAT_CLIPBOARD
  691. ***************
  692. *** 2736,2744 ****
  693.   
  694.   /*
  695.    * put contents of register "regname" into the text
  696. -  * For ":put" command count == -1.
  697.    * flags: PUT_FIXINDENT    make indent look nice
  698.    *      PUT_CURSEND    leave cursor after end of new text
  699.    */
  700.       void
  701.   do_put(regname, dir, count, flags)
  702. --- 2826,2834 ----
  703.   
  704.   /*
  705.    * put contents of register "regname" into the text
  706.    * flags: PUT_FIXINDENT    make indent look nice
  707.    *      PUT_CURSEND    leave cursor after end of new text
  708. +  *      PUT_LINE    force linewise put (":put")
  709.    */
  710.       void
  711.   do_put(regname, dir, count, flags)
  712. ***************
  713. *** 2750,2769 ****
  714.       char_u    *ptr;
  715.       char_u    *newp, *oldp;
  716.       int        yanklen;
  717. -     int        oldlen;
  718.       int        totlen = 0;        /* init for gcc */
  719.       linenr_T    lnum;
  720.       colnr_T    col;
  721.       long    i;            /* index in y_array[] */
  722.       int        y_type;
  723.       long    y_size;
  724.       long    y_width = 0;
  725. -     char_u    **y_array = NULL;
  726. -     long    nr_lines = 0;
  727.       colnr_T    vcol;
  728.       int        delcount;
  729.       int        incr = 0;
  730.       long    j;
  731.       pos_T    new_cursor;
  732.       int        indent;
  733.       int        orig_indent = 0;    /* init for gcc */
  734. --- 2840,2862 ----
  735.       char_u    *ptr;
  736.       char_u    *newp, *oldp;
  737.       int        yanklen;
  738.       int        totlen = 0;        /* init for gcc */
  739.       linenr_T    lnum;
  740.       colnr_T    col;
  741.       long    i;            /* index in y_array[] */
  742.       int        y_type;
  743.       long    y_size;
  744. + #ifdef FEAT_VISUAL
  745. +     int        oldlen;
  746.       long    y_width = 0;
  747.       colnr_T    vcol;
  748.       int        delcount;
  749.       int        incr = 0;
  750.       long    j;
  751. +     struct block_def bd;
  752. + #endif
  753. +     char_u    **y_array = NULL;
  754. +     long    nr_lines = 0;
  755.       pos_T    new_cursor;
  756.       int        indent;
  757.       int        orig_indent = 0;    /* init for gcc */
  758. ***************
  759. *** 2771,2777 ****
  760.       int        first_indent = TRUE;
  761.       int        lendiff = 0;
  762.       pos_T    old_pos;
  763. -     struct block_def bd;
  764.       char_u    *insert_string = NULL;
  765.       int        allocated = FALSE;
  766.       long    cnt;
  767. --- 2864,2869 ----
  768. ***************
  769. *** 2879,2894 ****
  770.       get_yank_register(regname, FALSE);
  771.   
  772.       y_type = y_current->y_type;
  773.       y_width = y_current->y_width;
  774.       y_size = y_current->y_size;
  775.       y_array = y_current->y_array;
  776.       }
  777.   
  778. !     if (count == -1)        /* :put command */
  779. !     {
  780.       y_type = MLINE;
  781. -     count = 1;
  782. -     }
  783.   
  784.       if (y_size == 0 || y_array == NULL)
  785.       {
  786. --- 2971,2987 ----
  787.       get_yank_register(regname, FALSE);
  788.   
  789.       y_type = y_current->y_type;
  790. + #ifdef FEAT_VISUAL
  791.       y_width = y_current->y_width;
  792. + #endif
  793.       y_size = y_current->y_size;
  794.       y_array = y_current->y_array;
  795.       }
  796.   
  797. !     if ((flags & PUT_LINE_BACKWARD) && y_type == MLINE)
  798. !     dir = BACKWARD;
  799. !     if (flags & PUT_LINE)        /* :put command */
  800.       y_type = MLINE;
  801.   
  802.       if (y_size == 0 || y_array == NULL)
  803.       {
  804. ***************
  805. *** 2897,2902 ****
  806. --- 2990,2996 ----
  807.       goto end;
  808.       }
  809.   
  810. + #ifdef FEAT_VISUAL
  811.       if (y_type == MBLOCK)
  812.       {
  813.       lnum = curwin->w_cursor.lnum + y_size + 1;
  814. ***************
  815. *** 2905,2911 ****
  816.       if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)
  817.           goto end;
  818.       }
  819. !     else if (y_type == MLINE)
  820.       {
  821.       lnum = curwin->w_cursor.lnum;
  822.   #ifdef FEAT_FOLDING
  823. --- 2999,3007 ----
  824.       if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)
  825.           goto end;
  826.       }
  827. !     else
  828. ! #endif
  829. !     if (y_type == MLINE)
  830.       {
  831.       lnum = curwin->w_cursor.lnum;
  832.   #ifdef FEAT_FOLDING
  833. ***************
  834. *** 2954,2959 ****
  835. --- 3050,3056 ----
  836.       lnum = curwin->w_cursor.lnum;
  837.       col = curwin->w_cursor.col;
  838.   
  839. + #ifdef FEAT_VISUAL
  840.       /*
  841.        * Block mode
  842.        */
  843. ***************
  844. *** 3126,3131 ****
  845. --- 3223,3229 ----
  846.           curwin->w_cursor.lnum = lnum;
  847.       }
  848.       else
  849. + #endif
  850.       {
  851.       /*
  852.        * Character or Line mode
  853. ***************
  854. *** 4093,4098 ****
  855. --- 4215,4221 ----
  856.   }
  857.   #endif
  858.   
  859. + #ifdef FEAT_VISUAL
  860.   /*
  861.    * prepare a few things for block mode yank/delete/tilde
  862.    *
  863. ***************
  864. *** 4255,4260 ****
  865. --- 4378,4384 ----
  866.       bdp->textcol = (colnr_T) (pstart - line);
  867.       bdp->textstart = pstart;
  868.   }
  869. + #endif /* FEAT_VISUAL */
  870.   
  871.   #ifdef FEAT_RIGHTLEFT
  872.   static void reverse_line __ARGS((char_u *s));
  873. ***************
  874. *** 4596,4608 ****
  875. --- 4720,4738 ----
  876.       str = skipwhite(str);
  877.       if (STRNCMP(str, "CHAR", 4) == 0)
  878.           y_current->y_type = MCHAR;
  879. + #ifdef FEAT_VISUAL
  880.       else if (STRNCMP(str, "BLOCK", 5) == 0)
  881.           y_current->y_type = MBLOCK;
  882. + #endif
  883.       else
  884.           y_current->y_type = MLINE;
  885.       /* get the block width; if it's missing we get a zero, which is OK */
  886.       str = skipwhite(skiptowhite(str));
  887. + #ifdef FEAT_VISUAL
  888.       y_current->y_width = getdigits(&str);
  889. + #else
  890. +     (void)getdigits(&str);
  891. + #endif
  892.       }
  893.   
  894.       while (!(eof = viminfo_readline(virp))
  895. ***************
  896. *** 4679,4687 ****
  897. --- 4809,4819 ----
  898.           case MCHAR:
  899.           type = (char_u *)"CHAR";
  900.           break;
  901. + #ifdef FEAT_VISUAL
  902.           case MBLOCK:
  903.           type = (char_u *)"BLOCK";
  904.           break;
  905. + #endif
  906.           default:
  907.           sprintf((char *)IObuff, _("Unknown register type %d"),
  908.               y_regs[i].y_type);
  909. ***************
  910. *** 4692,4698 ****
  911.       if (y_previous == &y_regs[i])
  912.           fprintf(fp, "\"");
  913.       c = get_register_name(i);
  914. !     fprintf(fp, "\"%c\t%s\t%d\n", c, type, y_regs[i].y_width);
  915.       num_lines = y_regs[i].y_size;
  916.   
  917.       /* If max_num_lines < 0, then we save ALL the lines in the register */
  918. --- 4824,4836 ----
  919.       if (y_previous == &y_regs[i])
  920.           fprintf(fp, "\"");
  921.       c = get_register_name(i);
  922. !     fprintf(fp, "\"%c\t%s\t%d\n", c, type,
  923. ! #ifdef FEAT_VISUAL
  924. !             (int)y_regs[i].y_width
  925. ! #else
  926. !             0
  927. ! #endif
  928. !             );
  929.       num_lines = y_regs[i].y_size;
  930.   
  931.       /* If max_num_lines < 0, then we save ALL the lines in the register */
  932. ***************
  933. *** 4803,4808 ****
  934. --- 4941,4947 ----
  935.   #endif
  936.       colnr_T    old_curswant;
  937.       int        old_set_curswant;
  938. +     pos_T    old_op_start, old_op_end;
  939.       oparg_T    oa;
  940.       cmdarg_T    ca;
  941.   
  942. ***************
  943. *** 4818,4823 ****
  944. --- 4957,4964 ----
  945.       old_cursor = curwin->w_cursor;
  946.       old_curswant = curwin->w_curswant;
  947.       old_set_curswant = curwin->w_set_curswant;
  948. +     old_op_start = curbuf->b_op_start;
  949. +     old_op_end = curbuf->b_op_end;
  950.   #ifdef FEAT_VISUAL
  951.       old_visual = VIsual;
  952.       old_visual_mode = VIsual_mode;
  953. ***************
  954. *** 4836,4841 ****
  955. --- 4977,4984 ----
  956.       curwin->w_cursor = old_cursor;
  957.       curwin->w_curswant = old_curswant;
  958.       curwin->w_set_curswant = old_set_curswant;
  959. +     curbuf->b_op_start = old_op_start;
  960. +     curbuf->b_op_end = old_op_end;
  961.   #ifdef FEAT_VISUAL
  962.       VIsual = old_visual;
  963.       VIsual_mode = old_visual_mode;
  964. ***************
  965. *** 5204,5210 ****
  966. --- 5347,5355 ----
  967.       }
  968.       y_ptr->y_type = type;
  969.       y_ptr->y_size = lnum;
  970. + # ifdef FEAT_VISUAL
  971.       y_ptr->y_width = 0;
  972. + # endif
  973.   }
  974.   #endif /* FEAT_CLIPBOARD || FEAT_EVAL || PROTO */
  975.   
  976. ***************
  977. *** 5320,5326 ****
  978.           if (VIsual_mode == Ctrl_V)
  979.           {
  980.           oparg.is_VIsual = 1;
  981. !         oparg.block_mode = 1;
  982.           oparg.op_type = OP_NOP;
  983.           getvcols(curwin, &min_pos, &max_pos,
  984.               &oparg.start_vcol, &oparg.end_vcol);
  985. --- 5465,5471 ----
  986.           if (VIsual_mode == Ctrl_V)
  987.           {
  988.           oparg.is_VIsual = 1;
  989. !         oparg.block_mode = TRUE;
  990.           oparg.op_type = OP_NOP;
  991.           getvcols(curwin, &min_pos, &max_pos,
  992.               &oparg.start_vcol, &oparg.end_vcol);
  993. *** ../vim60.227/src/structs.h    Thu Jan 17 16:30:27 2002
  994. --- src/structs.h    Sun Feb 17 16:22:11 2002
  995. ***************
  996. *** 1428,1435 ****
  997.                      do_change()) */
  998.   #ifdef FEAT_VISUAL
  999.       int        is_VIsual;    /* operator on Visual area */
  1000. - #endif
  1001.       int        block_mode;    /* current operator is Visual block mode */
  1002.       colnr_T    start_vcol;    /* start col for block mode operator */
  1003.       colnr_T    end_vcol;    /* end col for block mode operator */
  1004.   } oparg_T;
  1005. --- 1428,1435 ----
  1006.                      do_change()) */
  1007.   #ifdef FEAT_VISUAL
  1008.       int        is_VIsual;    /* operator on Visual area */
  1009.       int        block_mode;    /* current operator is Visual block mode */
  1010. + #endif
  1011.       colnr_T    start_vcol;    /* start col for block mode operator */
  1012.       colnr_T    end_vcol;    /* end col for block mode operator */
  1013.   } oparg_T;
  1014. *** ../vim60.227/src/vim.h    Mon Feb  4 17:08:29 2002
  1015. --- src/vim.h    Sun Feb 17 21:05:10 2002
  1016. ***************
  1017. *** 816,821 ****
  1018. --- 816,823 ----
  1019.   /* flags for do_put() */
  1020.   #define PUT_FIXINDENT    1    /* make indent look nice */
  1021.   #define PUT_CURSEND    2    /* leave cursor after end of new text */
  1022. + #define PUT_LINE    4    /* put register as lines */
  1023. + #define PUT_LINE_BACKWARD 8    /* put linewise register backwards */
  1024.   
  1025.   /* flags for set_indent() */
  1026.   #define SIN_CHANGED    1    /* call changed_bytes() when line changed */
  1027. *** ../vim60.227/src/version.c    Sun Feb 17 15:39:58 2002
  1028. --- src/version.c    Sun Feb 17 22:11:06 2002
  1029. ***************
  1030. *** 608,609 ****
  1031. --- 608,611 ----
  1032.   {   /* Add new patch number below this line */
  1033. + /**/
  1034. +     228,
  1035.   /**/
  1036.  
  1037.  
  1038.  
  1039. -- 
  1040. INSPECTOR END OF FILM: Move along.  There's nothing to see!  Keep moving!
  1041.    [Suddenly he notices the cameras.]
  1042. INSPECTOR END OF FILM: (to Camera) All right, put that away sonny.
  1043.    [He walks over to it and puts his hand over the lens.]
  1044.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  1045.  
  1046.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  1047. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  1048. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  1049.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  1050.