34595c99
—
pyros2097 13 years ago
Saving
- Widget/LexerSquirrel.py +3 -3
- Widget/editor.py +15 -24
- Widget/editor.pyc +0 -0
- Widget/keylex.py +3 -2
- config.yaml +2 -2
Widget/LexerSquirrel.py
CHANGED
|
@@ -12,9 +12,9 @@ from PyQt4.QtGui import *
|
|
|
12
12
|
#prefs.declare('font.size.code', 10)
|
|
13
13
|
#prefs.declare('color.editline', "#d0e0ff")
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class LexerSquirrel(QsciLexerCustom):
|
|
16
|
-
def __init__(self,
|
|
16
|
+
def __init__(self, parent = None):
|
|
17
|
-
QsciLexerCustom.__init__(self,
|
|
17
|
+
QsciLexerCustom.__init__(self, parent)
|
|
18
18
|
self.sci = None
|
|
19
19
|
self.plainFont = QFont()
|
|
20
20
|
self.plainFont.setPointSize(10)
|
Widget/editor.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from PyQt4.QtCore import SIGNAL
|
|
2
|
-
from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor
|
|
2
|
+
from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor
|
|
3
3
|
from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs
|
|
4
4
|
from globals import ospathjoin,workDir,fontSize,fontName
|
|
5
5
|
|
|
@@ -8,25 +8,23 @@ class Style:
|
|
|
8
8
|
def __init__(self):
|
|
9
9
|
self.font = QColor('#000000')
|
|
10
10
|
self.paper = QColor('#FFFFFF')
|
|
11
|
-
self.caret = QColor('#FFFFFF')
|
|
12
|
-
self.
|
|
11
|
+
self.caret = QColor('#ffe4e4')
|
|
12
|
+
self.marker = QColor('#ee1111')
|
|
13
13
|
self.margin = QColor('#cccccc')
|
|
14
14
|
self.font = QFont()
|
|
15
15
|
self.font.setFamily(fontName)
|
|
16
16
|
self.font.setFixedPitch(True)
|
|
17
17
|
self.font.setPointSize(fontSize)
|
|
18
18
|
|
|
19
|
-
self.setMarginsFont(font)
|
|
20
|
-
self.setText(text)
|
|
21
|
-
|
|
22
|
-
|
|
23
19
|
class Editor(QsciScintilla):
|
|
24
20
|
ARROW_MARKER_NUM = 8
|
|
25
21
|
def __init__(self,parent,text,styleIndex = 0):
|
|
26
22
|
QsciScintilla.__init__(self,parent)
|
|
27
23
|
self.parent = parent
|
|
28
24
|
self.styleIndex = styleIndex
|
|
29
|
-
self.
|
|
25
|
+
self.colorStyle = None
|
|
26
|
+
self.init()
|
|
27
|
+
self.setText(text)
|
|
30
28
|
|
|
31
29
|
#self.addAction(QAction("gg",self))
|
|
32
30
|
#self.findFirst("function",False,True,True,True)
|
|
@@ -43,20 +41,14 @@ class Editor(QsciScintilla):
|
|
|
43
41
|
|
|
44
42
|
# Brace matching: enable for a brace immediately before or after
|
|
45
43
|
# the current position
|
|
46
|
-
#
|
|
47
44
|
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# Current line visible with special background color
|
|
51
|
-
self.setCaretLineVisible(True)
|
|
52
|
-
|
|
53
45
|
self.lexer = QsciLexerPython()
|
|
54
46
|
#print ospathjoin(workDir,"emo.api")
|
|
55
47
|
self.api = QsciAPIs(self.lexer)
|
|
56
48
|
#api.load(ospathjoin(workDir,"emo.api"))
|
|
57
49
|
self.code_complete()
|
|
58
50
|
self.api.prepare()
|
|
59
|
-
self.lexer.setDefaultFont(font)
|
|
51
|
+
self.lexer.setDefaultFont(self.font)
|
|
60
52
|
self.setLexer(self.lexer) #Very important do not change line otherwise gg
|
|
61
53
|
|
|
62
54
|
self.setAutoCompletionThreshold(1)
|
|
@@ -66,26 +58,25 @@ class Editor(QsciScintilla):
|
|
|
66
58
|
|
|
67
59
|
def init(self):
|
|
68
60
|
self.setColorStyle(self.styleIndex)
|
|
69
|
-
self.font = self.
|
|
61
|
+
self.font = self.colorStyle.font
|
|
70
62
|
self.setFont(self.font)
|
|
71
63
|
self.fontmetrics = QFontMetrics(self.font)
|
|
72
64
|
self.setMarginsFont(self.font)
|
|
73
65
|
self.setMarginWidth(0, self.fontmetrics.width("00000") + 6)
|
|
74
66
|
# Margin 0 is used for line numbers
|
|
75
67
|
self.setMarginLineNumbers(0, True)
|
|
68
|
+
self.setCaretLineVisible(True)
|
|
69
|
+
|
|
76
70
|
|
|
77
71
|
def setColorStyle(self,styleIndex):
|
|
78
72
|
if styleIndex == 0:
|
|
79
|
-
self.
|
|
73
|
+
self.colorStyle = Style()
|
|
80
74
|
elif styleIndex == 1:
|
|
81
|
-
self.
|
|
75
|
+
self.colorStyle = Style()
|
|
82
|
-
self.setCaretLineBackgroundColor()
|
|
76
|
+
self.setCaretLineBackgroundColor(self.colorStyle.caret)
|
|
83
|
-
self.setMarginsBackgroundColor()
|
|
77
|
+
self.setMarginsBackgroundColor(self.colorStyle.margin)
|
|
84
|
-
self.setMarkerBackgroundColor(
|
|
78
|
+
self.setMarkerBackgroundColor(self.colorStyle.marker,self.ARROW_MARKER_NUM)
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
80
|
def code_complete(self):
|
|
90
81
|
self.api.add("emo.Runtime?0(use = runtime)")
|
|
91
82
|
self.api.add("runtime.import?1(filename)")
|
Widget/editor.pyc
CHANGED
|
Binary file
|
Widget/keylex.py
CHANGED
|
@@ -3,6 +3,7 @@ from PyQt4.QtCore import SIGNAL, SLOT, QString,QStringList
|
|
|
3
3
|
from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont
|
|
4
4
|
from PyQt4.Qsci import QsciScintilla, QsciLexerCustom, QsciStyle
|
|
5
5
|
|
|
6
|
+
from editor import Editor
|
|
6
7
|
_sample = """
|
|
7
8
|
This example shows how to highlight some specific lines or words.
|
|
8
9
|
|
|
@@ -125,7 +126,7 @@ class MainWindow(QMainWindow):
|
|
|
125
126
|
QMainWindow.__init__(self)
|
|
126
127
|
self.setWindowTitle('Custom Lexer For Config Files')
|
|
127
128
|
self.setGeometry(50, 200, 400, 400)
|
|
128
|
-
self.editor =
|
|
129
|
+
self.editor = Editor(self,_sample)
|
|
129
130
|
self.editor.setUtf8(True)
|
|
130
131
|
|
|
131
132
|
# LINES' NUMBER IN THE MARGIN
|
|
@@ -137,7 +138,7 @@ class MainWindow(QMainWindow):
|
|
|
137
138
|
self.setCentralWidget(self.editor)
|
|
138
139
|
self.lexer = ConfigLexer(self.editor)
|
|
139
140
|
self.editor.setLexer(self.lexer)
|
|
140
|
-
self.editor.setText(_sample)
|
|
141
|
+
#self.editor.setText(_sample)
|
|
141
142
|
|
|
142
143
|
|
|
143
144
|
class ConfigLexer(QsciLexerCustom):
|
config.yaml
CHANGED
|
@@ -5,8 +5,8 @@ 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/creditscene.nut
|
|
9
8
|
- C:/CODE/assetsdd/howtoscene.nut
|
|
9
|
+
- C:/CODE/assetsdd/logoscene.nut
|
|
10
10
|
Project:
|
|
11
11
|
- C:/CODE/data/
|
|
12
12
|
- C:/CODE/assetsdd/
|
|
@@ -19,4 +19,4 @@ Setting:
|
|
|
19
19
|
style: 0
|
|
20
20
|
thresh: 1
|
|
21
21
|
workspace: C:/CODE/
|
|
22
|
-
Style: 0
|
|
22
|
+
Style: 0
|