QScintilla/QsciScintillaCompat.py

changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
86 Public method to set the current style to be monospaced. 86 Public method to set the current style to be monospaced.
87 87
88 @param font font to be used (QFont) 88 @param font font to be used (QFont)
89 """ 89 """
90 try: 90 try:
91 rangeLow = range(self.STYLE_DEFAULT) 91 rangeLow = list(range(self.STYLE_DEFAULT))
92 except AttributeError: 92 except AttributeError:
93 rangeLow = range(32) 93 rangeLow = list(range(32))
94 try: 94 try:
95 rangeHigh = range(self.STYLE_LASTPREDEFINED + 1, 95 rangeHigh = list(range(self.STYLE_LASTPREDEFINED + 1,
96 self.STYLE_MAX + 1) 96 self.STYLE_MAX + 1))
97 except AttributeError: 97 except AttributeError:
98 rangeHigh = range(40, 128) 98 rangeHigh = list(range(40, 128))
99 99
100 f = font.family() 100 f = font.family()
101 ps = font.pointSize() 101 ps = font.pointSize()
102 for style in rangeLow + rangeHigh: 102 for style in rangeLow + rangeHigh:
103 self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, style, f) 103 self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, style, f)
120 120
121 @param pos position to calculate the line for (integer or QPoint) 121 @param pos position to calculate the line for (integer or QPoint)
122 @return linenumber at position or -1, if there is no line at pos 122 @return linenumber at position or -1, if there is no line at pos
123 (integer, zero based) 123 (integer, zero based)
124 """ 124 """
125 if type(pos) == type(1): 125 if isinstance(pos, int):
126 scipos = pos 126 scipos = pos
127 else: 127 else:
128 scipos = \ 128 scipos = \
129 self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT, pos.x(), pos.y()) 129 self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT, pos.x(), pos.y())
130 line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, scipos) 130 line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, scipos)
680 if endline < 0 or endindex < 0: 680 if endline < 0 or endindex < 0:
681 self.__targetSearchEnd = self.SendScintilla(QsciScintilla.SCI_GETTEXTLENGTH) 681 self.__targetSearchEnd = self.SendScintilla(QsciScintilla.SCI_GETTEXTLENGTH)
682 else: 682 else:
683 self.__targetSearchEnd = self.positionFromLineIndex(endline, endindex) 683 self.__targetSearchEnd = self.positionFromLineIndex(endline, endindex)
684 684
685 if self.isUtf8(): 685 ## if self.isUtf8():
686 self.__targetSearchExpr = expr_.encode("utf-8") 686 ## self.__targetSearchExpr = expr_.encode("utf-8")
687 else: 687 ## else:
688 self.__targetSearchExpr = expr_.encode("latin1") 688 ## self.__targetSearchExpr = expr_.encode("latin1")
689 self.__targetSearchExpr = expr_
689 690
690 if self.__targetSearchExpr: 691 if self.__targetSearchExpr:
691 self.__targetSearchActive = True 692 self.__targetSearchActive = True
692 693
693 return self.__doSearchTarget() 694 return self.__doSearchTarget()
719 else: 720 else:
720 cmd = QsciScintilla.SCI_REPLACETARGET 721 cmd = QsciScintilla.SCI_REPLACETARGET
721 722
722 start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART) 723 start = self.SendScintilla(QsciScintilla.SCI_GETTARGETSTART)
723 724
724 if self.isUtf8(): 725 ## if self.isUtf8():
725 r = replaceStr.encode("utf-8") 726 ## r = replaceStr.encode("utf-8")
726 else: 727 ## else:
727 r = replaceStr.encode("latin1") 728 ## r = replaceStr.encode("latin1")
729 r = replaceStr
728 730
729 self.SendScintilla(cmd, len(r), r) 731 self.SendScintilla(cmd, len(r), r)
730 732
731 self.__targetSearchStart = start + len(replaceStr) 733 self.__targetSearchStart = start + len(replaceStr)
732 734

eric ide

mercurial