PrEditor 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of PrEditor might be problematic. Click here for more details.

Files changed (158) hide show
  1. preditor/__init__.py +322 -0
  2. preditor/__main__.py +13 -0
  3. preditor/about_module.py +161 -0
  4. preditor/cli.py +192 -0
  5. preditor/config.py +302 -0
  6. preditor/contexts.py +119 -0
  7. preditor/cores/__init__.py +0 -0
  8. preditor/cores/core.py +20 -0
  9. preditor/dccs/maya/PrEditor_maya.mod +2 -0
  10. preditor/dccs/maya/plug-ins/PrEditor_maya.py +110 -0
  11. preditor/debug.py +144 -0
  12. preditor/delayable_engine/__init__.py +302 -0
  13. preditor/delayable_engine/delayables.py +85 -0
  14. preditor/enum.py +728 -0
  15. preditor/excepthooks.py +131 -0
  16. preditor/gui/__init__.py +93 -0
  17. preditor/gui/app.py +160 -0
  18. preditor/gui/codehighlighter.py +209 -0
  19. preditor/gui/completer.py +226 -0
  20. preditor/gui/console.py +867 -0
  21. preditor/gui/dialog.py +178 -0
  22. preditor/gui/drag_tab_bar.py +190 -0
  23. preditor/gui/editor_chooser.py +57 -0
  24. preditor/gui/errordialog.py +68 -0
  25. preditor/gui/find_files.py +125 -0
  26. preditor/gui/fuzzy_search/__init__.py +0 -0
  27. preditor/gui/fuzzy_search/fuzzy_search.py +93 -0
  28. preditor/gui/group_tab_widget/__init__.py +325 -0
  29. preditor/gui/group_tab_widget/grouped_tab_menu.py +35 -0
  30. preditor/gui/group_tab_widget/grouped_tab_models.py +108 -0
  31. preditor/gui/group_tab_widget/grouped_tab_widget.py +78 -0
  32. preditor/gui/group_tab_widget/one_tab_widget.py +54 -0
  33. preditor/gui/level_buttons.py +343 -0
  34. preditor/gui/logger_window_handler.py +48 -0
  35. preditor/gui/logger_window_plugin.py +32 -0
  36. preditor/gui/loggerwindow.py +1385 -0
  37. preditor/gui/newtabwidget.py +69 -0
  38. preditor/gui/set_text_editor_path_dialog.py +59 -0
  39. preditor/gui/status_label.py +99 -0
  40. preditor/gui/suggest_path_quotes_dialog.py +50 -0
  41. preditor/gui/ui/editor_chooser.ui +93 -0
  42. preditor/gui/ui/errordialog.ui +74 -0
  43. preditor/gui/ui/find_files.ui +140 -0
  44. preditor/gui/ui/loggerwindow.ui +1105 -0
  45. preditor/gui/ui/set_text_editor_path_dialog.ui +189 -0
  46. preditor/gui/ui/suggest_path_quotes_dialog.ui +225 -0
  47. preditor/gui/window.py +161 -0
  48. preditor/gui/workbox_mixin.py +389 -0
  49. preditor/gui/workbox_text_edit.py +137 -0
  50. preditor/gui/workboxwidget.py +298 -0
  51. preditor/logging_config.py +52 -0
  52. preditor/osystem.py +401 -0
  53. preditor/plugins.py +118 -0
  54. preditor/prefs.py +74 -0
  55. preditor/resource/environment_variables.html +26 -0
  56. preditor/resource/error_mail.html +85 -0
  57. preditor/resource/error_mail_inline.html +41 -0
  58. preditor/resource/img/README.md +17 -0
  59. preditor/resource/img/arrow_forward.png +0 -0
  60. preditor/resource/img/check-bold.png +0 -0
  61. preditor/resource/img/chevron-down.png +0 -0
  62. preditor/resource/img/chevron-up.png +0 -0
  63. preditor/resource/img/close-thick.png +0 -0
  64. preditor/resource/img/comment-edit.png +0 -0
  65. preditor/resource/img/content-copy.png +0 -0
  66. preditor/resource/img/content-cut.png +0 -0
  67. preditor/resource/img/content-duplicate.png +0 -0
  68. preditor/resource/img/content-paste.png +0 -0
  69. preditor/resource/img/content-save.png +0 -0
  70. preditor/resource/img/debug_disabled.png +0 -0
  71. preditor/resource/img/eye-check.png +0 -0
  72. preditor/resource/img/file-plus.png +0 -0
  73. preditor/resource/img/file-remove.png +0 -0
  74. preditor/resource/img/format-align-left.png +0 -0
  75. preditor/resource/img/format-letter-case-lower.png +0 -0
  76. preditor/resource/img/format-letter-case-upper.png +0 -0
  77. preditor/resource/img/format-letter-case.svg +1 -0
  78. preditor/resource/img/information.png +0 -0
  79. preditor/resource/img/logging_critical.png +0 -0
  80. preditor/resource/img/logging_custom.png +0 -0
  81. preditor/resource/img/logging_debug.png +0 -0
  82. preditor/resource/img/logging_error.png +0 -0
  83. preditor/resource/img/logging_info.png +0 -0
  84. preditor/resource/img/logging_not_set.png +0 -0
  85. preditor/resource/img/logging_warning.png +0 -0
  86. preditor/resource/img/marker.png +0 -0
  87. preditor/resource/img/play.png +0 -0
  88. preditor/resource/img/playlist-play.png +0 -0
  89. preditor/resource/img/plus-minus-variant.png +0 -0
  90. preditor/resource/img/preditor.ico +0 -0
  91. preditor/resource/img/preditor.png +0 -0
  92. preditor/resource/img/preditor.psd +0 -0
  93. preditor/resource/img/preditor.svg +44 -0
  94. preditor/resource/img/regex.svg +1 -0
  95. preditor/resource/img/restart.svg +1 -0
  96. preditor/resource/img/skip-forward-outline.png +0 -0
  97. preditor/resource/img/skip-next-outline.png +0 -0
  98. preditor/resource/img/skip-next.png +0 -0
  99. preditor/resource/img/skip-previous.png +0 -0
  100. preditor/resource/img/subdirectory-arrow-right.png +0 -0
  101. preditor/resource/img/text-search-variant.png +0 -0
  102. preditor/resource/img/warning-big.png +0 -0
  103. preditor/resource/lang/python.json +30 -0
  104. preditor/resource/settings.ini +25 -0
  105. preditor/resource/stylesheet/Bright.css +65 -0
  106. preditor/resource/stylesheet/Dark.css +199 -0
  107. preditor/scintilla/__init__.py +22 -0
  108. preditor/scintilla/delayables/__init__.py +11 -0
  109. preditor/scintilla/delayables/smart_highlight.py +94 -0
  110. preditor/scintilla/delayables/spell_check.py +173 -0
  111. preditor/scintilla/documenteditor.py +2038 -0
  112. preditor/scintilla/finddialog.py +68 -0
  113. preditor/scintilla/lang/__init__.py +80 -0
  114. preditor/scintilla/lang/config/bash.ini +15 -0
  115. preditor/scintilla/lang/config/batch.ini +14 -0
  116. preditor/scintilla/lang/config/cpp.ini +19 -0
  117. preditor/scintilla/lang/config/css.ini +19 -0
  118. preditor/scintilla/lang/config/eyeonscript.ini +17 -0
  119. preditor/scintilla/lang/config/html.ini +21 -0
  120. preditor/scintilla/lang/config/javascript.ini +24 -0
  121. preditor/scintilla/lang/config/lua.ini +16 -0
  122. preditor/scintilla/lang/config/maxscript.ini +20 -0
  123. preditor/scintilla/lang/config/mel.ini +18 -0
  124. preditor/scintilla/lang/config/mu.ini +22 -0
  125. preditor/scintilla/lang/config/nsi.ini +19 -0
  126. preditor/scintilla/lang/config/perl.ini +19 -0
  127. preditor/scintilla/lang/config/puppet.ini +19 -0
  128. preditor/scintilla/lang/config/python.ini +28 -0
  129. preditor/scintilla/lang/config/ruby.ini +19 -0
  130. preditor/scintilla/lang/config/sql.ini +7 -0
  131. preditor/scintilla/lang/config/xml.ini +21 -0
  132. preditor/scintilla/lang/config/yaml.ini +18 -0
  133. preditor/scintilla/lang/language.py +240 -0
  134. preditor/scintilla/lexers/__init__.py +0 -0
  135. preditor/scintilla/lexers/cpplexer.py +21 -0
  136. preditor/scintilla/lexers/javascriptlexer.py +25 -0
  137. preditor/scintilla/lexers/maxscriptlexer.py +234 -0
  138. preditor/scintilla/lexers/mellexer.py +368 -0
  139. preditor/scintilla/lexers/mulexer.py +32 -0
  140. preditor/scintilla/lexers/pythonlexer.py +41 -0
  141. preditor/scintilla/ui/finddialog.ui +160 -0
  142. preditor/settings.py +71 -0
  143. preditor/stream/__init__.py +80 -0
  144. preditor/stream/director.py +73 -0
  145. preditor/stream/manager.py +74 -0
  146. preditor/streamhandler_helper.py +46 -0
  147. preditor/utils/__init__.py +0 -0
  148. preditor/utils/cute.py +30 -0
  149. preditor/utils/stylesheets.py +54 -0
  150. preditor/utils/text_search.py +342 -0
  151. preditor/version.py +21 -0
  152. preditor/weakref.py +363 -0
  153. preditor-1.0.0.dist-info/METADATA +224 -0
  154. preditor-1.0.0.dist-info/RECORD +158 -0
  155. preditor-1.0.0.dist-info/WHEEL +5 -0
  156. preditor-1.0.0.dist-info/entry_points.txt +18 -0
  157. preditor-1.0.0.dist-info/licenses/LICENSE +165 -0
  158. preditor-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,11 @@
