Mercurial > vim
comparison src/diff.c @ 764:986753bbc441
updated for version 7.0225
author | vimboss |
---|---|
date | Wed, 15 Mar 2006 22:50:30 +0000 |
parents | 5c9e7c6e6e2e |
children | 23f82b5d2814 |
comparison
equal
deleted
inserted
replaced
763:fa0447b7a8a0 | 764:986753bbc441 |
---|---|
19 | 19 |
20 /* flags obtained from the 'diffopt' option */ | 20 /* flags obtained from the 'diffopt' option */ |
21 #define DIFF_FILLER 1 /* display filler lines */ | 21 #define DIFF_FILLER 1 /* display filler lines */ |
22 #define DIFF_ICASE 2 /* ignore case */ | 22 #define DIFF_ICASE 2 /* ignore case */ |
23 #define DIFF_IWHITE 4 /* ignore change in white space */ | 23 #define DIFF_IWHITE 4 /* ignore change in white space */ |
24 #define DIFF_HORIZONTAL 8 /* horizontal splits */ | |
25 #define DIFF_VERTICAL 16 /* vertical splits */ | |
24 static int diff_flags = DIFF_FILLER; | 26 static int diff_flags = DIFF_FILLER; |
25 | 27 |
26 #define LBUFLEN 50 /* length of line in diff file */ | 28 #define LBUFLEN 50 /* length of line in diff file */ |
27 | 29 |
28 static int diff_a_works = MAYBE; /* TRUE when "diff -a" works, FALSE when it | 30 static int diff_a_works = MAYBE; /* TRUE when "diff -a" works, FALSE when it |
975 need_mouse_correct = TRUE; | 977 need_mouse_correct = TRUE; |
976 #endif | 978 #endif |
977 /* don't use a new tab page, each tab page has its own diffs */ | 979 /* don't use a new tab page, each tab page has its own diffs */ |
978 cmdmod.tab = 0; | 980 cmdmod.tab = 0; |
979 | 981 |
980 if (win_split(0, 0) != FAIL) | 982 if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) |
981 { | 983 { |
982 /* Pretend it was a ":split fname" command */ | 984 /* Pretend it was a ":split fname" command */ |
983 eap->cmdidx = CMD_split; | 985 eap->cmdidx = CMD_split; |
984 eap->arg = tmp_new; | 986 eap->arg = tmp_new; |
985 do_exedit(eap, old_curwin); | 987 do_exedit(eap, old_curwin); |
1035 need_mouse_correct = TRUE; | 1037 need_mouse_correct = TRUE; |
1036 #endif | 1038 #endif |
1037 /* don't use a new tab page, each tab page has its own diffs */ | 1039 /* don't use a new tab page, each tab page has its own diffs */ |
1038 cmdmod.tab = 0; | 1040 cmdmod.tab = 0; |
1039 | 1041 |
1040 if (win_split(0, 0) != FAIL) | 1042 if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) |
1041 { | 1043 { |
1042 /* Pretend it was a ":split fname" command */ | 1044 /* Pretend it was a ":split fname" command */ |
1043 eap->cmdidx = CMD_split; | 1045 eap->cmdidx = CMD_split; |
1044 curwin->w_p_diff = TRUE; | 1046 curwin->w_p_diff = TRUE; |
1045 do_exedit(eap, old_curwin); | 1047 do_exedit(eap, old_curwin); |
1084 curbuf = curwin->w_buffer; | 1086 curbuf = curwin->w_buffer; |
1085 set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", | 1087 set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", |
1086 OPT_LOCAL|OPT_FREE, 0); | 1088 OPT_LOCAL|OPT_FREE, 0); |
1087 curwin = old_curwin; | 1089 curwin = old_curwin; |
1088 curbuf = curwin->w_buffer; | 1090 curbuf = curwin->w_buffer; |
1089 wp->w_p_fdc = 2; | 1091 wp->w_p_fdc = diff_foldcolumn; |
1090 wp->w_p_fen = TRUE; | 1092 wp->w_p_fen = TRUE; |
1091 wp->w_p_fdl = 0; | 1093 wp->w_p_fdl = 0; |
1092 foldUpdateAll(wp); | 1094 foldUpdateAll(wp); |
1093 /* make sure topline is not halfway a fold */ | 1095 /* make sure topline is not halfway a fold */ |
1094 changed_window_setting_win(wp); | 1096 changed_window_setting_win(wp); |
1698 diffopt_changed() | 1700 diffopt_changed() |
1699 { | 1701 { |
1700 char_u *p; | 1702 char_u *p; |
1701 int diff_context_new = 6; | 1703 int diff_context_new = 6; |
1702 int diff_flags_new = 0; | 1704 int diff_flags_new = 0; |
1705 int diff_foldcolumn_new = 2; | |
1703 tabpage_T *tp; | 1706 tabpage_T *tp; |
1704 | 1707 |
1705 p = p_dip; | 1708 p = p_dip; |
1706 while (*p != NUL) | 1709 while (*p != NUL) |
1707 { | 1710 { |
1722 } | 1725 } |
1723 else if (STRNCMP(p, "iwhite", 6) == 0) | 1726 else if (STRNCMP(p, "iwhite", 6) == 0) |
1724 { | 1727 { |
1725 p += 6; | 1728 p += 6; |
1726 diff_flags_new |= DIFF_IWHITE; | 1729 diff_flags_new |= DIFF_IWHITE; |
1730 } | |
1731 else if (STRNCMP(p, "horizontal", 10) == 0) | |
1732 { | |
1733 p += 10; | |
1734 diff_flags_new |= DIFF_HORIZONTAL; | |
1735 } | |
1736 else if (STRNCMP(p, "vertical", 8) == 0) | |
1737 { | |
1738 p += 8; | |
1739 diff_flags_new |= DIFF_VERTICAL; | |
1740 } | |
1741 else if (STRNCMP(p, "foldcolumn:", 11) == 0 && VIM_ISDIGIT(p[11])) | |
1742 { | |
1743 p += 11; | |
1744 diff_foldcolumn_new = getdigits(&p); | |
1727 } | 1745 } |
1728 if (*p != ',' && *p != NUL) | 1746 if (*p != ',' && *p != NUL) |
1729 return FAIL; | 1747 return FAIL; |
1730 if (*p == ',') | 1748 if (*p == ',') |
1731 ++p; | 1749 ++p; |
1732 } | 1750 } |
1733 | 1751 |
1752 /* Can't have both "horizontal" and "vertical". */ | |
1753 if ((diff_flags_new & DIFF_HORIZONTAL) && (diff_flags_new & DIFF_VERTICAL)) | |
1754 return FAIL; | |
1755 | |
1734 /* If "icase" or "iwhite" was added or removed, need to update the diff. */ | 1756 /* If "icase" or "iwhite" was added or removed, need to update the diff. */ |
1735 if (diff_flags != diff_flags_new) | 1757 if (diff_flags != diff_flags_new) |
1736 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) | 1758 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) |
1737 tp->tp_diff_invalid = TRUE; | 1759 tp->tp_diff_invalid = TRUE; |
1738 | 1760 |
1739 diff_flags = diff_flags_new; | 1761 diff_flags = diff_flags_new; |
1740 diff_context = diff_context_new; | 1762 diff_context = diff_context_new; |
1763 diff_foldcolumn = diff_foldcolumn_new; | |
1741 | 1764 |
1742 diff_redraw(TRUE); | 1765 diff_redraw(TRUE); |
1743 | 1766 |
1744 /* recompute the scroll binding with the new option value, may | 1767 /* recompute the scroll binding with the new option value, may |
1745 * remove or add filler lines */ | 1768 * remove or add filler lines */ |
1746 check_scrollbind((linenr_T)0, 0L); | 1769 check_scrollbind((linenr_T)0, 0L); |
1747 | 1770 |
1748 return OK; | 1771 return OK; |
1772 } | |
1773 | |
1774 /* | |
1775 * Return TRUE if 'diffopt' contains "horizontal". | |
1776 */ | |
1777 int | |
1778 diffopt_horizontal() | |
1779 { | |
1780 return (diff_flags & DIFF_HORIZONTAL) != 0; | |
1749 } | 1781 } |
1750 | 1782 |
1751 /* | 1783 /* |
1752 * Find the difference within a changed line. | 1784 * Find the difference within a changed line. |
1753 * Returns TRUE if the line was added, no other buffer has it. | 1785 * Returns TRUE if the line was added, no other buffer has it. |