PrEditor 0.4.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.

@@ -6,21 +6,33 @@
6
6
  <rect>
7
7
  <x>0</x>
8
8
  <y>0</y>
9
- <width>682</width>
10
- <height>151</height>
9
+ <width>1064</width>
10
+ <height>325</height>
11
11
  </rect>
12
12
  </property>
13
13
  <property name="windowTitle">
14
14
  <string>Set Text Editor Executable Path</string>
15
15
  </property>
16
16
  <layout class="QVBoxLayout" name="verticalLayout">
17
+ <property name="spacing">
18
+ <number>15</number>
19
+ </property>
17
20
  <item>
18
21
  <widget class="QWidget" name="widget" native="true">
19
22
  <layout class="QVBoxLayout" name="verticalLayout_2">
20
23
  <property name="spacing">
24
+ <number>3</number>
25
+ </property>
26
+ <property name="leftMargin">
27
+ <number>0</number>
28
+ </property>
29
+ <property name="topMargin">
21
30
  <number>0</number>
22
31
  </property>
23
- <property name="margin">
32
+ <property name="rightMargin">
33
+ <number>0</number>
34
+ </property>
35
+ <property name="bottomMargin">
24
36
  <number>0</number>
25
37
  </property>
26
38
  <item>
@@ -31,6 +43,11 @@
31
43
  <verstretch>0</verstretch>
32
44
  </sizepolicy>
33
45
  </property>
46
+ <property name="font">
47
+ <font>
48
+ <pointsize>10</pointsize>
49
+ </font>
50
+ </property>
34
51
  <property name="text">
35
52
  <string>Path to the executable of your preferred text editor</string>
36
53
  </property>
@@ -38,6 +55,11 @@
38
55
  </item>
39
56
  <item>
40
57
  <widget class="QLineEdit" name="uiTextEditorExecutablePathLE">
58
+ <property name="font">
59
+ <font>
60
+ <pointsize>10</pointsize>
61
+ </font>
62
+ </property>
41
63
  <property name="text">
42
64
  <string>C:\Program Files\Sublime Text 3\sublime_text.exe</string>
43
65
  </property>
@@ -50,9 +72,18 @@
50
72
  <widget class="QWidget" name="widget_2" native="true">
51
73
  <layout class="QVBoxLayout" name="verticalLayout_3">
52
74
  <property name="spacing">
75
+ <number>3</number>
76
+ </property>
77
+ <property name="leftMargin">
78
+ <number>0</number>
79
+ </property>
80
+ <property name="topMargin">
53
81
  <number>0</number>
54
82
  </property>
55
- <property name="margin">
83
+ <property name="rightMargin">
84
+ <number>0</number>
85
+ </property>
86
+ <property name="bottomMargin">
56
87
  <number>0</number>
57
88
  </property>
58
89
  <item>
@@ -63,10 +94,14 @@
63
94
  <verstretch>0</verstretch>
64
95
  </sizepolicy>
65
96
  </property>
97
+ <property name="font">
98
+ <font>
99
+ <pointsize>10</pointsize>
100
+ </font>
101
+ </property>
66
102
  <property name="text">
67
- <string>Command Prompt template (template of how your chosen text editor may implement line numbers in a Command Prompt command).
68
- Use these template strings: {exePath}, {modulePath}, {lineNum}
69
- </string>
103
+ <string>Command Prompt template (template of the Command Prompt command to launch your text editor, including how it may implement specifying line numbers).
104
+ Use these template strings: &quot;{exePath}&quot;, &quot;{modulePath}&quot;, {lineNum}. Include quotes around exePath and modulePath to handle filepaths which contain spaces.</string>
70
105
  </property>
71
106
  <property name="wordWrap">
72
107
  <bool>true</bool>
@@ -75,11 +110,16 @@ Use these template strings: {exePath}, {modulePath}, {lineNum}
75
110
  </item>
76
111
  <item>
77
112
  <widget class="QLineEdit" name="uiTextEditorCommandPatternLE">
113
+ <property name="font">
114
+ <font>
115
+ <pointsize>10</pointsize>
116
+ </font>
117
+ </property>
78
118
  <property name="toolTip">
