37864a72 pyros2097

13 years ago
v0.63 new lexer
Widget/lexersquirrel.py DELETED
@@ -1,381 +0,0 @@
1
- from PyQt4.Qsci import QsciLexerCustom,QsciStyle,QsciScintilla,QsciLexerPython
2
- from PyQt4.QtCore import QString
3
- from PyQt4.QtGui import QFont, QColor
4
- from globals import fontName, fontSize
5
-
6
- class LexerSquirrel(QsciLexerPython):
7
- words1 = [
8
- 'base','break','case','catch','class','clone',
9
- 'continue','const','default','delete','else','enum',
10
- 'extends','for','foreach','function',' if',' in',
11
- 'local','null','resume','return','switch','this',
12
- 'throw','try','typeof','while','yield','constructor',
13
- 'instanceof','true','false','static'
14
- ]
15
-
16
- words2 = [
17
- 'init', 'dest', 'onLoad', 'onDispose', 'onGainedFocus','onMotionEvent',
18
- 'onLostFocus','onUpdate','onFps','onKeyEvent','onSensorEvent',
19
- 'onControlEvent','onDrawFrame','onError','onLowMemory','onNetCallBack'
20
- ]
21
-
22
- words3 = [
23
- 'rawdelete', 'rawin', 'array', 'seterrorhandler', 'setdebughook',
24
- 'enabledebuginfo', 'getroottable', 'setroottable', 'getconsttable',
25
- 'setconsttable', 'assert', 'print', 'compilestring', 'collectgarbage',
26
- 'type', 'getstackinfos', 'newthread', 'tofloat', 'tostring',
27
- 'tointeger', 'tochar', 'weakref', 'slice', 'find', 'tolower',
28
- 'toupper', 'len', 'rawget', 'rawset', 'clear', 'append', 'push',
29
- 'extend', 'pop', 'top', 'insert', 'remove', 'resize', 'sort',
30
- 'reverse', 'call', 'pcall', 'acall', 'pacall', 'bindenv', 'instance',
31
- 'getattributes', 'getclass', 'getstatus', 'ref'
32
- ]
33
-
34
- def __init__(self,colorStyle, parent = None):
35
- QsciLexerPython.__init__(self, parent)
36
- self.setV2UnicodeAllowed(True)
37
- #self.setHighlightSubidentifiers(True)
38
- #self.parent = parent
39
- #self.sci = self.parent
40
- #print self.FunctionMethodName
41
- self.colorStyle = colorStyle
42
- self.plainFont = QFont()
43
- self.plainFont.setFamily(fontName)
44
- self.plainFont.setFixedPitch(True)
45
- self.plainFont.setPointSize(fontSize)
46
- self.marginFont = QFont()
47
- self.marginFont.setPointSize(10)
48
- self.marginFont.setFamily("MS Dlg")
49
- self.boldFont = QFont(self.plainFont)
50
- self.boldFont.setBold(True)
51
- """
52
- enum {
53
- Default = 0, Comment = 1, Number = 2,
54
- DoubleQuotedString = 3, SingleQuotedString = 4, Keyword = 5,
55
- TripleSingleQuotedString = 6, TripleDoubleQuotedString = 7, ClassName = 8,
56
- FunctionMethodName = 9, Operator = 10, Identifier = 11,
57
- CommentBlock = 12, UnclosedString = 13, HighlightedIdentifier = 14,
58
- Decorator = 15
59
- }
60
- enum IndentationWarning {
61
- NoWarning = 0, Inconsistent = 1, TabsAfterSpaces = 2,
62
- Spaces = 3, Tabs = 4
63
- }
64
- """
65
- self.styles = [
66
- #index description color paper font eol
67
- QsciStyle(0, QString("base"), self.colorStyle.color, self.colorStyle.paper, self.plainFont, True),
68
- QsciStyle(1, QString("comment"), QColor("#3f7f5f"), self.colorStyle.paper, self.plainFont, True),
69
- QsciStyle(2, QString("number"), QColor("#008000"), self.colorStyle.paper, self.plainFont, False),
70
- QsciStyle(3, QString("DoubleQuotedString"), QColor("#008000"), self.colorStyle.paper, self.plainFont, True),
71
- QsciStyle(4, QString("SingleQuotedString"), QColor("#008000"), self.colorStyle.paper, self.plainFont, True),
72
- QsciStyle(5, QString("Keyword"), QColor("#7f0055"), self.colorStyle.paper, self.boldFont, True),
73
- QsciStyle(6, QString("TripleSingleQuotedString"), QColor("#ffd0d0"),self.colorStyle.paper, self.plainFont, True),
74
- QsciStyle(7, QString("TripleDoubleQuotedString"),QColor("#001111"),self.colorStyle.paper, self.plainFont, False),
75
- QsciStyle(8, QString("ClassName"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False),
76
- QsciStyle(9, QString("FunctionMethodName"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False),
77
- QsciStyle(10, QString("Operator"), QColor("#ff00ff"), self.colorStyle.paper, self.plainFont, False),
78
- QsciStyle(11, QString("Identifier"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False),
79
- QsciStyle(12, QString("CommentBlock"), QColor("#3f5fbf"), self.colorStyle.paper, self.plainFont, False),
80
- QsciStyle(13, QString("UnclosedString"), QColor("#010101"), self.colorStyle.paper, self.plainFont, False),
81
- QsciStyle(14, QString("HighlightedIdentifier"), QColor("#0000ff"), self.colorStyle.paper, self.plainFont, False),
82
- QsciStyle(15, QString("Decorator"), QColor("#ff00ff"), self.colorStyle.paper, self.plainFont, False),
83
- ]
84
- self._foldcompact = True
85
-
86
- def setColorStyle(self,cs):
87
- self.colorStyle = cs
88
- for i in self.styles:
89
- i.setPaper(self.colorStyle.paper)
90
- self.styles[0].setColor(self.colorStyle.color)
91
-
92
-
93
- def language(self):
94
- return 'Squirrel'
95
-
96
- def foldCompact(self):
97
- return self._foldcompact
98
-
99
- def setFoldCompact(self, enable):
100
- self._foldcompact = bool(enable)
101
-
102
- def description(self, ix):
103
- for i in self.styles:
104
- if i.style() == ix:
105
- return i.description()
106
- return QString("")
107
-
108
- def defaultColor(self, ix):
109
- for i in self.styles:
110
- if i.style() == ix:
111
- return i.color()
112
- return QsciLexerCustom.defaultColor(self, ix)
113
-
114
- def defaultFont(self, ix):
115
- for i in self.styles:
116
- if i.style() == ix:
117
- return i.font()
118
- return QsciLexerCustom.defaultFont(self, ix)
119
-
120
- def defaultPaper(self, ix):
121
- for i in self.styles:
122
- if i.style() == ix:
123
- return i.paper()
124
- return QsciLexerCustom.defaultPaper(self, ix)
125
-
126
- def defaultEolFill(self, ix):
127
- for i in self.styles:
128
- if i.style() == ix:
129
- return i.eolFill()
130
- return QsciLexerCustom.defaultEolFill(self, ix)
131
-
132
- def styleText(self, start, end):
133
- editor = self.editor()
134
- if editor is None:
135
- return
136
-
137
- SCI = editor.SendScintilla
138
- GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
139
- SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
140
- HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
141
- LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
142
- NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
143
- WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
144
- set_style = self.setStyling
145
-
146
- source = ''
147
- if end > editor.length():
148
- end = editor.length()
149
- if end > start:
150
- source = bytearray(end - start)
151
- SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source)
152
- if not source:
153
- return
154
-
155
- compact = self.foldCompact()
156
- index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start)
157
- if index > 0:
158
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1)
159
- prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)
160
- else:
161
- prevState = self.styles[0]
162
-
163
- self.startStyling(start, 0x1f)
164
- for line in source.splitlines(True):
165
- # print line
166
- length = len(line)
167
- # We must take care of empty lines.This is done here.
168
- if length == 1:
169
- return
170
- if line.startswith('@@'):
171
- newState = self.styles[1]
172
- elif line.startswith('\t+') or line.startswith(' +'):
173
- newState = self.styles[3]
174
- #We work with a non empty line.
175
- else:
176
- if line.startswith('@'):
177
- newState = self.styles[1]
178
- elif line.startswith('@'):
179
- if prevState == self.styles[1] or prevState == self.styles[1]:
180
- newState = self.styles[1]
181
- else:
182
- newState = self.styles[0]
183
- #elif line.startswith('//'):
184
- # if prevState == self.styles[8] or prevState == self.styles[7]:
185
- # newState = self.styles[8]
186
- # else:
187
- # newState = self.styles[8]
188
- elif prevState == self.styles[8] or prevState == self.styles[7]:
189
- newState = self.styles[8]
190
- else:
191
- newState = self.styles[0]
192
- #set_style(length, newState)
193
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index) - length + 1
194
- i = 0
195
- while i < length:
196
- wordLength = 1
197
-
198
- self.startStyling(i + pos, 0x1f)
199
- newState = self.styles[0]
200
-
201
- for word in self.words2:
202
- if line[i:].startswith(word):
203
- newState = self.styles[4]
204
- wordLength = len(word)
205
-
206
-
207
- if chr(line[i]) in '0123456789':
208
- newState = self.styles[4]
209
- else:
210
- if line[i:].startswith("class"):
211
- newState = self.styles[2]
212
- wordLength = len('class')
213
- elif line[i:].startswith('function'):
214
- newState = self.styles[5]
215
- wordLength = len('function')
216
- elif line[i:].startswith(' if'):
217
- newState = self.styles[4]
218
- wordLength = len(' if')
219
- elif line[i:].startswith('#'):
220
- newState = self.styles[4]
221
- wordLength = length
222
- elif line[i:].startswith('//'):
223
- newState = self.styles[1]
224
- wordLength = length
225
- elif line[i:].startswith('/*'):
226
- newState = self.styles[1]
227
- wordLength = length
228
- elif line[i:].startswith('*/'):
229
- newState = self.styles[1]
230
- wordLength = length
231
- #else:
232
- #newState = self.styles[0]
233
-
234
-
235
- i += wordLength
236
- set_style(wordLength, newState)
237
- newState = None
238
-
239
- if newState:
240
- set_style(length, newState)
241
-
242
- #Folding
243
- # folding implementation goes here
244
- #levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index-1)
245
- #if line.startswith('+'):
246
- # SCI(SETFOLDLEVEL, index, levelFolder + 1)
247
- # #editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
248
- #elif line.startswith('function'):
249
- # SCI(SETFOLDLEVEL, index, levelFolder + 1)
250
- #editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
251
- """
252
- if newState == self.styles[7]:
253
- if prevState == self.styles[8]:
254
- level = LEVELBASE + 1
255
- else:
256
- level = LEVELBASE | HEADERFLAG
257
- elif newState == self.styles[8] or newState == self.styles[9]:
258
- level = LEVELBASE + 1
259
- else:
260
- level = LEVELBASE
261
-
262
- SCI(SETFOLDLEVEL, index, level)
263
-
264
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index)
265
- prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)"""
266
- index += 1
267
-
268
-
269
- """
270
- import sys
271
- from PyQt4 import QtCore, QtGui, Qsci
272
-
273
- class MainWindow(QtGui.QMainWindow):
274
- def __init__(self):
275
- QtGui.QMainWindow.__init__(self)
276
- self.setWindowTitle('Custom Lexer Example')
277
- self.setGeometry(QtCore.QRect(50,200,400,400))
278
- self.editor = Qsci.QsciScintilla(self)
279
- self.editor.setUtf8(True)
280
- self.editor.setMarginWidth(2, 15)
281
- self.editor.setFolding(True)
282
- self.setCentralWidget(self.editor)
283
- self.lexer = CustomLexer(self.editor)
284
- self.editor.setLexer(self.lexer)
285
- self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n')
286
-
287
- class CustomLexer(Qsci.QsciLexerCustom):
288
- def __init__(self, parent):
289
- Qsci.QsciLexerCustom.__init__(self, parent)
290
- self._styles = {
291
- 0: 'Default',
292
- 1: 'Comment',
293
- 2: 'Key',
294
- 3: 'Assignment',
295
- 4: 'Value',
296
- }
297
- for key,value in self._styles.iteritems():
298
- setattr(self, value, key)
299
-
300
- def description(self, style):
301
- return self._styles.get(style, '')
302
-
303
- def defaultColor(self, style):
304
- if style == self.Default:
305
- return QtGui.QColor('#000000')
306
- elif style == self.Comment:
307
- return QtGui.QColor('#C0C0C0')
308
- elif style == self.Key:
309
- return QtGui.QColor('#0000CC')
310
- elif style == self.Assignment:
311
- return QtGui.QColor('#CC0000')
312
- elif style == self.Value:
313
- return QtGui.QColor('#00CC00')
314
- return Qsci.QsciLexerCustom.defaultColor(self, style)
315
-
316
- def styleText(self, start, end):
317
- editor = self.editor()
318
- if editor is None:
319
- return
320
-
321
- # scintilla works with encoded bytes, not decoded characters.
322
- # this matters if the source contains non-ascii characters and
323
- # a multi-byte encoding is used (e.g. utf-8)
324
- source = ''
325
- if end > editor.length():
326
- end = editor.length()
327
- if end > start:
328
- if sys.hexversion >= 0x02060000:
329
- # faster when styling big files, but needs python 2.6
330
- source = bytearray(end - start)
331
- editor.SendScintilla(
332
- editor.SCI_GETTEXTRANGE, start, end, source)
333
- else:
334
- source = unicode(editor.text()
335
- ).encode('utf-8')[start:end]
336
- if not source:
337
- return
338
-
339
- # the line index will also be needed to implement folding
340
- index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start)
341
- if index > 0:
342
- # the previous state may be needed for multi-line styling
343
- pos = editor.SendScintilla(
344
- editor.SCI_GETLINEENDPOSITION, index - 1)
345
- state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos)
346
- else:
347
- state = self.Default
348
-
349
- set_style = self.setStyling
350
- self.startStyling(start, 0x1f)
351
-
352
- # scintilla always asks to style whole lines
353
- for line in source.splitlines(True):
354
- length = len(line)
355
- if line.startswith('#'):
356
- state = self.Comment
357
- else:
358
- # the following will style lines like "x = 0"
359
- pos = line.find('=')
360
- if pos > 0:
361
- set_style(pos, self.Key)
362
- set_style(1, self.Assignment)
363
- length = length - pos - 1
364
- state = self.Value
365
- else:
366
- state = self.Default
367
- set_style(length, state)
368
- # folding implementation goes here
369
- levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index-1)
370
- if line.startswith('+ '):
371
- editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
372
- index += 1
373
-
374
- if __name__ == "__main__":
375
- app = QtGui.QApplication(sys.argv)
376
- app.connect(app, QtCore.SIGNAL('lastWindowClosed()'),
377
- QtCore.SLOT('quit()'))
378
- win = MainWindow()
379
- win.show()
380
- sys.exit(app.exec_())
381
- """
api/php.api DELETED
@@ -1,60 +0,0 @@
1
- class
2
- function
3
- static
4
- global
5
- return
6
- if (expression)
7
- else
8
- while (expression)
9
- do
10
- for ($i = 0; $i < $len; $i++)
11
- foreach($array as $item)
12
- switch ($value)
13
- case
14
- default:
15
- break;
16
- continue;
17
- <<<TEXT
18
- TEXT;
19
- "\n"
20
- echo
21
- print_r?1($array)
22
- printf?1()
23
- rand?1(min, max)
24
- range?1(min, max)
25
- var_dump?1($value)
26
- phpversion?1()
27
-
28
- strlen?1()
29
- strtoupper?1()
30
- strtolower?1
31
- ctype_alpha?1($c)
32
- ctype_digit?1($c)
33
- ctype_space?1($c)
34
- substr?1($string,start,len)
35
- str_repeat?1($string,val)
36
- str_shuffle?1($string)
37
- explode(separator,$string)
38
- str_pad?1($string,val)
39
- array?1(values)
40
- sort?1($array) function to sort the contents of the array.
41
- count?1($array) ->int function to count the number of elements in the array
42
- array_sum?1($array) ->int function to calculate the sum of all values
43
- array_count_values?1($array) ->array function returns an array with the number of occurrences for each value
44
- array_unique?1($array) ->array function returns an array without duplicates
45
- current?1($array) function returns the current element in the array
46
- next?1($array) function advances the pointer by one position
47
- prev?1($array) returns the element, one position before the current one
48
- end?1($array) function returns the last element
49
- reset?1($array) function to set the internal pointer to the first element again
50
- list?1($idx, $val) function to create an array from two variables.
51
- each?1($array) function returns the current key and value pair from an array and advances the array cursor
52
- array_merge?1($array1, $array2) ($array) function to create $names array by merging the previous two arrays.
53
- array_push?1($array,values) function inserts one or more items to the end of the array
54
- array_pop?1($array) function removes the last item from the array
55
- array_unshift?1($array,values) function adds values to the beginning of the array
56
- array_shift?1($array) function removes the first item from the array
57
- in_array?1(value, $array) function checks, if a specific element is inside an array
58
- array_keys?1($array) function returns all the keys of an array
59
- array_values?1($array) function returns all the values of an array
60
- array_walk?1($array, func($value, $key)) function applies a user defined function to every member of the array
build/exe.win32-2.7/config.yml CHANGED
@@ -28,6 +28,7 @@ File:
28
28
  - C:/CODE/assets/howtoscene.nut
