Skip to content

Commit

Permalink
Add open all src menu item. #431
Browse files Browse the repository at this point in the history
  • Loading branch information
Robot-Will committed Apr 13, 2017
1 parent 91fcdef commit 5ed8c1e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
"command": "stino_open_in_new_win",
"checkbox": true
},
{
"caption": "All Source Files",
"id": "stino_open_all_src",
"command": "stino_open_all_src",
"checkbox": true
},
{"caption": "-"},
{
"caption": "New Sketch...",
Expand Down
19 changes: 19 additions & 0 deletions StinoCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,25 @@ def is_checked(self):
return state


class StinoOpenAllSrcCommand(sublime_plugin.WindowCommand):
"""."""

def run(self):
"""."""
if stino.arduino_info['init_done']:
state = \
bool(stino.arduino_info['settings'].get('open_all_src'))
stino.arduino_info['settings'].set('open_all_src', not state)

def is_checked(self):
"""."""
state = False
if stino.arduino_info['init_done']:
state = \
bool(stino.arduino_info['settings'].get('open_all_src'))
return state


class StinoOpenSketchCommand(sublime_plugin.WindowCommand):
"""Open Sketch."""

Expand Down
10 changes: 10 additions & 0 deletions libs/base_utils/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Doc."""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

6 changes: 4 additions & 2 deletions libs/stino_runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,16 @@ def open_project(project_path, win):
has_prj_file = True
break

if has_prj_file:
is_open_all_src = arduino_info['settings'].get('open_all_src')

if has_prj_file and not is_open_all_src:
win.open_file(file_path)
else:
paths = glob.glob(project_path + '/*')
file_paths = [p for p in paths if os.path.isfile(p)]
for file_path in file_paths:
ext = os.path.splitext(file_path)[-1]
if ext in c_file.INOC_EXTS:
if ext in c_file.SRC_EXTS:
win.open_file(file_path)


Expand Down
6 changes: 6 additions & 0 deletions libs/stino_runtime/st_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ def update_sketchbook_menu(arduino_info):
text += '\t' * 6 + '"command": "stino_open_in_new_win",\n'
text += '\t' * 6 + '"checkbox": true\n'
text += '\t' * 5 + '},\n'
text += '\t' * 5 + '{\n'
text += '\t' * 6 + '"caption": "All Source Files",\n'
text += '\t' * 6 + '"id": "stino_open_all_src",\n'
text += '\t' * 6 + '"command": "stino_open_all_src",\n'
text += '\t' * 6 + '"checkbox": true\n'
text += '\t' * 5 + '},\n'
text += '\t' * 5 + '{"caption": "-"},'
text += '\t' * 5 + '{\n'
text += '\t' * 6 + '"caption": "New Sketch...",\n'
Expand Down

0 comments on commit 5ed8c1e

Please sign in to comment.