QScintilla/QsciScintillaCompat.py

Mon, 17 Mar 2014 19:11:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 17 Mar 2014 19:11:48 +0100
changeset 3393
080ace4829b4
parent 3390
7f46edbfcbc0
child 3484
645c12de6b0c
child 3493
71f15675e89f
permissions
-rw-r--r--

Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3078
diff changeset
3 # Copyright (c) 2004 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a compatability interface class to QsciScintilla.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
10 from PyQt4.QtCore import pyqtSignal, Qt
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
11 from PyQt4.QtGui import QPalette, QColor, QApplication
3070
04e342ebf697 Fixed an issue in QsciScintillaCompat related to an old QScintilla change (snapshots report their correct to be version).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
12 from PyQt4.Qsci import QsciScintillaBase, QsciScintilla, \
04e342ebf697 Fixed an issue in QsciScintillaCompat related to an old QScintilla change (snapshots report their correct to be version).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
13 QSCINTILLA_VERSION as QSCIQSCINTILLA_VERSION
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
15 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
2077
68a34718a0ce Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
17
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 def QSCINTILLA_VERSION():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Module function to return the QScintilla version.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @return QScintilla version (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
3070
04e342ebf697 Fixed an issue in QsciScintillaCompat related to an old QScintilla change (snapshots report their correct to be version).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
24 return QSCIQSCINTILLA_VERSION
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
26 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
28
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 class QsciScintillaCompat(QsciScintilla):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Class implementing a compatability interface to QsciScintilla.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 This class implements all the functions, that were added to
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 QsciScintilla incrementally. This class ensures compatibility
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 to older versions of QsciScintilla.
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
36
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
37 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
39 zoomValueChanged = pyqtSignal(int)
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
40
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
41 ArrowFoldStyle = QsciScintilla.BoxedTreeFoldStyle + 1
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
42 ArrowTreeFoldStyle = ArrowFoldStyle + 1
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
43
448
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
44 UserSeparator = '\x04'
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
45
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
46 if QSCINTILLA_VERSION() < 0x020600:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
47 IndicatorStyleMax = QsciScintilla.INDIC_ROUNDBOX
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
48 elif QSCINTILLA_VERSION() < 0x020700:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
49 IndicatorStyleMax = QsciScintilla.INDIC_DOTBOX
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
50 elif QSCINTILLA_VERSION() < 0x020800:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
51 IndicatorStyleMax = QsciScintilla.INDIC_SQUIGGLEPIXMAP
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
52 else:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
53 IndicatorStyleMax = QsciScintilla.INDIC_COMPOSITIONTHICK
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
54
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
55 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param parent parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
61 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.zoom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__targetSearchFlags = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__targetSearchExpr = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__targetSearchStart = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__targetSearchEnd = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__targetSearchActive = False
3238
fa28dab59a9e Implemented a work-around for a buggy behavior for Qt5, where application focus is given to a completion list but not returned after selecting an entry by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3233
diff changeset
70
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
71 self.__modified = False
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
72
3238
fa28dab59a9e Implemented a work-around for a buggy behavior for Qt5, where application focus is given to a completion list but not returned after selecting an entry by double-clicking it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3233
diff changeset
73 self.userListActivated.connect(self.__completionListSelected)
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
74 self.modificationChanged.connect(self.__modificationChanged)
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
75
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
76 def __modificationChanged(self, m):
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
77 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
78 Private slot to handle the modificationChanged signal.
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
79
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
80 @param m modification status (boolean)
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
81 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
82 self.__modified = m
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
83
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
84 def isModified(self):
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
85 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
86 Public method to return the modification status.
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
87
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
88 @return flag indicating the modification status (boolean)
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
89 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
90 return self.__modified
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
91
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
92 def setModified(self, m):
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
93 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
94 Public slot to set the modification status.
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
95
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
96 @param m new modification status (boolean)
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
97 """
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
98 self.__modified = m
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
99 super().setModified(m)
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3390
diff changeset
100 self.modificationChanged.emit(m)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
102 def setLexer(self, lex=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Public method to set the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @param lex the lexer to be set or None to reset it.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
108 super().setLexer(lex)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 if lex is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.clearStyles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 def clearStyles(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 Public method to set the styles according the selected Qt style.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
116 palette = QApplication.palette()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.SendScintilla(QsciScintilla.SCI_STYLESETFORE,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
118 QsciScintilla.STYLE_DEFAULT,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
119 palette.color(QPalette.Text))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.SendScintilla(QsciScintilla.SCI_STYLESETBACK,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
121 QsciScintilla.STYLE_DEFAULT,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
122 palette.color(QPalette.Base))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.SendScintilla(QsciScintilla.SCI_STYLECLEARALL)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.SendScintilla(QsciScintilla.SCI_CLEARDOCUMENTSTYLE)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 def monospacedStyles(self, font):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 Public method to set the current style to be monospaced.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 @param font font to be used (QFont)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 try:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
133 rangeLow = list(range(self.STYLE_DEFAULT))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 except AttributeError:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
135 rangeLow = list(range(32))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 try:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
137 rangeHigh = list(range(self.STYLE_LASTPREDEFINED + 1,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
138 self.STYLE_MAX + 1))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 except AttributeError:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
140 rangeHigh = list(range(40, 128))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
551
e1074b63ff08 Fixed a compatibility issue with QsciScintilla 2.4.5 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 510
diff changeset
142 f = font.family().encode()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 ps = font.pointSize()
2472
4860fe0ed4a6 Extended the editor monospaced style to allow to set the weight, italic and underline properties.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2347
diff changeset
144 weight = -font.weight()
4860fe0ed4a6 Extended the editor monospaced style to allow to set the weight, italic and underline properties.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2347
diff changeset
145 italic = font.italic()
4860fe0ed4a6 Extended the editor monospaced style to allow to set the weight, italic and underline properties.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2347
diff changeset
146 underline = font.underline()
2564
3eb07bb2afd4 Fixed an issue in QsciScintillaCompat setting monospaced styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2537
diff changeset
147 bold = font.bold()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 for style in rangeLow + rangeHigh:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, style, f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, style, ps)
2564
3eb07bb2afd4 Fixed an issue in QsciScintillaCompat setting monospaced styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2537
diff changeset
151 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
152 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
153 QsciScintilla.SCI_STYLESETWEIGHT, style, weight)
2564
3eb07bb2afd4 Fixed an issue in QsciScintillaCompat setting monospaced styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2537
diff changeset
154 except AttributeError:
3eb07bb2afd4 Fixed an issue in QsciScintillaCompat setting monospaced styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2537
diff changeset
155 self.SendScintilla(QsciScintilla.SCI_STYLESETBOLD, style, bold)
2537
0ff250733d45 Fixed a few PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2472
diff changeset
156 self.SendScintilla(QsciScintilla.SCI_STYLESETITALIC, style, italic)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
157 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
158 QsciScintilla.SCI_STYLESETUNDERLINE, style, underline)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 def linesOnScreen(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 Public method to get the amount of visible lines.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @return amount of visible lines (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 return self.SendScintilla(QsciScintilla.SCI_LINESONSCREEN)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def lineAt(self, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Public method to calculate the line at a position.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 This variant is able to calculate the line for positions in the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 margins and for empty lines.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @param pos position to calculate the line for (integer or QPoint)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @return linenumber at position or -1, if there is no line at pos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 (integer, zero based)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
179 if isinstance(pos, int):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 scipos = pos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 scipos = \
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
183 self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
184 pos.x(), pos.y())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, scipos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if line >= self.lines():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 line = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 return line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 def currentPosition(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Public method to get the current position.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @return absolute position of the cursor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 return self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 def styleAt(self, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 Public method to get the style at a position in the text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @param pos position in the text (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 @return style at the requested position or 0, if the position
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 is negative or past the end of the document (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 return self.SendScintilla(QsciScintilla.SCI_GETSTYLEAT, pos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 def currentStyle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 Public method to get the style at the current position.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @return style at the current position (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 return self.styleAt(self.currentPosition())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 def getEndStyled(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 Public method to get the last styled position.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
219
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
220 @return end position of the last styling run (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 return self.SendScintilla(QsciScintilla.SCI_GETENDSTYLED)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 def startStyling(self, pos, mask):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 Public method to prepare styling.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 @param pos styling positition to start at (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 @param mask mask of bits to use for styling (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.SendScintilla(QsciScintilla.SCI_STARTSTYLING, pos, mask)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 def setStyling(self, length, style):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 Public method to style some text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 @param length length of text to style (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 @param style style to set for text (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 self.SendScintilla(QsciScintilla.SCI_SETSTYLING, length, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 def setStyleBits(self, bits):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 Public method to set the number of bits to be used for styling.
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
245
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
246 @param bits number of style bits (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.SendScintilla(QsciScintilla.SCI_SETSTYLEBITS, bits)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def charAt(self, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
252 Public method to get the character at a position in the text observing
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 multibyte characters.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 @param pos position in the text (integer)
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
256 @return character at the requested position or empty string, if the
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
257 position is negative or past the end of the document (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
259 ch = self.byteAt(pos)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if ch and ord(ch) > 127 and self.isUtf8():
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
261 if (ch[0] & 0xF0) == 0xF0:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 utf8Len = 4
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
263 elif (ch[0] & 0xE0) == 0xE0:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 utf8Len = 3
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
265 elif (ch[0] & 0xC0) == 0xC0:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 utf8Len = 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 while len(ch) < utf8Len:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 pos += 1
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
269 ch += self.byteAt(pos)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 return ch.decode('utf8')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 else:
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
272 return ch.decode()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
274 def byteAt(self, pos):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
276 Public method to get the raw character (bytes) at a position in the
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
277 text.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 @param pos position in the text (integer)
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
280 @return raw character at the requested position or empty bytes, if the
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
281 position is negative or past the end of the document (bytes)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 char = self.SendScintilla(QsciScintilla.SCI_GETCHARAT, pos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 if char == 0:
25
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
285 return b""
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
286 if char < 0:
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
287 char += 256
5163e6f94ba5 Ported the exporters to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
288 return bytes.fromhex("{0:02x}".format(char))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 def foldLevelAt(self, line):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 Public method to get the fold level of a line of the document.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 @param line line number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 @return fold level of the given line (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 lvl = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL, line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 return \
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
299 (lvl & QsciScintilla.SC_FOLDLEVELNUMBERMASK) - \
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
300 QsciScintilla.SC_FOLDLEVELBASE
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 def foldFlagsAt(self, line):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Public method to get the fold flags of a line of the document.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @param line line number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 @return fold flags of the given line (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 lvl = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL, line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 return lvl & ~QsciScintilla.SC_FOLDLEVELNUMBERMASK
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 def foldHeaderAt(self, line):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
314 Public method to determine, if a line of the document is a fold header
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
315 line.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 @param line line number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 @return flag indicating a fold header line (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 lvl = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL, line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 return lvl & QsciScintilla.SC_FOLDLEVELHEADERFLAG
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 def foldExpandedAt(self, line):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 Public method to determine, if a fold is expanded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 @param line line number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 @return flag indicating the fold expansion state of the line (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 return self.SendScintilla(QsciScintilla.SCI_GETFOLDEXPANDED, line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 def setIndentationGuideView(self, view):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 Public method to set the view of the indentation guides.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 @param view view of the indentation guides (SC_IV_NONE, SC_IV_REAL,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 SC_IV_LOOKFORWARD or SC_IV_LOOKBOTH)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 self.SendScintilla(QsciScintilla.SCI_SETINDENTATIONGUIDES, view)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 def indentationGuideView(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 Public method to get the indentation guide view.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @return indentation guide view (SC_IV_NONE, SC_IV_REAL,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 SC_IV_LOOKFORWARD or SC_IV_LOOKBOTH)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 return self.SendScintilla(QsciScintilla.SCI_GETINDENTATIONGUIDES)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
350 ###########################################################################
2659
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
351 ## methods below are missing from QScintilla
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
352 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
354 def zoomIn(self, zoom=1):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 Public method used to increase the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
358 @param zoom zoom factor increment (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
360 super().zoomIn(zoom)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
362 def zoomOut(self, zoom=1):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 Public method used to decrease the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
366 @param zoom zoom factor decrement (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
368 super().zoomOut(zoom)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 def zoomTo(self, zoom):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 Public method used to zoom to a specific zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
374 @param zoom zoom factor (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 self.zoom = zoom
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
377 super().zoomTo(zoom)
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
378 self.zoomValueChanged.emit(self.zoom)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 def getZoom(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 Public method used to retrieve the current zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383
2347
a4a4d710ebe8 Fixed the feedback of a changed zoom value from the editors, shell or terminal to the view manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
384 @return zoom factor (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 return self.zoom
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 def editorCommand(self, cmd):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 Public method to perform a simple editor command.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
392 @param cmd the scintilla command to be performed (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self.SendScintilla(cmd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 def scrollVertical(self, lines):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 Public method to scroll the text area.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 @param lines number of lines to scroll (negative scrolls up,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 positive scrolls down) (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.SendScintilla(QsciScintilla.SCI_LINESCROLL, 0, lines)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 def moveCursorToEOL(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 Public method to move the cursor to the end of line.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 self.SendScintilla(QsciScintilla.SCI_LINEEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 def moveCursorLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 Public method to move the cursor left.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 def moveCursorRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 Public method to move the cursor right.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 def moveCursorWordLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 Public method to move the cursor left one word.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.SendScintilla(QsciScintilla.SCI_WORDLEFT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 def moveCursorWordRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 Public method to move the cursor right one word.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 def newLineBelow(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 Public method to insert a new line below the current one.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.SendScintilla(QsciScintilla.SCI_LINEEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.SendScintilla(QsciScintilla.SCI_NEWLINE)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 def deleteBack(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 Public method to delete the character to the left of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 def delete(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 Public method to delete the character to the right of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 self.SendScintilla(QsciScintilla.SCI_CLEAR)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 def deleteWordLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 Public method to delete the word to the left of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 self.SendScintilla(QsciScintilla.SCI_DELWORDLEFT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 def deleteWordRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 Public method to delete the word to the right of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 self.SendScintilla(QsciScintilla.SCI_DELWORDRIGHT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 def deleteLineLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 Public method to delete the line to the left of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 self.SendScintilla(QsciScintilla.SCI_DELLINELEFT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 def deleteLineRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 Public method to delete the line to the right of the cursor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 self.SendScintilla(QsciScintilla.SCI_DELLINERIGHT)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 def extendSelectionLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 Public method to extend the selection one character to the left.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.SendScintilla(QsciScintilla.SCI_CHARLEFTEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 def extendSelectionRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 Public method to extend the selection one character to the right.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 self.SendScintilla(QsciScintilla.SCI_CHARRIGHTEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 def extendSelectionWordLeft(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 Public method to extend the selection one word to the left.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 self.SendScintilla(QsciScintilla.SCI_WORDLEFTEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 def extendSelectionWordRight(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 Public method to extend the selection one word to the right.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.SendScintilla(QsciScintilla.SCI_WORDRIGHTEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 def extendSelectionToBOL(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 Public method to extend the selection to the beginning of the line.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 self.SendScintilla(QsciScintilla.SCI_VCHOMEEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 def extendSelectionToEOL(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 Public method to extend the selection to the end of the line.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 self.SendScintilla(QsciScintilla.SCI_LINEENDEXTEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513
2593
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
514 def hasSelection(self):
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
515 """
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
516 Public method to check for a selection.
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
517
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
518 @return flag indicating the presence of a selection (boolean)
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
519 """
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
520 return self.getSelection()[0] != -1
a2df0adce985 Added entires to convert the selection to upper/lower case to the edit menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
521
3164
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
522 def hasSelectedText(self):
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
523 """
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
524 Public method to indicate the presence of selected text.
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
525
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
526 This is an overriding method to cope with a bug in QsciScintilla.
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
527
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
528 @return flag indicating the presence of selected text (boolean)
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
529 """
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
530 return bool(self.selectedText())
a027fc190f82 Fixed a bug creating a project from a repository and implemented a bugfix method for an issue in QsciScintilla.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
531
2587
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
532 def selectionIsRectangle(self):
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
533 """
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
534 Public method to check, if the current selection is rectangular.
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
535
2653
94ff2db166f5 Fixed a typo in some source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
536 @return flag indicating a rectangular selection (boolean)
2587
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
537 """
2650
1b495c651868 Fixed an issue causing the 'Selection only' entry to remain selectable in the Find and Find&Replace widget for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2632
diff changeset
538 startLine, startIndex, endLine, endIndex = self.getSelection()
1b495c651868 Fixed an issue causing the 'Selection only' entry to remain selectable in the Find and Find&Replace widget for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2632
diff changeset
539 return startLine != -1 and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
540 startLine != endLine and \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
541 self.SendScintilla(QsciScintilla.SCI_SELECTIONISRECTANGLE)
2587
68cc83a68883 Added a function to QsciScintillaCompat to check for a rectangular selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2564
diff changeset
542
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
543 def getRectangularSelection(self):
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
544 """
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
545 Public method to retrieve the start and end of a rectangular selection.
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
546
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
547 @return tuple with start line and index and end line and index
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
548 (tuple of four int)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
549 """
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
550 if not self.selectionIsRectangle():
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
551 return (-1, -1, -1, -1)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
552
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
553 startPos = self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
554 QsciScintilla.SCI_GETRECTANGULARSELECTIONANCHOR)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
555 endPos = self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
556 QsciScintilla.SCI_GETRECTANGULARSELECTIONCARET)
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
557 startLine, startIndex = self.lineIndexFromPosition(startPos)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
558 endLine, endIndex = self.lineIndexFromPosition(endPos)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
559
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
560 return (startLine, startIndex, endLine, endIndex)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
561
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
562 def setRectangularSelection(self, startLine, startIndex, endLine,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
563 endIndex):
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
564 """
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
565 Public method to set a rectangular selection.
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
566
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
567 @param startLine line number of the start of the selection (int)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
568 @param startIndex index number of the start of the selection (int)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
569 @param endLine line number of the end of the selection (int)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
570 @param endIndex index number of the end of the selection (int)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
571 """
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
572 startPos = self.positionFromLineIndex(startLine, startIndex)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
573 endPos = self.positionFromLineIndex(endLine, endIndex)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
574
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
575 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
576 QsciScintilla.SCI_SETRECTANGULARSELECTIONANCHOR, startPos)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
577 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
578 QsciScintilla.SCI_SETRECTANGULARSELECTIONCARET, endPos)
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2587
diff changeset
579
2658
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
580 def getSelectionCount(self):
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
581 """
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
582 Public method to get the number of active selections.
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
583
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
584 @return number of active selection (integer)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
585 """
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
586 return self.SendScintilla(QsciScintilla.SCI_GETSELECTIONS)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
587
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
588 def getSelectionN(self, index):
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
589 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
590 Public method to get the start and end of a selection given by its
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
591 index.
2658
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
592
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2763
diff changeset
593 @param index index of the selection (integer)
2658
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
594 @return tuple with start line and index and end line and index
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
595 (tuple of four int) for the given selection
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
596 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
597 startPos = self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
598 QsciScintilla.SCI_GETSELECTIONNSTART, index)
2658
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
599 endPos = self.SendScintilla(QsciScintilla.SCI_GETSELECTIONNEND, index)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
600 startLine, startIndex = self.lineIndexFromPosition(startPos)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
601 endLine, endIndex = self.lineIndexFromPosition(endPos)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
602
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
603 return (startLine, startIndex, endLine, endIndex)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
604
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
605 def getSelections(self):
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
606 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
607 Public method to get the start and end coordinates of all active
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
608 selections.
2658
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
609
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
610 @return list of tuples with start line and index and end line and index
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
611 of each active selection (list of tuples of four int)
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
612 """
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
613 selections = []
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
614 for index in range(self.getSelectionCount()):
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
615 selections.append(self.getSelectionN(index))
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
616 return selections
ec17f5d559e9 Added methods to QsciScintillaCompat to handle multiple selections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2653
diff changeset
617
2659
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
618 def setVirtualSpaceOptions(self, options):
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
619 """
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
620 Public method to set the virtual space usage options.
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
621
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
622 @param options usage options to set (integer, 0 to 3)
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
623 """
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
624 self.SendScintilla(QsciScintilla.SCI_SETVIRTUALSPACEOPTIONS, options)
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2658
diff changeset
625
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 def getLineSeparator(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 Public method to get the line separator for the current eol mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 @return eol string (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 m = self.eolMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 if m == QsciScintilla.EolWindows:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 eol = '\r\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 elif m == QsciScintilla.EolUnix:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 eol = '\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 elif m == QsciScintilla.EolMac:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 eol = '\r'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 eol = ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 return eol
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 def getEolIndicator(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 Public method to get the eol indicator for the current eol mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 @return eol indicator (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 m = self.eolMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 if m == QsciScintilla.EolWindows:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 eol = 'CRLF'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 elif m == QsciScintilla.EolUnix:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 eol = 'LF'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 elif m == QsciScintilla.EolMac:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 eol = 'CR'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 eol = ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 return eol
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 def setEolModeByEolString(self, eolStr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 Public method to set the eol mode given the eol string.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 @param eolStr eol string (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 if eolStr == '\r\n':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 self.setEolMode(QsciScintilla.EolMode(QsciScintilla.EolWindows))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 elif eolStr == '\n':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 self.setEolMode(QsciScintilla.EolMode(QsciScintilla.EolUnix))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 elif eolStr == '\r':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.setEolMode(QsciScintilla.EolMode(QsciScintilla.EolMac))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 def detectEolString(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 Public method to determine the eol string used.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 @param txt text from which to determine the eol string (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 @return eol string (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 if len(txt.split("\r\n", 1)) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 return '\r\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 elif len(txt.split("\n", 1)) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 return '\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 elif len(txt.split("\r", 1)) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 return '\r'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
689 def getCursorFlashTime(self):
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
690 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
691 Public method to get the flash (blink) time of the cursor in
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
692 milliseconds.
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
693
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
694 The flash time is the time required to display, invert and restore the
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
695 caret display. Usually the text cursor is displayed for half the cursor
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
696 flash time, then hidden for the same amount of time.
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
697
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
698 @return flash time of the cursor in milliseconds (integer)
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
699 """
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
700 return 2 * self.SendScintilla(QsciScintilla.SCI_GETCARETPERIOD)
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
701
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
702 def setCursorFlashTime(self, time):
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
703 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
704 Public method to get the flash (blink) time of the cursor in
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
705 milliseconds.
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
706
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
707 The flash time is the time required to display, invert and restore the
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
708 caret display. Usually the text cursor is displayed for half the cursor
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
709 flash time, then hidden for the same amount of time.
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
710
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
711 @param time flash time of the cursor in milliseconds (integer)
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
712 """
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
713 self.SendScintilla(QsciScintilla.SCI_SETCARETPERIOD, time // 2)
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
714
3067
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
715 def getCaretLineAlwaysVisible(self):
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
716 """
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
717 Public method to determine, if the caret line is visible even if
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
718 the editor doesn't have the focus.
3078
b9422535d0fe Corrected an incomplete source docu string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3071
diff changeset
719
b9422535d0fe Corrected an incomplete source docu string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3071
diff changeset
720 @return flag indicating an always visible caret line (boolean)
3067
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
721 """
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
722 try:
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
723 return self.SendScintilla(
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
724 QsciScintilla.SCI_GETCARETLINEVISIBLEALWAYS)
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
725 except AttributeError:
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
726 return False
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
727
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
728 def setCaretLineAlwaysVisible(self, alwaysVisible):
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
729 """
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
730 Public method to set the caret line visible even if the editor doesn't
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
731 have the focus.
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
732
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
733 @param alwaysVisible flag indicating that the caret line shall be
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
734 visible even if the editor doesn't have the focus (boolean)
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
735 """
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
736 try:
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
737 self.SendScintilla(
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
738 QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible)
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
739 except AttributeError:
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
740 pass
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
741
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
742 ###########################################################################
3169
7b1b754a60a6 Implemented a workaround for a non-working implementation of inputMethodEvent() in QScintilla 2.8.x. It simply overwrites these methods with empty ones in order to not loose selected text on focus out.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3164
diff changeset
743 ## methods to perform searches in target range
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
744 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 def positionFromPoint(self, point):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
748 Public method to calculate the scintilla position from a point in the
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
749 window.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 @param point point in the window (QPoint)
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
752 @return scintilla position (integer) or -1 to indicate, that the point
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
753 is not near any character
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
755 return self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINTCLOSE,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 point.x(), point.y())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 def positionBefore(self, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
760 Public method to get the position before the given position taking into
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
761 account multibyte characters.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 @param pos position (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 @return position before the given one (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 return self.SendScintilla(QsciScintilla.SCI_POSITIONBEFORE, pos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 def positionAfter(self, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
770 Public method to get the position after the given position taking into
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
771 account multibyte characters.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 @param pos position (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 @return position after the given one (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 return self.SendScintilla(QsciScintilla.SCI_POSITIONAFTER, pos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 def lineEndPosition(self, line):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 Public method to determine the line end position of the given line.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 @param line line number (integer)
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
783 @return position of the line end disregarding line end characters
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
784 (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 return self.SendScintilla(QsciScintilla.SCI_GETLINEENDPOSITION, line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 def __doSearchTarget(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 Private method to perform the search in target.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 @return flag indicating a successful search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 if self.__targetSearchStart == self.__targetSearchEnd:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 self.__targetSearchActive = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
798 self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
799 self.__targetSearchStart)
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
800 self.SendScintilla(QsciScintilla.SCI_SETTARGETEND,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
801 self.__targetSearchEnd)
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
802 self.SendScintilla(QsciScintilla.SCI_SETSEARCHFLAGS,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
803 self.__targetSearchFlags)
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
804 targetSearchExpr = self._encodeString(self.__targetSearchExpr)
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
805 pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
806 len(targetSearchExpr),
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
807 targetSearchExpr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 if pos == -1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 self.__targetSearchActive = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 targend = self.SendScintilla(QsciScintilla.SCI_GETTARGETEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 self.__targetSearchStart = targend
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 def getFoundTarget(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 Public method to get the recently found target.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 @return found target as a tuple of starting position and target length
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 (integer, integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 if self.__targetSearchActive:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 spos = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 epos = self.SendScintilla(QsciScintilla.SCI_GETTARGETEND)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 return (spos, epos - spos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 return (0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
832 def findFirstTarget(self, expr_, re_, cs_, wo_,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
833 begline=-1, begindex=-1, endline=-1, endindex=-1,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
834 ws_=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 Public method to search in a specified range of text without
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 setting the selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 @param expr_ search expression (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 @param re_ flag indicating a regular expression (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 @param cs_ flag indicating a case sensitive search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 @param wo_ flag indicating a word only search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 @keyparam begline line number to start from (-1 to indicate current
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 position) (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 @keyparam begindex index to start from (-1 to indicate current
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 position) (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 @keyparam endline line number to stop at (-1 to indicate end of
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 document) (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 @keyparam endindex index number to stop at (-1 to indicate end of
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 document) (integer)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
851 @keyparam ws_ flag indicating a word start search (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 @return flag indicating a successful search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 self.__targetSearchFlags = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 if re_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 self.__targetSearchFlags |= QsciScintilla.SCFIND_REGEXP
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 if cs_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 self.__targetSearchFlags |= QsciScintilla.SCFIND_MATCHCASE
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 if wo_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 self.__targetSearchFlags |= QsciScintilla.SCFIND_WHOLEWORD
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 if ws_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 self.__targetSearchFlags |= QsciScintilla.SCFIND_WORDSTART
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 if begline < 0 or begindex < 0:
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
865 self.__targetSearchStart = self.SendScintilla(
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
866 QsciScintilla.SCI_GETCURRENTPOS)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 else:
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
868 self.__targetSearchStart = self.positionFromLineIndex(
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
869 begline, begindex)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 if endline < 0 or endindex < 0:
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
872 self.__targetSearchEnd = self.SendScintilla(
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
873 QsciScintilla.SCI_GETTEXTLENGTH)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 else:
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
875 self.__targetSearchEnd = self.positionFromLineIndex(
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
876 endline, endindex)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
878 self.__targetSearchExpr = expr_
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 if self.__targetSearchExpr:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.__targetSearchActive = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 return self.__doSearchTarget()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 def findNextTarget(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 Public method to find the next occurrence in the target range.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 @return flag indicating a successful search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 if not self.__targetSearchActive:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 return self.__doSearchTarget()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 def replaceTarget(self, replaceStr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 Public method to replace the string found by the last search in target.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 @param replaceStr replacement string or regexp (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 if not self.__targetSearchActive:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 if self.__targetSearchFlags & QsciScintilla.SCFIND_REGEXP:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 cmd = QsciScintilla.SCI_REPLACETARGETRE
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 cmd = QsciScintilla.SCI_REPLACETARGET
510
84257fe1c8b4 Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 502
diff changeset
911 r = self._encodeString(replaceStr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 self.SendScintilla(cmd, len(r), r)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
916 self.__targetSearchStart = start + len(r)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
918 ###########################################################################
3169
7b1b754a60a6 Implemented a workaround for a non-working implementation of inputMethodEvent() in QScintilla 2.8.x. It simply overwrites these methods with empty ones in order to not loose selected text on focus out.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3164
diff changeset
919 ## indicator handling methods
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
920 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 def indicatorDefine(self, indicator, style, color):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 Public method to define the appearance of an indicator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
926 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
928 @param style style to be used for the indicator
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
929 (QsciScintilla.INDIC_PLAIN, QsciScintilla.INDIC_SQUIGGLE,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
930 QsciScintilla.INDIC_TT, QsciScintilla.INDIC_DIAGONAL,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
931 QsciScintilla.INDIC_STRIKE, QsciScintilla.INDIC_HIDDEN,
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
932 QsciScintilla.INDIC_BOX, QsciScintilla.INDIC_ROUNDBOX,
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
933 QsciScintilla.INDIC_STRAIGHTBOX, QsciScintilla.INDIC_DASH,
3071
83d066710d60 Added an extended progress dialog to make the progress bar label more descriptive.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3070
diff changeset
934 QsciScintilla.INDIC_DOTS, QsciScintilla.INDIC_SQUIGGLELOW,
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
935 QsciScintilla.INDIC_DOTBOX, QsciScintilla.INDIC_SQUIGGLEPIXMAP,
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
936 QsciScintilla.INDIC_COMPOSITIONTHICK depending upon QScintilla
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
937 version)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 @param color color to be used by the indicator (QColor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 @exception ValueError the indicator or style are not valid
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 if indicator < QsciScintilla.INDIC_CONTAINER or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 indicator > QsciScintilla.INDIC_MAX:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 raise ValueError("indicator number out of range")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
945 if style < QsciScintilla.INDIC_PLAIN or \
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
946 style > self.IndicatorStyleMax:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 raise ValueError("style out of range")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, indicator, style)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 self.SendScintilla(QsciScintilla.SCI_INDICSETFORE, indicator, color)
942
1d2a6b8509c6 Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
951 try:
1d2a6b8509c6 Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
952 self.SendScintilla(QsciScintilla.SCI_INDICSETALPHA, indicator,
1d2a6b8509c6 Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
953 color.alpha())
1d2a6b8509c6 Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
954 except AttributeError:
1d2a6b8509c6 Added capability to configure the alpha channel for some colors (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
955 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 def setCurrentIndicator(self, indicator):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 Public method to set the current indicator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
961 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 @exception ValueError the indicator or style are not valid
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 if indicator < QsciScintilla.INDIC_CONTAINER or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 indicator > QsciScintilla.INDIC_MAX:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 raise ValueError("indicator number out of range")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 self.SendScintilla(QsciScintilla.SCI_SETINDICATORCURRENT, indicator)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 def setIndicatorRange(self, indicator, spos, length):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 Public method to set an indicator for the given range.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
975 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 @param spos position of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 @param length length of the indicator (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 self.setCurrentIndicator(indicator)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 self.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE, spos, length)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 def setIndicator(self, indicator, sline, sindex, eline, eindex):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 Public method to set an indicator for the given range.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
987 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 @param sline line number of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 @param sindex index of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 @param eline line number of the indicator end (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 @param eindex index of the indicator end (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 spos = self.positionFromLineIndex(sline, sindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 epos = self.positionFromLineIndex(eline, eindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 self.setIndicatorRange(indicator, spos, epos - spos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 def clearIndicatorRange(self, indicator, spos, length):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 Public method to clear an indicator for the given range.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1001
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1002 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1003 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 @param spos position of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 @param length length of the indicator (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 self.setCurrentIndicator(indicator)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 self.SendScintilla(QsciScintilla.SCI_INDICATORCLEARRANGE, spos, length)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 def clearIndicator(self, indicator, sline, sindex, eline, eindex):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 Public method to clear an indicator for the given range.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1014 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 @param sline line number of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 @param sindex index of the indicator start (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 @param eline line number of the indicator end (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 @param eindex index of the indicator end (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 spos = self.positionFromLineIndex(sline, sindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 epos = self.positionFromLineIndex(eline, eindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 self.clearIndicatorRange(indicator, spos, epos - spos)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 def clearAllIndicators(self, indicator):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 Public method to clear all occurrences of an indicator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1029 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 self.clearIndicatorRange(indicator, 0, self.length())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 def hasIndicator(self, indicator, pos):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 Public method to test for the existence of an indicator.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1038 @param indicator number of the indicator (integer,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 QsciScintilla.INDIC_CONTAINER .. QsciScintilla.INDIC_MAX)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 @param pos position to test (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 @return flag indicating the existence of the indicator (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 """
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
1043 res = self.SendScintilla(QsciScintilla.SCI_INDICATORVALUEAT,
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
1044 indicator, pos)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 return res
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1047 def showFindIndicator(self, sline, sindex, eline, eindex):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1048 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1049 Public method to show the find indicator for the given range.
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1050
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1051 @param sline line number of the indicator start (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1052 @param sindex index of the indicator start (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1053 @param eline line number of the indicator end (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1054 @param eindex index of the indicator end (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1055 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1056 if hasattr(QsciScintilla, "SCI_FINDINDICATORSHOW"):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1057 spos = self.positionFromLineIndex(sline, sindex)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1058 epos = self.positionFromLineIndex(eline, eindex)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1059 self.SendScintilla(QsciScintilla.SCI_FINDINDICATORSHOW, spos, epos)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1060
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1061 def flashFindIndicator(self, sline, sindex, eline, eindex):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1062 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1063 Public method to flash the find indicator for the given range.
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1064
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1065 @param sline line number of the indicator start (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1066 @param sindex index of the indicator start (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1067 @param eline line number of the indicator end (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1068 @param eindex index of the indicator end (integer)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1069 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1070 if hasattr(QsciScintilla, "SCI_FINDINDICATORFLASH"):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1071 spos = self.positionFromLineIndex(sline, sindex)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1072 epos = self.positionFromLineIndex(eline, eindex)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1073 self.SendScintilla(QsciScintilla.SCI_FINDINDICATORFLASH,
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1074 spos, epos)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1075
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1076 def hideFindIndicator(self):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1077 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1078 Public method to hide the find indicator.
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1079 """
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1080 if hasattr(QsciScintilla, "SCI_FINDINDICATORHIDE"):
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1081 self.SendScintilla(QsciScintilla.SCI_FINDINDICATORHIDE)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
1082
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
1083 ###########################################################################
3169
7b1b754a60a6 Implemented a workaround for a non-working implementation of inputMethodEvent() in QScintilla 2.8.x. It simply overwrites these methods with empty ones in order to not loose selected text on focus out.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3164
diff changeset
1084 ## methods to perform folding related stuff
937
336c8f1ee7bb Adjusted QsciScintillaCompat to QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
1085 ###########################################################################
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1086
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1087 def __setFoldMarker(self, marknr, mark=QsciScintilla.SC_MARK_EMPTY):
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1088 """
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1089 Private method to define a fold marker.
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1090
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1091 @param marknr marker number to define (integer)
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1092 @param mark fold mark symbol to be used (integer)
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1093 """
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1094 self.SendScintilla(QsciScintilla.SCI_MARKERDEFINE, marknr, mark)
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1095
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1096 if mark != QsciScintilla.SC_MARK_EMPTY:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1097 self.SendScintilla(QsciScintilla.SCI_MARKERSETFORE,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1098 marknr, QColor(Qt.white))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1099 self.SendScintilla(QsciScintilla.SCI_MARKERSETBACK,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1100 marknr, QColor(Qt.black))
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1101
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1102 def setFolding(self, style, margin=2):
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1103 """
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1104 Public method to set the folding style and margin.
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1105
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1106 @param style folding style to set (integer)
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1107 @param margin margin number (integer)
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1108 """
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1109 if style < self.ArrowFoldStyle:
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
1110 super().setFolding(style, margin)
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1111 else:
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
1112 super().setFolding(
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
1113 QsciScintilla.PlainFoldStyle, margin)
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1114
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1115 if style == self.ArrowFoldStyle:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1116 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDER,
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1117 QsciScintilla.SC_MARK_ARROW)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1118 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPEN,
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1119 QsciScintilla.SC_MARK_ARROWDOWN)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1120 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERSUB)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1121 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERTAIL)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1122 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEREND)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1123 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPENMID)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1124 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERMIDTAIL)
330
4b4f242bf3f6 Added additional fold styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 325
diff changeset
1125 elif style == self.ArrowTreeFoldStyle:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1126 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDER,
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1127 QsciScintilla.SC_MARK_ARROW)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 944
diff changeset
1128 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPEN,
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
</