29
29
  - C:/CODE/assets/logoscene.nut
30
30
  - C:/CODE/assets/creditscene.nut
31
+ - C:/Documents and Settings/Administrator/Desktop/theRemix-haXenode.org-cfa44d3/Haxenode.hx
31
32
  PARAM:
32
33
  - Dude C:/CODE/assets/creditscene.nut C:/CODE/assets/physics.nut
33
34
  Project:
build/exe.win32-2.7/library.zip CHANGED
Binary file
config.yml CHANGED
@@ -25,9 +25,8 @@ ClosedProject:
25
25
  - 0
26
26
  File:
27
27
  - C:/CODE/assets/common.nut
28
- - C:/CODE/assets/howtoscene.nut
29
- - C:/CODE/assets/logoscene.nut
30
28
  - C:/CODE/assets/creditscene.nut
29
+ - C:/CODE/assets/logoscene.nut
31
30
  PARAM:
32
31
  - Dude C:/CODE/assets/creditscene.nut C:/CODE/assets/physics.nut
33
32
  Project:
@@ -40,13 +39,13 @@ Setting:
40
39
  fontsize: 10
41
40
  iconsize: 16
42
41
  indent: 0
43
- margin: 0
42
+ margin: 1
44
43
  mode: 0
45
44
  styleindex: 8
