7b8184f2
—
pyros2097 13 years ago
v0.48
- Widget/editor.py +3 -4
- Widget/editor.pyc +0 -0
- Widget/lexersquirrel.py +26 -19
- Widget/tree.py +8 -3
- Widget/tree.pyc +0 -0
- config.yaml +3 -2
- main.py +10 -9
- window.py +9 -14
Widget/editor.py
CHANGED
|
@@ -4,10 +4,9 @@ from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs ,QsciLexerCPP
|
|
|
4
4
|
from globals import ospathjoin,workDir,fontSize,fontName
|
|
5
5
|
from lexersquirrel import LexerSquirrel
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
class Style:
|
|
9
8
|
def __init__(self):
|
|
10
|
-
self.
|
|
9
|
+
self.color = QColor('#000000')
|
|
11
10
|
self.paper = QColor('#FFFFFF')
|
|
12
11
|
self.caret = QColor('#ffe4e4')
|
|
13
12
|
self.marker = QColor('#ee1111')
|
|
@@ -19,7 +18,7 @@ class Style:
|
|
|
19
18
|
|
|
20
19
|
class Editor(QsciScintilla):
|
|
21
20
|
ARROW_MARKER_NUM = 8
|
|
22
|
-
def __init__(self,parent,text,
|
|
21
|
+
def __init__(self,parent,text,lang = 2,styleIndex = 0):
|
|
23
22
|
QsciScintilla.__init__(self,parent)
|
|
24
23
|
self.parent = parent
|
|
25
24
|
self.styleIndex = styleIndex
|
|
@@ -70,7 +69,7 @@ class Editor(QsciScintilla):
|
|
|
70
69
|
elif self.lang == 1:
|
|
71
70
|
self.lexer = QsciLexerCPP()
|
|
72
71
|
elif self.lang == 2:
|
|
73
|
-
self.lexer = LexerSquirrel()
|
|
72
|
+
self.lexer = LexerSquirrel(self.colorStyle,self)
|
|
74
73
|
self.lexer.setDefaultFont(self.font)
|
|
75
74
|
|
|
76
75
|
|
Widget/editor.pyc
CHANGED
|
Binary file
|
Widget/lexersquirrel.py
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
from PyQt4.Qsci import QsciLexerCustom,QsciStyle
|
|
2
2
|
from PyQt4.QtCore import QString
|
|
3
|
-
from PyQt4.QtGui import
|
|
3
|
+
from PyQt4.QtGui import QFont, QColor
|
|
4
4
|
|
|
5
5
|
class LexerSquirrel(QsciLexerCustom):
|
|
6
|
-
def __init__(self, parent = None):
|
|
6
|
+
def __init__(self,colorStyle, parent = None):
|
|
7
7
|
QsciLexerCustom.__init__(self, parent)
|
|
8
|
-
|
|
8
|
+
self.parent = parent
|
|
9
|
-
self.sci =
|
|
9
|
+
self.sci = self.parent
|
|
10
|
-
|
|
10
|
+
self.colorStyle = colorStyle
|
|
11
|
-
self.plainFont = QFont()
|
|
12
|
-
self.plainFont.
|
|
11
|
+
self.plainFont = self.colorStyle.font
|
|
13
|
-
self.plainFont.setFamily("Courier New")
|
|
14
12
|
self.marginFont = QFont()
|
|
15
13
|
self.marginFont.setPointSize(10)
|
|
16
14
|
self.marginFont.setFamily("MS Dlg")
|
|
@@ -19,9 +17,10 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
19
17
|
self.boldFont.setFamily("Courier New")
|
|
20
18
|
self.boldFont.setBold(True)
|
|
21
19
|
self.styles = [
|
|
20
|
+
#index description color paper font eol
|
|
22
|
-
QsciStyle(0, QString("base"),
|
|
21
|
+
QsciStyle(0, QString("base"), self.colorStyle.color, self.colorStyle.paper, self.plainFont, True),
|
|
23
22
|
QsciStyle(1, QString("comment"), QColor("#008000"), QColor("#eeffee"), self.marginFont, True),
|
|
24
|
-
QsciStyle(2, QString("keyword"), QColor("#000080"), QColor("#ffffff"), self.boldFont,
|
|
23
|
+
QsciStyle(2, QString("keyword"), QColor("#000080"), QColor("#ffffff"), self.boldFont, False),
|
|
25
24
|
QsciStyle(3, QString("string"), QColor("#800000"), QColor("#ffffff"), self.marginFont, True),
|
|
26
25
|
QsciStyle(4, QString("atom"), QColor("#008080"), QColor("#ffffff"), self.plainFont, True),
|
|
27
26
|
QsciStyle(5, QString("macro"), QColor("#808000"), QColor("#ffffff"), self.boldFont, True),
|
|
@@ -29,6 +28,9 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
29
28
|
]
|
|
30
29
|
#print("LexerErlang created")
|
|
31
30
|
|
|
31
|
+
def setColorStyle(self,cs):
|
|
32
|
+
self.colorStyle = cs
|
|
33
|
+
|
|
32
34
|
def language(self):
|
|
33
35
|
return 'Squirrel'
|
|
34
36
|
|
|
@@ -42,7 +44,7 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
42
44
|
for i in self.styles:
|
|
43
45
|
if i.style() == ix:
|
|
44
46
|
return i.description()
|
|
45
|
-
return
|
|
47
|
+
return QString("")
|
|
46
48
|
|
|
47
49
|
def defaultColor(self, ix):
|
|
48
50
|
for i in self.styles:
|
|
@@ -68,10 +70,6 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
68
70
|
return i.eolFill()
|
|
69
71
|
return QsciLexerCustom.defaultEolFill(self, ix)
|
|
70
72
|
|
|
71
|
-
def setEditor(self, sci):
|
|
72
|
-
self.sci = sci
|
|
73
|
-
Qsci.QsciLexerCustom.setEditor(self, sci)
|
|
74
|
-
#print("LexerErlang.setEditor()")
|
|
75
73
|
def styleText(self, start, end):
|
|
76
74
|
#print("LexerErlang.styleText(%d,%d)" % (start, end))
|
|
77
75
|
lines = self.getText(start, end)
|
|
@@ -79,19 +77,28 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
79
77
|
self.startStyling(offset, 0)
|
|
80
78
|
#print("startStyling()")
|
|
81
79
|
for i in lines:
|
|
80
|
+
length = len(i)
|
|
82
81
|
if i == "":
|
|
83
82
|
self.setStyling(1, self.styles[0])
|
|
84
83
|
#print("setStyling(1)")
|
|
85
84
|
offset += 1
|
|
86
85
|
continue
|
|
86
|
+
if i == '#':
|
|
87
|
+
self.setStyling(1, self.styles[2])
|
|
88
|
+
offset += 1
|
|
89
|
+
continue
|
|
90
|
+
if i == 'g':
|
|
91
|
+
self.setStyling(1, self.styles[3])
|
|
92
|
+
offset += 1
|
|
93
|
+
continue
|
|
87
94
|
if i[0] == '%':
|
|
88
|
-
self.setStyling(
|
|
95
|
+
self.setStyling(length+1, self.styles[1])
|
|
89
96
|
#print("setStyling(%)")
|
|
90
|
-
offset +=
|
|
97
|
+
offset += length+1
|
|
91
98
|
continue
|
|
92
|
-
self.setStyling(
|
|
99
|
+
self.setStyling(length+1, self.styles[0])
|
|
93
100
|
#print("setStyling(n)")
|
|
94
|
-
offset +=
|
|
101
|
+
offset += length+1
|
|
95
102
|
|
|
96
103
|
def getText(self, start, end):
|
|
97
104
|
data = self.sci.text()
|
Widget/tree.py
CHANGED
|
@@ -23,6 +23,7 @@ class Dir(QTreeWidgetItem):
|
|
|
23
23
|
return False
|
|
24
24
|
|
|
25
25
|
class File(QTreeWidgetItem):
|
|
26
|
+
ext = [".txt",".nut",".py",".cpp",".c",".h"]
|
|
26
27
|
def __init__(self,parent,name,path):
|
|
27
28
|
QTreeWidgetItem.__init__(self,parent)
|
|
28
29
|
self.path = ospathjoin(path,name)
|
|
@@ -39,9 +40,13 @@ class File(QTreeWidgetItem):
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
def Doc(self,name):
|
|
43
|
+
for e in self.ext:
|
|
42
|
-
|
|
44
|
+
if name.endswith(e):
|
|
43
|
-
|
|
45
|
+
self.setIcon(0,os_icon("file_obj"))
|
|
44
|
-
|
|
46
|
+
self.doc = True
|
|
47
|
+
#if(name.endswith(".txt") or name.endswith(".nut") or name.endswith(".py")):
|
|
48
|
+
# self.setIcon(0,os_icon("file_obj"))
|
|
49
|
+
# self.doc = True
|
|
45
50
|
|
|
46
51
|
def Pic(self,name):
|
|
47
52
|
if(name.endswith(".png") or name.endswith(".gif") or name.endswith(".jpg")):
|
Widget/tree.pyc
CHANGED
|
Binary file
|
config.yaml
CHANGED
|
@@ -5,14 +5,15 @@ ADB:
|
|
|
5
5
|
- adb -d shell ps | grep com.emo_framework.examples | awk '{print $2}' | xargs adb
|
|
6
6
|
shell kill
|
|
7
7
|
File:
|
|
8
|
-
- C:/CODE/assetsdd/
|
|
8
|
+
- C:/CODE/assetsdd/common.nut
|
|
9
|
+
- C:/CODE/assetsdd/howtoscene.nut
|
|
9
10
|
Project:
|
|
10
11
|
- C:/CODE/data/
|
|
11
12
|
- C:/CODE/assetsdd/
|
|
12
13
|
Recent:
|
|
13
14
|
- C:\CODE\main.nut
|
|
14
15
|
Setting:
|
|
15
|
-
fontname: Courier
|
|
16
|
+
fontname: Courier New
|
|
16
17
|
fontsize: 10
|
|
17
18
|
iconsize: 16
|
|
18
19
|
style: 0
|
main.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
__author__ = "pyros2097"
|
|
3
3
|
__license__ = "GPLv3"
|
|
4
|
-
__version__ = "0.
|
|
4
|
+
__version__ = "0.48"
|
|
5
5
|
__copyright__ = 'Copyright (c) 2012, pyros2097'
|
|
6
6
|
__credits__ = ['pyros2097', 'eclipse']
|
|
7
7
|
__email__ = 'pyros2097@gmail.com'
|
|
@@ -15,8 +15,6 @@ from PyQt4.QtGui import (QApplication,QPixmap,QSplashScreen,QMessageBox,
|
|
|
15
15
|
QIcon,QAction,QCheckBox,QFileDialog)
|
|
16
16
|
from PyQt4.QtCore import SIGNAL,Qt,QStringList,QString
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
18
|
import icons_rc
|
|
21
19
|
from window import Window
|
|
22
20
|
from Widget import Editor,PyInterp,Adb
|
|
@@ -93,13 +91,11 @@ class MainWindow(Window):
|
|
|
93
91
|
if type(nfile) == str:
|
|
94
92
|
if(ospathexists(nfile)):
|
|
95
93
|
try:
|
|
96
|
-
#print type(nfile)
|
|
97
|
-
#print "file: "+nfile
|
|
98
94
|
infile = open(nfile, 'r')
|
|
99
95
|
self.files.append(nfile)
|
|
100
96
|
config.addFile(nfile)
|
|
101
97
|
self.dirty.append(False)
|
|
102
|
-
tab = Editor(self,infile.read())
|
|
98
|
+
tab = Editor(self,infile.read(),self.syntax(nfile))
|
|
103
99
|
infile.close()
|
|
104
100
|
self.tabWidget.addTab(tab,ospathbasename(nfile))
|
|
105
101
|
tab.textChanged.connect(lambda:self.setDirty(nfile))
|
|
@@ -189,7 +185,6 @@ class MainWindow(Window):
|
|
|
189
185
|
for file in self.files:
|
|
190
186
|
if(file != fname):
|
|
191
187
|
self.createTab(fname)
|
|
192
|
-
self.files.append(fname)
|
|
193
188
|
return
|
|
194
189
|
else:
|
|
195
190
|
QMessageBox.about(self, "Already Open","File Already Open")
|
|
@@ -256,8 +251,14 @@ class MainWindow(Window):
|
|
|
256
251
|
elif reply == QMessageBox.Yes:
|
|
257
252
|
self.fileSaveAll()
|
|
258
253
|
|
|
259
|
-
def syntax(self):
|
|
254
|
+
def syntax(self,nfile):
|
|
255
|
+
if nfile.endswith(".py"):
|
|
260
|
-
|
|
256
|
+
lang = 0
|
|
257
|
+
elif (nfile.endswith(".cpp") or nfile.endswith(".h") or nfile.endswith(".c")):
|
|
258
|
+
lang = 1
|
|
259
|
+
elif nfile.endswith(".nut"):
|
|
260
|
+
lang = 0
|
|
261
|
+
return lang
|
|
261
262
|
|
|
262
263
|
def style(self):
|
|
263
264
|
pass
|
window.py
CHANGED
|
@@ -10,7 +10,7 @@ from globals import (ospathsep,ospathjoin,ospathbasename,workDir,
|
|
|
10
10
|
iconSize,iconDir)
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
__version__ = "0.
|
|
13
|
+
__version__ = "0.48"
|
|
14
14
|
|
|
15
15
|
class Window(QMainWindow):
|
|
16
16
|
def __init__(self,parent = None):
|
|
@@ -220,27 +220,23 @@ class Window(QMainWindow):
|
|
|
220
220
|
self.action_Todo = QAction(os_icon('task_set'), 'Todo', self)
|
|
221
221
|
#self.action_Todo.triggered.connect(self.stop)
|
|
222
222
|
#Only variation CHeck Later
|
|
223
|
+
|
|
224
|
+
men = QMenu()
|
|
225
|
+
men.addAction(QAction("Ident",self))
|
|
226
|
+
men.addAction(QAction("Edit",self))
|
|
227
|
+
men.addAction(QAction("Paste",self))
|
|
228
|
+
men.addAction(QAction("Tabs",self))
|
|
223
229
|
self.action_Options = QAction(QIcon(":/{0}.png".format("Icons"+ospathsep+'emblem-system')), 'Options', self)
|
|
230
|
+
self.action_Options.setMenu(men)
|
|
224
231
|
self.action_Options.triggered.connect(self.options)
|
|
225
232
|
self.action_Full = QAction(os_icon('task_set'), 'Full', self)
|
|
226
233
|
self.action_Full.setShortcut('Shift+Enter')
|
|
227
234
|
self.action_Full.triggered.connect(self.full)
|
|
228
235
|
|
|
229
|
-
self.action_Syntax = QAction(os_icon('task_set'), 'Syntax', self)
|
|
230
|
-
men = QMenu()#public_co.gif
|
|
231
236
|
#chkBox =QCheckBox(men)
|
|
232
237
|
#chkBox.setText("MyCheckBox")
|
|
233
|
-
chkBoxAction=QWidgetAction(men)
|
|
238
|
+
#chkBoxAction=QWidgetAction(men)
|
|
234
239
|
#chkBoxAction.setDefaultWidget(QPixmap(":/Icons/public_co"))
|
|
235
|
-
men.addAction(chkBoxAction)
|
|
236
|
-
|
|
237
|
-
men.addAction(QAction("C",self))
|
|
238
|
-
men.addAction(QAction("C++",self))
|
|
239
|
-
men.addAction(QAction("Lua",self))
|
|
240
|
-
men.addAction(QAction("Squirrel",self))
|
|
241
|
-
self.action_Syntax.setMenu(men)
|
|
242
|
-
|
|
243
|
-
|
|
244
240
|
|
|
245
241
|
self.action_Style = QAction(os_icon('welcome16'), 'Style', self)
|
|
246
242
|
self.action_Style.triggered.connect(self.style)
|
|
@@ -283,7 +279,6 @@ class Window(QMainWindow):
|
|
|
283
279
|
self.toolbar.addAction(self.action_Design)
|
|
284
280
|
self.toolbar.addAction(self.action_Todo)
|
|
285
281
|
self.toolbar.addAction(self.action_Options)
|
|
286
|
-
self.toolbar.addAction(self.action_Syntax)
|
|
287
282
|
self.toolbar.addAction(self.action_Style)
|
|
288
283
|
self.toolbar.addSeparator()
|
|
289
284
|
self.toolbar.addAction(self.action_Help)
|