]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5066: timer_create is not available on every Mac system v8.2.5066
authorBram Moolenaar <Bram@vim.org>
Tue, 7 Jun 2022 09:16:15 +0000 (10:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 7 Jun 2022 09:16:15 +0000 (10:16 +0100)
Problem:    Timer_create is not available on every Mac system. (Hisashi T
            Fujinaka)
Solution:   Adjust #ifdef.

runtime/doc/options.txt
src/drawline.c
src/message.c
src/screen.c
src/structs.h
src/testdir/test_listchars.vim
src/version.c
src/window.c

index 799b856a7b6c4750d691ff7dc21653b79c28f468..932570c60cdcf2399bf79469536dbfbde1e8b8ce 100644 (file)
@@ -5076,14 +5076,23 @@ A jump table for the options with a short description can be found at |Q_op|.
                        "space" setting is used.  For example,
                        `:set listchars=multispace:---+` shows ten consecutive
                        spaces as:
-                               ---+---+--
+                               ---+---+-- ~
                                                        *lcs-lead*
          lead:c        Character to show for leading spaces.  When omitted,
                        leading spaces are blank.  Overrides the "space" and
                        "multispace" settings for leading spaces.  You can
                        combine it with "tab:", for example: >
                                :set listchars+=tab:>-,lead:.
-<                                                      *lcs-trail*
+<                                                      *lcs-leadmultispace*
+         leadmultispace:c...
+                       Like multispace value, but only for leading whitespace
+                       Overrides |lcs-lead| for leading multiple spaces.
+                       `:set listchars=leadmultispace:---+` shows ten consecutive
+                       leading spaces as:
+                               ---+---+--XXX ~
+                       Where "XXX" denotes the first non-blank characters in
+                       the line.
+                                                       *lcs-trail*
          trail:c       Character to show for trailing spaces.  When omitted,
                        trailing spaces are blank.  Overrides the "space" and
                        "multispace" settings for trailing spaces.
index a8739fe3d1a9e8be9f08f013c5fdfe96cb349d7c..59c62c79d378049bf41b59cbfb29a956e681dd28 100644 (file)
@@ -767,6 +767,7 @@ win_line(
     {
        if (wp->w_lcs_chars.space
                || wp->w_lcs_chars.multispace != NULL
+               || wp->w_lcs_chars.leadmultispace != NULL
                || wp->w_lcs_chars.trail
                || wp->w_lcs_chars.lead
                || wp->w_lcs_chars.nbsp)
@@ -781,7 +782,7 @@ win_line(
            trailcol += (colnr_T) (ptr - line);
        }
        // find end of leading whitespace
-       if (wp->w_lcs_chars.lead)
+       if (wp->w_lcs_chars.lead || wp->w_lcs_chars.leadmultispace != NULL)
        {
            leadcol = 0;
            while (VIM_ISWHITE(ptr[leadcol]))
@@ -2118,8 +2119,24 @@ win_line(
                if ((trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
                        || (leadcol != 0 && ptr < line + leadcol && c == ' '))
                {
-                   c = (ptr > line + trailcol) ? wp->w_lcs_chars.trail
-                                                       : wp->w_lcs_chars.lead;
+                   if (leadcol != 0 && in_multispace && ptr < line + leadcol
+                           && wp->w_lcs_chars.leadmultispace != NULL)
+                   {
+                       c = wp->w_lcs_chars.leadmultispace[multispace_pos++];
+                       if (wp->w_lcs_chars.leadmultispace[multispace_pos] == NUL)
+                           multispace_pos = 0;
+                   }
+
+                   else if (ptr > line + trailcol && wp->w_lcs_chars.trail)
+                       c = wp->w_lcs_chars.trail;
+
+                   else if (ptr < line + leadcol && wp->w_lcs_chars.lead)
+                       c = wp->w_lcs_chars.lead;
+
+                   else if (leadcol != 0 && c == ' ' && wp->w_lcs_chars.space)
+                       c = wp->w_lcs_chars.space;
+
+
                    if (!attr_pri)
                    {
                        n_attr = 1;
index 6e21d665ddc3ad5f633593ab461c716a7dfae8ba..c6bf6da00702a709070a70a5a6ae634618cc5721 100644 (file)
@@ -1881,7 +1881,7 @@ msg_prt_line(char_u *s, int list)
                --trail;
        }
        // find end of leading whitespace
-       if (curwin->w_lcs_chars.lead)
+       if (curwin->w_lcs_chars.lead || curwin->w_lcs_chars.leadmultispace != NULL)
        {
            lead = s;
            while (VIM_ISWHITE(lead[0]))
@@ -1993,7 +1993,15 @@ msg_prt_line(char_u *s, int list)
            }
            else if (c == ' ')
            {
-               if (lead != NULL && s <= lead)
+               if (list && lead != NULL && s <= lead && in_multispace
+                       && curwin->w_lcs_chars.leadmultispace != NULL)
+               {
+                   c = curwin->w_lcs_chars.leadmultispace[multispace_pos++];
+                   if (curwin->w_lcs_chars.leadmultispace[multispace_pos] == NUL)
+                       multispace_pos = 0;
+                   attr = HL_ATTR(HLF_8);
+               }
+               else if (lead != NULL && s <= lead && curwin->w_lcs_chars.lead)
                {
                    c = curwin->w_lcs_chars.lead;
                    attr = HL_ATTR(HLF_8);
@@ -2003,6 +2011,14 @@ msg_prt_line(char_u *s, int list)
                    c = curwin->w_lcs_chars.trail;
                    attr = HL_ATTR(HLF_8);
                }
+               else if (list && lead != NULL && s <= lead && in_multispace
+                       && curwin->w_lcs_chars.leadmultispace != NULL)
+               {
+                   c = curwin->w_lcs_chars.leadmultispace[multispace_pos++];
+                   if (curwin->w_lcs_chars.leadmultispace[multispace_pos] == NUL)
+                       multispace_pos = 0;
+                   attr = HL_ATTR(HLF_8);
+               }
                else if (list && in_multispace
                        && curwin->w_lcs_chars.multispace != NULL)
                {
index 29ccd3e3ee28e4ca0ee08510b98cf3a08ba3c2e0..503587953d182d902e146a84a142357004b32c78 100644 (file)
@@ -4831,11 +4831,13 @@ get_encoded_char_adv(char_u **p)
     char *
 set_chars_option(win_T *wp, char_u **varp)
 {
-    int                round, i, len, entries;
+    int                round, i, len, len2, entries;
     char_u     *p, *s;
     int                c1 = 0, c2 = 0, c3 = 0;
     char_u     *last_multispace = NULL; // Last occurrence of "multispace:"
+    char_u     *last_lmultispace = NULL; // Last occurrence of "leadmultispace:"
     int                multispace_len = 0;      // Length of lcs-multispace string
+    int                lead_multispace_len = 0; // Length of lcs-leadmultispace string
     struct charstab
     {
        int     *cp;
@@ -4909,6 +4911,14 @@ set_chars_option(win_T *wp, char_u **varp)
                }
                else
                    lcs_chars.multispace = NULL;
+
+               if (lead_multispace_len > 0)
+               {
+                   lcs_chars.leadmultispace = ALLOC_MULT(int, lead_multispace_len + 1);
+                   lcs_chars.leadmultispace[lead_multispace_len] = NUL;
+               }
+               else
+                   lcs_chars.leadmultispace = NULL;
            }
            else
            {
@@ -4972,6 +4982,7 @@ set_chars_option(win_T *wp, char_u **varp)
            if (i == entries)
            {
                len = (int)STRLEN("multispace");
+               len2 = (int)STRLEN("leadmultispace");
                if ((varp == &p_lcs || varp == &wp->w_p_lcs)
                        && STRNCMP(p, "multispace", len) == 0
                        && p[len] == ':'
@@ -5008,6 +5019,43 @@ set_chars_option(win_T *wp, char_u **varp)
                        p = s;
                    }
                }
+
+               else if ((varp == &p_lcs || varp == &wp->w_p_lcs)
+                       && STRNCMP(p, "leadmultispace", len2) == 0
+                       && p[len2] == ':'
+                       && p[len2 + 1] != NUL)
+               {
+                   s = p + len2 + 1;
+                   if (round == 0)
+                   {
+                       // Get length of lcsmultispace string in first round
+                       last_lmultispace = p;
+                       lead_multispace_len = 0;
+                       while (*s != NUL && *s != ',')
+                       {
+                           c1 = get_encoded_char_adv(&s);
+                           if (char2cells(c1) > 1)
+                               return e_invalid_argument;
+                           ++lead_multispace_len;
+                       }
+                       if (lead_multispace_len == 0)
+                           // lcsmultispace cannot be an empty string
+                           return e_invalid_argument;
+                       p = s;
+                   }
+                   else
+                   {
+                       int multispace_pos = 0;
+
+                       while (*s != NUL && *s != ',')
+                       {
+                           c1 = get_encoded_char_adv(&s);
+                           if (p == last_lmultispace)
+                               lcs_chars.leadmultispace[multispace_pos++] = c1;
+                       }
+                       p = s;
+                   }
+               }
                else
                    return e_invalid_argument;
            }
@@ -5020,6 +5068,8 @@ set_chars_option(win_T *wp, char_u **varp)
     {
        if (wp->w_lcs_chars.multispace != NULL)
            vim_free(wp->w_lcs_chars.multispace);
+       if (wp->w_lcs_chars.leadmultispace != NULL)
+           vim_free(wp->w_lcs_chars.leadmultispace);
        wp->w_lcs_chars = lcs_chars;
     }
 
index 4666d026138b15b036f22e64291304fb98a5cd70..58152b98bf23c17c82716d791e322f1f8eff8a2f 100644 (file)
@@ -3411,6 +3411,7 @@ typedef struct
     int                trail;
     int                lead;
     int                *multispace;
+    int                *leadmultispace;
 #ifdef FEAT_CONCEAL
     int                conceal;
 #endif
index 90e3d6b24195de4f4f612e78a6756713c204c066..0977543ba1667c9696fcfcd51e68aed487c55b95 100644 (file)
@@ -132,7 +132,7 @@ func Test_listchars()
              \ 'h<<<<<<<<<<<$',
              \ '<<<<<<<<<<<<$',
              \ '>>>>0xx0<<<<$',
-              \ '$'
+        \ '$'
              \ ]
   redraw!
   for i in range(1, 5)
@@ -162,7 +162,7 @@ func Test_listchars()
              \ ' hyYzZyYzZyY$',
              \ 'yYzZyYzZyYj $',
              \ 'yYzZ0yY0yYzZ$',
-              \ '$'
+        \ '$'
              \ ]
   redraw!
   for i in range(1, 5)
@@ -172,7 +172,133 @@ func Test_listchars()
 
   call assert_equal(expected, split(execute("%list"), "\n"))
 
+  " Test leadmultispace + multispace
+  normal ggdG
+  set listchars=eol:$,multispace:yYzZ,nbsp:S
+  set listchars+=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+             \ '    ffff    ',
+             \ '  i i     gg',
+             \ ' h          ',
+             \ '          j ',
+             \ '    0  0    ',
+             \ ])
+
+  let expected = [
+             \ '.-+*ffffyYzZ$',
+             \ '.-i iSyYzZgg$',
+             \ ' hyYzZyYzZyY$',
+             \ '.-+*.-+*.-j $',
+             \ '.-+*0yY0yYzZ$',
+        \ '$'
+             \ ]
+  redraw!
+  call assert_equal('eol:$,multispace:yYzZ,nbsp:S,leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace without multispace
+  normal ggdG
+  set listchars-=multispace:yYzZ
+  set listchars+=space:+,trail:>,eol:$
+  set list
+
+  call append(0, [
+             \ '    ffff    ',
+             \ '  i i     gg',
+             \ ' h          ',
+             \ '          j ',
+             \ '    0  0    ',
+             \ ])
+
+  let expected = [
+             \ '.-+*ffff>>>>$',
+             \ '.-i+i+++++gg$',
+             \ '+h>>>>>>>>>>$',
+             \ '.-+*.-+*.-j>$',
+             \ '.-+*0++0>>>>$',
+        \ '$',
+             \ ]
+
+  redraw!
+  call assert_equal('eol:$,nbsp:S,leadmultispace:.-+*,space:+,trail:>,eol:$', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace only
+  normal ggdG
+  set listchars&
+  set listchars=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+             \ '    ffff    ',
+             \ '  i i     gg',
+             \ ' h          ',
+             \ '          j ',
+             \ '    0  0    ',
+             \ ])
+
+  let expected = [
+             \ '.-+*ffff    ',
+             \ '.-i i     gg',
+             \ ' h          ',
+             \ '.-+*.-+*.-j ',
+             \ '.-+*0  0    ',
+        \ ' ',
+             \ ]
+  redraw!
+  call assert_equal('leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, 12))
+  endfor
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace and lead and space
+  normal ggdG
+  set listchars&
+  set listchars+=lead:<,space:-
+  set listchars+=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+             \ '    ffff    ',
+             \ '  i i     gg',
+             \ ' h          ',
+             \ '          j ',
+             \ '    0  0    ',
+             \ ])
+
+  let expected = [
+             \ '.-+*ffff----$',
+             \ '.-i-i-----gg$',
+             \ '<h----------$',
+             \ '.-+*.-+*.-j-$',
+             \ '.-+*0--0----$',
+        \ '$',
+             \ ]
+  redraw!
+  call assert_equal('eol:$,lead:<,space:-,leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
   " the last occurrence of 'multispace:' is used
+  set listchars&
+  set listchars+=multispace:yYzZ
   set listchars+=space:x,multispace:XyY
 
   let expected = [
@@ -181,9 +307,10 @@ func Test_listchars()
              \ 'xhXyYXyYXyYX$',
              \ 'XyYXyYXyYXjx$',
              \ 'XyYX0Xy0XyYX$',
-              \ '$'
+        \ '$'
              \ ]
   redraw!
+  call assert_equal('eol:$,multispace:yYzZ,space:x,multispace:XyY', &listchars)
   for i in range(1, 5)
     call cursor(i, 1)
     call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
@@ -199,7 +326,7 @@ func Test_listchars()
              \ '>h<<<<<<<<<<$',
              \ '>>>>>>>>>>j<$',
              \ '>>>>0Xy0<<<<$',
-              \ '$'
+        \ '$'
              \ ]
   redraw!
   for i in range(1, 5)
@@ -219,7 +346,7 @@ func Test_listchars()
              \ '>h<<<<<<<<<<$',
              \ '>>>>>>>>>>j<$',
              \ '>>>>0xx0<<<<$',
-              \ '$'
+        \ '$'
              \ ]
   redraw!
   for i in range(1, 5)
@@ -315,11 +442,13 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=x', 'E474:')
   call assert_fails('set listchars=x', 'E474:')
   call assert_fails('set listchars=multispace', 'E474:')
+  call assert_fails('set listchars=leadmultispace', 'E474:')
 
   " Too short
   call assert_fails('set listchars=space:', 'E474:')
   call assert_fails('set listchars=tab:x', 'E474:')
   call assert_fails('set listchars=multispace:', 'E474:')
+  call assert_fails('set listchars=leadmultispace:', 'E474:')
 
   " One occurrence too short
   call assert_fails('set listchars=space:,space:x', 'E474:')
@@ -328,6 +457,8 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx,tab:x', 'E474:')
   call assert_fails('set listchars=multispace:,multispace:x', 'E474:')
   call assert_fails('set listchars=multispace:x,multispace:', 'E474:')
+  call assert_fails('set listchars=leadmultispace:,leadmultispace:x', 'E474:')
+  call assert_fails('set listchars=leadmultispace:x,leadmultispace:', 'E474:')
 
   " Too long
   call assert_fails('set listchars=space:xx', 'E474:')
@@ -340,6 +471,8 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx·', 'E474:')
   call assert_fails('set listchars=multispace:·', 'E474:')
   call assert_fails('set listchars=multispace:xxx·', 'E474:')
+  call assert_fails('set listchars=leadmultispace:·', 'E474:')
+  call assert_fails('set listchars=leadmultispace:xxx·', 'E474:')
 
   " Has control character
   call assert_fails("set listchars=space:\x01", 'E474:')
@@ -354,6 +487,10 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx\\x01', 'E474:')
   call assert_fails('set listchars=multispace:\\x01', 'E474:')
   call assert_fails('set listchars=multispace:xxx\\x01', 'E474:')
+  call assert_fails("set listchars=leadmultispace:\x01", 'E474:')
+  call assert_fails('set listchars=leadmultispace:\\x01', 'E474:')
+  call assert_fails("set listchars=leadmultispace:xxx\x01", 'E474:')
+  call assert_fails('set listchars=leadmultispace:xxx\\x01', 'E474:')
 
   enew!
   set ambiwidth& listchars& ff&
index a131b35a37806d22b2401ab64e48bca559c7790e..34266c1a21805ed42e34e45c0bd9633c1347e2f8 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5066,
 /**/
     5065,
 /**/
index 9b5ac97286cdc776dd4a8c71f6b3cfb247276566..992593bed9828e2e76ad62ec5f1002f2ab699386 100644 (file)
@@ -5188,6 +5188,7 @@ win_free(
     clear_winopt(&wp->w_allbuf_opt);
 
     vim_free(wp->w_lcs_chars.multispace);
+    vim_free(wp->w_lcs_chars.leadmultispace);
 
 #ifdef FEAT_EVAL
     vars_clear(&wp->w_vars->dv_hashtab);       // free all w: variables