46
- tabwidth: 2
45
+ tabwidth: 4
47
46
  thresh: 1
48
47
  toollabel: 0
49
- whitespace: 0
48
+ whitespace: 1
50
49
  workspace: C:/CODE/
51
50
  Style: 0
52
51
  TODO:
editor/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from editor import Editor
{Widget → editor}/editor.py RENAMED
@@ -2,8 +2,9 @@ from globals import (fontSize,ospathjoin,os_pixmap,apiDir,config
2
2
  ,Auto,eol, Encoding)
3
3
  from PyQt4.QtCore import SIGNAL,QString,QEvent
4
4
  from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor, QPalette,QWidget
5
- from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs ,QsciLexerCPP
5
+ from PyQt4.Qsci import QsciScintilla, QsciAbstractAPIs, QsciLexerPython ,QsciAPIs ,QsciLexerCPP, QsciLexerJavaScript
6
- from lexersquirrel import LexerSquirrel
6
+ from lexer import QsciLexerSquirrel
7
+
7
8
 
8
9
  class Editor(QsciScintilla):
9
10
  ARROW_MARKER_NUM = 8
@@ -45,7 +46,6 @@ class Editor(QsciScintilla):
45
46
  self.setCaretLineBackgroundColor(self.colorStyle.caret)
46
47
  self.setCaretLineVisible(True)
