Skip to content

Commit

Permalink
New feature to "freeze" a sketch (Issue: #170)
Browse files Browse the repository at this point in the history
  • Loading branch information
gepd committed Sep 20, 2017
1 parent 3859ded commit bce723a
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 1 deletion.
2 changes: 2 additions & 0 deletions commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .deviot_upload_sketch import DeviotUploadSketchCommand
from .deviot_overwrite_upload_baud import DeviotOverwriteUploadBaudCommand
from .deviot_clean_sketch import DeviotCleanSketchCommand
from .deviot_freeze_sketch import DeviotFreezeSketchCommand
from .deviot_open_ini_file import DeviotOpenIniFile
from .deviot_show_console import DeviotShowConsoleCommand
from .deviot_hide_console import DeviotHideConsoleCommand
Expand Down Expand Up @@ -69,6 +70,7 @@
'DeviotUploadSketchCommand',
'DeviotOverwriteUploadBaudCommand',
'DeviotCleanSketchCommand',
'DeviotFreezeSketchCommand',
'DeviotOpenIniFile',
'DeviotShowConsoleCommand',
'DeviotHideConsoleCommand',
Expand Down
33 changes: 33 additions & 0 deletions commands/deviot_freeze_sketch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from sublime import active_window
from sublime_plugin import WindowCommand
from ..libraries.tools import save_setting, get_setting

class DeviotFreezeSketchCommand(WindowCommand):
"""
Store the freeze directory
"""
sketch_path = None
setting_path = None

def run(self):
if(self.setting_path):
self.sketch_path = None
save_setting('freeze_sketch', self.sketch_path)

def is_checked(self):
return bool(self.setting_path)

def is_enabled(self):
enabled = False
window = active_window()
view = window.active_view()
self.sketch_path = view.file_name()

self.setting_path = get_setting('freeze_sketch', None)

if(self.sketch_path.endswith('.ino') or
self.sketch_path.endswith('.cpp') or
self.setting_path):
enabled = True

return enabled
3 changes: 3 additions & 0 deletions languages/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Overwrite Upload Speed"
msgid "menu_clean"
msgstr "Clean"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Open Build Config File"

Expand Down
3 changes: 3 additions & 0 deletions languages/es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Sobre Escribir Velocidad de Carga"
msgid "menu_clean"
msgstr "Limpiar"

msgid "menu_freeze_sketch"
msgstr "Congelar Sketch"

msgid "menu_open_ini_file"
msgstr "Abrir Archivo Para Compilación"

Expand Down
3 changes: 3 additions & 0 deletions languages/fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Overwrite Upload Speed"
msgid "menu_clean"
msgstr "Nettoyage"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Ouvrir Config de compilation"

Expand Down
3 changes: 3 additions & 0 deletions languages/it.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Overwrite Upload Speed"
msgid "menu_clean"
msgstr "Pulisci"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Apri Config File di Compilazione"

Expand Down
3 changes: 3 additions & 0 deletions languages/ko.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Overwrite Upload Speed"
msgid "menu_clean"
msgstr "클린"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Open Build Config File"

Expand Down
3 changes: 3 additions & 0 deletions languages/pl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "Overwrite Upload Speed"
msgid "menu_clean"
msgstr "Wyczyść"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Otwórz Plik Konfiguracji Builda"

Expand Down
3 changes: 3 additions & 0 deletions languages/pt_br.lang
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ msgstr "Excesso de Velocidade de Upload"
msgid "menu_clean"
msgstr "Limpar"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "Open Build Config File"

Expand Down
3 changes: 3 additions & 0 deletions languages/zh.lang
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ msgstr "覆盖上传波特率"
msgid "menu_clean"
msgstr "清除"

msgid "menu_freeze_sketch"
msgstr "Freeze Sketch"

msgid "menu_open_ini_file"
msgstr "配置文件"

Expand Down
4 changes: 4 additions & 0 deletions libraries/project_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ def structurize_project(self):

if('src' not in file_path and not path.exists(dst)):
from shutil import move
from .tools import get_setting, save_setting

move(file_path, dst)
self.view.retarget(dst)

if(get_setting('freeze_sketch', None)):
save_setting('freeze_sketch', dst)

def override_src(self):
"""Adds src_dir
Expand Down
6 changes: 5 additions & 1 deletion platformio/project_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import os
import sublime

from ..libraries.tools import get_setting

class ProjectRecognition(object):
def __init__(self):
Expand Down Expand Up @@ -56,6 +56,10 @@ def get_file_path(self):
Returns:
[str] -- path of the file path/path/file.ext
"""
freeze = get_setting('freeze_sketch', None)

if(freeze):
return freeze
return self.view.file_name()

def get_project_path(self):
Expand Down
5 changes: 5 additions & 0 deletions presets/main_menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
"caption": "menu_clean",
"id": "clean_sketch",
"command": "deviot_clean_sketch"
},{
"caption": "menu_freeze_sketch",
"id": "freeze_sketch",
"checkbox": true,
"command": "deviot_freeze_sketch"
},{
"caption": "menu_open_ini_file",
"id": "open_ini_file",
Expand Down

0 comments on commit bce723a

Please sign in to comment.