-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.py
130 lines (101 loc) · 3.5 KB
/
command.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
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
import sublime_plugin
from .tomato_time import get_tomato
class CreateTomatoCommand(sublime_plugin.TextCommand):
def show_desc_panel(self):
window = self.view.window()
caption = "Tomato Time Description:"
def on_done(desc):
self.tomato.set_desc(desc)
self.tomato.set_tag(self.tag)
self.tomato.start()
window.show_input_panel(caption, self.tomato.get_desc(), on_done, None, None)
def create_tag(self):
window = self.view.window()
caption = "New Tag's Name:"
def on_done(name):
self.tomato.create_tag(name)
self.show_tags_panel()
window.show_input_panel(caption, "", on_done, None, None)
def delete_tag(self):
window = self.view.window()
items = []
tags = self.tomato.get_tags()
if len(tags) == 0:
self.show_tags_panel()
return
for t in tags:
items.append(": %s" % t)
def on_select(index):
if index < 0:
return
self.tomato.delete_tag(tags[index])
self.show_tags_panel()
window.show_quick_panel(items, on_select)
def show_tags_panel(self):
window = self.view.window()
items = []
tag = self.tomato.get_tag()
desc = self.tomato.get_desc()
if tag:
items.append("Go on with last tomato: [%s] %s" % (tag, desc))
else:
items.append("Go on with last tomato: %s" % (desc))
items.append("Discard Tag")
items.append("Create Tag")
items.append("Delete Tag")
tags = self.tomato.get_tags()
for t in tags:
items.append(": %s" % t)
def on_select(index):
if index < 0:
return
if index == 0:
self.tag = self.tomato.get_tag()
self.show_desc_panel()
return
if index == 1:
self.tag = None
self.show_desc_panel()
return
if index == 2:
self.create_tag()
return
if index == 3:
self.delete_tag()
return
self.tag = tags[index - 4]
self.show_desc_panel()
window.show_quick_panel(items, on_select)
def run(self, edit):
self.tomato = get_tomato()
self.tag = None
self.show_tags_panel()
class DiscardTomatoCommand(sublime_plugin.TextCommand):
def run(self, edit):
tomato = get_tomato()
tomato.discard()
def is_visible(self):
tomato = get_tomato()
return tomato.is_actived()
class ShowTomatoProgressCommand(sublime_plugin.TextCommand):
def run(self, edit):
tomato = get_tomato()
tomato.set_status_visiable(True)
def is_visible(self):
tomato = get_tomato()
return tomato.is_actived() and not tomato.get_status_visiable()
class HideTomatoProgressCommand(sublime_plugin.TextCommand):
def run(self, edit):
tomato = get_tomato()
tomato.set_status_visiable(False)
def is_visible(self):
tomato = get_tomato()
return tomato.is_actived() and tomato.get_status_visiable()
class ShowCompleteRecordsCommand(sublime_plugin.TextCommand):
def run(self, edit):
tomato = get_tomato()
tomato.show_records()
class ClearCompleteRecordsCommand(sublime_plugin.TextCommand):
def run(self, edit):
tomato = get_tomato()
tomato.clear_records()