47
48
 
48
-
49
49
  #Indicator
50
50
  #self.setIndicatorForegroundColor(self.colorStyle.color)
51
51
  #self.setIndicatorOutlineColor(self.colorStyle.paper)
@@ -54,6 +54,11 @@ class Editor(QsciScintilla):
54
54
  self.markerDefine(QsciScintilla.RightArrow,self.ARROW_MARKER_NUM)
55
55
  self.markerDefine(Auto.auto_error,0)
56
56
  self.setMarkerBackgroundColor(self.colorStyle.marker,self.ARROW_MARKER_NUM)
57
+ self.font = QFont(config.fontName(),config.fontSize())
58
+ #self.font.setFixedPitch(True)
59
+ self.setFont(self.font)
60
+ self.fontmetrics = QFontMetrics(self.font)
61
+ self.setMarginsFont(self.font)
57
62
 
58
63
  #Code-Complete
59
64
  self.registerImage(0,Auto.auto_class2)
@@ -62,35 +67,30 @@ class Editor(QsciScintilla):
62
67
  self.registerImage(3,Auto.auto_package)
63
68
  self.setAutoCompletionThreshold(config.thresh())
64
69
  self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
65
-
66
- #Property
67
70
  self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
68
71
  self.setBackspaceUnindents(True)