79
119
  <string/>
80
120
  </property>
81
121
  <property name="text">
82
- <string>{exePath} {modulePath}:{lineNum}</string>
122
+ <string>&quot;{exePath}&quot; &quot;{modulePath}&quot;:{lineNum}</string>
83
123
  </property>
84
124
  </widget>
85
125
  </item>
@@ -0,0 +1,225 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ui version="4.0">
3
+ <class>uiSuggestPathQuotesDLG</class>
4
+ <widget class="QDialog" name="uiSuggestPathQuotesDLG">
5
+ <property name="geometry">
6
+ <rect>
7
+ <x>0</x>
8
+ <y>0</y>
9
+ <width>716</width>
10
+ <height>342</height>
11
+ </rect>
12
+ </property>
13
+ <property name="windowTitle">
14
+ <string>Set Text Editor Executable Path</string>
15
+ </property>
16
+ <layout class="QVBoxLayout" name="verticalLayout">
17
+ <property name="spacing">
18
+ <number>15</number>
19
+ </property>
20
+ <item>
21
+ <widget class="QWidget" name="widget" native="true">
22
+ <layout class="QVBoxLayout" name="verticalLayout_2">
23
+ <property name="spacing">
24
+ <number>3</number>
25
+ </property>
26
+ <property name="leftMargin">
27
+ <number>0</number>
28
+ </property>
29
+ <property name="topMargin">
30
+ <number>0</number>
31
+ </property>
32
+ <property name="rightMargin">
33
+ <number>0</number>
34
+ </property>
35
+ <property name="bottomMargin">
36
+ <number>0</number>
37
+ </property>
38
+ <item>
39
+ <widget class="QLabel" name="label">
40
+ <property name="sizePolicy">
41
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
42
+ <horstretch>0</horstretch>
43
+ <verstretch>0</verstretch>
44
+ </sizepolicy>
45
+ </property>
46
+ <property name="font">
47
+ <font>
48
+ <pointsize>10</pointsize>
49
+ </font>
50
+ </property>
51
+ <property name="text">
52
+ <string>It is recommended to wrap filepaths in double-quotes in case of spaces in the paths. Would you like to update the command template from:</string>
53
+ </property>
54
+ <property name="wordWrap">
55
+ <bool>true</bool>
56
+ </property>
57
+ </widget>
58
+ </item>
59
+ <item>
60
+ <widget class="QLineEdit" name="uiTextEditorOldCommandPatternLE">
61
+ <property name="enabled">
62
+ <bool>false</bool>
63
+ </property>
64
+ <property name="font">
65
+ <font>
66
+ <pointsize>10</pointsize>
67
+ </font>
68
+ </property>
69
+ <property name="toolTip">
70
+ <string/>
71
+ </property>
72
+ <property name="text">
73
+ <string>uiTextEditorOldCommandPatternLE</string>
74
+ </property>
75
+ </widget>
76
+ </item>
77
+ </layout>
78
+ </widget>
79
+ </item>
80
+ <item>
81
+ <widget class="QWidget" name="widget_3" native="true">
82
+ <layout class="QVBoxLayout" name="verticalLayout_4">
83
+ <property name="spacing">
84
+ <number>3</number>
85
+ </property>
86
+ <property name="leftMargin">
87
+ <number>0</number>
88
+ </property>
89
+ <property name="topMargin">
90
+ <number>0</number>
91
+ </property>
92
+ <property name="rightMargin">
93
+ <number>0</number>
94
+ </property>
95
+ <property name="bottomMargin">
96
+ <number>0</number>
97
+ </property>
98
+ <item>
99
+ <widget class="QLabel" name="label_2">
100
+ <property name="sizePolicy">
101
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
102
+ <horstretch>0</horstretch>
103
+ <verstretch>0</verstretch>
104
+ </sizepolicy>
105
+ </property>
106
+ <property name="font">
107
+ <font>
108
+ <pointsize>10</pointsize>
109
+ </font>
110
+ </property>
111
+ <property name="text">
112
+ <string>to:</string>
113
+ </property>
114
+ <property name="wordWrap">
115
+ <bool>true</bool>
116
+ </property>
117
+ </widget>
118
+ </item>
119
+ <item>
120
+ <widget class="QLineEdit" name="uiTextEditorNewCommandPatternLE">
121
+ <property name="font">
122
+ <font>
123
+ <pointsize>10</pointsize>
124
+ </font>
125
+ </property>
126
+ <property name="toolTip">
127
+ <string/>
128
+ </property>
129
+ <property name="text">
130
+ <string/>
131
+ </property>
132
+ </widget>
133
+ </item>
134
+ </layout>
135
+ </widget>
136
+ </item>
137
+ <item>
138
+ <widget class="QWidget" name="widget_4" native="true">
139
+ <layout class="QVBoxLayout" name="verticalLayout_5">
140
+ <property name="spacing">
141
+ <number>3</number>
142
+ </property>
143
+ <property name="leftMargin">
144
+ <number>0</number>
145
+ </property>
146
+ <property name="topMargin">
147
+ <number>0</number>
148
+ </property>
149
+ <property name="rightMargin">
150
+ <number>0</number>
151
+ </property>
152
+ <property name="bottomMargin">
153
+ <number>0</number>
154
+ </property>
155
+ </layout>
156
+ </widget>
157
+ </item>
158
+ <item>
159
+ <spacer name="verticalSpacer">
160
+ <property name="orientation">
161
+ <enum>Qt::Vertical</enum>
162
+ </property>
163
+ <property name="sizeHint" stdset="0">
164
+ <size>
165
+ <width>20</width>
166
+ <height>40</height>
167
+ </size>
168
+ </property>
169
+ </spacer>
170
+ </item>
171
+ <item>
172
+ <widget class="QCheckBox" name="uiDontAskAgainCHK">
173
+ <property name="text">
174
+ <string>Don't Ask Again</string>
175
+ </property>
176
+ </widget>
177
+ </item>
178
+ <item>
179
+ <widget class="QDialogButtonBox" name="uiDialogButtonBox">
180
+ <property name="orientation">
181
+ <enum>Qt::Horizontal</enum>
182
+ </property>
183
+ <property name="standardButtons">
184
+ <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
185
+ </property>
186
+ </widget>
187
+ </item>
188
+ </layout>
189
+ </widget>
190
+ <resources/>
191
+ <connections>
192
+ <connection>
193
+ <sender>uiDialogButtonBox</sender>
194
+ <signal>accepted()</signal>
195
+ <receiver>uiSuggestPathQuotesDLG</receiver>
196
+ <slot>accept()</slot>
197
+ <hints>
198
+ <hint type="sourcelabel">
199
+ <x>248</x>
200
+ <y>254</y>
201
+ </hint>
202
+ <hint type="destinationlabel">
203
+ <x>157</x>
204
+ <y>274</y>
205
+ </hint>
206
+ </hints>
207
+ </connection>
208
+ <connection>
209
+ <sender>uiDialogButtonBox</sender>
210
+ <signal>rejected()</signal>
211
+ <receiver>uiSuggestPathQuotesDLG</receiver>
212
+ <slot>reject()</slot>
213
+ <hints>
214
+ <hint type="sourcelabel">
215
+ <x>316</x>
216
+ <y>260</y>
217
+ </hint>
218
+ <hint type="destinationlabel">
219
+ <x>286</x>
220
+ <y>274</y>
221
+ </hint>
222
+ </hints>
223
+ </connection>
224
+ </connections>
225
+ </ui>
@@ -67,8 +67,8 @@ class WorkboxMixin(object):
67
67
  def __exec_all__(self):
