summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-06-25 14:39:50 +0200
committerBram Moolenaar <Bram@vim.org>2014-06-25 14:39:50 +0200
commit597a422416f37f8e22ed8f561667d6bab8814958 (patch)
tree8bada5798d608ac2a37b7f0ddbf7a24e8da4bd25 /src/option.c
parent15a35c4f4a1670dd6ca228068a451f78d2bf75e0 (diff)
downloadvim-597a422416f37f8e22ed8f561667d6bab8814958.zip
updated for version 7.4.338
Problem: Cannot wrap lines taking indent into account. Solution: Add the 'breakindent' option. (many authors, final improvements by Christian Brabandt)
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index f2f232e35..05dc992d9 100644
--- a/src/option.c
+++ b/src/option.c
@@ -188,6 +188,10 @@
#ifdef FEAT_ARABIC
# define PV_ARAB OPT_WIN(WV_ARAB)
#endif
+#ifdef FEAT_LINEBREAK
+# define PV_BRI OPT_WIN(WV_BRI)
+# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
+#endif
#ifdef FEAT_DIFF
# define PV_DIFF OPT_WIN(WV_DIFF)
#endif
@@ -648,6 +652,24 @@ static struct vimoption
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
+ {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
+#ifdef FEAT_LINEBREAK
+ (char_u *)VAR_WIN, PV_BRI,
+ {(char_u *)FALSE, (char_u *)0L}
+#else
+ (char_u *)NULL, PV_NONE,
+ {(char_u *)0L, (char_u *)0L}
+#endif
+ SCRIPTID_INIT},
+ {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_COMMA|P_NODUP,
+#ifdef FEAT_LINEBREAK
+ (char_u *)VAR_WIN, PV_BRIOPT,
+ {(char_u *)"", (char_u *)NULL}
+#else
+ (char_u *)NULL, PV_NONE,
+ {(char_u *)"", (char_u *)NULL}
+#endif
+ SCRIPTID_INIT},
{"browsedir", "bsdir",P_STRING|P_VI_DEF,
#ifdef FEAT_BROWSE
(char_u *)&p_bsdir, PV_NONE,
@@ -5256,6 +5278,9 @@ didset_options()
/* set cedit_key */
(void)check_cedit();
#endif
+#ifdef FEAT_LINEBREAK
+ briopt_check();
+#endif
}
/*
@@ -5709,6 +5734,14 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
*p_pm == '.' ? p_pm + 1 : p_pm) == 0)
errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
}
+#ifdef FEAT_LINEBREAK
+ /* 'breakindentopt' */
+ else if (varp == &curwin->w_p_briopt)
+ {
+ if (briopt_check() == FAIL)
+ errmsg = e_invarg;
+ }
+#endif
/*
* 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
@@ -10018,6 +10051,8 @@ get_varp(p)
case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
#ifdef FEAT_LINEBREAK
case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
+ case PV_BRI: return (char_u *)&(curwin->w_p_bri);
+ case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
#endif
#ifdef FEAT_SCROLLBIND
case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
@@ -10207,6 +10242,8 @@ copy_winopt(from, to)
#endif
#ifdef FEAT_LINEBREAK
to->wo_lbr = from->wo_lbr;
+ to->wo_bri = from->wo_bri;
+ to->wo_briopt = vim_strsave(from->wo_briopt);
#endif
#ifdef FEAT_SCROLLBIND
to->wo_scb = from->wo_scb;
@@ -10294,6 +10331,9 @@ check_winopt(wop)
#ifdef FEAT_CONCEAL
check_string_option(&wop->wo_cocu);
#endif
+#ifdef FEAT_LINEBREAK
+ check_string_option(&wop->wo_briopt);
+#endif
}
/*
@@ -10313,6 +10353,9 @@ clear_winopt(wop)
# endif
clear_string_option(&wop->wo_fmr);
#endif
+#ifdef FEAT_LINEBREAK
+ clear_string_option(&wop->wo_briopt);
+#endif
#ifdef FEAT_RIGHTLEFT
clear_string_option(&wop->wo_rlc);
#endif
@@ -11927,3 +11970,49 @@ find_mps_values(initc, findc, backwards, switchit)
++ptr;
}
}
+
+#if defined(FEAT_LINEBREAK) || defined(PROTO)
+/*
+ * This is called when 'breakindentopt' is changed and when a window is
+ * initialized.
+ */
+ int
+briopt_check()
+{
+ char_u *p;
+ int bri_shift = 0;
+ long bri_min = 20;
+ int bri_sbr = FALSE;
+
+ p = curwin->w_p_briopt;
+ while (*p != NUL)
+ {
+ if (STRNCMP(p, "shift:", 6) == 0
+ && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
+ {
+ p += 6;
+ bri_shift = getdigits(&p);
+ }
+ else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
+ {
+ p += 4;
+ bri_min = getdigits(&p);
+ }
+ else if (STRNCMP(p, "sbr", 3) == 0)
+ {
+ p += 3;
+ bri_sbr = TRUE;
+ }
+ if (*p != ',' && *p != NUL)
+ return FAIL;
+ if (*p == ',')
+ ++p;
+ }
+
+ curwin->w_p_brishift = bri_shift;
+ curwin->w_p_brimin = bri_min;
+ curwin->w_p_brisbr = bri_sbr;
+
+ return OK;
+}
+#endif