72
+ self.setAutoCompletionCaseSensitivity(True)
73
+ self.setIndentationsUseTabs(True)
74
+ self.setTabIndents(True)
75
+ self.setAutoIndent(True)
69
- self.setEolMode(self.EolWindows)
76
+ self.setIndent(config.indent())
77
+ #self.copyAvailable.connect(self.highlightWord)
78
+ #self.indicatorClicked.connect(self.indicate)
79
+ self.setIndicatorOutlineColor(QColor("#FFFFFF"))
80
+ self.indicatorDefine(self.INDIC_BOX)
70
- #self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
81
+ self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
71
82
  #self.setAutoCompletionSource(QsciScintilla.AcsAll)
72
83
  #self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
73
-
74
- self.font = QFont(config.fontName(),config.fontSize())
75
- #self.font.setFixedPitch(True)
76
- self.setFont(self.font)
84
+ #self.setIndentation(5,25)
77
- self.fontmetrics = QFontMetrics(self.font)
85
+ #self.setSelectionBackgroundColor()
78
- self.setMarginsFont(self.font)
86
+ #self.setSelectionForegroundColor()
79
-
80
- if self.lang == 0:
81
- self.lexer = QsciLexerPython()
87
+ #self.SendScintilla(QsciScintilla.SCI_MARKERSETBACK,11,QColor(220,220,220))
82
- elif self.lang == 1:
88
+ self.setLanguage()
83
- self.lexer = QsciLexerCPP()
84
- elif self.lang == 2:
85
- self.lexer = LexerSquirrel(self.colorStyle,self)
86
89
  self.lexer.setDefaultFont(self.font)
87
90
  self.api = QsciAPIs(self.lexer)
88
91
  self.api.load(ospathjoin(apiDir,"emo.api"))
89
92
  self.api.prepare()
90
93
  self.lexer.setAPIs(self.api) #Very important do not change line otherwise gg
91
- self.setAutoIndent(True)
92
- self.setBackspaceUnindents(True)
93
- self.setIndent(config.indent())
94
94
  self.setLexer(self.lexer) #Very important do not change line otherwise gg
95
95
 
96
96
 
@@ -102,7 +102,23 @@ class Editor(QsciScintilla):
102
102
  self.setMarkerBackgroundColor(self.colorStyle.marker,self.ARROW_MARKER_NUM)