68
68
  raise NotImplementedError("Mixin method not overridden.")
69
69
 
70
- def __exec_selected__(self):
71
- txt = self.__selected_text__()
70
+ def __exec_selected__(self, truncate=True):
71
+ txt, line = self.__selected_text__()
72
72
 
73
73
  # Remove any leading white space shared across all lines
74
74
  txt = textwrap.dedent(txt)
@@ -76,8 +76,9 @@ class WorkboxMixin(object):
76
76
  # Get rid of pesky \r's
77
77
  txt = self.__unix_end_lines__(txt)
78
78
 
79
- # Make workbox line numbers match the workbox line numbers.
80
- line, _ = self.__cursor_position__()
79
+ # Make workbox line numbers match the workbox line numbers, by adding
80
+ # the appropriate number of newlines to mimic it's original position in
81
+ # the workbox.
81
82
  txt = '\n' * line + txt
82
83
 
83
84
  # execute the code
@@ -87,7 +88,10 @@ class WorkboxMixin(object):
87
88
  # If the selected code was a statement print the result of the statement.
88
89
  ret = repr(ret)
89
90
  self.__console__().startOutputLine()
90
- print(self.truncate_middle(ret, 100))
91
+ if truncate:
92
+ print(self.truncate_middle(ret, 100))
93
+ else:
94
+ print(ret)
91
95
 
