@@ -469,14 +469,25 @@ function! s:CreateSynMatch(color, pattern)
469
469
return ' '
470
470
endfunction
471
471
472
+ let s: _funcname = ' \(rgb\|hsl\)a\?'
473
+ let s: _numval = ' \(\d\{1,3}%\?\)'
474
+ let s: _ws_ = ' \s*'
475
+ let s: _listsep = s: _ws_ . ' ,' . s: _ws_
476
+ let s: _otherargs_ = ' \%(,[^)]*\)\?'
477
+ let s: _funcexpr = s: _funcname . ' [(]' . s: _numval . s: _listsep . s: _numval . s: _listsep . s: _numval . s: _ws_ . s: _otherargs_ . ' [)]'
478
+ let s: _hexcolor = ' #\(\x\{3}\|\x\{6}\)\>'
479
+ let s: _grammar = s: _funcexpr . ' \|' . s: _hexcolor
472
480
function ! s: ParseScreen ()
473
- " N.B. these substitute() calls are here just for the side effect
481
+ " N.B. this substitute() call is here just for the side effect
474
482
" of invoking s:CreateSynMatch during substitution -- because
475
483
" match() and friends do not allow finding all matches in a single
476
484
" scan without examining the start of the string over and over
477
- call substitute ( substitute ( join ( getline (' w0' ,' w$' ), " \n " ),
478
- \ ' #\(\x\{3}\|\x\{6}\)\>' , ' \=s:CreateSynMatch(submatch(1), submatch(0))' , ' g' ),
479
- \ ' \(rgb\|hsl\)a\?(\s*\(\d\{1,3}%\?\)\s*,\s*\(\d\{1,3}%\?\)\s*,\s*\(\d\{1,3}%\?\)\s*\%(,[^)]*\)\?)' , ' \=s:CreateSynMatch(submatch(1) == "rgb" ? s:RGB2Color(submatch(2),submatch(3),submatch(4)) : s:HSL2Color(submatch(2),submatch(3),submatch(4)), submatch(0))' , ' g' )
485
+ call substitute ( join ( getline (' w0' ,' w$' ), " \n " ), s: _grammar ,
486
+ \ ' \=s:CreateSynMatch(('
487
+ \ . ' submatch(1) == "rgb" ? s:RGB2Color(submatch(2),submatch(3),submatch(4)) :'
488
+ \ . ' submatch(1) == "hsl" ? s:HSL2Color(submatch(2),submatch(3),submatch(4)) :'
489
+ \ . ' submatch(5)'
490
+ \ . ' ), submatch(0))' , ' g' )
480
491
endfunction
481
492
482
493
call s: ParseScreen ()
0 commit comments