Re: bug: commandline not visible after :tabedit in maximized window

2007-02-11 Thread Václav Šmilauer
[Bram, sorry for sending to your personal address by accident for the first 
time]

 What system?  If Unix: what GUI?

Sorry for not mentioning that. I am running the gnome GUI on Linux. I 
double-checked on a different machine to exclude the influence of the 
breakindent patch that is also applied. It seems that it works differently 
with Metacity WM than with the Xfce window manager (running the same program 
locally is different from running it remotely); also, the machine with 
Metacity is xinerama-doublehead, which may make some bugs in the WM code 
show up. I will install a clean version here and try to determine if it is 
really a vim bug.


Regards, Vaclav



breakindent, take 2

2007-05-14 Thread Václav Šmilauer

Hello,

I submit patch that implements the 'breakindent' feature. It is on vim todo 
list, since the moment I tried a few years ago (see e.g. 
http://marc.info/?l=vim-devm=109921292009721w=1). Picture says what it's 
about (showbreak is aligned with first non-whitespace):


http://beta.arcig.cz/~eudoxos/vim7/breakindent1.png
http://beta.arcig.cz/~eudoxos/vim7/breakindent2.png

I tried to address all Bram's comments he had to the original patch, like 
coding style, functionality in diff mode, selections etc. I had to change a 
few prototypes to pass line number.


There is one bug and some (easily fixable) limitations:

* BUG: there is some weird interaction with quickfix window, where very 
rarely there is the ml_get(): invalid line number error. I think it is 
caused by passing wrong line number thgouth the *chartabsize*  family 
routines (line in the main buffer interpreted as line in the quickfix window 
or something like that), but I am not sure.


* No test case. This will be added once there is enough interest from 
developers (there _is_ documentation).


* The bri_min variable is not exposed to userspace yet, is set to 20 in the 
code. If the rest is considered ready for inclusion, I will add a 
user-serrable variable for that.


The patch is against current svn (vim7, rev. 288). Any comments are welcome.

Best regards,

Václav Šmilauer


Re: breakindent, take 2

2007-05-27 Thread Václav Šmilauer
* BUG: there is some weird interaction with quickfix window, where very 
rarely there is the ml_get(): invalid line number error. I think it is 
caused by passing wrong line number thgouth the *chartabsize*  family 
routines (line in the main buffer interpreted as line in the quickfix 
window or something like that), but I am not sure.


Thanks to Tim Pope (to whom I wish to give credit for his try and
comments) I was able to debug this one (the code was supposing that the
window in question was always current, which is not the case with
quickfix window (and possibly other cases)). I know of no other bugs at
this moment.

I also added the brimin option (used to be hardcoded at 20). The
hardcoded 8 for numberlines was fixed as well, now uses number_width.

The patch is against svn 296, please go ahead and test.

Regards, Vaclav.


Index: ex_cmds.c
===
--- ex_cmds.c	(revision 296)
+++ ex_cmds.c	(working copy)
@@ -260,7 +260,7 @@
 	;
 save = *last;
 *last = NUL;
-len = linetabsize(line);		/* get line length */
+len = linetabsize(line, curwin-w_cursor.lnum); /* get line length */
 if (has_tab != NULL)		/* check for embedded TAB */
 	*has_tab = (vim_strrchr(first, TAB) != NULL);
 *last = save;
Index: option.c
===
--- option.c	(revision 296)
+++ option.c	(working copy)
@@ -186,6 +186,10 @@
 #ifdef FEAT_ARABIC
 # define PV_ARAB	OPT_WIN(WV_ARAB)
 #endif
+#ifdef FEAT_LINEBREAK
+# define PV_BRI		OPT_WIN(WV_BRI)
+# define PV_BRIMIN	OPT_WIN(WV_BRIMIN)
+#endif
 #ifdef FEAT_DIFF
 # define PV_DIFF	OPT_WIN(WV_DIFF)
 #endif
@@ -627,6 +631,21 @@
 			{(char_u *)0L, (char_u *)0L}
 #endif
 			},
+{breakindent,   bri,  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
+#ifdef FEAT_LINEBREAK
+			(char_u *)VAR_WIN, PV_BRI,
+#else
+			(char_u *)NULL, PV_NONE,
+#endif
+			{(char_u *)FALSE, (char_u *)0L}},
+{breakindentmin, brimin, P_NUM|P_VI_DEF|P_VIM|P_RWIN,
+#ifdef FEAT_LINEBREAK
+			(char_u *)VAR_WIN, PV_BRIMIN,
+#else
+			(char_u *)NULL, PV_NONE,
+#endif
+			{(char_u *)20L, (char_u *)20L}},
+			
 {browsedir,   bsdir,P_STRING|P_VI_DEF,
 #ifdef FEAT_BROWSE
 			(char_u *)p_bsdir, PV_NONE,
@@ -7867,6 +7886,16 @@
 	}
 	curwin-w_nrwidth_line_count = 0;
 }