92
96
  def __file_monitoring_enabled__(self):
93
97
  """Returns True if this workbox supports file monitoring.
@@ -183,8 +187,9 @@ class WorkboxMixin(object):
183
187
  def __save__(self):
184
188
  raise NotImplementedError("Mixin method not overridden.")
185
189
 
186
- def __selected_text__(self, start_of_line=False):
187
- """Returns selected text or the current line of text.
190
+ def __selected_text__(self, start_of_line=False, selectText=False):
191
+ """Returns selected text or the current line of text, plus the line
192
+ number of the begining of selection / cursor position.
188
193
 
189
194
  If text is selected, it is returned. If nothing is selected, returns the
190
195
  entire line of text the cursor is currently on.
@@ -192,6 +197,13 @@ class WorkboxMixin(object):
192
197
  Args:
193
198
  start_of_line (bool, optional): If text is selected, include any
194
199
  leading text from the first line of the selection.
200
+ selectText (bool): If expanding to the entire line from the cursor,
201
+ indicates whether to select that line of text
202
+
203
+ Returns:
204
+ str: The requested text
205
+ line (int): plus the line number of the beginning of selection / cursor
206
+ position.
195
207
  """
196
208
  raise NotImplementedError("Mixin method not overridden.")
197
209
 
@@ -343,15 +355,35 @@ class WorkboxMixin(object):
343
355
  __exec_selected__: If the user pressed Shift + Return or pressed the
344
356
  number pad enter key calling `__exec_selected__`.
345
357
  """
346
- if event.key() == Qt.Key_Enter or (
347
- event.key() == Qt.Key_Return and event.modifiers() == Qt.ShiftModifier
348
- ):
349
- # Number pad enter, or Shift + Return pressed, execute selected
350
- if run:
351
- self.__exec_selected__()
352
-
353
- if self.window().uiAutoPromptACT.isChecked():
354
- self.__console__().startInputLine()
355
- return '__exec_selected__'
356
358
 
357
- return False
359
+ # Number pad enter, or Shift + Return pressed, execute selected
360
+ # Ctrl+ Shift+Return pressed, execute selected without truncating output
361
+ if run:
362
+ # self.__exec_selected__()
363
+ # Collect what was pressed
364
+ key = event.key()
365
+ modifiers = event.modifiers()
366
+
367
+ # Determine which relevant combos are pressed
368
+ ret = key == Qt.Key_Return
369
+ enter = key == Qt.Key_Enter
370
+ shift = modifiers == Qt.ShiftModifier
371
+ ctrlShift = modifiers == Qt.ControlModifier | Qt.ShiftModifier
372
+
373
+ # Determine which actions to take
374
+ evalTrunc = enter or (ret and shift)
375
+ evalNoTrunc = ret and ctrlShift
376
+
377
+ if evalTrunc:
378
+ # Execute with truncation
379
+ self.window().execSelected()
380
+ elif evalNoTrunc:
381
+ # Execute without truncation
382
+ self.window().execSelected(truncate=False)
383
+
384
+ if evalTrunc or evalNoTrunc:
385
+ if self.window().uiAutoPromptACT.isChecked():
386
+ self.__console__().startInputLine()
387
+ return '__exec_selected__'
388
+ else:
389
+ return False
@@ -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.4.0'
5
- version_tuple = (0, 4, 0)
4
+ version = '0.5.0'
5
+ version_tuple = (0, 5, 0)