Skip to content

Commit

Permalink
Merge pull request #19 from haydnhkim/master
Browse files Browse the repository at this point in the history
Add support sublime context menu and file syntax option
  • Loading branch information
sickmartian committed Nov 22, 2015
2 parents dc448ad + 0a4ff2e commit 126db45
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 7 deletions.
92 changes: 92 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[
{
"caption": "Preferences",
"id": "preferences",
"mnemonic": "n",
"children":
[
{
"caption": "Package Settings",
"id": "package-settings",
"mnemonic": "P",
"children":
[
{
"caption": "QuickSimplenote",
"children":
[
{
"args": {
"file": "${packages}/QuickSimplenote/README.md"
},
"caption": "README",
"command": "open_file"
},
{ "caption": "-" },
{
"command": "open_file",
"args": {"file": "${packages}/QuickSimplenote/quick_simplenote.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/quick_simplenote.sublime-settings"},
"caption": "Settings – User"
},
{ "caption": "-" },
{
"args": {
"file": "${packages}/QuickSimplenote/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/QuickSimplenote/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/QuickSimplenote/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{ "caption": "-" }
]
}
]
}
]
}
]
17 changes: 12 additions & 5 deletions quick_simplenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_note_from_path(view_filepath):
if note:
note = note[0]


return note

def get_note_name(note):
Expand Down Expand Up @@ -294,6 +294,13 @@ def flush_saves():
HandleNoteViewCommand.waiting_to_save.append(new_entry)
sublime.set_timeout(flush_saves, debounce_time)

def on_load(self, view):
view_filepath = view.file_name()
note = get_note_from_path(view_filepath)
syntax = settings.get('note_syntax')
if note and syntax:
view.set_syntax_file(syntax)

def get_current_content(self, view):
note_file_content = ""
try:
Expand Down Expand Up @@ -433,7 +440,7 @@ def notes_synch(self, notes):
for view in view_list:
if view.file_name() == None:
continue

if view.is_dirty():
open_files_dirty.append(path.split(view.file_name())[1])
else:
Expand All @@ -447,13 +454,13 @@ def notes_synch(self, notes):

if not note['needs_update']:
continue

try:
filename = note['filename']
except KeyError as e:
others.append(note)
continue

if filename in open_files_dirty:
lu.append(note)
elif filename in open_files_ok:
Expand Down Expand Up @@ -637,4 +644,4 @@ def reload_if_needed():
settings.add_on_change('username', reload_if_needed)
settings.add_on_change('password', reload_if_needed)

reload_if_needed()
reload_if_needed()
11 changes: 9 additions & 2 deletions quick_simplenote.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"username": ""
,"password": ""
// --------------------------------
// Simplenote Synctax setting:
// (If you are using MarkdownEditing, try
// "note_syntax": "Packages/MarkdownEditing/Markdown.tmLanguage"
// )
// --------------------------------
,"note_syntax": ""
// --------------------------------
// Sync settings:
// --------------------------------
// Sync when sublime text starts:
Expand Down Expand Up @@ -32,5 +39,5 @@
// "title_regex": "\\[ST\\]",
// "extension": "todo"
// }]
}

}

0 comments on commit 126db45

Please sign in to comment.