Source

ansi_esc_echo / autoload / ansi_esc_echo.vim

Diff from to

autoload/ansi_esc_echo.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@/resources': '0.0'})
+execute frawor#Setup('0.0', {'@/resources': '0.0',
+            \                  '@/options': '0.0',
+            \                       '@/os': '0.0',})
 let s:r={}
+let s:_options={
+            \'color_file': {'default': s:_r.os.path.join(s:_frawor.runtimepath,
+            \                                            'config',
+            \                                            'ansi_esc_echo',
+            \                                            'colors.yaml'),
+            \                'scopes': 'g',
+            \               'checker': 'either (is=(0) path)'},
+        \}
+let s:_messages={
+            \'misscol': 'Color file is missing',
+        \}
+"▶1 Get colors
+if has('gui_running')
+    let s:pref='gui'
+    let s:colorfile=s:_f.getoption('ColorFile')
+    let s:colorfile=
+    if !filereadable(s:colorfile)
+        call s:_f.warn('misscol')
+    else
+        let s:colors=map(filter(readfile(s:colorfile, 'b'), 'v:val[:1]==#"- "'),
+                    \    'v:val[3:9]')
+    endif
+    function s:F.getcolor(key, spec)
+        return 'gui'.a:key.'='.((type(a:spec)==type(0))?
+                    \               get(s:colors, a:spec, 'NONE'):
+                    \               a:spec)
+    endfunction
+else
+    let s:pref='cterm'
+    function s:F.getcolor(key, spec)
+        return 'cterm'.a:key.'='.a:spec
+    endfunction
+endif
 "▶1 addtext
 function s:F.addtext(lines, text)
     if a:lines.col==len(a:lines.cur.line)
     if !has_key(s:hls, hl)
         let cmd='hi '.hl.' '
         for key in filter(['fg', 'bg'], 'has_key(a:color, v:val)')
-            let cmd.=' cterm'.key.'='.a:color[key]
-            " TODO guifg/guibg
+            let cmd.=' '.s:F.getcolor(key, a:color[key])
         endfor
         if has_key(a:color, 'fattrs') && !empty(a:color.fattrs)
-            let cmd.=' cterm='.join(a:color.fattr, ',')
-            let cmd.=' gui='.join(a:color.fattr, ',')
+            let cmd.=' '.s:pref.'='.join(a:color.fattr, ',')
         endif
         execute cmd
         let s:hls[hl]=1