1
+ from __future__ import absolute_import, print_function
2
+
3
+ from . import smart_highlight, spell_check
4
+
5
+ # Import the base classes used to make most Delayables
6
+ # TODO: Make these imports a plugin based system of some sort.
7
+
8
+ __all__ = [
9
+ "smart_highlight",
10
+ "spell_check",
11
+ ]
@@ -0,0 +1,94 @@
1
+ from __future__ import absolute_import, print_function
2
+
3
+ from PyQt5.Qsci import QsciScintilla
4
+ from Qt.QtCore import QSignalMapper
5
+ from Qt.QtWidgets import QWidget
6
+
7
+ from ...delayable_engine.delayables import SearchDelayable
8
+ from .. import FindState
9
+
10
+
11
+ class SmartHighlight(SearchDelayable):
12
+ key = 'smart_highlight'
13
+ indicator_number = 30
14
+ indicator_style = QsciScintilla.StraightBoxIndicator
15
+ border_alpha = 255
16
+
17
+ def __init__(self, engine):
18
+ super(SmartHighlight, self).__init__(engine)
19
+ self.signal_mapper = QSignalMapper(self)
20
+ # Respect style sheet changes
21
+ # TODO: Correctly connect this signal
22
+ # LoggerWindow.styleSheetChanged.connect(self.update_indicator_color)
23
+
24
+ def add_document(self, document):
25
+ document.indicatorDefine(self.indicator_style, self.indicator_number)
26
+ document.SendScintilla(
27
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
28
+ )
29
+ document.setIndicatorForegroundColor(
30
+ document.paperSmartHighlight, self.indicator_number
31
+ )
32
+ document.SendScintilla(
33
+ QsciScintilla.SCI_INDICSETOUTLINEALPHA,
34
+ self.indicator_number,
35
+ self.border_alpha,
36
+ )
37
+
38
+ self.signal_mapper.setMapping(document, document)
39
+ self.signal_mapper.mapped[QWidget].connect(self.update_highlighter)
40
+ document.selectionChanged.connect(self.signal_mapper.map)
41
+
42
+ def clear_markings(self, document):
43
+ """Remove markings made by this Delayable for the given document.
44
+
45
+ Args:
46
+ document (blurdev.scintilla.documenteditor.DocumentEditor): The document
47
+ to clear spell check markings from.
48
+ """
49
+ document.SendScintilla(
50
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
51
+ )
52
+ document.SendScintilla(
53
+ QsciScintilla.SCI_INDICATORCLEARRANGE, 0, len(document.text())
54
+ )
55
+
56
+ def loop(self, document, find_state, clear):
57
+ # Clear the document if needed
58
+ if clear:
59
+ self.clear_markings(document)
60
+ ret = super(SmartHighlight, self).loop(document, find_state)
61
+ if ret:
62
+ # clear should always be false when continuing
63
+ return ret + (False,)
64
+
65
+ def remove_document(self, document):
66
+ self.clear_markings(document)
67
+ document.selectionChanged.disconnect(self.signal_mapper.map)
68
+
69
+ def text_found(self, document, start, end, find_state):
70
+ if not document.is_word(start, end):
71
+ # Don't highlight the word if its not a word on its own
72
+ return
73
+ document.SendScintilla(
74
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
75
+ )
76
+ document.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE, start, end - start)
77
+
78
+ def update_highlighter(self, document):
79
+ self.clear_markings(document)
80
+ if document.selection_is_word():
81
+ find_state = FindState()
82
+ find_state.expr = document.selectedText()
83
+ self.search_from_position(document, find_state, None, False)
84
+
85
+ def update_indicator_color(self):
86
+ for document in self.engine.documents:
87
+ document.setIndicatorForegroundColor(
88
+ document.paperSmartHighlight, self.indicator_number
89
+ )
90
+ document.SendScintilla(
91
+ QsciScintilla.SCI_INDICSETOUTLINEALPHA,
92
+ self.indicator_number,
93
+ self.border_alpha,
94
+ )
@@ -0,0 +1,173 @@
1
+ from __future__ import absolute_import, print_function
2
+
3
+ import logging
4
+ import re
5
+ import string
6
+
7
+ from PyQt5.Qsci import QsciScintilla
8
+ from Qt.QtCore import Qt
9
+ from Qt.QtGui import QColor
10
+
11
+ from ...delayable_engine.delayables import RangeDelayable
12
+ from .. import lang
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ try: # noqa: C901
18
+ import aspell
19
+ except ImportError:
20
+ # if we can't import aspell don't define the SpellCheckDelayable class
21
+ logger.debug('Unable to import aspell')
22
+ else:
23
+
24
+ class SpellCheckDelayable(RangeDelayable):
25
+ """Spell check some text in the document.
26
+
27
+ IF the document is not visible, the spell check will be skipped.
28
+
29
+ Loop Args:
30
+ start_pos (int): The document position to start spell checking.
31
+ end_pos (int or None): The document position to stop spell checking.
32
+ If None, then check to the end of the document.
33
+ """
34
+
35
+ indicator_number = 31
36
+ key = 'spell_check'
37
+
38
+ def __init__(self, engine):
39
+ super(SpellCheckDelayable, self).__init__(engine)
40
+ self.chunk_re = re.compile('([^A-Za-z0-9]*)([A-Za-z0-9]*)')
41
+ self.camel_case_re = re.compile(
42
+ '.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)'
43
+ )
44
+
45
+ def add_document(self, document):
46
+ # Create the speller for the document
47
+ document.__speller__ = aspell.Speller()
48
+
49
+ # https://www.scintilla.org/ScintillaDox.html#SCI_INDICSETSTYLE
50
+ # https://qscintilla.com/#clickable_text/indicators
51
+ document.indicatorDefine(
52
+ QsciScintilla.SquiggleLowIndicator, self.indicator_number
53
+ )
54
+ document.SendScintilla(
55
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
56
+ )
57
+ document.setIndicatorForegroundColor(QColor(Qt.red), self.indicator_number)
58
+
59
+ document.SCN_MODIFIED.connect(document.onTextModified)
60
+
61
+ # Update __speller__ dictionary with programming language words
62
+ # and force spellcheck of the document
63
+ self.reset_session(document)
64
+
65
+ def camel_case_split(self, identifier):
66
+ return [m.group(0) for m in self.camel_case_re.finditer(identifier)]
67
+
68
+ def clear_markings(self, document):
69
+ """Remove markings made by this Delayable for the given document.
70
+
71
+ Args:
72
+ document (blurdev.scintilla.documenteditor.DocumentEditor): The document
73
+ to clear spell check markings from.
74
+ """
75
+ document.SendScintilla(
76
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
77
+ )
78
+ document.SendScintilla(
79
+ QsciScintilla.SCI_INDICATORCLEARRANGE, 0, len(document.text())
80
+ )
81
+
82
+ def loop(self, document, start_pos, end_pos):
83
+ # If end_pos is None, use the whole document
84
+ end_pos = len(document.text()) if end_pos is None else end_pos
85
+ match = next(self.chunk_re.finditer(document.text(start_pos, end_pos)))
86
+ if match:
87
+ start = start_pos
88
+ space, result = tuple(match.groups())
89
+ if space:
90
+ # If the user inserted space between two words, that space
91
+ # will still be marked as incorrect. Clear its indicator.
92
+ document.SendScintilla(
93
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
94
+ )
95
+ document.SendScintilla(
96
+ QsciScintilla.SCI_INDICATORCLEARRANGE, start, len(space)
97
+ )
98
+ start += len(space)
99
+ for word in self.camel_case_split(result):
100
+ length_word = len(word)
101
+ if any(
102
+ letter in string.digits for letter in word
103
+ ) or document.__speller__.check(word):
104
+ document.SendScintilla(
105
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
106
+ )
107
+ document.SendScintilla(
108
+ QsciScintilla.SCI_INDICATORCLEARRANGE, start, length_word
109
+ )
110
+ else:
111
+ document.SendScintilla(
112
+ QsciScintilla.SCI_SETINDICATORCURRENT, self.indicator_number
113
+ )
114
+ document.SendScintilla(
115
+ QsciScintilla.SCI_INDICATORFILLRANGE, start, length_word
116
+ )
117
+ start += length_word
118
+
119
+ if start < end_pos:
120
+ # There is more text to process
121
+ return (start, end_pos)
122
+
123
+ return
124
+
125
+ def remove_document(self, document):
126
+ try:
127
+ document.SCN_MODIFIED.disconnect(document.onTextModified)
128
+ except TypeError:
129
+ pass
130
+
131
+ self.clear_markings(document)
132
+
133
+ def reset_session(self, document):
134
+ """Resets the speller dictionary and adds document language
135
+ specific words"""
136
+ if document.__speller__ is None:
137
+ return
138
+ elif not document.lexer() or not document._language:
139
+ # Force spellcheck of the documents
140
+ self.engine.enqueue(document, self.key, 0, None)
141
+ return
142
+
143
+ keywords = ''
144
+ language = lang.byName(document._language)
145
+ max_int = {
146
+ key for _, keys in language.lexerColorTypes().items() for key in keys
147
+ }
148
+ # The SQL lexer returns an empty maxEnumIntList
149
+ max_int = max(max_int) if max_int else 0
150
+ for i in range(max_int):
151
+ lexer_keywords = document.lexer().keywords(i)
152
+ if lexer_keywords:
153
+ keywords += ' ' + lexer_keywords
154
+ document.__speller__.clearSession()
155
+
156
+ if not keywords:
157
+ return
158
+
159
+ for keyword in keywords.split():
160
+ # Split along whitespace
161
+ # Convert '-' to '_' because aspell doesn't process them
162
+ keyword = keyword.replace('-', '_')
163
+ # Strip '_' because aspell doesn't process them
164
+ keyword = keyword.strip('_')
165
+ # Remove non-alpha chars because aspell doesn't process them
166
+ keyword = ''.join(i for i in keyword if i.isalpha())
167
+ for word in keyword.split('_'):
168
+ # Split along '_' because aspell doesn't process them
169
+ if '' != word:
170
+ document.__speller__.addtoSession(word)
171
+
172
+ # Force spellcheck of the documents
173
+ self.engine.enqueue(document, self.key, 0, None)