8ac156eb
—
pyros2097 13 years ago
Saves
- Widget/editor.py +8 -4
- Widget/editor.pyc +0 -0
- Widget/lexersquirrel.py +102 -39
- build/exe.win32-2.7/Sabel.exe +0 -0
- build/exe.win32-2.7/Sabel.zip +0 -0
- build/exe.win32-2.7/config.yaml +5 -9
- build/exe.win32-2.7/library.zip +0 -0
- config.yaml +0 -1
- cx.py +1 -1
Widget/editor.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from globals import fontSize,fontName,ospathjoin,os_pixmap,apiDir
|
|
2
2
|
|
|
3
|
-
from PyQt4.QtCore import SIGNAL
|
|
3
|
+
from PyQt4.QtCore import SIGNAL,QString
|
|
4
4
|
from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor ,QPalette
|
|
5
5
|
from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs ,QsciLexerCPP
|
|
6
6
|
from lexersquirrel import LexerSquirrel
|
|
@@ -12,7 +12,7 @@ class Editor(QsciScintilla):
|
|
|
12
12
|
self.parent = parent
|
|
13
13
|
self.lang = lang
|
|
14
14
|
self.colorStyle = colorStyle
|
|
15
|
-
self.init()
|
|
15
|
+
#self.init()
|
|
16
16
|
self.setText(text)
|
|
17
17
|
#self.addAction(QAction("gg",self))
|
|
18
18
|
#self.findFirst("function",False,True,True,True)
|
|
@@ -31,8 +31,10 @@ class Editor(QsciScintilla):
|
|
|
31
31
|
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
|
|
32
32
|
self.setAutoCompletionThreshold(1)
|
|
33
33
|
self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
|
|
34
|
+
self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
|
|
34
35
|
#self.setAutoCompletionSource(QsciScintilla.AcsAll)
|
|
35
36
|
#self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
|
|
37
|
+
self.init()
|
|
36
38
|
|
|
37
39
|
def init(self):
|
|
38
40
|
self.setCaretLineBackgroundColor(self.colorStyle.caret)
|
|
@@ -45,9 +47,11 @@ class Editor(QsciScintilla):
|
|
|
45
47
|
self.setFont(self.font)
|
|
46
48
|
self.fontmetrics = QFontMetrics(self.font)
|
|
47
49
|
self.setMarginsFont(self.font)
|
|
48
|
-
self.setMarginWidth(0, self.fontmetrics.width("0000") + 6)
|
|
49
50
|
# Margin 0 is used for line numbers
|
|
50
|
-
self.setMarginLineNumbers(0, True)
|
|
51
|
+
#self.setMarginLineNumbers(0, True)
|
|
52
|
+
#self.setMarginWidth(0, self.fontmetrics.width("0000") + 6)
|
|
53
|
+
self.setMarginLineNumbers(1, True)
|
|
54
|
+
self.setMarginWidth(1, QString("-------"))
|
|
51
55
|
self.setCaretLineVisible(True)
|
|
52
56
|
if self.lang == 0:
|
|
53
57
|
self.lexer = QsciLexerPython()
|
Widget/editor.pyc
CHANGED
|
Binary file
|
Widget/lexersquirrel.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from PyQt4.Qsci import QsciLexerCustom,QsciStyle,QsciScintilla
|
|
1
|
+
from PyQt4.Qsci import QsciLexerCustom,QsciStyle,QsciScintilla,QsciLexerPython
|
|
2
2
|
from PyQt4.QtCore import QString
|
|
3
3
|
from PyQt4.QtGui import QFont, QColor
|
|
4
4
|
from globals import fontName, fontSize
|
|
5
5
|
|
|
6
|
-
class LexerSquirrel(
|
|
6
|
+
class LexerSquirrel(QsciLexerPython):
|
|
7
7
|
words1 = [
|
|
8
8
|
'base','break','case','catch','class','clone',
|
|
9
9
|
'continue','const','default','delete','else','enum',
|
|
10
|
-
'extends','for','foreach','function','if','in',
|
|
10
|
+
'extends','for','foreach','function',' if',' in',
|
|
11
11
|
'local','null','resume','return','switch','this',
|
|
12
12
|
'throw','try','typeof','while','yield','constructor',
|
|
13
13
|
'instanceof','true','false','static'
|
|
@@ -31,12 +31,10 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
31
31
|
'getattributes', 'getclass', 'getstatus', 'ref'
|
|
32
32
|
]
|
|
33
33
|
|
|
34
|
-
words4 = [
|
|
35
|
-
]
|
|
36
34
|
def __init__(self,colorStyle, parent = None):
|
|
37
|
-
|
|
35
|
+
QsciLexerPython.__init__(self, parent)
|
|
38
|
-
self.parent = parent
|
|
36
|
+
#self.parent = parent
|
|
39
|
-
self.sci = self.parent
|
|
37
|
+
#self.sci = self.parent
|
|
40
38
|
self.colorStyle = colorStyle
|
|
41
39
|
self.plainFont = QFont()
|
|
42
40
|
self.plainFont.setFamily(fontName)
|
|
@@ -45,21 +43,22 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
45
43
|
self.marginFont = QFont()
|
|
46
44
|
self.marginFont.setPointSize(10)
|
|
47
45
|
self.marginFont.setFamily("MS Dlg")
|
|
48
|
-
self.boldFont = QFont()
|
|
46
|
+
self.boldFont = QFont(self.plainFont)
|
|
49
|
-
self.boldFont.setPointSize(10)
|
|
50
|
-
self.boldFont.setFamily("Courier New")
|
|
51
47
|
self.boldFont.setBold(True)
|
|
52
48
|
self.styles = [
|
|
53
49
|
#index description color paper font eol
|
|
54
50
|
QsciStyle(0, QString("base"), self.colorStyle.color, self.colorStyle.paper, self.plainFont, True),
|
|
55
|
-
QsciStyle(1, QString("comment"), QColor("#008000"), QColor("#eeffee"), self.
|
|
51
|
+
QsciStyle(1, QString("comment"), QColor("#008000"), QColor("#eeffee"), self.plainFont, True),
|
|
56
|
-
QsciStyle(2, QString("keyword"), QColor("#
|
|
52
|
+
QsciStyle(2, QString("keyword"), QColor("#008000"), QColor("#ffffff"), self.boldFont, False),
|
|
57
|
-
QsciStyle(3, QString("string"), QColor("#
|
|
53
|
+
QsciStyle(3, QString("string"), QColor("#008000"), QColor("#ffffff"), self.plainFont, True),
|
|
58
|
-
QsciStyle(4, QString("
|
|
54
|
+
QsciStyle(4, QString("number"), QColor("#008000"), QColor("#ffffff"), self.plainFont, True),
|
|
59
|
-
QsciStyle(5, QString("macro"), QColor("#808000"), QColor("#ffffff"), self.
|
|
55
|
+
QsciStyle(5, QString("macro"), QColor("#808000"), QColor("#ffffff"), self.plainFont, True),
|
|
60
56
|
QsciStyle(6, QString("error"), QColor("#000000"), QColor("#ffd0d0"), self.plainFont, True),
|
|
57
|
+
QsciStyle(7, QString("MultiComment_start"), QColor("#ff00ff"), QColor("#001111"), self.plainFont, False),
|
|
58
|
+
QsciStyle(8, QString("MultiComment"), QColor("#ff00ff"), QColor("#001111"), self.plainFont, False),
|
|
59
|
+
QsciStyle(9, QString("MultiComment_stop"), QColor("#ff00ff"), QColor("#001111"), self.plainFont, False)
|
|
61
60
|
]
|
|
62
|
-
|
|
61
|
+
self._foldcompact = True
|
|
63
62
|
|
|
64
63
|
def setColorStyle(self,cs):
|
|
65
64
|
self.colorStyle = cs
|
|
@@ -111,6 +110,12 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
111
110
|
return
|
|
112
111
|
|
|
113
112
|
SCI = editor.SendScintilla
|
|
113
|
+
GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
|
|
114
|
+
SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
|
|
115
|
+
HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
|
|
116
|
+
LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
|
|
117
|
+
NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
|
|
118
|
+
WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
|
|
114
119
|
set_style = self.setStyling
|
|
115
120
|
|
|
116
121
|
source = ''
|
|
@@ -121,38 +126,62 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
121
126
|
SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source)
|
|
122
127
|
if not source:
|
|
123
128
|
return
|
|
124
|
-
|
|
129
|
+
|
|
125
|
-
self.
|
|
130
|
+
compact = self.foldCompact()
|
|
126
|
-
|
|
127
131
|
index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start)
|
|
128
|
-
|
|
132
|
+
if index > 0:
|
|
133
|
+
pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1)
|
|
134
|
+
prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)
|
|
135
|
+
else:
|
|
136
|
+
prevState = self.styles[0]
|
|
137
|
+
|
|
138
|
+
self.startStyling(start, 0x1f)
|
|
129
139
|
for line in source.splitlines(True):
|
|
130
|
-
# Try to uncomment the following line to see in the console
|
|
131
|
-
# how Scintiallla works. You have to think in terms of isolated
|
|
132
|
-
# lines rather than globally on the whole text.
|
|
133
140
|
# print line
|
|
134
|
-
|
|
135
141
|
length = len(line)
|
|
136
|
-
|
|
142
|
+
# We must take care of empty lines.This is done here.
|
|
143
|
+
if length == 1:
|
|
144
|
+
if prevState == self.styles[8] or prevState == self.styles[7]:
|
|
145
|
+
newState = self.styles[8]
|
|
146
|
+
else:
|
|
147
|
+
newState = self.styles[0]
|
|
137
|
-
if line.startswith('#'):
|
|
148
|
+
#if line.startswith('#'):
|
|
138
|
-
|
|
149
|
+
# newState = self.styles[3]
|
|
139
|
-
elif line.startswith('\t+') or line.startswith(' +'):
|
|
150
|
+
#elif line.startswith('\t+') or line.startswith(' +'):
|
|
140
|
-
|
|
151
|
+
# newState = self.styles[3]
|
|
152
|
+
#We work with a non empty line.
|
|
141
153
|
else:
|
|
154
|
+
if line.startswith('@'):
|
|
155
|
+
newState = self.styles[7]
|
|
156
|
+
elif line.startswith('@'):
|
|
157
|
+
if prevState == self.styles[8] or prevState == self.styles[7]:
|
|
158
|
+
newState = self.styles[9]
|
|
159
|
+
else:
|
|
160
|
+
newState = self.styles[0]
|
|
161
|
+
#elif line.startswith('//'):
|
|
162
|
+
# if prevState == self.styles[8] or prevState == self.styles[7]:
|
|
163
|
+
# newState = self.styles[8]
|
|
164
|
+
# else:
|
|
165
|
+
# newState = self.styles[8]
|
|
166
|
+
elif prevState == self.styles[8] or prevState == self.styles[7]:
|
|
167
|
+
newState = self.styles[8]
|
|
168
|
+
else:
|
|
169
|
+
newState = self.styles[0]
|
|
170
|
+
#set_style(length, newState)
|
|
142
171
|
pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index) - length + 1
|
|
143
172
|
i = 0
|
|
144
173
|
while i < length:
|
|
145
174
|
wordLength = 1
|
|
146
|
-
|
|
175
|
+
|
|
147
176
|
self.startStyling(i + pos, 0x1f)
|
|
148
177
|
newState = self.styles[0]
|
|
149
|
-
|
|
178
|
+
|
|
150
|
-
for word in self.
|
|
179
|
+
for word in self.words2:
|
|
151
180
|
if line[i:].startswith(word):
|
|
152
|
-
newState = self.styles[
|
|
181
|
+
newState = self.styles[4]
|
|
153
182
|
wordLength = len(word)
|
|
154
183
|
|
|
155
|
-
|
|
184
|
+
|
|
156
185
|
if chr(line[i]) in '0123456789':
|
|
157
186
|
newState = self.styles[4]
|
|
158
187
|
else:
|
|
@@ -162,27 +191,60 @@ class LexerSquirrel(QsciLexerCustom):
|
|
|
162
191
|
elif line[i:].startswith('function'):
|
|
163
192
|
newState = self.styles[3]
|
|
164
193
|
wordLength = len('function')
|
|
165
|
-
elif line[i:].startswith('if'):
|
|
194
|
+
elif line[i:].startswith(' if'):
|
|
166
195
|
newState = self.styles[4]
|
|
167
|
-
wordLength = len('if')
|
|
196
|
+
wordLength = len(' if')
|
|
168
197
|
elif line[i:].startswith('#'):
|
|
169
198
|
newState = self.styles[4]
|
|
170
199
|
wordLength = length
|
|
171
200
|
elif line[i:].startswith('//'):
|
|
172
201
|
newState = self.styles[4]
|
|
173
202
|
wordLength = length
|
|
203
|
+
elif line[i:].startswith('/*'):
|
|
204
|
+
newState = self.styles[4]
|
|
205
|
+
wordLength = length
|
|
206
|
+
elif line[i:].startswith('*/'):
|
|
207
|
+
newState = self.styles[4]
|
|
208
|
+
wordLength = length
|
|
174
|
-
else:
|
|
209
|
+
#else:
|
|
175
|
-
newState = self.styles[0]
|
|
210
|
+
#newState = self.styles[0]
|
|
211
|
+
|
|
176
212
|
|
|
177
213
|
i += wordLength
|
|
178
214
|
set_style(wordLength, newState)
|
|
179
215
|
newState = None
|
|
216
|
+
|
|
180
217
|
if newState:
|
|
181
218
|
set_style(length, newState)
|
|
219
|
+
|
|
220
|
+
#Folding
|
|
221
|
+
# folding implementation goes here
|
|
222
|
+
#levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index-1)
|
|
223
|
+
#if line.startswith('+'):
|
|
224
|
+
# SCI(SETFOLDLEVEL, index, levelFolder + 1)
|
|
225
|
+
# #editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
|
|
226
|
+
#elif line.startswith('function'):
|
|
227
|
+
# SCI(SETFOLDLEVEL, index, levelFolder + 1)
|
|
228
|
+
#editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
|
|
229
|
+
"""
|
|
230
|
+
if newState == self.styles[7]:
|
|
231
|
+
if prevState == self.styles[8]:
|
|
232
|
+
level = LEVELBASE + 1
|
|
233
|
+
else:
|
|
234
|
+
level = LEVELBASE | HEADERFLAG
|
|
235
|
+
elif newState == self.styles[8] or newState == self.styles[9]:
|
|
236
|
+
level = LEVELBASE + 1
|
|
237
|
+
else:
|
|
238
|
+
level = LEVELBASE
|
|
239
|
+
|
|
240
|
+
SCI(SETFOLDLEVEL, index, level)
|
|
182
241
|
|
|
242
|
+
pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index)
|
|
243
|
+
prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)"""
|
|
183
244
|
index += 1
|
|
184
245
|
|
|
185
246
|
|
|
247
|
+
"""
|
|
186
248
|
import sys
|
|
187
249
|
from PyQt4 import QtCore, QtGui, Qsci
|
|
188
250
|
|
|
@@ -294,3 +356,4 @@ if __name__ == "__main__":
|
|
|
294
356
|
win = MainWindow()
|
|
295
357
|
win.show()
|
|
296
358
|
sys.exit(app.exec_())
|
|
359
|
+
"""
|
build/exe.win32-2.7/Sabel.exe
CHANGED
|
Binary file
|
build/exe.win32-2.7/Sabel.zip
CHANGED
|
Binary file
|
build/exe.win32-2.7/config.yaml
CHANGED
|
@@ -5,21 +5,17 @@ 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/
|
|
8
|
+
- C:/CODE/assets/creditscene.nut
|
|
9
|
-
- C:/CODE/assetsdd/howtoscene.nut
|
|
10
9
|
Project:
|
|
11
10
|
- C:/CODE/data/
|
|
12
|
-
- C:/CODE/
|
|
11
|
+
- C:/CODE/assets/
|
|
13
12
|
Recent:
|
|
14
13
|
- C:\CODE\main.nut
|
|
15
14
|
Setting:
|
|
16
|
-
fontname: Courier
|
|
15
|
+
fontname: Courier New
|
|
17
16
|
fontsize: 10
|
|
18
17
|
iconsize: 16
|
|
19
|
-
|
|
18
|
+
styleindex: 0
|
|
20
19
|
thresh: 1
|
|
21
20
|
workspace: C:/CODE/
|
|
22
|
-
|
|
21
|
+
Style: 0
|
|
23
|
-
default:
|
|
24
|
-
bg: white
|
|
25
|
-
color: black
|
build/exe.win32-2.7/library.zip
CHANGED
|
Binary file
|
config.yaml
CHANGED
|
@@ -5,7 +5,6 @@ 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/assets/creditscene.nut
|
|
9
8
|
- C:/CODE/assets/runtime.nut
|
|
10
9
|
Project:
|
|
11
10
|
- C:/CODE/data/
|
cx.py
CHANGED
|
@@ -17,7 +17,7 @@ exe = Executable(
|
|
|
17
17
|
copyDependentFiles = True,
|
|
18
18
|
appendScriptToExe = False,
|
|
19
19
|
appendScriptToLibrary = False,
|
|
20
|
-
icon =
|
|
20
|
+
icon = "C:\CODE\Icons\sabel.ico"
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
setup(
|