QScintilla/QsciScintillaCompat.py

branch
Py2 comp.
changeset 3178
f25fc1364c88
parent 3161
06f57a834adf
parent 3176
51feb6174cc2
child 3484
645c12de6b0c
equal deleted inserted replaced
3161:06f57a834adf 3178:f25fc1364c88
488 488
489 @return flag indicating the presence of a selection (boolean) 489 @return flag indicating the presence of a selection (boolean)
490 """ 490 """
491 return self.getSelection()[0] != -1 491 return self.getSelection()[0] != -1
492 492
493 def hasSelectedText(self):
494 """
495 Public method to indicate the presence of selected text.
496
497 This is an overriding method to cope with a bug in QsciScintilla.
498
499 @return flag indicating the presence of selected text (boolean)
500 """
501 return bool(self.selectedText())
502
493 def selectionIsRectangle(self): 503 def selectionIsRectangle(self):
494 """ 504 """
495 Public method to check, if the current selection is rectangular. 505 Public method to check, if the current selection is rectangular.
496 506
497 @return flag indicating a rectangular selection (boolean) 507 @return flag indicating a rectangular selection (boolean)
699 QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible) 709 QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible)
700 except AttributeError: 710 except AttributeError:
701 pass 711 pass
702 712
703 ########################################################################### 713 ###########################################################################
704 # methods to perform searches in target range 714 ## methods to perform searches in target range
705 ########################################################################### 715 ###########################################################################
706 716
707 def positionFromPoint(self, point): 717 def positionFromPoint(self, point):
708 """ 718 """
709 Public method to calculate the scintilla position from a point in the 719 Public method to calculate the scintilla position from a point in the
875 self.SendScintilla(cmd, len(r), r) 885 self.SendScintilla(cmd, len(r), r)
876 886
877 self.__targetSearchStart = start + len(r) 887 self.__targetSearchStart = start + len(r)
878 888
879 ########################################################################### 889 ###########################################################################
880 # indicator handling methods 890 ## indicator handling methods
881 ########################################################################### 891 ###########################################################################
882 892
883 def indicatorDefine(self, indicator, style, color): 893 def indicatorDefine(self, indicator, style, color):
884 """ 894 """
885 Public method to define the appearance of an indicator. 895 Public method to define the appearance of an indicator.
1040 """ 1050 """
1041 if hasattr(QsciScintilla, "SCI_FINDINDICATORHIDE"): 1051 if hasattr(QsciScintilla, "SCI_FINDINDICATORHIDE"):
1042 self.SendScintilla(QsciScintilla.SCI_FINDINDICATORHIDE) 1052 self.SendScintilla(QsciScintilla.SCI_FINDINDICATORHIDE)
1043 1053
1044 ########################################################################### 1054 ###########################################################################
1045 # methods to perform folding related stuff 1055 ## methods to perform folding related stuff
1046 ########################################################################### 1056 ###########################################################################
1047 1057
1048 def __setFoldMarker(self, marknr, mark=QsciScintilla.SC_MARK_EMPTY): 1058 def __setFoldMarker(self, marknr, mark=QsciScintilla.SC_MARK_EMPTY):
1049 """ 1059 """
1050 Private method to define a fold marker. 1060 Private method to define a fold marker.
1141 QsciScintilla.SC_MARKNUM_FOLDEREND, foreColor) 1151 QsciScintilla.SC_MARKNUM_FOLDEREND, foreColor)
1142 self.SendScintilla(QsciScintilla.SCI_MARKERSETBACK, 1152 self.SendScintilla(QsciScintilla.SCI_MARKERSETBACK,
1143 QsciScintilla.SC_MARKNUM_FOLDEREND, backColor) 1153 QsciScintilla.SC_MARKNUM_FOLDEREND, backColor)
1144 1154
1145 ########################################################################### 1155 ###########################################################################
1146 # interface methods to the standard keyboard command set 1156 ## interface methods to the standard keyboard command set
1147 ########################################################################### 1157 ###########################################################################
1148 1158
1149 def clearKeys(self): 1159 def clearKeys(self):
1150 """ 1160 """
1151 Protected method to clear the key commands. 1161 Protected method to clear the key commands.
1159 """ 1169 """
1160 # call into the QsciCommandSet 1170 # call into the QsciCommandSet
1161 self.standardCommands().clearAlternateKeys() 1171 self.standardCommands().clearAlternateKeys()
1162 1172
1163 ########################################################################### 1173 ###########################################################################
1164 # specialized event handlers 1174 ## specialized event handlers
1165 ########################################################################### 1175 ###########################################################################
1166 1176
1167 def focusOutEvent(self, event): 1177 def focusOutEvent(self, event):
1168 """ 1178 """
1169 Public method called when the editor loses focus. 1179 Public method called when the editor loses focus.
1184 1194
1185 @param evt event object to handle (QEvent) 1195 @param evt event object to handle (QEvent)
1186 @return result of the event handling (boolean) 1196 @return result of the event handling (boolean)
1187 """ 1197 """
1188 return QsciScintillaBase.event(self, evt) 1198 return QsciScintillaBase.event(self, evt)
1199
1200 # TODO: adjust this once we have a working QScintilla version
1201 if "inputMethodEvent" in QsciScintillaBase.__dict__ and \
1202 QSCINTILLA_VERSION() < 0x020900:
1203 def inputMethodEvent(self, evt):
1204 """
1205 Protected method to cope with a glitch in some Qscintilla versions
1206 handling input events.
1207
1208 Note: This simply disables the Qscintilla behavior.
1209
1210 @param evt reference to the input method event object
1211 (QInputMethodEvent)
1212 """
1213 pass
1214
1215 def inputMethodQuery(self, query):
1216 """
1217 Protected method to cope with a glitch in some Qscintilla versions
1218 handling input events.
1219
1220 Note: This simply disables the Qscintilla behavior.
1221
1222 @param query reference to the input method query object
1223 (Qt.InputMethodQuery)
1224 @return object containing the requested information
1225 """
1226 return None
1189 1227
1190 ########################################################################### 1228 ###########################################################################
1191 # interface methods to the mini editor 1229 ## interface methods to the mini editor
1192 ########################################################################### 1230 ###########################################################################
1193 1231
1194 def getFileName(self): 1232 def getFileName(self):
1195 """ 1233 """
1196 Public method to return the name of the file being displayed. 1234 Public method to return the name of the file being displayed.
1205 return p.getFileName() 1243 return p.getFileName()
1206 except AttributeError: 1244 except AttributeError:
1207 return "" 1245 return ""
1208 1246
1209 ########################################################################### 1247 ###########################################################################
1210 # replacements for buggy methods 1248 ## replacements for buggy methods
1211 ########################################################################### 1249 ###########################################################################
1212 1250
1213 def showUserList(self, id, lst): 1251 def showUserList(self, id, lst):
1214 """ 1252 """
1215 Public method to show a user supplied list. 1253 Public method to show a user supplied list.
1224 ord(self.UserSeparator)) 1262 ord(self.UserSeparator))
1225 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id, 1263 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id,
1226 self._encodeString(self.UserSeparator.join(lst))) 1264 self._encodeString(self.UserSeparator.join(lst)))
1227 1265
1228 ########################################################################### 1266 ###########################################################################
1229 # utility methods 1267 ## utility methods
1230 ########################################################################### 1268 ###########################################################################
1231 1269
1232 def _encodeString(self, string): 1270 def _encodeString(self, string):
1233 """ 1271 """
1234 Protected method to encode a string depending on the current mode. 1272 Protected method to encode a string depending on the current mode.
1243 return string.encode("utf-8") 1281 return string.encode("utf-8")
1244 else: 1282 else:
1245 return string.encode("latin-1") 1283 return string.encode("latin-1")
1246 1284
1247 ########################################################################### 1285 ###########################################################################
1248 # methods below have been added to QScintilla starting with version 2.5 1286 ## methods below have been added to QScintilla starting with version 2.5
1249 ########################################################################### 1287 ###########################################################################
1250 1288
1251 if "positionFromLineIndex" not in QsciScintilla.__dict__: 1289 if "positionFromLineIndex" not in QsciScintilla.__dict__:
1252 def positionFromLineIndex(self, line, index): 1290 def positionFromLineIndex(self, line, index):
1253 """ 1291 """

eric ide

mercurial