Skip to content

Commit e6de778

Browse files
committed
add custom sort order
1 parent d64ca73 commit e6de778

File tree

5 files changed

+274
-11
lines changed

5 files changed

+274
-11
lines changed

CSScomb - Order.sublime-settings

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
{
2+
"sort_order": [
3+
"position",
4+
"top",
5+
"right",
6+
"bottom",
7+
"left",
8+
"z-index",
9+
"float",
10+
"clear",
11+
"display",
12+
"visibility",
13+
"overflow",
14+
"overflow-x",
15+
"overflow-y",
16+
"overflow-style",
17+
"clip",
18+
"-webkit-box-sizing",
19+
"-moz-box-sizing",
20+
"box-sizing",
21+
"margin",
22+
"margin-top",
23+
"margin-right",
24+
"margin-bottom",
25+
"margin-left",
26+
"padding",
27+
"padding-top",
28+
"padding-right",
29+
"padding-bottom",
30+
"padding-left",
31+
"height",
32+
"width",
33+
"max-width",
34+
"max-height",
35+
"min-width",
36+
"min-height",
37+
"outline",
38+
"outline-width",
39+
"outline-style",
40+
"outline-color",
41+
"outline-offset",
42+
"border",
43+
"border-collapse",
44+
"border-color",
45+
"border-style",
46+
"border-width",
47+
"border-top",
48+
"border-right",
49+
"border-bottom",
50+
"border-left",
51+
"-webkit-border-radius",
52+
"-khtml-border-radius",
53+
"-moz-border-radius",
54+
"border-radius",
55+
"-webkit-border-top-right-radius",
56+
"-khtml-border-top-right-radius",
57+
"-moz-border-top-right-radius",
58+
"-moz-border-radius-topright",
59+
"border-top-right-radius",
60+
"-webkit-border-bottom-right-radius",
61+
"-khtml-border-bottom-right-radius",
62+
"-moz-border-bottom-right-radius",
63+
"-moz-border-radius-bottomright",
64+
"border-bottom-right-radius",
65+
"-webkit-border-bottom-left-radius",
66+
"-khtml-border-bottom-left-radius",
67+
"-moz-border-bottom-left-radius",
68+
"-moz-border-radius-bottomleft",
69+
"border-bottom-left-radius",
70+
"-webkit-border-top-left-radius",
71+
"-khtml-border-top-left-radius",
72+
"-moz-border-top-left-radius",
73+
"-moz-border-radius-topleft",
74+
"border-top-left-radius",
75+
"-webkit-border-image",
76+
"-moz-border-image",
77+
"-o-border-image",
78+
"border-image",
79+
"-webkit-border-image-source",
80+
"-moz-border-image-source",
81+
"-o-border-image-source",
82+
"border-image-source",
83+
"-webkit-border-image-slice",
84+
"-moz-border-image-slice",
85+
"-o-border-image-slice",
86+
"border-image-slice",
87+
"-webkit-border-image-width",
88+
"-moz-border-image-width",
89+
"-o-border-image-width",
90+
"border-image-width",
91+
"-webkit-border-image-outset",
92+
"-moz-border-image-outset",
93+
"-o-border-image-outset",
94+
"border-image-outset",
95+
"-webkit-border-image-repeat",
96+
"-moz-border-image-repeat",
97+
"-o-border-image-repeat",
98+
"border-image-repeat",
99+
"-webkit-border-top-image",
100+
"-moz-border-top-image",
101+
"-o-border-top-image",
102+
"border-top-image",
103+
"-webkit-border-right-image",
104+
"-moz-border-right-image",
105+
"-o-border-right-image",
106+
"border-right-image",
107+
"-webkit-border-bottom-image",
108+
"-moz-border-bottom-image",
109+
"-o-border-bottom-image",
110+
"border-bottom-image",
111+
"-webkit-border-left-image",
112+
"-moz-border-left-image",
113+
"-o-border-left-image",
114+
"border-left-image",
115+
"-webkit-border-corner-image",
116+
"-moz-border-corner-image",
117+
"-o-border-corner-image",
118+
"border-corner-image",
119+
"-webkit-border-top-left-image",
120+
"-moz-border-top-left-image",
121+
"-o-border-top-left-image",
122+
"border-top-left-image",
123+
"-webkit-border-top-right-image",
124+
"-moz-border-top-right-image",
125+
"-o-border-top-right-image",
126+
"border-top-right-image",
127+
"-webkit-border-bottom-right-image",
128+
"-moz-border-bottom-right-image",
129+
"-o-border-bottom-right-image",
130+
"border-bottom-right-image",
131+
"-webkit-border-bottom-left-image",
132+
"-moz-border-bottom-left-image",
133+
"-o-border-bottom-left-image",
134+
"border-bottom-left-image",
135+
"background",
136+
"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
137+
"background-color",
138+
"background-image",
139+
"background-position",
140+
"background-size",
141+
"background-repeat",
142+
"background-attachment",
143+
"background-clip",
144+
"background-origin",
145+
"box-decoration-break",
146+
"-webkit-box-shadow",
147+
"-moz-box-shadow",
148+
"box-shadow",
149+
"color",
150+
"table-layout",
151+
"caption-side",
152+
"empty-cells",
153+
"list-style",
154+
"list-style-position",
155+
"list-style-type",
156+
"list-style-image",
157+
"quotes",
158+
"content",
159+
"counter-increment",
160+
"counter-reset",
161+
"vertical-align",
162+
"text-align",
163+
"text-decoration",
164+
"text-emphasis",
165+
"text-indent",
166+
"text-justify",
167+
"text-outline",
168+
"text-transform",
169+
"text-wrap",
170+
"text-overflow",
171+
"text-overflow-ellipsis",
172+
"text-overflow-mode",
173+
"text-shadow",
174+
"white-space",
175+
"word-spacing",
176+
"word-wrap",
177+
"-moz-tab-size",
178+
"-o-tab-size",
179+
"tab-size",
180+
"letter-spacing",
181+
"font",
182+
"font-weight",
183+
"font-style",
184+
"font-variant",
185+
"font-size-adjust",
186+
"font-stretch",
187+
"font-size",
188+
"font-family",
189+
"src",
190+
"line-height",
191+
"opacity",
192+
"-ms-filter:'progid:DXImageTransform.Microsoft.Alpha",
193+
"filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
194+
"resize",
195+
"cursor",
196+
"nav-index",
197+
"nav-up",
198+
"nav-right",
199+
"nav-down",
200+
"nav-left",
201+
"-webkit-transition",
202+
"-moz-transition",
203+
"-o-transition",
204+
"transition",
205+
"-webkit-transition-delay",
206+
"-moz-transition-delay",
207+
"-o-transition-delay",
208+
"transition-delay",
209+
"-webkit-transition-timing-function",
210+
"-moz-transition-timing-function",
211+
"-o-transition-timing-function",
212+
"transition-timing-function",
213+
"-webkit-transition-duration",
214+
"-moz-transition-duration",
215+
"-o-transition-duration",
216+
"transition-duration",
217+
"-webkit-transition-property",
218+
"-moz-transition-property",
219+
"-o-transition-property",
220+
"transition-property",
221+
"-webkit-transform",
222+
"-moz-transform",
223+
"-o-transform",
224+
"transform",
225+
"-webkit-transform-origin",
226+
"-moz-transform-origin",
227+
"-o-transform-origin",
228+
"transform-origin",
229+
"unicode-bidi",
230+
"direction",
231+
"break-after",
232+
"break-before",
233+
"break-inside",
234+
"columns",
235+
"column-span",
236+
"column-width",
237+
"column-count",
238+
"column-fill",
239+
"column-gap",
240+
"column-rule",
241+
"column-rule-color",
242+
"column-rule-style",
243+
"column-rule-width",
244+
"page-break-before",
245+
"page-break-inside",
246+
"page-break-after",
247+
"orphans",
248+
"widows",
249+
"zoom",
250+
"max-zoom",
251+
"min-zoom",
252+
"user-zoom",
253+
"orientation"
254+
]
255+
}

