Mercurial > vim
comparison src/ops.c @ 18265:fe5afdc03bd2 v8.1.2127
patch 8.1.2127: the indent.c file is a bit big
Commit: https://github.com/vim/vim/commit/14c01f83487d5c53192297a710eda2b8a4ab17c9
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Oct 9 22:53:08 2019 +0200
patch 8.1.2127: the indent.c file is a bit big
Problem: The indent.c file is a bit big.
Solution: Move C-indent code a a new cindent.c file. Move other
indent-related code to indent.c. (Yegappan Lakshmanan,
closes #5031)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 09 Oct 2019 23:00:04 +0200 |
parents | c8a53c0daeed |
children | 9f51d0cef8da |
comparison
equal
deleted
inserted
replaced
18264:5202d9b99bee | 18265:fe5afdc03bd2 |
---|---|
588 changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L); | 588 changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L); |
589 | 589 |
590 State = oldstate; | 590 State = oldstate; |
591 } | 591 } |
592 | 592 |
593 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(PROTO) | |
594 /* | |
595 * op_reindent - handle reindenting a block of lines. | |
596 */ | |
597 static void | |
598 op_reindent(oparg_T *oap, int (*how)(void)) | |
599 { | |
600 long i; | |
601 char_u *l; | |
602 int amount; | |
603 linenr_T first_changed = 0; | |
604 linenr_T last_changed = 0; | |
605 linenr_T start_lnum = curwin->w_cursor.lnum; | |
606 | |
607 /* Don't even try when 'modifiable' is off. */ | |
608 if (!curbuf->b_p_ma) | |
609 { | |
610 emsg(_(e_modifiable)); | |
611 return; | |
612 } | |
613 | |
614 for (i = oap->line_count; --i >= 0 && !got_int; ) | |
615 { | |
616 /* it's a slow thing to do, so give feedback so there's no worry that | |
617 * the computer's just hung. */ | |
618 | |
619 if (i > 1 | |
620 && (i % 50 == 0 || i == oap->line_count - 1) | |
621 && oap->line_count > p_report) | |
622 smsg(_("%ld lines to indent... "), i); | |
623 | |
624 /* | |
625 * Be vi-compatible: For lisp indenting the first line is not | |
626 * indented, unless there is only one line. | |
627 */ | |
628 #ifdef FEAT_LISP | |
629 if (i != oap->line_count - 1 || oap->line_count == 1 | |
630 || how != get_lisp_indent) | |
631 #endif | |
632 { | |
633 l = skipwhite(ml_get_curline()); | |
634 if (*l == NUL) /* empty or blank line */ | |
635 amount = 0; | |
636 else | |
637 amount = how(); /* get the indent for this line */ | |
638 | |
639 if (amount >= 0 && set_indent(amount, SIN_UNDO)) | |
640 { | |
641 /* did change the indent, call changed_lines() later */ | |
642 if (first_changed == 0) | |
643 first_changed = curwin->w_cursor.lnum; | |
644 last_changed = curwin->w_cursor.lnum; | |
645 } | |
646 } | |
647 ++curwin->w_cursor.lnum; | |
648 curwin->w_cursor.col = 0; /* make sure it's valid */ | |
649 } | |
650 | |
651 /* put cursor on first non-blank of indented line */ | |
652 curwin->w_cursor.lnum = start_lnum; | |
653 beginline(BL_SOL | BL_FIX); | |
654 | |
655 /* Mark changed lines so that they will be redrawn. When Visual | |
656 * highlighting was present, need to continue until the last line. When | |
657 * there is no change still need to remove the Visual highlighting. */ | |
658 if (last_changed != 0) | |
659 changed_lines(first_changed, 0, | |
660 oap->is_VIsual ? start_lnum + oap->line_count : | |
661 last_changed + 1, 0L); | |
662 else if (oap->is_VIsual) | |
663 redraw_curbuf_later(INVERTED); | |
664 | |
665 if (oap->line_count > p_report) | |
666 { | |
667 i = oap->line_count - (i + 1); | |
668 smsg(NGETTEXT("%ld line indented ", | |
669 "%ld lines indented ", i), i); | |
670 } | |
671 /* set '[ and '] marks */ | |
672 curbuf->b_op_start = oap->start; | |
673 curbuf->b_op_end = oap->end; | |
674 } | |
675 #endif /* defined(FEAT_LISP) || defined(FEAT_CINDENT) */ | |
676 | |
677 /* | 593 /* |
678 * Stuff a string into the typeahead buffer, such that edit() will insert it | 594 * Stuff a string into the typeahead buffer, such that edit() will insert it |
679 * literally ("literally" TRUE) or interpret is as typed characters. | 595 * literally ("literally" TRUE) or interpret is as typed characters. |
680 */ | 596 */ |
681 void | 597 void |
1914 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); | 1830 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); |
1915 curwin->w_cursor.coladd = ecol - scol + 1; | 1831 curwin->w_cursor.coladd = ecol - scol + 1; |
1916 } | 1832 } |
1917 } | 1833 } |
1918 } | 1834 } |
1919 | |
1920 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) || defined(PROTO) | |
1921 /* | |
1922 * Return TRUE if lines starting with '#' should be left aligned. | |
1923 */ | |
1924 int | |
1925 preprocs_left(void) | |
1926 { | |
1927 return | |
1928 # ifdef FEAT_SMARTINDENT | |
1929 # ifdef FEAT_CINDENT | |
1930 (curbuf->b_p_si && !curbuf->b_p_cin) || | |
1931 # else | |
1932 curbuf->b_p_si | |
1933 # endif | |
1934 # endif | |
1935 # ifdef FEAT_CINDENT | |
1936 (curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE) | |
1937 && curbuf->b_ind_hash_comment == 0) | |
1938 # endif | |
1939 ; | |
1940 } | |
1941 #endif | |
1942 | 1835 |
1943 /* | 1836 /* |
1944 * If "process" is TRUE and the line begins with a comment leader (possibly | 1837 * If "process" is TRUE and the line begins with a comment leader (possibly |
1945 * after some white space), return a pointer to the text after it. Put a boolean | 1838 * after some white space), return a pointer to the text after it. Put a boolean |
1946 * value indicating whether the line ends with an unclosed comment in | 1839 * value indicating whether the line ends with an unclosed comment in |