PrEditor 0.3.0__py2.py3-none-any.whl → 0.5.0__py2.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.

@@ -32,6 +32,12 @@ class WorkboxTextEdit(WorkboxMixin, QTextEdit):
32
32
  highlight.setLanguage('Python')
33
33
  self.uiCodeHighlighter = highlight
34
34
 
35
+ def __auto_complete_enabled__(self):
36
+ pass
37
+
38
+ def __set_auto_complete_enabled__(self, state):
39
+ pass
40
+
35
41
  def __copy_indents_as_spaces__(self):
36
42
  """When copying code, should it convert leading tabs to spaces?"""
37
43
  return False
@@ -93,12 +99,25 @@ class WorkboxTextEdit(WorkboxMixin, QTextEdit):
93
99
  super(WorkboxTextEdit, self).__set_text__(text)
94
100
  self.setPlainText(text)
95
101
 
96
- def __selected_text__(self, start_of_line=False):
102
+ def __selected_text__(self, start_of_line=False, selectText=False):
97
103
  cursor = self.textCursor()
98
104
 
105
+ # Get starting line number. Must set the cursor's position to the start of the
106
+ # selection, otherwise we may instead get the ending line number.
107
+ tempCursor = self.textCursor()
108
+ tempCursor.setPosition(tempCursor.selectionStart())
109
+ line = tempCursor.block().firstLineNumber()
110
+
99
111
  # If no selection, return the current line
100
112
  if cursor.selection().isEmpty():
101
- return cursor.block().text()
113
+ text = cursor.block().text()
114
+
115
+ selectText = self.window().uiSelectTextACT.isChecked() or selectText
116
+ if selectText:
117
+ cursor.select(QTextCursor.LineUnderCursor)
118
+ self.setTextCursor(cursor)
119
+
120
+ return text, line
102
121
 
103
122
  # Otherwise return the selected text
104
123
  if start_of_line:
@@ -106,9 +125,10 @@ class WorkboxTextEdit(WorkboxMixin, QTextEdit):
106
125
  sc.setPosition(cursor.selectionStart())
107
126
  sc.movePosition(cursor.StartOfLine, sc.MoveAnchor)
108
127
  sc.setPosition(cursor.selectionEnd(), sc.KeepAnchor)
109
- return sc.selection().toPlainText()
110
128
 
111
- return self.textCursor().selection().toPlainText()
129
+ return sc.selection().toPlainText(), line
130
+
131
+ return self.textCursor().selection().toPlainText(), line
112
132
 
113
133
  def keyPressEvent(self, event):
114
134
  if self.process_shortcut(event):
@@ -37,6 +37,8 @@ class WorkboxWidget(WorkboxMixin, DocumentEditor):
37
37
  self.setLanguage('Python')
38
38
  # Default to unix newlines
39
39
  self.setEolMode(self.EolUnix)
40
+ if hasattr(self.window(), "setWorkboxFontBasedOnConsole"):
41
+ self.window().setWorkboxFontBasedOnConsole()
40
42
 
41
43
  def __auto_complete_enabled__(self):
42
44
  return self.autoCompletionSource() == self.AcsAll
@@ -142,19 +144,26 @@ class WorkboxWidget(WorkboxMixin, DocumentEditor):
142
144
  def __save__(self):
143
145
  self.save()
144
146
 
145
- def __selected_text__(self, start_of_line=False):
147
+ def __selected_text__(self, start_of_line=False, selectText=False):
146
148
  line, s, end, e = self.getSelection()
147
149
  if line == -1:
148
150
  # Nothing is selected, return the current line of text
149
151
  line, index = self.getCursorPosition()
150
152
  txt = self.text(line)
153
+
154
+ lineLength = len(self.text(line).rstrip())
155
+ selectText = self.window().uiSelectTextACT.isChecked() or selectText
156
+
157
+ if selectText:
158
+ self.setSelection(line, 0, line, lineLength)
159
+
151
160
  elif start_of_line:
152
161
  ss = self.positionFromLineIndex(line, 0)
153
162
  ee = self.positionFromLineIndex(end, e)
154
163
  txt = self.text(ss, ee)
155
164
  else:
156
165
  txt = self.selectedText()
157
- return self.regex.split(txt)[0]
166
+ return self.regex.split(txt)[0], line
158
167
 
159
168
  def __tab_width__(self):
160
169
  return self.tabWidth()
@@ -194,12 +203,25 @@ class WorkboxWidget(WorkboxMixin, DocumentEditor):
194
203
  fle.write(cls.__unix_end_lines__(txt))
195
204
 
196
205
  def keyPressEvent(self, event):
206
+ """Check for certain keyboard shortcuts, and handle them as needed,
207
+ otherwise pass the keyPress to the superclass.
208
+
209
+ NOTE! We handle the "shift+return" shortcut here, rather than the
210
+ QAction's shortcut, because the workbox will always intercept that
211
+ shortcut. So, we handle it here, and call the main window's
212
+ execSelected, which ultimately calls this workbox's __exec_selected__.
213
+
214
+ Also note, it would make sense to have ctrl+Enter also execute without
215
+ truncation, but no modifiers are registered when Enter is pressed (unlike
216
+ when Return is pressed), so this combination is not detectable.
217
+ """
197
218
  if self._software == 'softimage':
198
219
  DocumentEditor.keyPressEvent(self, event)
199
220
  else:
200
221
  if self.process_shortcut(event):
201
222
  return
202
223
  else:
224
+ # Send regular keystroke
203
225
  DocumentEditor.keyPressEvent(self, event)
204
226
 
205
227
  def initShortcuts(self):
@@ -21,8 +21,9 @@ from functools import partial
21
21
 
22
22
  import six
23
23
  from PyQt5.Qsci import QsciScintilla
24
+ from PyQt5.QtCore import QTextCodec
24
25
  from Qt import QtCompat
25
- from Qt.QtCore import Property, QFile, QPoint, Qt, QTextCodec, Signal
26
+ from Qt.QtCore import Property, QFile, QPoint, Qt, Signal
26
27
  from Qt.QtGui import QColor, QFont, QFontMetrics, QIcon
27
28
  from Qt.QtWidgets import (
28
29
  QAction,
@@ -331,7 +332,6 @@ class DocumentEditor(QsciScintilla):
331
332
 
332
333
  # Do not toggle comments on the last line if it contains no selection
333
334
  if line != endLine or endCol:
334
-
335
335
  if doWhich == "Comment":
336
336
  self.setCursorPosition(line, indent)
337
337
  self.insert(commentSpace)
@@ -431,7 +431,7 @@ class DocumentEditor(QsciScintilla):
431
431
  line, index = None, None
432
432
  if not self.hasSelectedText():
433
433
  line, index = self.getCursorPosition()
434
- self.setSelection(line, 0, line, self.lineLength(line) - 2)
434
+ self.setSelection(line, 0, line, self.lineLength(line))
435
435
  return line, index
436
436
 
437
437
  def copy(self):
preditor/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
  # file generated by setuptools_scm
3
3
  # don't change, don't track in version control
4
- version = '0.3.0'
5
- version_tuple = (0, 3, 0)
4
+ version = '0.5.0'
5
+ version_tuple = (0, 5, 0)