+
+/* 'breakindentmin' must be positive */
+else if (pp == curwin-w_p_brimin)
+{
+	if (curwin-w_p_brimin  1)
+	{
+	errmsg = e_positive;
+	curwin-w_p_brimin = 1;
+	}
+}
 #endif
 
 /*
@@ -9012,6 +9041,8 @@
 	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_BRIMIN:	return (char_u *)(curwin-w_p_brimin);
 #endif
 #ifdef FEAT_SCROLLBIND
 	case PV_SCBIND: return (char_u *)(curwin-w_p_scb);
@@ -9190,6 +9221,8 @@
 to-wo_wrap = from-wo_wrap;
 #ifdef FEAT_LINEBREAK
 to-wo_lbr = from-wo_lbr;
+to-wo_bri = from-wo_bri;
+to-wo_brimin = from-wo_brimin;
 #endif
 #ifdef FEAT_SCROLLBIND
 to-wo_scb = from-wo_scb;
Index: option.h
===
--- option.h	(revision 296)
+++ option.h	(working copy)
@@ -1007,6 +1007,10 @@
 #ifdef FEAT_ARABIC
 , WV_ARAB
 #endif
+#ifdef FEAT_LINEBREAK
+, WV_BRI
+, WV_BRIMIN
+#endif
 #ifdef FEAT_DIFF
 , WV_DIFF
 #endif
Index: proto/charset.pro
===
--- proto/charset.pro	(revision 296)
+++ proto/charset.pro	(working copy)
@@ -14,8 +14,8 @@
 int vim_strsize __ARGS((char_u *s));
 int vim_strnsize __ARGS((char_u *s, int len));
 int chartabsize __ARGS((char_u *p, colnr_T col));
-int linetabsize __ARGS((char_u *s));
-int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
+int linetabsize __ARGS((char_u *s, linenr_T lnum));
+int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len, linenr_T lnum));
 int vim_isIDc __ARGS((int c));
 int vim_iswordc __ARGS((int c));
 int vim_iswordp __ARGS((char_u *p));
@@ -23,9 +23,9 @@
 int vim_isfilec __ARGS((int c));
 int vim_isprintc __ARGS((int c));
 int vim_isprintc_strict __ARGS((int c));
-int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
-int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
-int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
+int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col, linenr_T lnum));
+int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col, linenr_T lnum));
+int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp, linenr_T lnum));
 int in_win_border __ARGS((win_T *wp, colnr_T vcol));
 void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
 colnr_T getvcol_nolist __ARGS((pos_T *posp));
Index: proto/misc1.pro
===
--- proto/misc1.pro	

Re: breakindent, take 2

2007-05-29 Thread Václav Šmilauer
It would be nice if I could specificy additional indent for continuation 
lines.
You make indent for continuation line *EQUAL* to indent of the 1st 
screen line.


I use showbreak for this. Wouldn't breakindent=2 just duplicate the 
funcitonality of ':set breakindent' and ':set showbreak=\ \ ' (except 
the higlighting color)? It would not be difficult to add, though.
(And for negative breakindent, well, I would think this is rather 
typesetting issue; but it is true once breakindent is a number, that 
would be trivial enhancement).


Vaclav



Re: breakindent, take 2

2007-05-29 Thread Václav Šmilauer

Would there be any benefit from making it a string option that
accepted numbers only, so there could be three styles?

breakindent=nabsolute positioning or broken lines
breakindent=+n   broken lines have additional indentation
breakindent=-n   broken lines have reduced indentation


I am a bit at loss now:

(a) if I switch to breakindent being a number, how will it be turned 
off? As suggested, the actual breakindent is 0, positive/negative values 
would be possible for shifting the indent right/left. But there is no 
value to say: no breakindent, except for the suggestion


(b) breakindent being string and parsing 0' as no breakindent, +0 
(=-0) as keep the indentation, etc for +-1, ... . But it is 
non-intuitive to have +0==-0!=0 and I am not sure how to do that (e.g. 
what variable will keep that in? if string, it will be very slow, it 
would have to be parsed at every line being displayed (!) etc.).


(c) Another option would be to have a numerical value 'breakindentextra' 
 or 'breakindentshift' (or some different name) taking numerical 
(negative, 0, positive) that would do the extra indent, while keeping 
breakindent bool to turn that on/off. But that gives 3 variables (bri, 
brimin, briextra).


(d) To save the variable, 'breakindentmin' could be used do disable 
breakindent (if 0, since that makes no sense) or enable it (if 0), 
while breakindentextra would be as sub (c). In this case, 
'breakindentmin' would be probably renamed to breakindent. But it is not 
very intuitive.


What do you think? I prefer (c) from implementation, efficiency and 
intuitivity perspective.


Vaclav


Re: breakindent, take 2

2007-05-30 Thread Václav Šmilauer
What do you think? I prefer (c) from implementation, efficiency and 
intuitivity perspective.


I agree. Strongly.


Based on popular demand, this patch implements, in addition, 
'breakindentshift' (brishift). It seems to work well, report problems. 
And please suggestions for some shorter names: breakindent is already 
long enough, breakindentshift is not nice at all.


Vaclav
Index: runtime/doc/eval.txt
===
--- runtime/doc/eval.txt	(revision 296)
+++ runtime/doc/eval.txt	(working copy)
@@ -5262,8 +5262,8 @@
 keymap			Compiled with 'keymap' support.
 langmap			Compiled with 'langmap' support.
 libcall			Compiled with |libcall()| support.
-linebreak		Compiled with 'linebreak', 'breakat' and 'showbreak'
-			support.
+linebreak		Compiled with 'linebreak', 'breakat', 'showbreak' and
+			'breakindent' support.
 lispindent		Compiled with support for lisp indenting.
 listcmds		Compiled with commands for the buffer list |:files|
 			and the argument list |arglist|.
Index: runtime/doc/options.txt
===
--- runtime/doc/options.txt	(revision 296)
+++ runtime/doc/options.txt	(working copy)
@@ -1145,6 +1145,39 @@
 	break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
 	characters when 'encoding' is an 8-bit encoding.
 
+	
+		*'breakindent'* *'bri'*
+'breakindent' 'bri'	boolean (default off)
+			local to window
+			{not in Vi}
+			{not available when compiled without the |+linebreak|
+			feature}
+	Every wrapped line will continue visually indented (same amount of
+	space as the beginning of that line), thus preserving horizontal blocks
+	of text.
+
+		*'breakindentmin'* *'brimin'*
+'breakindentmin' 'brimin' number (default 20)
+			local to window
+			{not in Vi}
+			{not available when compiled without the |+linebreak|
+			feature}
+	Minimum text width that will be kept after applying 'breakindent',
+	even if the resulting text should normally be narrower. This prevents
+	text indented almost to the right window border oocupying lot of
+	vertical space when broken.
+
+		*'breakindentshift'* *'brishift'*
+'breakindentshift' 'brishift' number (default 20)
+			local to window
+			{not in Vi}
+			{not available when compiled without the |+linebreak|
+			feature}
+	After applying 'breakindent', wrapped line beginning will be shift by
+	given number of characters. It permits dynamic French paragraph
+	indentation (negative) or emphasizing the line continuation
+	(positive).
+
 		*'browsedir'* *'bsdir'*
 'browsedir' 'bsdir'	string	(default: last)
 			global
@@ -4227,12 +4260,13 @@
 			{not in Vi}
 			{not available when compiled without the  |+linebreak|
 			feature}
-	If on Vim will wrap long lines at a character in 'breakat' rather
+	If on, Vim will wrap long lines at a character in 'breakat' rather
 	than at the last character that fits on the screen.  Unlike
 	'wrapmargin' and 'textwidth', this does not insert EOLs in the file,
-	it only affects the way the file is displayed, not its contents.  The
-	value of 'showbreak' is used to put in front of wrapped lines.
-	This option is not used when the 'wrap' option is off or 'list' is on.
+	it only affects the way the file is displayed, not its contents.
+	If 'breakindent' is set, line is visually indented. Then, the value
+	of 'showbreak' is used to put in front of wrapped lines. This option
+	is not used when the 'wrap' option is off or 'list' is on.
 	Note that Tab characters after an EOL are mostly not displayed
 	with the right amount of white space.
 
Index: runtime/optwin.vim
===
--- runtime/optwin.vim	(revision 296)
+++ runtime/optwin.vim	(working copy)
@@ -329,6 +329,15 @@
 call append($, linebreak\twrap long lines at a character in 'breakat')
 call append($, \t(local to window))
 call SIDBinOptionL(lbr)
+call append($, breakindent\tpreserve indentation in wrapped text)
+call append($, \t(local to window))
+call SIDBinOptionL(bri)
+call append($, breakindentmin\tminimum text width after indent in 'breakindent')
+call append($, \t(local to window))
+call SIDOptionL(brimin)
+call append($, breakindentshift\tshift beginning of 'breakindent'ed line by this number of characters (negative left))
+call append($, \t(local to window))
+call SIDOptionL(brishift)
 call append($, breakat\twhich characters might cause a line break)
 call SIDOptionG(brk, brk)
 call append($, showbreak\tstring to put before wrapped screen lines)
Index: src/ex_cmds.c
===
--- src/ex_cmds.c	(revision 296)
+++ src/ex_cmds.c	(working copy)
@@ -260,7 +260,7 @@
 	;
 save = *last;
 *last = NUL;
-len = linetabsize(line);		/* get line length */
+len = linetabsize(line, curwin-w_cursor.lnum); /* get line length */
 if (has_tab != NULL)		/* check for embedded TAB */
 	*has_tab = (vim_strrchr(first, TAB) !=