1 function! Pl#Theme#Create(...) " {{{
2 let buffer_segments = []
4 for buffer_segment in a:000
5 " Remove empty segments (e.g. 'Pl#Theme#Function's)
6 if empty(buffer_segment)
10 call add(buffer_segments, buffer_segment)
13 let buffer_segments = Pl#Colorscheme#Apply(g:Powerline_colorscheme, buffer_segments)
15 return buffer_segments
17 function! Pl#Theme#Callback(name, expr) " {{{
18 return ['callback', a:name, a:expr]
20 function! Pl#Theme#Buffer(ns, ...) " {{{
22 let ns = ! empty(a:ns) ? a:ns .':' : ''
24 " Match namespace parameter by default
25 let matches = Pl#Match#Any(a:ns)
29 let args = Pl#Mod#ApplySegmentMods(args)
31 " Fetch segment data dicts
33 if type(item) == type([])
35 " Match item, overrides default namespace match
40 elseif item[0] == 'callback'
41 " Store the item as a callback expression
42 let matches = ['match', 'none']
43 let callback = [a:ns, item[1], item[2]]
49 " printf segment, append ns to first item in list
50 let item[0] = ns . item[0]
55 let segment = Pl#Segment#Get(item)
58 " Skip empty (possible disabled) segments
59 call add(segments, segment)
67 \ , 'callback': callback
68 \ , 'segments': segments
71 function! Pl#Theme#InsertSegment(new_segment, where, target_segment) " {{{
72 " It's very important to NOT refer to the theme dict until everything's loaded!
74 " Because these functions are called from the vimrc, we need to put the
75 " actions in a list which will be parsed later.
77 " These functions don't accept a name parameter, because they work on the
78 " currently selected theme (will change any selected theme)
79 call Pl#Mod#AddSegmentMod('insert_segment', {
80 \ 'new_segment': a:new_segment,
82 \ 'target_segment': a:target_segment
85 function! Pl#Theme#RemoveSegment(target_segment) " {{{
86 " It's very important to NOT refer to the theme dict until everything's loaded!
88 " Because these functions are called from the vimrc, we need to put the
89 " actions in a list which will be parsed later.
91 " These functions don't accept a name parameter, because they work on the
92 " currently selected theme (will change any selected theme)
93 call Pl#Mod#AddSegmentMod('remove_segment', {
94 \ 'target_segment': a:target_segment
97 function! Pl#Theme#ReplaceSegment(old_segment, new_segment) " {{{
98 call Pl#Theme#InsertSegment(a:new_segment, 'after', a:old_segment)
99 call Pl#Theme#RemoveSegment(a:old_segment)