Skip to content

Commit ca0e0f6

Browse files
committed
ST2 compatibility
1 parent aa120d1 commit ca0e0f6

10 files changed

+44
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
*.cache

Note.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"tab_completion": true,
2323

2424
"trim_trailing_white_space_on_save": false,
25-
"trim_automatic_white_space": false,
25+
"trim_automatic_white_space": false
2626
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ It's been designed with these ground rules in mind:
2020
</p>
2121

2222
## Usage
23+
24+
**Note:** Although PlainNotes works under SublimeText 2, some features might not be available. We're not actively testing it
25+
under SublimeText 2 but will do our best to make it compatible and usable. We appreciate bug reports and pull requests.
26+
2327
Most of PlainNotes commands are accessible from the SublimeText main menu. You should have a menu item called `Notes` right after `Help`. Although, there are faster and easier ways of running those commnads that are mentioned below.
2428

2529
#### Starting a new note (`super+F4`)

jotter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
13
import sublime, sublime_plugin
24
import os, time
35

6+
ST3 = int(sublime.version()) >= 3000
7+
if not ST3:
8+
from codecs import open
9+
410

511
def settings():
612
return sublime.load_settings('Notes.sublime-settings')
@@ -15,11 +21,10 @@ def run(self, edit):
1521
window = self.view.window()
1622
output = self.view.window().get_output_panel("jotter")
1723
self.view.window().run_command("show_panel", {"panel": "output.jotter"})
18-
print(settings().get("jotter_color_scheme"))
1924
output.settings().set("color_scheme", settings().get("jotter_color_scheme"))
2025
output.settings().set("is_jott", True)
2126
output.set_syntax_file("Packages/PlainNotes/Note.tmLanguage")
22-
sublime.status_message(" ✎ Jot down your note and press ESC when done. It will be saved to your 'Inbox'")
27+
sublime.status_message(u" ✎ Jot down your note and press ESC when done. It will be saved to your 'Inbox'")
2328
output.set_read_only(False)
2429
window.focus_view(output)
2530

@@ -39,7 +44,7 @@ def run(self, edit):
3944
w.run_command("hide_panel", {"cancel": True})
4045
return
4146

42-
jot = '# ' + time.strftime(settings().get("jotter_date_format")) + ' — ' + time.strftime(settings().get("jotter_time_format")) + u'\n' + text.rstrip(u'\r\n') + u'\n\n'
47+
jot = '# ' + time.strftime(settings().get("jotter_date_format")) + u' — ' + time.strftime(settings().get("jotter_time_format")) + u'\n' + text.rstrip(u'\r\n') + u'\n\n'
4348

4449
with open(os.path.join(get_root(), ".brain", "Inbox.note"), mode='r+', encoding='utf-8') as f:
4550
content = f.read()

lib/headline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""Some utility functions for working with headline of Markdown.
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Some utility functions for working with headline of Markdown.
25
36
Terminologies
47
- Headline :: The headline entity OR the text of the headline

lib/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
# Helper functions
24

35
def return_sublist(main_list, indices ):

lib/utilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""Some utility functions for working with sublime.
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
Some utility functions for working with sublime.
25
"""
36

47

note_headings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""This is borrowed from [SmartMarkdown plugin](https://github.com/demon386/SmartMarkdown)
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
This is borrowed from [SmartMarkdown plugin](https://github.com/demon386/SmartMarkdown)
25
Smart folding is a feature borrowed from [Org-mode](http://org-mode.org).
36
It enables folding / unfolding the headlines by simply pressing TAB on headlines.
47
Global headline folding / unfolding is recommended to be trigged by Shift + TAB,

notes.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
13
import sublime, sublime_plugin
24
import os, fnmatch, re, time, helpers
35
from gzip import GzipFile
46
from pickle import load, dump
57

68
ST3 = int(sublime.version()) >= 3000
79

10+
if not ST3:
11+
from codecs import open
12+
813

914
def settings():
1015
return sublime.load_settings('Notes.sublime-settings')
@@ -229,8 +234,10 @@ def run(self):
229234
self.window = sublime.active_window()
230235
self.original_cs = self.window.active_view().settings().get("color_scheme")
231236
current_color = os.path.basename(self.original_cs).replace("Sticky-","").replace(".tmTheme", "")
232-
# show_quick_panel(items, on_done, <flags>, <selected_index>, <on_highlighted>)
233-
self.window.show_quick_panel(self.colors, self.on_select, 0, self.colors.index(current_color), self.on_highlight)
237+
if ST3:
238+
self.window.show_quick_panel(self.colors, self.on_select, 0, self.colors.index(current_color), self.on_highlight)
239+
else:
240+
self.window.show_quick_panel(self.colors, self.on_select, 0, self.colors.index(current_color))
234241

235242
def on_select(self, index):
236243
global db

notes_index.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
import sublime, sublime_plugin
24
import os, fnmatch, re
35

@@ -17,7 +19,7 @@ class NotesBufferCommand(sublime_plugin.WindowCommand):
1719
def run(self):
1820
view = self.window.new_file()
1921
view.set_scratch(True)
20-
view.set_name("✎ Notes Index")
22+
view.set_name(u"✎ Notes Index")
2123
view.set_syntax_file('Packages/PlainNotes/Notes Index.hidden-tmLanguage')
2224
view.settings().set('color_scheme', 'Packages/PlainNotes/Color Schemes/Notes-Index.hidden-tmTheme')
2325
self.window.focus_view(view)
@@ -35,7 +37,7 @@ def run(self, edit):
3537

3638
v.settings().set('notes_buffer_files', lines)
3739

38-
v.insert(edit, 0, "\n".join([f[0] for f in lines]))
40+
v.insert(edit, 0, u"\n".join([f[0] for f in lines]))
3941
v.set_read_only(True)
4042

4143
def list_files(self, path):
@@ -45,14 +47,14 @@ def list_files(self, path):
4547
indent = ' ' * TAB_SIZE * (level)
4648
relpath = os.path.relpath(root, path)
4749
if not relpath.startswith("."):
48-
line_str = '{0}▣ {1}'.format(indent, os.path.relpath(root, path))
50+
line_str = u'{0}▣ {1}'.format(indent, os.path.relpath(root, path))
4951
lines.append((line_str, root))
5052
if not relpath.startswith(".brain"):
5153
subindent = ' ' * TAB_SIZE * (level + 1)
5254
for f in files:
5355
for ext in settings().get("note_file_extensions"): # display only files with given extension
5456
if fnmatch.fnmatch(f, "*." + ext):
55-
line_str = '{0}≡ {1}'.format(subindent, re.sub(r'\.note$', '', f))
57+
line_str = u'{0}≡ {1}'.format(subindent, re.sub(r'\.note$', '', f))
5658
line_path = os.path.normpath(os.path.join(root, f))
5759
lines.append((line_str, line_path))
5860
return lines

0 commit comments

Comments
 (0)