103
103
  if self.lang == 2:
104
104
  self.lexer.setColorStyle(self.colorStyle)
105
- self.lexer.setColor(QColor("#008000"),0)
105
+ #self.lexer.setColor(QColor("#008000"),0)
106
+
107
+ def setLanguage(self):
108
+ if self.lang == 0:
109
+ self.lexer = QsciLexerPython()
110
+ elif self.lang == 1:
111
+ self.lexer = QsciLexerCPP()
112
+ elif self.lang == 2:
113
+ self.lexer = QsciLexerSquirrel(self, self.colorStyle)
114
+
115
+ def highlightWord(self, bool):
116
+ if(bool):
117
+ print "yes"
118
+
119
+ def indicate(self, line, index , key):
120
+ print line
121
+
106
122
  def on_margin_clicked(self, nmargin, nline, modifiers):
107
123
  # Toggle marker for the line the margin was clicked on
108
124
  if self.markersAtLine(nline) != 0:
@@ -134,28 +150,10 @@ class Editor(QsciScintilla):
134
150
  self.markerDelete(i, 0)
135
151
  self.errorLines[:] = []
136
152
 
137
- def zoomin(self):
138
- self.fontSize += 1
139
- config.setFontSize(self.fontSize)
140
- self.font.setPointSize(self.fontSize)
141
- #self.setFont(self.font)
142
- self.lexer.setFont(self.font)
143
- self.setMarginsFont(self.font)
144
-
145
- def zoomout(self):
146
- self.fontSize -= 1
147
- config.setFontSize(self.fontSize)
148
- self.font.setPointSize(self.fontSize)
149
- #self.setFont(self.font)
150
- self.lexer.setFont(self.font)
151
- self.setMarginsFont(self.font)
152
-
153
153
  def setNewFont(self,font):
154
154
  self.setFont(font)
155
155
  self.lexer.setFont(font)
156
156
 
157
-
158
-
159
157
  def setFontSize(self):
160
158
  self.font.setPointSize(config.fontSize())
161
159
  self.lexer.setFont(self.font)
