eric6/QScintilla/Shell.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7759
51aa6c6b66f7
child 7802
eefe954f01e8
child 7824
096b3ebc1409
permissions
-rw-r--r--

Performed some more code cleanup.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7267
diff changeset
3 # Copyright (c) 2002 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a graphical Python shell.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7703
1f800f8295ea Third Party packages: removed th no longer needed 'enum' package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7536
diff changeset
13 from enum import Enum
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
14
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5712
diff changeset
15 from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
16 from PyQt5.QtGui import QClipboard, QPalette, QFont
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
17 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
18 QDialog, QInputDialog, QApplication, QMenu, QWidget, QHBoxLayout,
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 QVBoxLayout, QShortcut, QSizePolicy
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
20 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
21 from PyQt5.Qsci import QsciScintilla
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
23 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
24 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
26 from .QsciScintillaCompat import QsciScintillaCompat
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Preferences
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 import Utilities
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
30
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
33 from Debugger.DebugClientCapabilities import HasCompleter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
35
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
36 class ShellAssembly(QWidget):
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
37 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
38 Class implementing the containing widget for the shell.
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
39 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
40 def __init__(self, dbs, vm, project, horizontal=True, parent=None):
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
41 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
42 Constructor
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
43
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
44 @param dbs reference to the debug server object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
45 @type DebugServer
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
46 @param vm reference to the viewmanager object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
47 @type ViewManager
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
48 @param project reference to the project object
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
49 @type Project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
50 @param horizontal flag indicating a horizontal layout
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
51 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
52 @param parent parent widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
53 @type QWidget
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
54 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
55 super(ShellAssembly, self).__init__(parent)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
56
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
57 self.__shell = Shell(dbs, vm, project, False, self)
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
58
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
59 from UI.SearchWidget import SearchWidget
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
60 self.__searchWidget = SearchWidget(self.__shell, self, horizontal)
6387
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6377
diff changeset
61 self.__searchWidget.setSizePolicy(QSizePolicy.Fixed,
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6377
diff changeset
62 QSizePolicy.Preferred)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
63 self.__searchWidget.hide()
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
64
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
65 if horizontal:
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
66 self.__layout = QHBoxLayout(self)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
67 else:
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
68 self.__layout = QVBoxLayout(self)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
69 self.__layout.setContentsMargins(1, 1, 1, 1)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
70 self.__layout.addWidget(self.__shell)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
71 self.__layout.addWidget(self.__searchWidget)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
72
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
73 self.__searchWidget.searchNext.connect(self.__shell.searchNext)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
74 self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev)
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
75 self.__shell.searchStringFound.connect(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
76 self.__searchWidget.searchStringFound)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
77
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
78 def showFind(self, txt=""):
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
79 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
80 Public method to display the search widget.
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
81
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
82 @param txt text to be shown in the combo (string)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
83 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
84 self.__searchWidget.showFind(txt)
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
85
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
86 def shell(self):
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
87 """
6987
3371a03ed0a7 Performed some interface cleanups.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
88 Public method to get a reference to the shell widget.
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
89
2474
8727522a69d5 Removed the Terminal widget because there are severe issues with certain shells that cannot be fixed and it is a rarely used feature.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
90 @return reference to the shell widget (Shell)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
91 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
92 return self.__shell
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
93
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
94
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
95 class ShellHistoryStyle(Enum):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
96 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
97 Class defining the shell history styles.
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
98 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
99 Disabled = 0
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
100 LinuxStyle = 1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
101 WindowsStyle = 2
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
102
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
103
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 class Shell(QsciScintillaCompat):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Class implementing a graphical Python shell.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
108 A user can enter commands that are executed in the remote
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
109 Python interpreter.
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
110
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
111 @signal searchStringFound(bool) emitted to indicate the search
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
112 result
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
113 @signal historyStyleChanged(ShellHistoryStyle) emitted to indicate a
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
114 change of the history style
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
115 @signal queueText(str) emitted to queue some text for processing
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
116 @signal virtualEnvironmentChanged(str) emitted to signal the new virtual
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
117 environment of the shell
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
119 searchStringFound = pyqtSignal(bool)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
120 historyStyleChanged = pyqtSignal(ShellHistoryStyle)
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
121 queueText = pyqtSignal(str)
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
122 virtualEnvironmentChanged = pyqtSignal(str)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
123
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
124 def __init__(self, dbs, vm, project, windowedVariant, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @param dbs reference to the debug server object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
129 @type DebugServer
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 @param vm reference to the viewmanager object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
131 @type ViewManager
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
132 @param project reference to the project object
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
133 @type Project
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
134 @param windowedVariant flag indicating the shell window variant
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
135 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
136 @param parent parent widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
137 @type QWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
139 super(Shell, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.setUtf8(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.vm = vm
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
143 self.__mainWindow = parent
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
144 self.__lastSearch = ()
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
145 self.__windowed = windowedVariant
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
146 self.__currentVenv = ""
6633
c5aab2ede19a Debugger, Shell: start the shell in the project directory if one is open ([issue290]).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6581
diff changeset
147 self.__currentWorkingDirectory = ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.linesepRegExp = r"\r\n|\n|\r"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
151 self.passive = ((not self.__windowed) and
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
152 Preferences.getDebugger("PassiveDbgEnabled"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if self.passive:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
154 self.setWindowTitle(self.tr('Shell - Passive'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
156 self.setWindowTitle(self.tr('Shell'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
158 if self.__windowed:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
159 self.setWhatsThis(self.tr(
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
160 """<b>The Shell Window</b>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
161 """<p>You can use the cursor keys while entering commands."""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
162 """ There is also a history of commands that can be recalled"""
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
163 """ using the up and down cursor keys while holding down the"""
5800
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
164 """ Ctrl-key. This can be switched to just the up and down"""
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
165 """ cursor keys on the Shell page of the configuration"""
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
166 """ dialog. Pressing these keys after some text has been"""
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
167 """ entered will start an incremental search.</p>"""
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
168 """<p>The shell has some special commands. 'restart' kills"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
169 """ the shell and starts a new one. 'clear' clears the"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
170 """ display of the shell window. 'start' is used to start a"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
171 """ shell for a virtual environment and should be followed"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
172 """ by a virtual environment name. start' without a virtual"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
173 """ environment name starts the default shell. Available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
174 """ virtual environments may be listed with the 'envs' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
175 """ 'environments' commands. The active virtual environment"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
176 """ can be questioned by the 'which' command. 'quit' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
177 """ 'exit' is used to exit the application. These commands"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
178 """ (except environments', 'envs' and 'which') are available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
179 """ through the window menus as well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
180 """<p>Pressing the Tab key after some text has been entered"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
181 """ will show a list of possible completions. The relevant"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
182 """ entry may be selected from this list. If only one entry"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
183 """ is available, this will be inserted automatically.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
184 ))
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
185 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
186 self.setWhatsThis(self.tr(
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
187 """<b>The Shell Window</b>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
188 """<p>This is simply an interpreter running in a window. The"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
189 """ interpreter is the one that is used to run the program"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
190 """ being debugged. This means that you can execute any"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
191 """ command while the program being debugged is running.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
192 """<p>You can use the cursor keys while entering commands."""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
193 """ There is also a history of commands that can be recalled"""
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
194 """ using the up and down cursor keys while holding down the"""
5800
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
195 """ Ctrl-key. This can be switched to just the up and down"""
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
196 """ cursor keys on the Shell page of the configuration"""
c3379bf35654 Updated translations and source docu for the shell changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5799
diff changeset
197 """ dialog. Pressing these keys after some text has been"""
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
198 """ entered will start an incremental search.</p>"""
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
199 """<p>The shell has some special commands. 'restart' kills"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
200 """ the shell and starts a new one. 'clear' clears the"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
201 """ display of the shell window. 'start' is used to start a"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
202 """ shell for a virtual environment and should be followed"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
203 """ by a virtual environment name. start' without a virtual"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
204 """ environment name starts the default shell. Available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
205 """ virtual environments may be listed with the 'envs' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
206 """ 'environments' commands. The active virtual environment"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
207 """ can be questioned by the 'which' command. These commands"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
208 """ (except environments' and 'envs') are available through"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
209 """ the context menu as well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
210 """<p>Pressing the Tab key after some text has been entered"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
211 """ will show a list of possible completions. The relevant"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
212 """ entry may be selected from this list. If only one entry"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
213 """ is available, this will be inserted automatically.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
214 """<p>In passive debugging mode the shell is only available"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
215 """ after the program to be debugged has connected to the"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
216 """ IDE until it has finished. This is indicated by a"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
217 """ different prompt and by an indication in the window"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
218 """ caption.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
219 ))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
221 self.userListActivated.connect(self.__completionListSelected)
2640
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
222 self.linesChanged.connect(self.__resizeLinenoMargin)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
224 if self.__windowed:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
225 self.__showStdOutErr = True
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
226 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
227 self.__showStdOutErr = Preferences.getShell("ShowStdOutErr")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if self.__showStdOutErr:
481
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
229 dbs.clientProcessStdout.connect(self.__writeStdOut)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
230 dbs.clientProcessStderr.connect(self.__writeStdErr)
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
231 dbs.clientOutput.connect(self.__writeQueued)
481
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
232 dbs.clientStatement.connect(self.__clientStatement)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
233 dbs.clientGone.connect(self.__initialise)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
234 dbs.clientRawInput.connect(self.__raw_input)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
235 dbs.clientBanner.connect(self.__writeBanner)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
236 dbs.clientCompletionList.connect(self.__showCompletions)
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
237 dbs.clientCapabilities.connect(self.__clientCapabilities)
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
238 dbs.clientException.connect(self.__clientException)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
239 dbs.clientSyntaxError.connect(self.__clientSyntaxError)
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
240 dbs.clientSignal.connect(self.__clientSignal)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 self.dbs = dbs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
2640
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
243 # Initialize instance variables.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 self.__initialise()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.prline = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 self.prcol = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.inDragDrop = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 self.completionText = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
251 self.clientType = ''
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
252
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 # Initialize history
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
254 self.__historyLists = {}
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
255 self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
256 self.__historyStyle = Preferences.getShell("HistoryStyle")
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
257 self.__historyWrap = Preferences.getShell("HistoryWrap")
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
258 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
259 self.__setHistoryIndex()
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
260 # remove obsolete shell histories (Python and Ruby)
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
261 for clientType in ["Python", "Ruby"]:
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
262 Preferences.Prefs.settings.remove("Shell/Histories/" + clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 # clear QScintilla defined keyboard commands
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 # we do our own handling through the view manager
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.clearAlternateKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.clearKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 self.__actionsAdded = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 # Make sure we have prompts.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 if self.passive:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
272 sys.ps1 = self.tr("Passive >>> ")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 sys.ps1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 sys.ps1 = ">>> "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 sys.ps2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 sys.ps2 = "... "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 if self.passive:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 self.__getBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
286 if not self.__windowed:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
287 # Create a little language context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
288 self.lmenu = QMenu(self.tr('Start'))
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
289 self.lmenu.aboutToShow.connect(self.__showStartMenu)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
290 self.lmenu.triggered.connect(self.__startDebugClient)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
291
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
292 # Create the history context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
293 self.hmenu = QMenu(self.tr('History'))
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
294 self.hmenu.addAction(self.tr('Select entry'), self.selectHistory)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
295 self.hmenu.addAction(self.tr('Show'), self.showHistory)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
296 self.hmenu.addAction(self.tr('Clear'), self.clearHistory)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
297
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
298 # Create a little context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
299 self.menu = QMenu(self)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
300 self.menu.addAction(self.tr('Cut'), self.cut)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
301 self.menu.addAction(self.tr('Copy'), self.copy)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
302 self.menu.addAction(self.tr('Paste'), self.paste)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
303 self.menu.addMenu(self.hmenu).setEnabled(self.isHistoryEnabled())
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
304
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
305 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
306 self.menu.addAction(self.tr('Find'), self.__find)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
307 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
308 self.menu.addAction(self.tr('Clear'), self.clear)
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
309 self.menu.addAction(self.tr('Restart'), self.doRestart)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
310 self.menu.addAction(
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
311 self.tr('Restart and Clear'), self.doClearRestart)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
312 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
313 self.menu.addMenu(self.lmenu)
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
314 self.menu.addAction(self.tr('Active Name'), self.__showVenvName)
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
315 self.menu.addSeparator()
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
316 self.menu.addAction(self.tr("Configure..."), self.__configure)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 self.__bindLexer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.__setTextDisplay()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 # set the autocompletion and calltips function
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 self.__setAutoCompletion()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__setCallTips()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7387
diff changeset
326 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.incrementalSearchString = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 self.incrementalSearchActive = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 self.supportedEditorCommands = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
332 QsciScintilla.SCI_LINEDELETE: self.__clearCurrentLine,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
333 QsciScintilla.SCI_TAB: self.__QScintillaTab,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
334 QsciScintilla.SCI_NEWLINE: self.__QScintillaNewline,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
336 QsciScintilla.SCI_DELETEBACK: self.__QScintillaDeleteBack,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
337 QsciScintilla.SCI_CLEAR: self.__QScintillaDelete,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
338 QsciScintilla.SCI_DELWORDLEFT: self.__QScintillaDeleteWordLeft,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
339 QsciScintilla.SCI_DELWORDRIGHT: self.__QScintillaDeleteWordRight,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
340 QsciScintilla.SCI_DELLINELEFT: self.__QScintillaDeleteLineLeft,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
341 QsciScintilla.SCI_DELLINERIGHT: self.__QScintillaDeleteLineRight,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
343 QsciScintilla.SCI_CHARLEFT: self.__QScintillaCharLeft,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
344 QsciScintilla.SCI_CHARRIGHT: self.__QScintillaCharRight,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
345 QsciScintilla.SCI_WORDLEFT: self.__QScintillaWordLeft,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
346 QsciScintilla.SCI_WORDRIGHT: self.__QScintillaWordRight,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
347 QsciScintilla.SCI_VCHOME: self.__QScintillaVCHome,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
348 QsciScintilla.SCI_LINEEND: self.__QScintillaLineEnd,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349
6037
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
350 QsciScintilla.SCI_LINEUP: self.__QScintillaCursorCommand,
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
351 QsciScintilla.SCI_LINEDOWN: self.__QScintillaCursorCommand,
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
352 QsciScintilla.SCI_LINESCROLLUP: self.__QScintillaCursorCommand,
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
353 QsciScintilla.SCI_LINESCROLLDOWN: self.__QScintillaCursorCommand,
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
354
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
355 QsciScintilla.SCI_PAGEUP: self.__QScintillaAutoCompletionCommand,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
356 QsciScintilla.SCI_PAGEDOWN: self.__QScintillaAutoCompletionCommand,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
358 QsciScintilla.SCI_CHARLEFTEXTEND: self.__QScintillaCharLeftExtend,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
359 QsciScintilla.SCI_CHARRIGHTEXTEND: self.extendSelectionRight,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
360 QsciScintilla.SCI_WORDLEFTEXTEND: self.__QScintillaWordLeftExtend,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
361 QsciScintilla.SCI_WORDRIGHTEXTEND: self.extendSelectionWordRight,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
362 QsciScintilla.SCI_VCHOMEEXTEND: self.__QScintillaVCHomeExtend,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
363 QsciScintilla.SCI_LINEENDEXTEND: self.extendSelectionToEOL,
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
364
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
365 QsciScintilla.SCI_CANCEL: self.__QScintillaCancel,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 }
6037
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
367
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368 self.__historyNavigateByCursor = (
6037
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
369 Preferences.getShell("HistoryNavigateByCursor")
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
370 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
372 self.__queuedText = ''
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
373 self.__blockTextProcessing = False
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
374 self.queueText.connect(self.__concatenateText, Qt.QueuedConnection)
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
375
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
376 self.__project = project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
377 if self.__project:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
378 self.__project.projectOpened.connect(self.__projectOpened)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
379 self.__project.projectClosed.connect(self.__projectClosed)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
380
1518
e6e21910210d Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
381 self.grabGesture(Qt.PinchGesture)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
382
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
383 def __showStartMenu(self):
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
384 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
385 Private slot to prepare the start submenu.
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
386 """
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
387 self.lmenu.clear()
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
388 venvManager = e5App().getObject("VirtualEnvManager")
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
389 for venvName in sorted(venvManager.getVirtualenvNames()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
390 self.lmenu.addAction(venvName)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
391 if self.__project.isOpen():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
392 self.lmenu.addSeparator()
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
393 self.lmenu.addAction(self.tr("Project"))
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
394
2640
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
395 def __resizeLinenoMargin(self):
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
396 """
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
397 Private slot to resize the line numbers margin.
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
398 """
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
399 linenoMargin = Preferences.getShell("LinenoMargin")
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
400 if linenoMargin:
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
401 self.setMarginWidth(0, '8' * (len(str(self.lines())) + 1))
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
402
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 def closeShell(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
405 Public method to shutdown the shell.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
407 for clientType in self.__historyLists:
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
408 self.saveHistory(clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
410 def __bindLexer(self, language='Python3'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 Private slot to set the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 @param language lexer language to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 self.language = language
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 if Preferences.getShell("SyntaxHighlightingEnabled"):
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
418 from . import Lexers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 self.lexer_ = Lexers.getLexer(self.language, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 if self.lexer_ is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.setLexer(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 font = Preferences.getShell("MonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self.monospacedStyles(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 # get the font for style 0 and set it as the default font
428
58405c24aa09 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
430 key = 'Scintilla/{0}/style0/font'.format(self.lexer_.language())
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
431 fdesc = Preferences.Prefs.settings.value(key)
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
432 if fdesc is not None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 font = QFont(fdesc[0], int(fdesc[1]))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 self.lexer_.setDefaultFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.setLexer(self.lexer_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla")
6858
9d962e654978 Corrected the SubstyledLexer.hasSubStyle() method to SubstyledLexer.hasSubstyle() to be consistent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6845
diff changeset
437 if self.lexer_.hasSubstyles():
6845
4680adb641e0 Lexer: implemented basic support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6841
diff changeset
438 self.lexer_.readSubstyles(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 # initialize the lexer APIs settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 api = self.vm.getAPIsManager().getAPIs(self.language)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 api = api.getQsciAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 self.lexer_.setAPIs(api)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446
1566
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
447 self.lexer_.setDefaultColor(self.lexer_.color(0))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
448 self.lexer_.setDefaultPaper(self.lexer_.paper(0))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
449
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 def __setMargin0(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 Private method to configure margin 0.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 # set the settings for all margins
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 self.setMarginsFont(Preferences.getShell("MarginsFont"))
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
456 self.setMarginsForegroundColor(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
457 Preferences.getEditorColour("MarginsForeground"))
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
458 self.setMarginsBackgroundColor(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
459 Preferences.getEditorColour("MarginsBackground"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 # set margin 0 settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 linenoMargin = Preferences.getShell("LinenoMargin")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 self.setMarginLineNumbers(0, linenoMargin)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 if linenoMargin:
2640
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2474
diff changeset
465 self.__resizeLinenoMargin()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.setMarginWidth(0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 # disable margins 1 and 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 self.setMarginWidth(1, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 self.setMarginWidth(2, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 def __setTextDisplay(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 Private method to configure the text display.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 self.setTabWidth(Preferences.getEditor("TabWidth"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 if Preferences.getEditor("ShowWhitespace"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 self.setWhitespaceVisibility(QsciScintilla.WsVisible)
943
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
480 try:
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
481 self.setWhitespaceForegroundColor(
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
482 Preferences.getEditorColour("WhitespaceForeground"))
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
483 self.setWhitespaceBackgroundColor(
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
484 Preferences.getEditorColour("WhitespaceBackground"))
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
485 self.setWhitespaceSize(
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
486 Preferences.getEditor("WhitespaceSize"))
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
487 except AttributeError:
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
488 # QScintilla before 2.5 doesn't support this
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
489 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 if Preferences.getEditor("BraceHighlighting"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 self.setBraceMatching(QsciScintilla.NoBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 self.setMatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 Preferences.getEditorColour("MatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.setMatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 Preferences.getEditorColour("MatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 self.setUnmatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 Preferences.getEditorColour("NonmatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 self.setUnmatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 Preferences.getEditorColour("NonmatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
506 self.setSelectionBackgroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 Preferences.getEditorColour("SelectionBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
509 self.setSelectionBackgroundColor(
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
510 QApplication.palette().color(QPalette.Highlight))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 if Preferences.getEditor("ColourizeSelText"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 self.resetSelectionForegroundColor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
514 self.setSelectionForegroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 Preferences.getEditorColour("SelectionForeground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
517 self.setSelectionForegroundColor(
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
518 QApplication.palette().color(QPalette.HighlightedText))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 self.setCaretForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 Preferences.getEditorColour("CaretForeground"))
3068
e2650fb5db4e Removed the highlight of the caret line from the shell window because that doesn't make sense.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
522 self.setCaretLineVisible(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 self.caretWidth = Preferences.getEditor("CaretWidth")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 self.setCaretWidth(self.caretWidth)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 if Preferences.getShell("WrapEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 self.setWrapMode(QsciScintilla.WrapWord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 self.setWrapMode(QsciScintilla.WrapNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 self.useMonospaced = Preferences.getShell("UseMonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 self.__setMonospaced(self.useMonospaced)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
532 self.setCursorFlashTime(QApplication.cursorFlashTime())
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
533
1566
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
534 if Preferences.getEditor("OverrideEditAreaColours"):
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
535 self.setColor(Preferences.getEditorColour("EditAreaForeground"))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
536 self.setPaper(Preferences.getEditorColour("EditAreaBackground"))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
537
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 def __setMonospaced(self, on):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 Private method to set/reset a monospaced font.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 @param on flag to indicate usage of a monospace font (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 if on:
3087
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3068
diff changeset
545 if not self.lexer_:
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3068
diff changeset
546 f = Preferences.getShell("MonospacedFont")
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3068
diff changeset
547 self.monospacedStyles(f)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 if not self.lexer_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 self.clearStyles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 self.setFont(Preferences.getShell("MonospacedFont"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 self.useMonospaced = on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
556 def __setAutoCompletion(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 Private method to configure the autocompletion function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 @param language of the autocompletion set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 self.setAutoCompletionCaseSensitivity(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 Preferences.getEditor("AutoCompletionCaseSensitivity"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 self.setAutoCompletionThreshold(-1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 self.racEnabled = Preferences.getShell("AutoCompletionEnabled")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567
6305
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
568 self.maxLines = Preferences.getEditor("AutoCompletionMaxLines")
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
569 self.maxChars = Preferences.getEditor("AutoCompletionMaxChars")
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
570
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
571 def __setCallTips(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 Private method to configure the calltips function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 @param language of the calltips set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 if Preferences.getShell("CallTipsEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 self.setCallTipsBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 Preferences.getEditorColour("CallTipsBackground"))
7536
861e46f99d65 Editor, Shell: added configuration option for the calltips foreground and highlight color.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
580 self.setCallTipsForegroundColor(
861e46f99d65 Editor, Shell: added configuration option for the calltips foreground and highlight color.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
581 Preferences.getEditorColour("CallTipsForeground"))
861e46f99d65 Editor, Shell: added configuration option for the calltips foreground and highlight color.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
582 self.setCallTipsHighlightColor(
861e46f99d65 Editor, Shell: added configuration option for the calltips foreground and highlight color.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
583 Preferences.getEditorColour("CallTipsHighlight"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 calltipsStyle = Preferences.getEditor("CallTipsStyle")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 if calltipsStyle == QsciScintilla.CallTipsNoContext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
588 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
589 calltipsStyle ==
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
590 QsciScintilla.CallTipsNoAutoCompletionContext
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
591 ):
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
592 self.setCallTipsStyle(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
593 QsciScintilla.CallTipsNoAutoCompletionContext)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 self.setCallTipsStyle(QsciScintilla.CallTipsContext)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 self.setCallTipsStyle(QsciScintilla.CallTipsNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 def setDebuggerUI(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 Public method to set the debugger UI.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 @param ui reference to the debugger UI object (DebugUI)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 """
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 481
diff changeset
605 ui.exceptionInterrupt.connect(self.__writePrompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 def __initialise(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 Private method to get ready for a new remote interpreter.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 self.buff = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 self.inRawMode = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 self.echoInput = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 self.clientCapabilities = 0
1056
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
616 self.inCommandExecution = False
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
617 self.interruptCommandExecution = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
619 def __clientCapabilities(self, cap, clType, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 Private slot to handle the reporting of the clients capabilities.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
623 @param cap client capabilities
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
624 @type int
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
625 @param clType type of the debug client
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
626 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
627 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
628 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.clientCapabilities = cap
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
631 self.__currentVenv = venvName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 if clType != self.clientType:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.clientType = clType
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
634 self.__bindLexer(self.clientType)
2010
07ae45dc6986 Fixed an issue in the Shell window causing wrong fonts set when monospaced is active.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1965
diff changeset
635 self.__setTextDisplay()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 self.__setMargin0()
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
637 self.__setAutoCompletion(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
638 self.__setCallTips(self.clientType)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
639 self.racEnabled = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
640 Preferences.getShell("AutoCompletionEnabled") and
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
641 (cap & HasCompleter) > 0
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
642 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
644 if self.clientType not in self.__historyLists:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 # load history list
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
646 self.loadHistory(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
647 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
648 self.__setHistoryIndex()
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
649
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
650 self.virtualEnvironmentChanged.emit(venvName)
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
651 Preferences.setShell("LastVirtualEnvironment", venvName)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
652
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
653 def __setHistoryIndex(self, index=None):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
654 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
655 Private method to set the initial history index.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
657 @param index index value to be set
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
658 @type int or None
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
659 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
660 if index is None:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
661 # determine based on history style
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
662 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
663 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
664 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
665 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
666 idx = int(Preferences.Prefs.settings.value(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
667 "Shell/HistoryIndexes/" + self.clientType, -1))
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
668 if idx >= len(self.__history):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
669 idx = -1
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
670 self.__histidx = idx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
671 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
672 self.__histidx = -1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
673 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
674 self.__histidx = index
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
675 if self.__histidx >= len(self.__history):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
676 self.__histidx = -1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
677 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
678 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
679 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
680 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
681 Preferences.Prefs.settings.setValue(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
682 "Shell/HistoryIndexes/" + self.clientType, self.__histidx)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
683
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
684 def __isHistoryIndexValid(self):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
685 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
686 Private method to test, if the history index is valid.
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
687
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
688 @return flag indicating validity
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
689 @rtype bool
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
690 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
691 return (0 <= self.__histidx < len(self.__history))
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
692
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
693 def getHistoryIndex(self):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
694 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
695 Public method to get the current value of the history index.
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
696
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
697 @return history index
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
698 @rtype int
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
699 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
700 return self.__histidx
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
701
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 def loadHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 Public method to load the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 """
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
708 hl = Preferences.Prefs.settings.value("Shell/Histories/" + clientType)
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
709 if hl is not None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
710 self.__historyLists[clientType] = hl[-self.__maxHistoryEntries:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
712 self.__historyLists[clientType] = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 def reloadHistory(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
716 Public method to reload the history of the currently selected client
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
717 type.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 self.loadHistory(self.clientType)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
720 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
721 self.__setHistoryIndex()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 def saveHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 Public method to save the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
729 if clientType in self.__historyLists:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
730 Preferences.Prefs.settings.setValue(
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
731 "Shell/Histories/" + clientType,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
732 self.__historyLists[clientType])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 def getHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 Public method to get the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 @param clientType type of the debug client (string).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 If it is None, the current history is returned.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 @return reference to the history list (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 if clientType is None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
743 return self.__history
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
744 elif clientType in self.__historyLists:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
745 return self.__historyLists[clientType]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
749 def clearHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
751 Public slot to clear the current history.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 """
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
753 if self.clientType:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
754 self.__historyLists[self.clientType] = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
755 self.__history = self.__historyLists[self.clientType]
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
756 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
757 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
758 self.__setHistoryIndex(index=-1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
760 def selectHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
762 Public slot to select a history entry to execute.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
764 current = self.__histidx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
765 if current == -1:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
766 current = len(self.__history) - 1
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
767 cmd, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
769 self.tr("Select History"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
770 self.tr("Select the history entry to execute"
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
771 " (most recent shown last)."),
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
772 self.__history,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
773 current, False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 self.__insertHistory(cmd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
777 def showHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
779 Public slot to show the shell history dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
781 from .ShellHistoryDialog import ShellHistoryDialog
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
782 dlg = ShellHistoryDialog(self.__history, self.vm, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7703
diff changeset
783 if dlg.exec() == QDialog.Accepted:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
784 self.__historyLists[self.clientType], idx = dlg.getHistory()
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
785 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
786 self.__setHistoryIndex(index=idx)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
788 def clearAllHistories(self):
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
789 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
790 Public method to clear all available histories and sync them.
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
791 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
792 Preferences.Prefs.settings.beginGroup("Shell/Histories")
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
793 for clientType in Preferences.Prefs.settings.childKeys():
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
794 self.__historyLists[clientType] = []
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
795 self.saveHistory(clientType)
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
796 Preferences.Prefs.settings.endGroup()
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
797
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
798 self.clearHistory()
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
799
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 def getClientType(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 Public slot to get the clients type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 @return client type (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 return self.clientType
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 def __getBanner(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 Private method to get the banner for the remote interpreter.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 It requests the interpreter version and platform running on the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 debug client side.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 if self.passive:
6639
86f10cfa3653 Shell: fixed an issue calling __writeBanner() with too few arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6633
diff changeset
816 self.__writeBanner('', '', '', '')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 self.dbs.remoteBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
820 def __writeBanner(self, version, platform, dbgclient, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 Private method to write a banner with info from the debug client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
824 @param version interpreter version string
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
825 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
826 @param platform platform of the remote interpreter
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
827 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
828 @param dbgclient debug client variant used
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
829 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
830 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
831 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
833 super(Shell, self).clear()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 if self.passive and not self.dbs.isConnected():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
835 self.__write(self.tr('Passive Debug Mode'))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
836 self.__write(self.tr('\nNot connected'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 else:
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
838 self.__currentVenv = venvName
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
839 version = version.replace("#", self.tr("No."))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 if platform != "" and dbgclient != "":
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
841 self.__write(
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
842 self.tr('{0} on {1}, {2}')
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
843 .format(version, platform, dbgclient))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.__write(version)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
846 if venvName:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
847 self.__write("\n[{0}]".format(venvName))
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
848
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
849 self.virtualEnvironmentChanged.emit(venvName)
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
850 Preferences.setShell("LastVirtualEnvironment", venvName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 self.__write('\n')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 self.__write(sys.ps1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 def __writePrompt(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
857 Private method to write the prompt using a write queue.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
859 self.queueText.emit(self.inContinue and sys.ps2 or sys.ps1)
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
860
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 def __clientStatement(self, more):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 Private method to handle the response from the debugger client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 @param more flag indicating that more user input is required (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 if not self.inRawMode:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 self.inContinue = more
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 self.__writePrompt()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 self.inCommandExecution = False
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
871
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
872 def __clientException(self, exceptionType, exceptionMessage, stackTrace):
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
873 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
874 Private method to handle an exception of the client.
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
875
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
876 @param exceptionType type of exception raised (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
877 @param exceptionMessage message given by the exception (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
878 @param stackTrace list of stack entries (list of string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
879 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
880 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
881
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
882 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
883 not self.__windowed and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
884 Preferences.getDebugger("ShowExceptionInShell")
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
885 ):
5126
d28b92dabc2b Fixed two little issues related to wrong parameter types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5108
diff changeset
886 if exceptionType:
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
887 if stackTrace:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
888 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
889 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
890 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
891 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
892 exceptionMessage,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
893 stackTrace[0][0],
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
894 stackTrace[0][1]
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
895 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
896 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
897 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
898 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
899 self.tr('Exception "{0}"\n{1}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
900 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
901 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
902 exceptionMessage)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
903 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
904
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
905 def __clientSyntaxError(self, message, filename, lineNo, characterNo):
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
906 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
907 Private method to handle a syntax error in the debugged program.
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
908
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
909 @param message message of the syntax error (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
910 @param filename translated filename of the syntax error position
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
911 (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
912 @param lineNo line number of the syntax error position (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
913 @param characterNo character number of the syntax error position
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
914 (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
915 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
916 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
917
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
918 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
919 not self.__windowed and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
920 Preferences.getDebugger("ShowExceptionInShell")
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
921 ):
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
922 if message is None:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
923 self.__write(self.tr("Unspecified syntax error.\n"))
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
924 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
925 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
926 self.tr('Syntax error "{1}" in file {0} at line {2},'
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
927 ' character {3}.\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
928 .format(filename, message, lineNo, characterNo)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
929 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
930
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
931 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs):
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
932 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
933 Private method to handle a signal generated on the client side.
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
934
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
935 @param message message of the syntax error
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
936 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
937 @param filename translated filename of the syntax error position
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
938 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
939 @param lineNo line number of the syntax error position
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
940 @type int
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
941 @param funcName name of the function causing the signal
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
942 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
943 @param funcArgs function arguments
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
944 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
945 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
946 self.__clientError()
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
947
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
948 self.__write(
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
949 self.tr("""Signal "{0}" generated in file {1} at line {2}.\n"""
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
950 """Function: {3}({4})""")
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
951 .format(message, filename, lineNo, funcName, funcArgs)
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
952 )
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
953
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 def __clientError(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 Private method to handle an error in the client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 self.inCommandExecution = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 self.interruptCommandExecution = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 def __getEndPos(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 Private method to return the line and column of the last character.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 @return tuple of two values (int, int) giving the line and column
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 line = self.lines() - 1
1743
4f9afcd8eb9d Fixed a unicode issue in the terminal and interpreter shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
969 return (line, len(self.text(line)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
971 def __writeQueued(self, s):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 """
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
973 Private method to display some text using a write queue.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 """
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
977 self.queueText.emit(s)
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
978
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
979 def __concatenateText(self, text):
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
980 """
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
981 Private slot to queue text and process it in one step.
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
982
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
983 @param text text to be appended
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
984 @type str
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
985 """
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
986 self.__queuedText += text
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
987 if self.__blockTextProcessing:
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
988 return
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
989
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
990 self.__blockTextProcessing = True
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
991 # Get all text which is still waiting for output
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
992 QApplication.processEvents()
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
993
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
994 # Finally process the accumulated text
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
995 self.__flushQueuedText()
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
996
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
997 def __flushQueuedText(self):
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
998 """
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
999 Private slot to flush the accumulated text output.
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1000 """
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1001 self.__write(self.__queuedText)
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1002
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1003 self.__queuedText = ''
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1004 self.__blockTextProcessing = False
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1005
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1006 # little trick to get the cursor position registered within QScintilla
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1007 self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1008 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1009
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1010 def __write(self, s):
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1011 """
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1012 Private method to display some text without queuing.
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1013
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1014 @param s text to be displayed
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1015 @type str
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1016 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 line, col = self.__getEndPos()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 self.setCursorPosition(line, col)
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1019 self.insert(Utilities.filterAnsiSequences(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 self.prline, self.prcol = self.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 self.ensureLineVisible(self.prline)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 def __writeStdOut(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 Private method to display some text with StdOut label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1030 self.__write(self.tr("StdOut: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 def __writeStdErr(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 Private method to display some text with StdErr label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1038 self.__write(self.tr("StdErr: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1040 def __raw_input(self, prompt, echo):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 Private method to handle raw input.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1044 @param prompt prompt to be displayed
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1045 @type str
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1046 @param echo Flag indicating echoing of the input
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1047 @type bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 self.setFocus()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 self.inRawMode = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 self.echoInput = echo
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1052
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1053 # Get all text which is still waiting for output
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1054 QApplication.processEvents()
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1055 self.__flushQueuedText()
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1056
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1057 self.__write(prompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058 line, col = self.__getEndPos()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
1059 self.setCursorPosition(line, col)
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1060 buf = self.text(line)
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1061 if buf.startswith(sys.ps1):
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1062 buf = buf.replace(sys.ps1, "")
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1063 if buf.startswith(sys.ps2):
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1064 buf = buf.replace(sys.ps2, "")
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1065 self.prompt = buf
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1066 # move cursor to end of line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1067 self.moveCursorToEOL()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1068
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1069 def paste(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1070 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1071 Public slot to handle the paste action.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072 """
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1073 if self.__isCursorOnLastLine():
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1074 line, col = self.getCursorPosition()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1075 lastLine = self.text(line)
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1076 if lastLine.startswith(sys.ps1):
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1077 lastLine = lastLine[len(sys.ps1):]
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1078 col -= len(sys.ps1)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1079 prompt = sys.ps1
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1080 elif lastLine.startswith(sys.ps2):
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1081 lastLine = lastLine[len(sys.ps2):]
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1082 col -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1083 prompt = sys.ps2
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1084 else:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1085 prompt = ""
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1086 if col < 0:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1087 col = 0
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1088 prompt = ""
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1089
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1090 # Remove if text is selected
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1091 if self.hasSelectedText():
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1092 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1093 if self.text(lineFrom).startswith(sys.ps1):
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1094 indexFrom -= len(sys.ps1)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1095 indexTo -= len(sys.ps1)
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1096 elif self.text(lineFrom).startswith(sys.ps2):
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1097 indexFrom -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1098 indexTo -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1099 if indexFrom < 0:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1100 indexFrom = 0
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1101 lastLine = lastLine[:indexFrom] + lastLine[indexTo:]
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1102 col = indexFrom
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1103
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1104 self.setCursorPosition(line, len(prompt))
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1105 self.deleteLineRight()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1106
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T&#