Skip to content

Commit

Permalink
Organice snipplets, improve run
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Ribelotta <martinribelotta@gmail.com>
  • Loading branch information
martinribelotta committed Dec 8, 2015
1 parent c5f3e05 commit ec6c962
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pydevproject
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
<path>/${PROJECT_DIR_NAME}/src</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
Expand Down
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//src/resources.py=utf-8
4 changes: 4 additions & 0 deletions share/snipplet/snipplet_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Description: Class declaration
class NAME(object):
def __init__(self):
pass
19 changes: 19 additions & 0 deletions share/snipplet/snipplet_iterator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Description: Object iterator
class firstn(object):
def __init__(self, n):
self.n = n
self.num = 0

def __iter__(self):
return self

# Python 3 compatibility
def __next__(self):
return self.next()

def next(self):
if self.num < self.n:
cur, self.num = self.num, self.num+1
return cur
else:
raise StopIteration()
3 changes: 3 additions & 0 deletions share/snipplet/snipplet_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Description: Main of module
if __name__ == '__main__':
pass
3 changes: 3 additions & 0 deletions share/snipplet/snipplet_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Description: open file
with open('NAME', 'rwa+') as f:
pass
9 changes: 9 additions & 0 deletions share/snipplet/snipplet_try.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Description: Try/Except/Finally/Else block
try:
pass
except Exception as e:
print(e)
else:
pass
finally:
pass
1 change: 1 addition & 0 deletions src/termWidget.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import glob
import pyte
import serial
Expand Down
9 changes: 4 additions & 5 deletions src/uPyIDE.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def rccfile(path):
class WidgetSpacer(QtWidgets.QWidget):
def __init__(self, parent):
super(WidgetSpacer, self).__init__(parent)
self.setSizePolicy(
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)


class SnipplerWidget(QtWidgets.QDockWidget):
Expand All @@ -54,7 +53,6 @@ def __init__(self, parent):
self.snippletView.itemDoubleClicked.connect(self._insertToParent)

def _insertToParent(self, item):
print(("insertToParent", item))
self.parent().editor.insertPlainText(item.toolTip())

def addSnipplet(self, description, contents):
Expand Down Expand Up @@ -236,6 +234,7 @@ def openTerm(self):
if self.termAction.isChecked():
self.stack.setCurrentIndex(1)
self.term.setFocus()
# self.term.remoteExec(b'\x04')
else:
self.stack.setCurrentIndex(0)

Expand All @@ -261,7 +260,7 @@ def progrun1(text):
if progrun1.text.endswith(b'to exit\r\n>'):
progrun2.text = b''
# print("{} {}".format(3, progrun1.text))
cmd = 'print("\033c")\r{}\r\x04'.format(script)
cmd = 'print("\033c")\r{}\r\x04\x02'.format(script)
# print("{} {}".format(3.5, cmd))
self.term.remoteExec(bytes(cmd, 'utf-8'), progrun2)
return True
Expand Down

0 comments on commit ec6c962

Please sign in to comment.