comparison src/ops.c @ 14175:2ad722003b36 v8.1.0105

patch 8.1.0105: all tab stops are the same commit https://github.com/vim/vim/commit/04958cbaf25eea27eceedaa987adfb354ad5f7fd Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 23 19:23:02 2018 +0200 patch 8.1.0105: all tab stops are the same Problem: All tab stops are the same. Solution: Add the variable tabstop feature. (Christian Brabandt, closes #2711)
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Jun 2018 19:30:07 +0200
parents dc67449d648c
children 51693b1a640e
comparison
equal deleted inserted replaced
14174:d36eedd19166 14175:2ad722003b36
396 int oldstate = State; 396 int oldstate = State;
397 int total; 397 int total;
398 char_u *newp, *oldp; 398 char_u *newp, *oldp;
399 int oldcol = curwin->w_cursor.col; 399 int oldcol = curwin->w_cursor.col;
400 int p_sw = (int)get_sw_value(curbuf); 400 int p_sw = (int)get_sw_value(curbuf);
401 #ifdef FEAT_VARTABS
402 int *p_vts = curbuf->b_p_vts_array;
403 #endif
401 int p_ts = (int)curbuf->b_p_ts; 404 int p_ts = (int)curbuf->b_p_ts;
402 struct block_def bd; 405 struct block_def bd;
403 int incr; 406 int incr;
404 colnr_T ws_vcol; 407 colnr_T ws_vcol;
405 int i = 0, j = 0; 408 int i = 0, j = 0;
457 total += incr; 460 total += incr;
458 bd.start_vcol += incr; 461 bd.start_vcol += incr;
459 } 462 }
460 /* OK, now total=all the VWS reqd, and textstart points at the 1st 463 /* OK, now total=all the VWS reqd, and textstart points at the 1st
461 * non-ws char in the block. */ 464 * non-ws char in the block. */
465 #ifdef FEAT_VARTABS
466 if (!curbuf->b_p_et)
467 tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j);
468 else
469 j = total;
470 #else
462 if (!curbuf->b_p_et) 471 if (!curbuf->b_p_et)
463 i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */ 472 i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */
464 if (i) 473 if (i)
465 j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */ 474 j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */
466 else 475 else
467 j = total; 476 j = total;
477 #endif
468 /* if we're splitting a TAB, allow for it */ 478 /* if we're splitting a TAB, allow for it */
469 bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0); 479 bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0);
470 len = (int)STRLEN(bd.textstart) + 1; 480 len = (int)STRLEN(bd.textstart) + 1;
471 newp = alloc_check((unsigned)(bd.textcol + i + j + len)); 481 newp = alloc_check((unsigned)(bd.textcol + i + j + len));
472 if (newp == NULL) 482 if (newp == NULL)
3695 { 3705 {
3696 if (gchar_cursor() == TAB) 3706 if (gchar_cursor() == TAB)
3697 { 3707 {
3698 /* Don't need to insert spaces when "p" on the last position of a 3708 /* Don't need to insert spaces when "p" on the last position of a
3699 * tab or "P" on the first position. */ 3709 * tab or "P" on the first position. */
3710 #ifdef FEAT_VARTABS
3711 int viscol = getviscol();
3712 if (dir == FORWARD
3713 ? tabstop_padding(viscol, curbuf->b_p_ts,
3714 curbuf->b_p_vts_array) != 1
3715 : curwin->w_cursor.coladd > 0)
3716 coladvance_force(viscol);
3717 #else
3700 if (dir == FORWARD 3718 if (dir == FORWARD
3701 ? (int)curwin->w_cursor.coladd < curbuf->b_p_ts - 1 3719 ? (int)curwin->w_cursor.coladd < curbuf->b_p_ts - 1
3702 : curwin->w_cursor.coladd > 0) 3720 : curwin->w_cursor.coladd > 0)
3703 coladvance_force(getviscol()); 3721 coladvance_force(getviscol());
3722 #endif
3704 else 3723 else
3705 curwin->w_cursor.coladd = 0; 3724 curwin->w_cursor.coladd = 0;
3706 } 3725 }
3707 else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL) 3726 else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)
3708 coladvance_force(getviscol() + (dir == FORWARD)); 3727 coladvance_force(getviscol() + (dir == FORWARD));