QScintilla/QsciScintillaCompat.py

changeset 502
7500b9d5b21d
parent 448
a1f1b226ff4b
child 510
84257fe1c8b4
equal deleted inserted replaced
501:5c615a85241a 502:7500b9d5b21d
186 self.SendScintilla(QsciScintilla.SCI_SETSTYLING, length, style) 186 self.SendScintilla(QsciScintilla.SCI_SETSTYLING, length, style)
187 187
188 def setStyleBits(self, bits): 188 def setStyleBits(self, bits):
189 """ 189 """
190 Public method to set the number of bits to be used for styling. 190 Public method to set the number of bits to be used for styling.
191
192 @param bits number of style bits (integer)
191 """ 193 """
192 self.SendScintilla(QsciScintilla.SCI_SETSTYLEBITS, bits) 194 self.SendScintilla(QsciScintilla.SCI_SETSTYLEBITS, bits)
193 195
194 def charAt(self, pos): 196 def charAt(self, pos):
195 """ 197 """
329 331
330 def editorCommand(self, cmd): 332 def editorCommand(self, cmd):
331 """ 333 """
332 Public method to perform a simple editor command. 334 Public method to perform a simple editor command.
333 335
334 @param cmd the scintilla command to be performed 336 @param cmd the scintilla command to be performed (integer)
335 """ 337 """
336 self.SendScintilla(cmd) 338 self.SendScintilla(cmd)
337 339
338 def scrollVertical(self, lines): 340 def scrollVertical(self, lines):
339 """ 341 """
637 return False 639 return False
638 640
639 self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.__targetSearchStart) 641 self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.__targetSearchStart)
640 self.SendScintilla(QsciScintilla.SCI_SETTARGETEND, self.__targetSearchEnd) 642 self.SendScintilla(QsciScintilla.SCI_SETTARGETEND, self.__targetSearchEnd)
641 self.SendScintilla(QsciScintilla.SCI_SETSEARCHFLAGS, self.__targetSearchFlags) 643 self.SendScintilla(QsciScintilla.SCI_SETSEARCHFLAGS, self.__targetSearchFlags)
642 pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET, 644 targetSearchExpr = self._encodeString(self.__targetSearchExpr)
643 len(self.__targetSearchExpr), 645 pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET,
644 self.__targetSearchExpr) 646 len(targetSearchExpr),
647 targetSearchExpr)
645 648
646 if pos == -1: 649 if pos == -1:
647 self.__targetSearchActive = False 650 self.__targetSearchActive = False
648 return False 651 return False
649 652
737 if not self.__targetSearchActive: 740 if not self.__targetSearchActive:
738 return 741 return
739 742
740 if self.__targetSearchFlags & QsciScintilla.SCFIND_REGEXP: 743 if self.__targetSearchFlags & QsciScintilla.SCFIND_REGEXP:
741 cmd = QsciScintilla.SCI_REPLACETARGETRE 744 cmd = QsciScintilla.SCI_REPLACETARGETRE
745 r = replaceStr
742 else: 746 else:
743 cmd = QsciScintilla.SCI_REPLACETARGET 747 cmd = QsciScintilla.SCI_REPLACETARGET
748 r = self._encodeString(replaceStr)
744 749
745 start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART) 750 start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART)
746
747 r = replaceStr
748
749 self.SendScintilla(cmd, len(r), r) 751 self.SendScintilla(cmd, len(r), r)
750 752
751 self.__targetSearchStart = start + len(replaceStr) 753 self.__targetSearchStart = start + len(r)
752 754
753 ##################################################################################### 755 #####################################################################################
754 # indicator handling methods 756 # indicator handling methods
755 ##################################################################################### 757 #####################################################################################
756 758
1036 if id <= 0: 1038 if id <= 0:
1037 return 1039 return
1038 1040
1039 self.SendScintilla(QsciScintilla.SCI_AUTOCSETSEPARATOR, 1041 self.SendScintilla(QsciScintilla.SCI_AUTOCSETSEPARATOR,
1040 ord(self.UserSeparator)) 1042 ord(self.UserSeparator))
1041 if self.isUtf8(): 1043 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id,
1042 lst = self.UserSeparator.join(lst).encode("utf-8") 1044 self._encodeString(self.UserSeparator.join(lst)))
1043 else: 1045
1044 lst = self.UserSeparator.join(lst).encode("latin-1") 1046 #####################################################################################
1045 self.SendScintilla(QsciScintilla.SCI_USERLISTSHOW, id, lst) 1047 # utility methods
1048 #####################################################################################
1049
1050 def _encodeString(self, string):
1051 """
1052 Protected method to encode a string depending on the current mode.
1053
1054 @param string string to be encoded (str)
1055 @return encoded string (bytes)
1056 """
1057 if isinstance(string, bytes):
1058 return string
1059 else:
1060 if self.isUtf8():
1061 return string.encode("utf-8")
1062 else:
1063 return string.encode("latin-1")
1046 1064
1047 ## ##################################################################################### 1065 ## #####################################################################################
1048 ## # methods below have been added to QScintilla starting with version after 2.x 1066 ## # methods below have been added to QScintilla starting with version after 2.x
1049 ## ##################################################################################### 1067 ## #####################################################################################
1050 ## 1068 ##

eric ide

mercurial