editor/lexer.py ADDED
@@ -0,0 +1,211 @@
1
+ from PyQt4.Qsci import QsciLexerCPP,QsciStyle,QsciScintilla,QsciLexerPython, QsciLexerJavaScript
2
+ from PyQt4.QtCore import QString
3
+ from PyQt4.QtGui import QFont, QColor
4
+ from globals import fontName, fontSize
5
+
6
+ class QsciLexerSquirrel(QsciLexerJavaScript):#QsciLexerPython
7
+ words1 = [
8
+ 'base','break','case','catch','class','clone',
9
+ 'continue','const','default','delete','else','enum',
10
+ 'extends','for','foreach','function',' if',' in',
11
+ 'local','null','resume','return','switch','this',
12
+ 'throw','try','typeof','while','yield','constructor',
13
+ 'instanceof','true','false','static'
14
+ ]
15
+
16
+ words2 = [
17
+ 'init', 'dest', 'onLoad', 'onDispose', 'onGainedFocus','onMotionEvent',
18
+ 'onLostFocus','onUpdate','onFps','onKeyEvent','onSensorEvent',
19
+ 'onControlEvent','onDrawFrame','onError','onLowMemory','onNetCallBack'
20
+ ]
21
+
22
+ words3 = [
23
+ 'rawdelete', 'rawin', 'array', 'seterrorhandler', 'setdebughook',
24
+ 'enabledebuginfo', 'getroottable', 'setroottable', 'getconsttable',
25
+ 'setconsttable', 'assert', 'print', 'compilestring', 'collectgarbage',
26
+ 'type', 'getstackinfos', 'newthread', 'tofloat', 'tostring',
27
+ 'tointeger', 'tochar', 'weakref', 'slice', 'find', 'tolower',
28
+ 'toupper', 'len', 'rawget', 'rawset', 'clear', 'append', 'push',
29
+ 'extend', 'pop', 'top', 'insert', 'remove', 'resize', 'sort',
30
+ 'reverse', 'call', 'pcall', 'acall', 'pacall', 'bindenv', 'instance',
31
+ 'getattributes', 'getclass', 'getstatus', 'ref'
32
+ ]
33
+
34
+ def __init__(self,parent,colorStyle):
35
+ #QsciLexerPython.__init__(self, parent)
36
+ QsciLexerJavaScript.__init__(self, parent)
37
+ self.parent = parent
38
+ self.colorStyle = colorStyle
39
+ self.plainFont = QFont()
40
+ self.plainFont.setFamily(fontName)
41
+ self.plainFont.setFixedPitch(True)
42
+ self.plainFont.setPointSize(fontSize)
43
+ self.boldFont = QFont(self.plainFont)
44
+ self.boldFont.setBold(True)
45
+ self.setFoldCompact(True)
46
+
47
+ self.styles = [
48
+ #index description color paper font eol
49
+ QsciStyle(0, QString("base"), self.colorStyle.color, self.colorStyle.paper, self.plainFont, True),
50
+ QsciStyle(1, QString("comment"), QColor("#3f7f5f"), self.colorStyle.paper, self.plainFont, True),
51
+ QsciStyle(4, QString("number"), QColor("#008000"), self.colorStyle.paper, self.plainFont, True),
52
+ QsciStyle(5, QString("Keyword"), QColor("#7f0055"), self.colorStyle.paper, self.boldFont, True),
53
+ QsciStyle(6, QString("String"), QColor("#7f0010"),self.colorStyle.paper, self.plainFont, True),
54
+ #QsciStyle(10, QString("Operator"), QColor("#ff0000"), self.colorStyle.paper, self.plainFont, False),
55
+ #QsciStyle(11, QString("Identifier"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False),
56
+ #QsciStyle(12, QString("CommentBlock"), QColor("#3f5fbf"), self.colorStyle.paper, self.plainFont, False),
57
+ #QsciStyle(13, QString("UnclosedString"), QColor("#010101"), self.colorStyle.paper, self.plainFont, False),
58
+ #QsciStyle(14, QString("HighlightedIdentifier"), QColor("#0000ff"), self.colorStyle.paper, self.plainFont, False),
59
+ #QsciStyle(15, QString("Decorator"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False),
60
+ ]
61
+
62
+ def setColorStyle(self,cs):
63
+ self.colorStyle = cs
64
+ for i in self.styles:
65
+ i.setPaper(self.colorStyle.paper)
66
+ self.styles[0].setColor(self.colorStyle.color)
67
+
68
+
69
+ def language(self):
70
+ return 'Squirrel'
71
+
72
+ def foldCompact(self):
73
+ return self._foldcompact
74
+
75
+ def setFoldCompact(self, enable):
76
+ self._foldcompact = bool(enable)
77
+
78
+ def description(self, ix):
79
+ for i in self.styles:
80
+ if i.style() == ix:
81
+ return i.description()
82
+ return QString("")
83
+
84
+ def defaultColor(self, ix):
85
+ for i in self.styles:
86
+ if i.style() == ix:
87
+ return i.color()
88
+ return QsciLexerCPP.defaultColor(self, ix)
89
+
90
+ def defaultFont(self, ix):
91
+ for i in self.styles:
92
+ if i.style() == ix:
93
+ return i.font()
94
+ return QsciLexerCPP.defaultFont(self, ix)
95
+
96
+ def defaultPaper(self, ix):
97
+ for i in self.styles:
98
+ if i.style() == ix:
99
+ return i.paper()
100
+ return QsciLexerCPP.defaultPaper(self, ix)
101
+
102
+ def defaultEolFill(self, ix):
103
+ for i in self.styles:
104
+ if i.style() == ix:
105
+ return i.eolFill()
106
+ return QsciLexerCPP.defaultEolFill(self, ix)
107
+
108
+ '''
109
+ def styleText(self, start, end):
110
+ editor = self.editor()
111
+ if editor is None:
112
+ return
113
+ SCI = editor.SendScintilla
114
+ GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
115
+ SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
116
+ HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
117
+ LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
118
+ NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
119
+ WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
120
+ INDIC_SET = QsciScintilla.SCI_INDICSETSTYLE
121
+ INDIC_SETCURRENT = QsciScintilla.SCI_SETINDICATORCURRENT
122
+ INDIC_FILL = QsciScintilla.SCI_INDICATORFILLRANGE
123
+ INDIC_CLEAR = QsciScintilla.SCI_INDICATORCLEARRANGE
124
+ INDIC_START = QsciScintilla.SCI_INDICATORSTART
125
+ INDIC_END = QsciScintilla.SCI_INDICATOREND
126
+
127
+ # using indicator 7 with Boxed style
128
+ SCI(INDIC_SET, 7 ,QsciScintilla.INDIC_BOX)
129
+ SCI(INDIC_SETCURRENT, 7)
130
+
131
+ set_style = self.setStyling
132
+ source = ''
133
+ if end > editor.length():
134
+ end = editor.length()
135
+ if end > start:
136
+ source = bytearray(end - start)
137
+ SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source)
138
+ if not source:
139
+ return
140
+ #compact = self.foldCompact()
141
+ index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start)
142
+ self.startStyling(start, 0x1f)
143
+ lineno = -1
144
+ source = source.splitlines(True)
145
+ for line in source:
146
+ lineno += 1
147
+ length = len(line)
148
+ if length == 0: #lol gg this had to be Zero
149
+ return
150
+ if line.startswith('#'):
151
+ newState = self.styles[1]
152
+ else:
153
+ pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index) - length + 1
154
+ i = 0
155
+ while i < length:
156
+ wordLength = 1
157
+ self.startStyling(i + pos, 0x1f)
158
+ newState = self.styles[0]
159
+ for word in self.words2:
160
+ if line[i:].startswith(word):
161
+ newState = self.styles[4]
162
+ wordLength = len(word)
163
+
164
+ if chr(line[i]) in '0123456789':
165
+ newState = self.styles[4]
166
+ 'startpos=3, length=3, use current indicator'
167
+ #SCI(INDIC_FILL,pos+line[i],1)
168
+ else:
169
+ if line[i:].startswith('"'):
170
+ newState = self.styles[1]
171
+ pos2 = line.find('"',i+1)
172
+ size = pos2 - i
173
+ if(size != 0 and pos2 != -1 ):
174
+ wordLength = size
175
+ #print "line: ",lineno, "pos: ",pos1, pos2
176
+ elif line[i:].startswith("'"):
177
+ newState = self.styles[1]
178
+ pos2 = line.find("'",i+1)
179
+ size = pos2 - i
180
+ if(size != 0 and pos2 != -1 ):
181
+ wordLength = size
182
+ #print "line: ",lineno, "pos: ",pos1, pos2
183
+
184
+ elif line[i:].startswith("class"):
185
+ newState = self.styles[5]
186
+ wordLength = 5
187
+ elif line[i:].startswith('function'):
188
+ newState = self.styles[5]
189
+ wordLength = 8
190
+ elif line[i:].startswith('enum'):
191
+ newState = self.styles[5]
192
+ wordLength = 4
193
+ elif line[i:].startswith(' if'):
194
+ newState = self.styles[4]
195
+ wordLength = 3
196
+ elif line[i:].startswith('#'):
197
+ # get end of line position and set word length to that
198
+ newState = self.styles[4]
199
+ pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, lineno)
200
+ wordLength = pos
201
+ #print "#end", pos
202
+ #elif line[i:].startswith(','):
203
+ # newState = self.styles[1]
204
+ # wordLength = 1
205
+ i += wordLength
206
+ set_style(wordLength, newState)
207
+ if newState:
208
+ set_style(length, newState)
209
+ pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index)
210
+ index += 1
211
+ '''
globals.py CHANGED
@@ -4,7 +4,7 @@ __license__ = "GPLv3"
4
4
  __copyright__ = 'Copyright (c) 2013, pyros2097'
