-
Notifications
You must be signed in to change notification settings - Fork 3
/
排序.ini
162 lines (149 loc) · 4.74 KB
/
排序.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[Command]
Name=\x6392\x5e8f
Command="
copyq:
// \x5355\x9009\x6761\x76ee\x65f6\x5bf9\x6574\x4e2a\x6807\x7b7e\x9875\x8fdb\x884c\x6392\x5e8f
// \x591a\x9009\x6761\x76ee\x65f6\x5bf9\x9009\x4e2d\x7684\x6761\x76ee\x8fdb\x884c\x6392\x5e8f
var date_reverse = {
[mimeText]: '\x6700\x65b0\x5728\x524d',
[mimeIcon]: '\xf1da',
format: \"application/x-copyq-user-item-time\",
reverse: true
}
var date = {
[mimeText]: '\x6700\x65e7\x5728\x524d',
[mimeIcon]: '\xf017',
format: \"application/x-copyq-user-item-time\",
reverse: false
}
var pinned = {
[mimeText]: '\x7f6e\x9876\x56fa\x5b9a',
[mimeIcon]: '\xf08d',
format: \"application/x-copyq-item-pinned\",
reverse: false
}
var alphabet = {
[mimeText]: '\x5b57\x6bcd\x987a\x5e8f',
[mimeIcon]: '\xf15d',
format: mimeText,
reverse: false
}
var alphabet_reverse = {
[mimeText]: '\x5b57\x6bcd\x5012\x5e8f',
[mimeIcon]: '\xf881',
format: mimeText,
reverse: true
}
var size_reverse = {
[mimeText]: '\x4ece\x5927\x5230\x5c0f',
[mimeIcon]: '\xf160',
format: \"ItemSize\",
reverse: true
}
var size = {
[mimeText]: '\x4ece\x5c0f\x5230\x5927',
[mimeIcon]: '\xf884',
format: \"ItemSize\",
reverse: false
}
// \x6392\x5e8f\x83dc\x5355\x9879\x76ee
var sorts = [
date_reverse,
date,
pinned,
alphabet,
alphabet_reverse,
size_reverse,
size
]
// \x663e\x793a\x6392\x5e8f\x83dc\x5355
var selectedIndex = menuItems(sorts)
var sel = ItemSelection().current()
if (sel.length <= 1) {
// \x5f53\x524d\x6807\x7b7e\x9875\x53ea\x4e00\x4e2a\x6761\x76ee\xff0c\x5219\x9000\x51fa
length() <= 1 ? abort() : ''
// \x5355\x9009\xff0c\x5c06\x9009\x533a\x8bbe\x7f6e\x4e3a\x6574\x4e2a\x6807\x7b7e\x9875
sel = ItemSelection().selectAll()
handle_pinned(sel.length)
} else {
// \x591a\x9009\xff0c\x5224\x65ad\x662f\x5426\x4ece\x30\x5f00\x59cb\x9009\x62e9\x3002
// \x662f\xff1a\x5904\x7406\x56fa\x5b9a\x884c\xff1b\x5426\xff1a\x65e0\x64cd\x4f5c
sel.rows()[0] == 0 ? handle_pinned(sel.length) : ''
}
const rows = sel.rows()
var order = ''
if (selectedIndex != -1) {
// \x83b7\x53d6\x9009\x62e9\x7684\x6392\x5e8f\x6761\x4ef6
const selectedFormat = sorts[selectedIndex].format
switch (selectedFormat) {
case 'ItemSize':
popup('\x6392\x5e8f\x4e2d\x23f3', '', rows.length * 3)
order = sizeList()
break;
case \"application/x-copyq-item-pinned\":
move_pinned_to(0)
abort()
default:
order = sel.itemsFormat(selectedFormat)
}
} else {
abort()
}
// \x6392\x5e8f
sel.sort(function (i, j) {
if (sorts[selectedIndex].reverse) {
return order[i] > order[j];
} else {
return order[i] < order[j];
}
});
popup('\x6392\x5e8f\x5b8c\x6210\x2705', '', 1000)
// \x83b7\x53d6sel\x9009\x533a\x4e2d\x6bcf\x4e2a\x6761\x76ee\x7684\x5b57\x8282\x6570
function sizeList() {
var items = sel.items()
var sizes = []
for (let row in rows) {
var itemSize = 0
var item = items[row]
for (var format in item) {
itemSize += read(format, row).size()
}
sizes.push(itemSize)
}
return sizes
}
// \x79fb\x52a8\x6240\x6709\x56fa\x5b9a\x884c\x81f3row\x884c
function move_pinned_to(row) {
var sel = ItemSelection().selectAll()
var pinned = []
for (var i = 0; i < sel.length; i++) {
if (plugins.itempinned.isPinned(i))
pinned.push(i)
}
if (pinned.length > 0) {
sel.deselectIndexes(pinned)
sel.invert().move(row)
selectItems(row)
}
}
// \x5904\x7406\x56fa\x5b9a\x884c
function handle_pinned(sel_length) {
var pinned = []
// \x83b7\x53d6\x4ece\x30\x884c\x5f00\x59cb\x8fde\x7eed\x7684\x56fa\x5b9a\x884c
for (var i = 0; i < sel_length; i++) {
if (plugins.itempinned.isPinned(i)) {
pinned.push(i)
} else {
break
}
}
// \x56fa\x5b9a\x884c\x5411\x4e0b\x79fb\x52a8\x31\x884c
if (0 < pinned.length < sel_length) {
var selAll = ItemSelection().selectAll()
selAll.deselectIndexes(pinned)
selAll.invert().move(pinned.length + 1)
}
}"
InMenu=true
Icon=\xf0dc
Shortcut=shift+s