CSScomb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ def __init__(self, view):
1919
self.view = view
2020

2121
def run(self, edit):
22+
self.sortorder = False
23+
self.order_settings = sublime.load_settings('CSScomb - Order.sublime-settings')
24+
if self.order_settings:
25+
self.sortorder = self.order_settings.get('sort_order')
26+
sublime.status_message('Sorting with custom sort order...')
2227

2328
selections = self.get_selections()
2429

2530
threads = []
2631
for sel in selections:
2732
selbody = self.view.substr(sel)
2833
selbody = selbody.encode('utf-8')
29-
thread = LocalSort(sel, selbody)
34+
thread = LocalSort(sel, selbody, self.sortorder)
3035

3136
threads.append(thread)
3237
thread.start()

csscomb/basesort.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
class BaseSort(threading.Thread):
55

6-
def __init__(self, sel, original):
6+
def __init__(self, sel, original, sortorder):
77
self.sel = sel
88
self.original = original
99
self.result = None
1010
self.error = None
11+
self.sortorder = sortorder
1112
threading.Thread.__init__(self)
1213

1314
def exec_request(self):
@@ -16,6 +17,6 @@ def exec_request(self):
1617
def run(self):
1718
try:
1819
self.result = self.exec_request()
19-
except (OSError) as (e):
20-
self.error = True
21-
self.result = 'Sorter Error: attempt to sort non-existent file'
20+
except (OSError):
21+
self.error = True
22+
self.result = 'Sorter Error: attempt to sort non-existent file'

csscomb/libs/call_string.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
/* Обертка для вызова CSScomb */
44
$csscomb = new csscomb();
55
/*$sort_type = is_file($argv[2]) ? file_get_contents($argv[2]) : $argv[2];*/
6-
$input = $csscomb->csscomb($argv[1], false, null);
6+
$input = $csscomb->csscomb($argv[1], false, $argv[2]);
77
echo $input;

csscomb/localsort.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ def check_php_on_path(self):
2525

2626
def exec_request(self):
2727
if not self.error:
28-
myprocess = subprocess.Popen(['php', csscomb_path, self.original], shell=False, stdout=subprocess.PIPE, startupinfo=self.startupinfo)
28+
order = '["' + '","'.join(self.sortorder) + '"]'
29+
print order
30+
myprocess = subprocess.Popen(['php', csscomb_path, self.original, order], shell=False, stdout=subprocess.PIPE, startupinfo=self.startupinfo)
2931
(sout, serr) = myprocess.communicate()
3032
myprocess.wait()
3133

32-
if len(sout) > 0:
33-
return sout
34-
else:
35-
return None
34+
if len(sout) > 0:
35+
return sout
36+
37+
return None
3638

3739
def run(self):
3840
self.check_php_on_path()

0 commit comments

Comments
 (0)