5
5
  __credits__ = ['pyros2097', 'eclipse']
6
6
  __email__ = 'pyros2097@gmail.com'
7
- __version__ = "0.62"
7
+ __version__ = "0.63"
8
8
 
9
9
  import os
10
10
  from platform import system,python_version
mainwindow.py CHANGED
@@ -2,7 +2,8 @@ from PyQt4.QtGui import (QApplication,QPixmap,QSplashScreen,QMessageBox,
2
2
  QIcon,QAction,QCheckBox,QFileDialog)
3
3
  from PyQt4.QtCore import SIGNAL,Qt,QStringList,QString
4
4
  from window import Window
5
- from Widget import Editor,Audio,Image,Tool
5
+ from Widget import Audio,Image,Tool
6
+ from editor import Editor
6
7
  from core import PyInterp,Adb,Ant,Parser,Command,update
7
8
  from globals import (ospathsep,ospathjoin,ospathbasename,workDir,config,workSpace,
8
9
  iconSize,iconDir,ospathexists,os_icon, __version__)
update.txt CHANGED
@@ -1,3 +1,4 @@
1
- 0.62
1
+ 0.63
2
- Added Updater
2
+ Added new Squirrel Lexer
3
- Improved designer
3
+ Unicode broken
4
+ Code Complete Broken
window.py CHANGED
@@ -6,12 +6,9 @@ from PyQt4.QtGui import (QAction,QIcon,QMessageBox,QWidgetAction,QMenu,QWidget,
6
6
  QFrame)
7
7
  from PyQt4.QtCore import QSize,Qt,QStringList,SIGNAL,SLOT,QString
8
8
 
9
-
10
-
11
9
  from Widget import EditorTab, TreeTab, OutputTab
12
10
  from Widget import ProjectTree, ErrorTree, OutlineTree
13
- from Widget import Popup
11
+ from Widget import Popup
14
-
15
12
  from Widget import DialogAndroid,DialogAbout,DialogAnt,DialogSquirrel,DialogTodo,DialogBrowse
16
13
 
17
14
  from design import Level
@@ -526,6 +523,7 @@ class Window(QMainWindow):
526
523
  elif(no == 1):
527
524
  self.fileChanged(no)
528
525
 
526
+ ''' This is to refresh the outline widget'''
529
527
  def fileChanged(self,no):
530
528
  if(self.explorerTabWidget.currentIndex() == 1):
531
529
  edt = self.tabWidget.widget(self.tabWidget.currentIndex())