|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing functions to map QScintilla keyboard commands to |
|
8 QKeySequence standard keys. |
|
9 """ |
|
10 |
|
11 from PyQt6.QtGui import QKeySequence |
|
12 from PyQt6.Qsci import QsciScintilla |
|
13 |
|
14 __all__ = ["s2qTranslate"] |
|
15 |
|
16 Scintilla2QKeySequence = { |
|
17 QsciScintilla.SCI_CHARLEFT: QKeySequence.StandardKey.MoveToPreviousChar, |
|
18 QsciScintilla.SCI_CHARRIGHT: QKeySequence.StandardKey.MoveToNextChar, |
|
19 QsciScintilla.SCI_LINEUP: QKeySequence.StandardKey.MoveToPreviousLine, |
|
20 QsciScintilla.SCI_LINEDOWN: QKeySequence.StandardKey.MoveToNextLine, |
|
21 QsciScintilla.SCI_WORDPARTLEFT: QKeySequence.StandardKey.UnknownKey, |
|
22 QsciScintilla.SCI_WORDPARTRIGHT: QKeySequence.StandardKey.UnknownKey, |
|
23 QsciScintilla.SCI_WORDLEFT: QKeySequence.StandardKey.MoveToNextWord, |
|
24 QsciScintilla.SCI_WORDRIGHT: QKeySequence.StandardKey.MoveToPreviousWord, |
|
25 QsciScintilla.SCI_VCHOME: QKeySequence.StandardKey.MoveToStartOfLine, |
|
26 QsciScintilla.SCI_HOMEDISPLAY: QKeySequence.StandardKey.UnknownKey, |
|
27 QsciScintilla.SCI_LINEEND: QKeySequence.StandardKey.MoveToEndOfLine, |
|
28 QsciScintilla.SCI_LINESCROLLDOWN: QKeySequence.StandardKey.UnknownKey, |
|
29 QsciScintilla.SCI_LINESCROLLUP: QKeySequence.StandardKey.UnknownKey, |
|
30 QsciScintilla.SCI_PARAUP: QKeySequence.StandardKey.MoveToStartOfBlock, |
|
31 QsciScintilla.SCI_PARADOWN: QKeySequence.StandardKey.MoveToEndOfBlock, |
|
32 QsciScintilla.SCI_PAGEUP: QKeySequence.StandardKey.MoveToPreviousPage, |
|
33 QsciScintilla.SCI_PAGEDOWN: QKeySequence.StandardKey.MoveToNextPage, |
|
34 QsciScintilla.SCI_DOCUMENTSTART: |
|
35 QKeySequence.StandardKey.MoveToStartOfDocument, |
|
36 QsciScintilla.SCI_DOCUMENTEND: |
|
37 QKeySequence.StandardKey.MoveToEndOfDocument, |
|
38 QsciScintilla.SCI_TAB: QKeySequence.StandardKey.UnknownKey, |
|
39 QsciScintilla.SCI_BACKTAB: QKeySequence.StandardKey.UnknownKey, |
|
40 QsciScintilla.SCI_CHARLEFTEXTEND: |
|
41 QKeySequence.StandardKey.SelectPreviousChar, |
|
42 QsciScintilla.SCI_CHARRIGHTEXTEND: QKeySequence.StandardKey.SelectNextChar, |
|
43 QsciScintilla.SCI_LINEUPEXTEND: |
|
44 QKeySequence.StandardKey.SelectPreviousLine, |
|
45 QsciScintilla.SCI_LINEDOWNEXTEND: QKeySequence.StandardKey.SelectNextLine, |
|
46 QsciScintilla.SCI_WORDPARTLEFTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
47 QsciScintilla.SCI_WORDPARTRIGHTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
48 QsciScintilla.SCI_WORDLEFTEXTEND: |
|
49 QKeySequence.StandardKey.SelectPreviousWord, |
|
50 QsciScintilla.SCI_WORDRIGHTEXTEND: QKeySequence.StandardKey.SelectNextWord, |
|
51 QsciScintilla.SCI_VCHOMEEXTEND: QKeySequence.StandardKey.SelectStartOfLine, |
|
52 QsciScintilla.SCI_LINEENDEXTEND: QKeySequence.StandardKey.SelectEndOfLine, |
|
53 QsciScintilla.SCI_PARAUPEXTEND: |
|
54 QKeySequence.StandardKey.SelectStartOfBlock, |
|
55 QsciScintilla.SCI_PARADOWNEXTEND: |
|
56 QKeySequence.StandardKey.SelectEndOfBlock, |
|
57 QsciScintilla.SCI_PAGEUPEXTEND: |
|
58 QKeySequence.StandardKey.SelectPreviousPage, |
|
59 QsciScintilla.SCI_PAGEDOWNEXTEND: QKeySequence.StandardKey.SelectNextPage, |
|
60 QsciScintilla.SCI_DOCUMENTSTARTEXTEND: |
|
61 QKeySequence.StandardKey.SelectStartOfDocument, |
|
62 QsciScintilla.SCI_DOCUMENTENDEXTEND: |
|
63 QKeySequence.StandardKey.SelectEndOfDocument, |
|
64 QsciScintilla.SCI_DELETEBACK: QKeySequence.StandardKey.UnknownKey, |
|
65 QsciScintilla.SCI_DELETEBACKNOTLINE: QKeySequence.StandardKey.UnknownKey, |
|
66 QsciScintilla.SCI_CLEAR: QKeySequence.StandardKey.Delete, |
|
67 QsciScintilla.SCI_DELWORDLEFT: QKeySequence.StandardKey.DeleteStartOfWord, |
|
68 QsciScintilla.SCI_DELWORDRIGHT: QKeySequence.StandardKey.DeleteEndOfWord, |
|
69 QsciScintilla.SCI_DELLINELEFT: QKeySequence.StandardKey.UnknownKey, |
|
70 QsciScintilla.SCI_DELLINERIGHT: QKeySequence.StandardKey.DeleteEndOfLine, |
|
71 QsciScintilla.SCI_NEWLINE: QKeySequence.StandardKey.InsertLineSeparator, |
|
72 QsciScintilla.SCI_LINEDELETE: QKeySequence.StandardKey.UnknownKey, |
|
73 QsciScintilla.SCI_LINEDUPLICATE: QKeySequence.StandardKey.UnknownKey, |
|
74 QsciScintilla.SCI_LINETRANSPOSE: QKeySequence.StandardKey.UnknownKey, |
|
75 QsciScintilla.SCI_LINECUT: QKeySequence.StandardKey.UnknownKey, |
|
76 QsciScintilla.SCI_LINECOPY: QKeySequence.StandardKey.UnknownKey, |
|
77 QsciScintilla.SCI_EDITTOGGLEOVERTYPE: QKeySequence.StandardKey.UnknownKey, |
|
78 QsciScintilla.SCI_LINEENDDISPLAY: QKeySequence.StandardKey.UnknownKey, |
|
79 QsciScintilla.SCI_LINEENDDISPLAYEXTEND: |
|
80 QKeySequence.StandardKey.UnknownKey, |
|
81 QsciScintilla.SCI_FORMFEED: QKeySequence.StandardKey.UnknownKey, |
|
82 QsciScintilla.SCI_CANCEL: QKeySequence.StandardKey.UnknownKey, |
|
83 QsciScintilla.SCI_LINEDOWNRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
84 QsciScintilla.SCI_LINEUPRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
85 QsciScintilla.SCI_CHARLEFTRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
86 QsciScintilla.SCI_CHARRIGHTRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
87 QsciScintilla.SCI_VCHOMERECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
88 QsciScintilla.SCI_LINEENDRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
89 QsciScintilla.SCI_PAGEUPRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
90 QsciScintilla.SCI_PAGEDOWNRECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
91 QsciScintilla.SCI_SELECTIONDUPLICATE: QKeySequence.StandardKey.UnknownKey, |
|
92 QsciScintilla.SCI_SCROLLTOSTART: QKeySequence.StandardKey.UnknownKey, |
|
93 QsciScintilla.SCI_SCROLLTOEND: QKeySequence.StandardKey.UnknownKey, |
|
94 QsciScintilla.SCI_VERTICALCENTRECARET: QKeySequence.StandardKey.UnknownKey, |
|
95 QsciScintilla.SCI_WORDRIGHTEND: QKeySequence.StandardKey.UnknownKey, |
|
96 QsciScintilla.SCI_WORDRIGHTENDEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
97 QsciScintilla.SCI_WORDLEFTEND: QKeySequence.StandardKey.UnknownKey, |
|
98 QsciScintilla.SCI_WORDLEFTENDEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
99 QsciScintilla.SCI_HOME: QKeySequence.StandardKey.UnknownKey, |
|
100 QsciScintilla.SCI_HOMEEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
101 QsciScintilla.SCI_HOMERECTEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
102 QsciScintilla.SCI_HOMEDISPLAYEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
103 QsciScintilla.SCI_HOMEWRAP: QKeySequence.StandardKey.UnknownKey, |
|
104 QsciScintilla.SCI_HOMEWRAPEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
105 QsciScintilla.SCI_VCHOMEWRAP: QKeySequence.StandardKey.UnknownKey, |
|
106 QsciScintilla.SCI_VCHOMEWRAPEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
107 QsciScintilla.SCI_LINEENDWRAP: QKeySequence.StandardKey.UnknownKey, |
|
108 QsciScintilla.SCI_LINEENDWRAPEXTEND: QKeySequence.StandardKey.UnknownKey, |
|
109 QsciScintilla.SCI_STUTTEREDPAGEUP: QKeySequence.StandardKey.UnknownKey, |
|
110 QsciScintilla.SCI_STUTTEREDPAGEUPEXTEND: |
|
111 QKeySequence.StandardKey.UnknownKey, |
|
112 QsciScintilla.SCI_STUTTEREDPAGEDOWN: QKeySequence.StandardKey.UnknownKey, |
|
113 QsciScintilla.SCI_STUTTEREDPAGEDOWNEXTEND: |
|
114 QKeySequence.StandardKey.UnknownKey, |
|
115 QsciScintilla.SCI_DELWORDRIGHTEND: QKeySequence.StandardKey.UnknownKey, |
|
116 QsciScintilla.SCI_MOVESELECTEDLINESUP: QKeySequence.StandardKey.UnknownKey, |
|
117 QsciScintilla.SCI_MOVESELECTEDLINESDOWN: |
|
118 QKeySequence.StandardKey.UnknownKey, |
|
119 QsciScintilla.SCI_LOWERCASE: QKeySequence.StandardKey.UnknownKey, |
|
120 QsciScintilla.SCI_UPPERCASE: QKeySequence.StandardKey.UnknownKey, |
|
121 QsciScintilla.SCI_LINEDELETE: QKeySequence.StandardKey.DeleteCompleteLine, |
|
122 QsciScintilla.SCI_DELETEBACK: QKeySequence.StandardKey.Backspace, |
|
123 } |
|
124 |
|
125 |
|
126 def s2qTranslate(scintillaCommand): |
|
127 """ |
|
128 Function to translate a QScintilla command to a QKeySequence. |
|
129 |
|
130 @param scintillaCommand QScintilla command |
|
131 @type int |
|
132 @return Qt key sequence |
|
133 @rtype QKeySequence.StandardKey |
|
134 """ |
|
135 return Scintilla2QKeySequence[scintillaCommand] |