5 |
5 |
6 """ |
6 """ |
7 Module implementing a compatability interface class to QsciScintilla. |
7 Module implementing a compatability interface class to QsciScintilla. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtGui import QApplication, QPalette |
10 from PyQt4.QtCore import Qt |
|
11 from PyQt4.QtGui import QApplication, QPalette, QColor |
11 from PyQt4.Qsci import QsciScintilla, \ |
12 from PyQt4.Qsci import QsciScintilla, \ |
12 QSCINTILLA_VERSION as QsciQSCINTILLA_VERSION, QSCINTILLA_VERSION_STR |
13 QSCINTILLA_VERSION as QsciQSCINTILLA_VERSION, QSCINTILLA_VERSION_STR |
13 |
14 |
14 |
15 |
15 ##################################################################################### |
16 ##################################################################################### |
36 |
37 |
37 This class implements all the functions, that were added to |
38 This class implements all the functions, that were added to |
38 QsciScintilla incrementally. This class ensures compatibility |
39 QsciScintilla incrementally. This class ensures compatibility |
39 to older versions of QsciScintilla. |
40 to older versions of QsciScintilla. |
40 """ |
41 """ |
|
42 ArrowFoldStyle = QsciScintilla.BoxedTreeFoldStyle + 1 |
|
43 ArrowTreeFoldStyle = ArrowFoldStyle + 1 |
|
44 |
41 def __init__(self, parent = None): |
45 def __init__(self, parent = None): |
42 """ |
46 """ |
43 Constructor |
47 Constructor |
44 |
48 |
45 @param parent parent widget (QWidget) |
49 @param parent parent widget (QWidget) |
838 """ |
842 """ |
839 res = self.SendScintilla(QsciScintilla.SCI_INDICATORVALUEAT, indicator, pos) |
843 res = self.SendScintilla(QsciScintilla.SCI_INDICATORVALUEAT, indicator, pos) |
840 return res |
844 return res |
841 |
845 |
842 ##################################################################################### |
846 ##################################################################################### |
|
847 # methods to perform folding related stuff |
|
848 ##################################################################################### |
|
849 |
|
850 def __setFoldMarker(self, marknr, mark = QsciScintilla.SC_MARK_EMPTY): |
|
851 """ |
|
852 Private method to define a fold marker. |
|
853 |
|
854 @param marknr marker number to define (integer) |
|
855 @param mark fold mark symbol to be used (integer) |
|
856 """ |
|
857 self.SendScintilla(QsciScintilla.SCI_MARKERDEFINE, marknr, mark) |
|
858 |
|
859 if mark != QsciScintilla.SC_MARK_EMPTY: |
|
860 self.SendScintilla(QsciScintilla.SCI_MARKERSETFORE, |
|
861 marknr, QColor(Qt.white)) |
|
862 self.SendScintilla(QsciScintilla.SCI_MARKERSETBACK, |
|
863 marknr, QColor(Qt.black)) |
|
864 |
|
865 def setFolding(self, style, margin = 2): |
|
866 """ |
|
867 Public method to set the folding style and margin. |
|
868 |
|
869 @param style folding style to set (integer) |
|
870 @param margin margin number (integer) |
|
871 """ |
|
872 if style < self.ArrowFoldStyle: |
|
873 QsciScintilla.setFolding(self, style, margin) |
|
874 else: |
|
875 QsciScintilla.setFolding(self, QsciScintilla.PlainFoldStyle, margin) |
|
876 |
|
877 if style == self.ArrowFoldStyle: |
|
878 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDER, |
|
879 QsciScintilla.SC_MARK_ARROW); |
|
880 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPEN, |
|
881 QsciScintilla.SC_MARK_ARROWDOWN); |
|
882 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERSUB); |
|
883 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERTAIL); |
|
884 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEREND); |
|
885 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPENMID); |
|
886 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERMIDTAIL); |
|
887 elif style == self.ArrowTreeFoldStyle: |
|
888 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDER, |
|
889 QsciScintilla.SC_MARK_ARROW); |
|
890 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPEN, |
|
891 QsciScintilla.SC_MARK_ARROWDOWN); |
|
892 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERSUB, |
|
893 QsciScintilla.SC_MARK_VLINE); |
|
894 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERTAIL, |
|
895 QsciScintilla.SC_MARK_LCORNER); |
|
896 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEREND, |
|
897 QsciScintilla.SC_MARK_ARROW); |
|
898 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDEROPENMID, |
|
899 QsciScintilla.SC_MARK_ARROWDOWN); |
|
900 self.__setFoldMarker(QsciScintilla.SC_MARKNUM_FOLDERMIDTAIL, |
|
901 QsciScintilla.SC_MARK_TCORNER); |
|
902 |
|
903 ##################################################################################### |
843 # interface methods to the standard keyboard command set |
904 # interface methods to the standard keyboard command set |
844 ##################################################################################### |
905 ##################################################################################### |
845 |
906 |
846 def clearKeys(self): |
907 def clearKeys(self): |
847 """ |
908 """ |