Skip to content

Commit 540ccde

Browse files
committed
first github push
1 parent 798a172 commit 540ccde

5 files changed

+39
-17
lines changed

Default.sublime-commands

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
22
{ "caption": "Notes: List…", "command": "notes_list"},
33
{ "caption": "Notes: New…", "command": "notes_new"},
4-
{ "caption": "Note: Change Color", "command": "note_change_color"}
4+
{ "caption": "Note: Change Color", "command": "note_change_color"}
55
]

Note.sublime-settings

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"color_scheme": "Packages/SublimeNotes/Color Schemes/Sticky-GreenLight.tmTheme",
2+
"color_scheme": "Packages/PlainNotes/Color Schemes/Sticky-GreenLight.tmTheme",
33
"draw_indent_guides": false,
44
"enable_table_editor": true,
55
"highlight_line": false,

Notes Index.sublime-settings

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"line_numbers": false,
3-
"margin": 0,
3+
"margin": 20,
44
"word_wrap": true,
5-
"wrap_width": 0,
6-
"draw_centered": true,
5+
"wrap_width": 100,
6+
//"draw_centered": true,
77
"rulers": [],
88
"spell_check": false,
99
"highlight_line": true,

notes.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ def open_note(self, index):
3838
if index == -1:
3939
return
4040
file_path = self.file_list[index][1]
41-
# self.window.run_command("new_pane",{"move": True})
42-
view = sublime.active_window().open_file(file_path)
43-
f_id = file_id(file_path)
44-
if db.get(f_id) and db[f_id]["color_scheme"]:
45-
view.settings().set("color_scheme", db[f_id]["color_scheme"])
46-
view.settings().set("is_note", True)
41+
42+
def open_and_activate():
43+
view = sublime.active_window().open_file(file_path, sublime.ENCODED_POSITION)
44+
f_id = file_id(file_path)
45+
if db.get(f_id) and db[f_id]["color_scheme"]:
46+
view.settings().set("color_scheme", db[f_id]["color_scheme"])
47+
view.settings().set("is_note", True)
48+
49+
sublime.set_timeout(open_and_activate, 0)
4750

4851

4952
class NotesNewCommand(sublime_plugin.ApplicationCommand):
@@ -108,7 +111,7 @@ def on_select(self, index):
108111
if index == -1:
109112
self.window.active_view().settings().set("color_scheme", self.original_cs)
110113
else:
111-
path = os.path.join("Packages" , "SublimeNotes", "Color Schemes", "Sticky-" + self.colors[index] + ".tmTheme")
114+
path = os.path.join("Packages" , "PlainNotes", "Color Schemes", "Sticky-" + self.colors[index] + ".tmTheme")
112115
view = self.window.active_view()
113116
view.settings().set("color_scheme", path)
114117
f_id = file_id(view.file_name())
@@ -118,7 +121,7 @@ def on_select(self, index):
118121
save_to_brain()
119122

120123
def on_highlight(self, index):
121-
path = os.path.join("Packages" , "SublimeNotes", "Color Schemes", "Sticky-" + self.colors[index] + ".tmTheme")
124+
path = os.path.join("Packages" , "PlainNotes", "Color Schemes", "Sticky-" + self.colors[index] + ".tmTheme")
122125
self.window.active_view().settings().set("color_scheme", path)
123126

124127
def is_enabled(self):

notes_buffer.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import sublime, sublime_plugin
2-
import os
2+
import os, fnmatch, re
3+
4+
def settings():
5+
return sublime.load_settings('Notes.sublime-settings')
36

47
class NotesBufferCommand(sublime_plugin.WindowCommand):
58
def run(self):
69
view = self.window.new_file()
710
view.set_scratch(True)
811
view.set_name("✎ Notes Index")
9-
view.set_syntax_file('Packages/SublimeNotes/Notes Index.hidden-tmLanguage')
10-
view.settings().set('color_scheme', 'Packages/SublimeNotes/Color Schemes/Notes-Index.hidden-tmTheme')
12+
view.set_syntax_file('Packages/PlainNotes/Notes Index.hidden-tmLanguage')
13+
view.settings().set('color_scheme', 'Packages/PlainNotes/Color Schemes/Notes-Index.hidden-tmTheme')
1114
self.window.focus_view(view)
1215
view.run_command('notes_buffer_refresh')
1316

@@ -16,6 +19,22 @@ def run(self, edit):
1619
v = self.view
1720
v.set_read_only(False)
1821
v.erase(edit, sublime.Region(0, self.view.size()))
19-
v.insert(edit, 0, "\n\nTEST")
22+
23+
root = os.path.normpath(os.path.expanduser(settings().get("root")))
24+
lines = self.list_files(root)
25+
v.insert(edit, 0, "\n"+"\n".join(lines))
2026
v.set_read_only(True)
2127

28+
def list_files(self, path):
29+
lines = []
30+
for root, dirs, files in os.walk(path, topdown=False):
31+
level = root.replace(path, '').count(os.sep) - 1
32+
indent = ' ' * 4 * (level)
33+
relpath = os.path.relpath(root, path)
34+
if not (relpath == "." or relpath == ".brain"):
35+
lines.append('{0}▣ {1}'.format(indent, os.path.relpath(root, path)))
36+
if not (relpath == ".brain"):
37+
subindent = ' ' * 4 * (level + 1)
38+
for f in files:
39+
lines.append('{0}≡ {1}'.format(subindent, re.sub('\.note$', '', f)))
40+
return lines

0 commit comments

Comments
 (0)