forked from bollu/sublimeBookmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddBookmarks.py
52 lines (31 loc) · 1.06 KB
/
addBookmarks.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
import sublime, sublime_plugin
import threading
from . import common
class AddBookmarkCommand(sublime_plugin.WindowCommand, common.BaseBookmarkCommand):
def __init__(self, window):
self.thread = None
common.BaseBookmarkCommand.__init__(self, window)
def run(self):
if self.thread is not None:
self.thread.join()
self.thread = AddBookmarkHandler(self.window, self)
self.thread.start()
def description(self):
return "Add a Bookmark"
class AddBookmarkHandler(threading.Thread):
def __init__(self, window, addBookmarkCommand):
self.window = window
self.bookmarks = common.get_bookmarks(self.window)
threading.Thread.__init__(self)
def run(self):
view = self.window.active_view()
defaultString = ""
self.window.show_input_panel("Add Bookmark", defaultString, self._done, None, self._cancel)
def _cancel(self):
return
def _done(self, viewString):
bookmark = common.Bookmark(self.window, viewString)
bookmark.print_dbg()
self.bookmarks.append(bookmark)
common.set_bookmarks(self.bookmarks, self.window)
return