Mercurial > vim
comparison src/ops.c @ 18100:df5778d73320 v8.1.2045
patch 8.1.2045: the option.c file is too big
Commit: https://github.com/vim/vim/commit/dac1347b4d9c1a1aef6aa73fdea08a9d1077d6ea
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 16 21:06:21 2019 +0200
patch 8.1.2045: the option.c file is too big
Problem: The option.c file is too big.
Solution: Split off the code dealing with strings. (Yegappan Lakshmanan,
closes #4937)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Sep 2019 21:15:05 +0200 |
parents | 0b351691071c |
children | f57481564f2c |
comparison
equal
deleted
inserted
replaced
18099:349ea1199661 | 18100:df5778d73320 |
---|---|
313 int amount, | 313 int amount, |
314 int call_changed_bytes) /* call changed_bytes() */ | 314 int call_changed_bytes) /* call changed_bytes() */ |
315 { | 315 { |
316 int count; | 316 int count; |
317 int i, j; | 317 int i, j; |
318 int p_sw = (int)get_sw_value_indent(curbuf); | 318 int sw_val = (int)get_sw_value_indent(curbuf); |
319 | 319 |
320 count = get_indent(); /* get current indent */ | 320 count = get_indent(); /* get current indent */ |
321 | 321 |
322 if (round) /* round off indent */ | 322 if (round) /* round off indent */ |
323 { | 323 { |
324 i = count / p_sw; /* number of p_sw rounded down */ | 324 i = count / sw_val; /* number of p_sw rounded down */ |
325 j = count % p_sw; /* extra spaces */ | 325 j = count % sw_val; /* extra spaces */ |
326 if (j && left) /* first remove extra spaces */ | 326 if (j && left) /* first remove extra spaces */ |
327 --amount; | 327 --amount; |
328 if (left) | 328 if (left) |
329 { | 329 { |
330 i -= amount; | 330 i -= amount; |
331 if (i < 0) | 331 if (i < 0) |
332 i = 0; | 332 i = 0; |
333 } | 333 } |
334 else | 334 else |
335 i += amount; | 335 i += amount; |
336 count = i * p_sw; | 336 count = i * sw_val; |
337 } | 337 } |
338 else /* original vi indent */ | 338 else /* original vi indent */ |
339 { | 339 { |
340 if (left) | 340 if (left) |
341 { | 341 { |
342 count -= p_sw * amount; | 342 count -= sw_val * amount; |
343 if (count < 0) | 343 if (count < 0) |
344 count = 0; | 344 count = 0; |
345 } | 345 } |
346 else | 346 else |
347 count += p_sw * amount; | 347 count += sw_val * amount; |
348 } | 348 } |
349 | 349 |
350 /* Set new indent */ | 350 /* Set new indent */ |
351 if (State & VREPLACE_FLAG) | 351 if (State & VREPLACE_FLAG) |
352 change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); | 352 change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); |
364 int left = (oap->op_type == OP_LSHIFT); | 364 int left = (oap->op_type == OP_LSHIFT); |
365 int oldstate = State; | 365 int oldstate = State; |
366 int total; | 366 int total; |
367 char_u *newp, *oldp; | 367 char_u *newp, *oldp; |
368 int oldcol = curwin->w_cursor.col; | 368 int oldcol = curwin->w_cursor.col; |
369 int p_sw = (int)get_sw_value_indent(curbuf); | 369 int sw_val = (int)get_sw_value_indent(curbuf); |
370 #ifdef FEAT_VARTABS | 370 int ts_val = (int)curbuf->b_p_ts; |
371 int *p_vts = curbuf->b_p_vts_array; | |
372 #endif | |
373 int p_ts = (int)curbuf->b_p_ts; | |
374 struct block_def bd; | 371 struct block_def bd; |
375 int incr; | 372 int incr; |
376 colnr_T ws_vcol; | 373 colnr_T ws_vcol; |
377 int i = 0, j = 0; | 374 int i = 0, j = 0; |
378 int len; | 375 int len; |
386 block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); | 383 block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); |
387 if (bd.is_short) | 384 if (bd.is_short) |
388 return; | 385 return; |
389 | 386 |
390 /* total is number of screen columns to be inserted/removed */ | 387 /* total is number of screen columns to be inserted/removed */ |
391 total = (int)((unsigned)amount * (unsigned)p_sw); | 388 total = (int)((unsigned)amount * (unsigned)sw_val); |
392 if ((total / p_sw) != amount) | 389 if ((total / sw_val) != amount) |
393 return; /* multiplication overflow */ | 390 return; /* multiplication overflow */ |
394 | 391 |
395 oldp = ml_get_curline(); | 392 oldp = ml_get_curline(); |
396 | 393 |
397 if (!left) | 394 if (!left) |
429 } | 426 } |
430 /* OK, now total=all the VWS reqd, and textstart points at the 1st | 427 /* OK, now total=all the VWS reqd, and textstart points at the 1st |
431 * non-ws char in the block. */ | 428 * non-ws char in the block. */ |
432 #ifdef FEAT_VARTABS | 429 #ifdef FEAT_VARTABS |
433 if (!curbuf->b_p_et) | 430 if (!curbuf->b_p_et) |
434 tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j); | 431 tabstop_fromto(ws_vcol, ws_vcol + total, |
432 ts_val, curbuf->b_p_vts_array, &i, &j); | |
435 else | 433 else |
436 j = total; | 434 j = total; |
437 #else | 435 #else |
438 if (!curbuf->b_p_et) | 436 if (!curbuf->b_p_et) |
439 i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */ | 437 i = ((ws_vcol % ts_val) + total) / ts_val; /* number of tabs */ |
440 if (i) | 438 if (i) |
441 j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */ | 439 j = ((ws_vcol % ts_val) + total) % ts_val; /* number of spp */ |
442 else | 440 else |
443 j = total; | 441 j = total; |
444 #endif | 442 #endif |
445 /* if we're splitting a TAB, allow for it */ | 443 /* if we're splitting a TAB, allow for it */ |
446 bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0); | 444 bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0); |
565 oparg_T *oap, | 563 oparg_T *oap, |
566 char_u *s, | 564 char_u *s, |
567 int b_insert, | 565 int b_insert, |
568 struct block_def *bdp) | 566 struct block_def *bdp) |
569 { | 567 { |
570 int p_ts; | 568 int ts_val; |
571 int count = 0; /* extra spaces to replace a cut TAB */ | 569 int count = 0; /* extra spaces to replace a cut TAB */ |
572 int spaces = 0; /* non-zero if cutting a TAB */ | 570 int spaces = 0; /* non-zero if cutting a TAB */ |
573 colnr_T offset; /* pointer along new line */ | 571 colnr_T offset; /* pointer along new line */ |
574 unsigned s_len; /* STRLEN(s) */ | 572 unsigned s_len; /* STRLEN(s) */ |
575 char_u *newp, *oldp; /* new, old lines */ | 573 char_u *newp, *oldp; /* new, old lines */ |
587 | 585 |
588 oldp = ml_get(lnum); | 586 oldp = ml_get(lnum); |
589 | 587 |
590 if (b_insert) | 588 if (b_insert) |
591 { | 589 { |
592 p_ts = bdp->start_char_vcols; | 590 ts_val = bdp->start_char_vcols; |
593 spaces = bdp->startspaces; | 591 spaces = bdp->startspaces; |
594 if (spaces != 0) | 592 if (spaces != 0) |
595 count = p_ts - 1; /* we're cutting a TAB */ | 593 count = ts_val - 1; /* we're cutting a TAB */ |
596 offset = bdp->textcol; | 594 offset = bdp->textcol; |
597 } | 595 } |
598 else /* append */ | 596 else /* append */ |
599 { | 597 { |
600 p_ts = bdp->end_char_vcols; | 598 ts_val = bdp->end_char_vcols; |
601 if (!bdp->is_short) /* spaces = padding after block */ | 599 if (!bdp->is_short) /* spaces = padding after block */ |
602 { | 600 { |
603 spaces = (bdp->endspaces ? p_ts - bdp->endspaces : 0); | 601 spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0); |
604 if (spaces != 0) | 602 if (spaces != 0) |
605 count = p_ts - 1; /* we're cutting a TAB */ | 603 count = ts_val - 1; /* we're cutting a TAB */ |
606 offset = bdp->textcol + bdp->textlen - (spaces != 0); | 604 offset = bdp->textcol + bdp->textlen - (spaces != 0); |
607 } | 605 } |
608 else /* spaces = padding to block edge */ | 606 else /* spaces = padding to block edge */ |
609 { | 607 { |
610 /* if $ used, just append to EOL (ie spaces==0) */ | 608 /* if $ used, just append to EOL (ie spaces==0) */ |
649 offset += s_len; | 647 offset += s_len; |
650 | 648 |
651 if (spaces && !bdp->is_short) | 649 if (spaces && !bdp->is_short) |
652 { | 650 { |
653 /* insert post-padding */ | 651 /* insert post-padding */ |
654 vim_memset(newp + offset + spaces, ' ', (size_t)(p_ts - spaces)); | 652 vim_memset(newp + offset + spaces, ' ', (size_t)(ts_val - spaces)); |
655 /* We're splitting a TAB, don't copy it. */ | 653 /* We're splitting a TAB, don't copy it. */ |
656 oldp++; | 654 oldp++; |
657 /* We allowed for that TAB, remember this now */ | 655 /* We allowed for that TAB, remember this now */ |
658 count++; | 656 count++; |
659 } | 657 } |
5589 pos_T save_cursor = curwin->w_cursor; | 5587 pos_T save_cursor = curwin->w_cursor; |
5590 int maxlen = 0; | 5588 int maxlen = 0; |
5591 pos_T startpos; | 5589 pos_T startpos; |
5592 pos_T endpos; | 5590 pos_T endpos; |
5593 | 5591 |
5594 dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */ | 5592 dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX" |
5595 dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */ | 5593 dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal" |
5596 dobin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); /* "Bin" */ | 5594 dobin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); // "Bin" |
5597 doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); /* "alPha" */ | 5595 doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha" |
5598 | 5596 |
5599 curwin->w_cursor = *pos; | 5597 curwin->w_cursor = *pos; |
5600 ptr = ml_get(pos->lnum); | 5598 ptr = ml_get(pos->lnum); |
5601 col = pos->col; | 5599 col = pos->col; |
5602 | 5600 |