-
Notifications
You must be signed in to change notification settings - Fork 29
/
ui.py
75 lines (58 loc) · 2.44 KB
/
ui.py
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
from copy import deepcopy
class OptionsSelector:
def __init__(self, window, panelItems, onDone, onHighlight):
self.window = window
self.panelItems = deepcopy(panelItems)
self.onDone = onDone
self.onHighlight = onHighlight
def start(self):
startIndex = 0
self.window.show_quick_panel(self.panelItems,
self.onDone,
0,
startIndex,
self.onHighlight)
class OptionsInput:
def __init__(self, window, caption, initalText, onDone, onCancel):
self.window = window
self.caption = caption
self.initalText = initalText
self.onDone = onDone
self.onCancel = onCancel
def start(self):
inputPanelView = self.window.show_input_panel(self.caption,
self.initalText,
self.onDone,
None,
self.onCancel)
# select the text in the view so that
# when the user types a new name, the old name is overwritten
assert (len(inputPanelView.sel()) > 0)
selectionRegion = inputPanelView.full_line(inputPanelView.sel()[0])
inputPanelView.sel().add(selectionRegion)
def createBookmarkPanelItems(window, visibleBookmarks):
def ellipsisStringEnd(string, length):
# I have NO idea why the hell this would happen. But it's happening.
if string is None:
return ""
else:
if len(string) <= length:
return string
else:
return string[0:length - 3] + '.' * 3
def ellipsisStringBegin(string, length):
if string is None:
return ""
else:
if len(string) <= length:
return string
else:
return '.' * 3 + string[len(string)+3-(length):len(string)]
bookmarkItems = []
for bookmark in visibleBookmarks:
bookmarkName = bookmark.getName()
bookmarkLine = bookmark.getLineStr().lstrip()
filepath = bookmark.getFilePath().lstrip()
bookmarkFile = ellipsisStringBegin(filepath, 55)
bookmarkItems.append([bookmarkName, bookmarkLine, bookmarkFile])
return bookmarkItems