Skip to content

Commit 8d295c6

Browse files
committed
Merge branch 'release/v2.1.0'
2 parents 5a04b38 + 6cd4345 commit 8d295c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+707
-282
lines changed

CHANGES.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
# Deviot Release Notes
2+
3+
## Version 2.1.0 | 14 Aug 2017
4+
5+
#### New
6+
* Text history in the "Send" Serial Monitor input panel (Issue: https://github.com/gepd/Deviot/issues/84)
7+
* Deviot fala Portugues (Thanks to Alexandre Fernandes)
8+
* Experimental feature to avoid wrong line number with ino files
9+
10+
#### Improvements
11+
* Show a progress bar when the PlatformIO terminal is used
12+
* Updated caption for "Clean Monitor" to avoid confusion when the quick panel use
13+
* Updated shortcuts to avoid override sublime text hot keys in Linux and OSX (Issue: https://github.com/gepd/Deviot/issues/132)
14+
* QuickPanel shorcut will be the same in all platforms (ctrl+alt+q)
15+
* Rebuild the syntax file after add/remove an extra library folder
16+
* Highlight improvements
17+
* Changed the setup settings to a new file to make the plugin compatible with the sync plugin(s). This change will allow to exclude the deviot.ini file locate in Package/User/Deviot in the sync plugin (Issue: https://github.com/gepd/Deviot/issues/127)
18+
* Bring back the persistence in the "send" input text (Issue: https://github.com/gepd/Deviot/issues/135)
19+
* Improved the way to implement the phantom (create and hide)
20+
21+
#### Bugs
22+
* Avoid to stop the message queue after use the first command in the platformIO terminal
23+
* Search libraries in the extra library folder if it's set
24+
* Show the list of examples instead of "Import Library" list
25+
* Some Linux distro and OSX versions are not working well, when "pio" command is use. "plaformio" will be used instead.
26+
* Make sure the serial port is in use before to remove it
27+
* Check the last action when not IOT file is in the buffer
28+
* When PlatformIO is already installed and accessible. The command won't be modified (Issue: https://github.com/gepd/Deviot/issues/133)
29+
* Check and replace the old syntax file after load the plugin (Issue: https://github.com/gepd/Deviot/issues/133)
30+
* Make sure to get the extension of the file in buffer (Issue: https://github.com/gepd/Deviot/issues/139)
31+
* Force to initialize the sketch even if it already exitst in the temp folder when "Use PlatformIO Structure" is activated. The 'src_dir' flag will be add before compile/upload the sketch and removed after the task is finished (issue: https://github.com/gepd/Deviot/issues/137)
32+
233
## Version 2.0.1 | 03 Jul 2017
334
* Improvement Syntax is created even if the PlatformIO setup fails (Issue: https://github.com/gepd/Deviot/issues/125)
435
* Improvement Force Sublime Text to assign deviot syntax when it's a IOT file (Issue: https://github.com/gepd/Deviot/issues/125)

Deviot.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,27 @@
77
from __future__ import unicode_literals
88

99
from os import path
10+
from sublime import windows
1011
from sublime_plugin import EventListener
1112

1213
from .commands import *
1314
from .platformio.update import Update
1415
from .beginning.pio_install import PioInstall
15-
from .libraries.tools import get_setting, save_setting, get_phantoms, del_phantom, set_deviot_syntax
16-
from .libraries.paths import getBoardsFileDataPath, getMainMenuPath
16+
from .libraries.tools import get_setting, save_setting, set_deviot_syntax
17+
from .libraries.paths import getBoardsFileDataPath, getMainMenuPath, getPluginPath
1718
from .libraries.preferences_bridge import PreferencesBridge
1819
from .libraries.project_check import ProjectCheck
1920

2021
def plugin_loaded():
22+
# Load or fix the right deviot syntax file
23+
for window in windows():
24+
for view in window.views():
25+
set_deviot_syntax(view)
26+
27+
# Install PlatformIO
2128
PioInstall()
29+
30+
# Search updates
2231
Update().check_update_async()
2332

2433
menu_path = getMainMenuPath()
@@ -29,6 +38,14 @@ def plugin_loaded():
2938
TopMenu().make_menu_files()
3039
save_setting('compile_lang', False)
3140

41+
# check if the syntax file exist
42+
deviot_syntax = getPluginPath()
43+
syntax_path = path.join(deviot_syntax, 'deviot.sublime-syntax')
44+
45+
if(not path.exists(syntax_path)):
46+
active_window().run_command('deviot_rebuild_syntax')
47+
48+
3249
class DeviotListener(EventListener):
3350
def on_load(self, view):
3451
set_deviot_syntax(view)
@@ -46,25 +63,4 @@ def on_close(self, view):
4663
port_id = search_id[1]
4764
serial_monitor = serial.serial_monitor_dict.get(port_id, None)
4865
serial_monitor.stop()
49-
del serial.serial_monitor_dict[port_id]
50-
51-
def on_modified(self, view):
52-
"""On modify file
53-
54-
checks the phantoms in the current view and remove it
55-
when it's neccesary
56-
57-
Arguments:
58-
view {obj} -- sublime text object
59-
"""
60-
is_iot = ProjectCheck().is_iot()
61-
phantoms = get_phantoms()
62-
63-
if(not len(phantoms) and not is_iot):
64-
return
65-
66-
line, column = view.rowcol(view.sel()[0].begin())
67-
pname = 'error' + str(line + 1)
68-
69-
if(pname in phantoms and view.file_name()):
70-
del_phantom(pname)
66+
del serial.serial_monitor_dict[port_id]

beginning/pio_install.py

+36-9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
###
4343
from ..libraries.syntax import Syntax
4444
from ..libraries.tools import get_setting, save_setting
45+
from ..libraries.tools import get_sysetting, save_sysetting
46+
from ..libraries.paths import getSystemIniPath
4547
from ..libraries.thread_progress import ThreadProgress
4648
from ..libraries.I18n import I18n
4749
from ..platformio.pio_bridge import PioBridge
@@ -59,9 +61,13 @@ def __init__(self, window=False):
5961
self.sub_ver = sublime.version()
6062

6163
###
62-
installed = get_setting('installed', False)
64+
installed = get_sysetting('installed', False)
65+
if(not installed):
66+
found = self.check_old_settings()
67+
if(found):
68+
return
6369

64-
if(installed):
70+
if(bool(installed)):
6571
return
6672

6773
Syntax()
@@ -77,6 +83,27 @@ def __init__(self, window=False):
7783
thread.start()
7884
ThreadProgress(thread, caption, '')
7985

86+
def check_old_settings(self):
87+
"""
88+
All the dynamic settings are being stored in the
89+
deviot.ini file instead of the deviot.sublime-settings.
90+
To avoid make the user remove all the preferences and
91+
run the setup process again, this function will move the
92+
preferences automatically
93+
"""
94+
found = False
95+
settings = ['env_path', 'symlink', 'external_bins', 'last_check_update',
96+
'last_action', 'installed']
97+
98+
for setting in settings:
99+
current = get_setting(setting)
100+
if(current):
101+
save_sysetting(setting, current)
102+
save_setting(setting)
103+
found = True
104+
105+
return found
106+
80107
def file_paths(self):
81108
""" Set Initial Values
82109
@@ -165,7 +192,7 @@ def install(self):
165192
env_path = [self.V_ENV_PATH, self.V_ENV_BIN_PATH]
166193
save_env_paths(env_path)
167194

168-
save_setting('installed', True)
195+
save_sysetting('installed', True)
169196
PioBridge().save_boards_list()
170197

171198
derror("setup_finished")
@@ -219,7 +246,7 @@ def check_sym_link(self):
219246
dprint("symlink_detected")
220247
self.version = sub(r'\D', '', out[1])
221248
self.SYMLINK = 'python2'
222-
save_setting('symlink', True)
249+
save_sysetting('symlink', True)
223250

224251
def check_python(self):
225252
"""Python requirement
@@ -256,16 +283,16 @@ def check_pio():
256283
257284
Check if platformIO is already installed in the machine
258285
"""
259-
cmd = ['pio', '--version']
286+
cmd = ['platformio', '--version']
260287
out = run_command(cmd)
261288

262289
status = out[0]
263290

264291
if(status is 0):
265292
env_path = get_env_paths()
266-
save_setting('installed', True)
267-
save_setting('external_bins', True)
268-
save_setting('env_path', env_path)
293+
save_sysetting('installed', True)
294+
save_sysetting('external_bins', True)
295+
save_sysetting('env_path', env_path)
269296
PioBridge().save_boards_list()
270297
derror("pio_is_installed")
271298

@@ -339,7 +366,7 @@ def save_env_paths(new_path):
339366
paths = list(OrderedDict.fromkeys(paths))
340367
paths = path.pathsep.join(paths)
341368

342-
save_setting('env_path', paths)
369+
save_sysetting('env_path', paths)
343370

344371

345372
def get_default_paths():

commands/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .deviot_toggle_serial_monitor import DeviotToggleSerialMonitorCommand
2626
from .deviot_send_serial_monitor import DeviotSendSerialMonitorCommand
2727
from .deviot_output_console import DeviotOutputConsoleCommand
28+
from .deviot_send_persistent import DeviotSendPersistentCommand
2829
from .deviot_automatic_scroll import DeviotAutomaticScrollCommand
2930
from .deviot_auto_clean import DeviotAutoCleanCommand
3031
from .deviot_choose_baudrate import DeviotChooseBaudrateCommand
@@ -49,6 +50,7 @@
4950
from .deviot_clean_console import DeviotCleanConsoleCommand
5051
from .deviot_reload import DeviotReloadCommand
5152
from .deviot_set_ip import DeviotSetIpCommand
53+
from .deviot_history import InputTextHistoryCommand
5254

5355
__all__ = [
5456
'DeviotNewSketchCommand',
@@ -77,6 +79,7 @@
7779
'DeviotSetPasswordCommand',
7880
'DeviotToggleSerialMonitorCommand',
7981
'DeviotSendSerialMonitorCommand',
82+
'DeviotSendPersistentCommand',
8083
'DeviotOutputConsoleCommand',
8184
'DeviotStatusInformationCommand',
8285
'DeviotAutomaticScrollCommand',
@@ -101,5 +104,6 @@
101104
'DeviotCleanViewCommand',
102105
'DeviotCleanConsoleCommand',
103106
'DeviotReloadCommand',
104-
'DeviotSetIpCommand'
107+
'DeviotSetIpCommand',
108+
'InputTextHistoryCommand'
105109
]

commands/deviot_extra_library_folder.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ class DeviotExtraLibraryFolderCommand(WindowCommand):
88
"""
99

1010
def run(self):
11-
folder_explorer(key='extra_library', callback=save_setting)
11+
folder_explorer(key='extra_library', callback=self.done)
12+
13+
def done(self, key, value):
14+
save_setting(key, value)
15+
self.window.run_command('deviot_rebuild_syntax')

commands/deviot_history.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Copyright (c) 2015 Randy Lai <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
"""
22+
23+
from sublime import Region
24+
from sublime_plugin import TextCommand
25+
26+
27+
class History:
28+
hist = []
29+
index = None
30+
31+
def insert(self, user_input):
32+
if not self.hist or (user_input != self.last() and user_input != "last_regex"):
33+
self.hist.append(user_input)
34+
self.index = None
35+
36+
def roll(self, backwards=False):
37+
if self.index is None:
38+
self.index = -1 if backwards else 0
39+
else:
40+
self.index += -1 if backwards else 1
41+
42+
if self.index == len(self.hist) or self.index < -len(self.hist):
43+
self.index = -1 if backwards else 0
44+
45+
def last(self):
46+
return self.hist[-1] if self.hist else None
47+
48+
def get(self, index=None):
49+
if not index:
50+
index = self.index
51+
return self.hist[index] if self.hist else None
52+
53+
def reset_index(self):
54+
self.index = None
55+
56+
if 'history' not in globals():
57+
history = History()
58+
59+
60+
class InputTextHistoryCommand(TextCommand):
61+
def run(self, edit, backwards=False):
62+
history.roll(backwards)
63+
self.view.erase(edit, Region(0, self.view.size()))
64+
self.view.insert(edit, 0, history.get())

commands/deviot_pio_structure.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from sublime_plugin import WindowCommand
22
from ..libraries.tools import get_setting, save_setting
3+
from ..libraries.project_check import ProjectCheck
34

45
class DeviotPioStructureCommand(WindowCommand):
56
"""

commands/deviot_remove_extra_library_folder.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class DeviotRemoveExtraLibraryFolderCommand(WindowCommand):
99

1010
def run(self):
1111
save_setting('extra_library', None)
12+
self.window.run_command('deviot_rebuild_syntax')
1213

1314
def is_enabled(self):
1415
extra = get_setting('extra_library', None)

commands/deviot_send_persistent.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from sublime_plugin import WindowCommand
2+
from ..libraries.tools import get_setting, save_setting
3+
4+
class DeviotSendPersistentCommand(WindowCommand):
5+
"""
6+
Sets the input text for the serial communication, persistent,
7+
this means; after send a text, the input text will be displayed
8+
until press the esc key
9+
10+
Extends: sublime_plugin.WindowCommand
11+
"""
12+
13+
def run(self):
14+
send_persistent = get_setting('send_persistent', True)
15+
save_setting('send_persistent', not send_persistent)
16+
17+
18+
def is_checked(self):
19+
return get_setting('send_persistent', True)

commands/deviot_send_serial_monitor.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
from sublime_plugin import WindowCommand
1+
from sublime_plugin import TextCommand
22
from ..libraries import serial
33
from ..libraries.tools import get_setting
4+
from .deviot_history import history
45

5-
class DeviotSendSerialMonitorCommand(WindowCommand):
6+
class DeviotSendSerialMonitorCommand(TextCommand):
67
text_send = None
78
output_console = None
9+
window = None
810

9-
def run(self):
11+
def run(self, edit):
12+
self.window = self.view.window()
1013
caption = 'send'
11-
self.window.show_input_panel(caption, '', self.on_done, None, self.on_cancel)
14+
v = self.window.show_input_panel(caption, '', self.on_done, None, self.on_cancel)
15+
v.settings().set('deviotInputText', True)
1216

1317
def on_done(self, text):
18+
history.insert(text)
1419
self.text_send(text)
20+
self.window.run_command('deviot_send_serial_monitor')
1521

1622
if(self.output_console):
1723
self.window.run_command('deviot_show_console')
1824

1925
def on_cancel(self):
26+
history.reset_index()
2027
if(self.output_console):
2128
self.window.run_command('deviot_show_console')
2229

0 commit comments

Comments
 (0)