eric6/QScintilla/Shell.py

Sun, 11 Apr 2021 18:45:10 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 11 Apr 2021 18:45:10 +0200
changeset 8222
5994b80b8760
parent 8218
7c09585bd960
child 8235
78e6d29eb773
permissions
-rw-r--r--

Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7802
diff changeset
3 # Copyright (c) 2002 - 2021 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
7408
0d58e708f57b Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7389
diff changeset
15 from PyQt5.QtCore import pyqtSignal, pyqtSlot, 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 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8169
diff changeset
55 super().__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)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
61 self.__searchWidget.setSizePolicy(QSizePolicy.Policy.Fixed,
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
62 QSizePolicy.Policy.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 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8169
diff changeset
139 super().__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>"""
8146
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
168 """<p>The shell has some special commands. '%restart' kills"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
169 """ the shell and starts a new one. '%clear' clears the"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
170 """ display of the shell window. '%start' is used to start a"""
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
171 """ shell for a virtual environment and should be followed"""
8146
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
172 """ by a virtual environment name. '%start' without a"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
173 """ virtual environment name starts the default shell."""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
174 """ Available virtual environments may be listed with the"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
175 """ '%envs' or '%environments' commands. The active virtual"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
176 """ environment can be questioned by the '%which' command."""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
177 """ '%quit' or '%exit' is used to exit the application."""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
178 """ These commands (except '%environments', '%envs' and"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
179 """ '%which') are available through the window menus as"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
180 """ well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
181 """<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
182 """ 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
183 """ 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
184 """ 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
185 ))
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
186 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
187 self.setWhatsThis(self.tr(
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
188 """<b>The Shell Window</b>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
189 """<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
190 """ 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
191 """ 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
192 """ 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
193 """<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
194 """ 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
195 """ 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
196 """ 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
197 """ 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
198 """ 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
199 """ entered will start an incremental search.</p>"""
8146
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
200 """<p>The shell has some special commands. '%restart' kills"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
201 """ the shell and starts a new one. '%clear' clears the"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
202 """ display of the shell window. '%start' is used to start a"""
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
203 """ shell for a virtual environment and should be followed"""
8146
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
204 """ by a virtual environment name. '%start' without a"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
205 """ virtual environment name starts the default shell."""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
206 """ Available virtual environments may be listed with the"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
207 """ '%envs' or '%environments' commands. The active virtual"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
208 """ environment can be questioned by the '%which' command."""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
209 """ These commands (except '%environments' and '%envs') are"""
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
210 """ available through the context menu as well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
211 """<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
212 """ 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
213 """ 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
214 """ 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
215 """<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
216 """ 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
217 """ 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
218 """ 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
219 """ caption.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
220 ))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
222 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
223 self.linesChanged.connect(self.__resizeLinenoMargin)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
225 if self.__windowed:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
226 self.__showStdOutErr = True
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
227 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
228 self.__showStdOutErr = Preferences.getShell("ShowStdOutErr")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 if self.__showStdOutErr:
481
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 dbs.clientSignal.connect(self.__clientSignal)
8138
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
242 dbs.mainClientExit.connect(self.__writePrompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.dbs = dbs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
7408
0d58e708f57b Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7389
diff changeset
245 self.__debugUI = None
0d58e708f57b Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7389
diff changeset
246
8138
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
247 # Make sure we have prompts.
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
248 if self.passive:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
249 sys.ps1 = self.tr("Passive >>> ")
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
250 else:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
251 try:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
252 sys.ps1
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
253 except AttributeError:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
254 sys.ps1 = ">>> "
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
255 try:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
256 sys.ps2
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
257 except AttributeError:
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
258 sys.ps2 = "... "
169e65a6787c Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7990
diff changeset
259
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
260 # Initialize instance variables.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.__initialise()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 self.prline = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 self.prcol = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 self.inDragDrop = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.completionText = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
268 self.clientType = ''
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
269
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 # Initialize history
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
271 self.__historyLists = {}
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
272 self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
273 self.__historyStyle = Preferences.getShell("HistoryStyle")
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
274 self.__historyWrap = Preferences.getShell("HistoryWrap")
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
275 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
276 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
277 # 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
278 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
279 Preferences.Prefs.settings.remove("Shell/Histories/" + clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 # clear QScintilla defined keyboard commands
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 # we do our own handling through the view manager
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 self.clearAlternateKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 self.clearKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 self.__actionsAdded = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 if self.passive:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 self.__getBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
290 if not self.__windowed:
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
291 # Create a little language context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
292 self.lmenu = QMenu(self.tr('Start'))
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
293 self.lmenu.aboutToShow.connect(self.__showStartMenu)
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
294 self.lmenu.triggered.connect(self.__startDebugClient)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
295
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
296 # Create the history context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
297 self.hmenu = QMenu(self.tr('History'))
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
298 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
299 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
300 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
301
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
302 # Create a little context menu
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
303 self.menu = QMenu(self)
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
304 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
305 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
306 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
307 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
308
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
309 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
310 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
311 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
312 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
313 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
314 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
315 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
316 self.menu.addSeparator()
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
317 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
318 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
319 self.menu.addSeparator()
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
320 self.menu.addAction(self.tr("Configure..."), self.__configure)
0
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 self.__bindLexer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 self.__setTextDisplay()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 # set the autocompletion and calltips function
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__setAutoCompletion()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.__setCallTips()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
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
330 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 self.incrementalSearchString = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 self.incrementalSearchActive = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 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
336 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
337 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
338 QsciScintilla.SCI_NEWLINE: self.__QScintillaNewline,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339
945
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_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
341 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
342 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
343 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
344 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
345 QsciScintilla.SCI_DELLINERIGHT: self.__QScintillaDeleteLineRight,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346
945
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_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
348 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
349 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
350 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
351 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
352 QsciScintilla.SCI_LINEEND: self.__QScintillaLineEnd,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
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
354 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
355 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
356 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
357 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
358
945
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_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
360 QsciScintilla.SCI_PAGEDOWN: self.__QScintillaAutoCompletionCommand,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361
945
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_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
363 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
364 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
365 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
366 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
367 QsciScintilla.SCI_LINEENDEXTEND: self.extendSelectionToEOL,
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
368
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
369 QsciScintilla.SCI_CANCEL: self.__QScintillaCancel,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 }
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
371
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372 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
373 Preferences.getShell("HistoryNavigateByCursor")
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375
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
376 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
377 self.__blockTextProcessing = False
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
378 self.queueText.connect(self.__concatenateText,
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
379 Qt.ConnectionType.QueuedConnection)
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
380
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
381 self.__project = project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
382 if self.__project:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
383 self.__project.projectOpened.connect(self.__projectOpened)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
384 self.__project.projectClosed.connect(self.__projectClosed)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
385
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
386 self.grabGesture(Qt.GestureType.PinchGesture)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
387
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
388 def __showStartMenu(self):
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
389 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
390 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
391 """
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
392 self.lmenu.clear()
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
393 venvManager = e5App().getObject("VirtualEnvManager")
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
394 for venvName in sorted(venvManager.getVirtualenvNames()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
395 self.lmenu.addAction(venvName)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
396 if self.__project.isOpen():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
397 self.lmenu.addSeparator()
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
398 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
399
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
400 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
401 """
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 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
403 """
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
404 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
405 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
406 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
407
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 def closeShell(self):
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 Public method to shutdown the shell.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
412 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
413 self.saveHistory(clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
415 def __bindLexer(self, language='Python3'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 Private slot to set the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 @param language lexer language to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.language = language
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 if Preferences.getShell("SyntaxHighlightingEnabled"):
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
423 from . import Lexers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.lexer_ = Lexers.getLexer(self.language, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 if self.lexer_ is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 self.setLexer(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 font = Preferences.getShell("MonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 self.monospacedStyles(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 # 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
435 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
436 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
437 if fdesc is not None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 font = QFont(fdesc[0], int(fdesc[1]))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.lexer_.setDefaultFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.setLexer(self.lexer_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 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
442 if self.lexer_.hasSubstyles():
6845
4680adb641e0 Lexer: implemented basic support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6841
diff changeset
443 self.lexer_.readSubstyles(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 # initialize the lexer APIs settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 api = self.vm.getAPIsManager().getAPIs(self.language)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 api = api.getQsciAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 self.lexer_.setAPIs(api)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451
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
452 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
453 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
454
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 def __setMargin0(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 Private method to configure margin 0.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 # set the settings for all margins
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 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
461 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
462 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
463 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
464 Preferences.getEditorColour("MarginsBackground"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 # set margin 0 settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 linenoMargin = Preferences.getShell("LinenoMargin")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 self.setMarginLineNumbers(0, linenoMargin)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 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
470 self.__resizeLinenoMargin()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 self.setMarginWidth(0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 # disable margins 1 and 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 self.setMarginWidth(1, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 self.setMarginWidth(2, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 def __setTextDisplay(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 Private method to configure the text display.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.setTabWidth(Preferences.getEditor("TabWidth"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 if Preferences.getEditor("ShowWhitespace"):
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
484 self.setWhitespaceVisibility(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
485 QsciScintilla.WhitespaceVisibility.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
486 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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 # 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
495 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
497 self.setWhitespaceVisibility(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
498 QsciScintilla.WhitespaceVisibility.WsInvisible)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 if Preferences.getEditor("BraceHighlighting"):
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
501 self.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
503 self.setBraceMatching(QsciScintilla.BraceMatch.NoBraceMatch)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 self.setMatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 Preferences.getEditorColour("MatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 self.setMatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 Preferences.getEditorColour("MatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 self.setUnmatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 Preferences.getEditorColour("NonmatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 self.setUnmatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 Preferences.getEditorColour("NonmatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
513 self.setSelectionBackgroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 Preferences.getEditorColour("SelectionBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
516 self.setSelectionBackgroundColor(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
517 QApplication.palette().color(QPalette.ColorRole.Highlight))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 if Preferences.getEditor("ColourizeSelText"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 self.resetSelectionForegroundColor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
521 self.setSelectionForegroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 Preferences.getEditorColour("SelectionForeground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
524 self.setSelectionForegroundColor(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
525 QApplication.palette().color(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
526 QPalette.ColorRole.HighlightedText))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 self.setCaretForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 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
530 self.setCaretLineVisible(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.caretWidth = Preferences.getEditor("CaretWidth")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.setCaretWidth(self.caretWidth)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 if Preferences.getShell("WrapEnabled"):
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
534 self.setWrapMode(QsciScintilla.WrapMode.WrapWord)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
536 self.setWrapMode(QsciScintilla.WrapMode.WrapNone)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 self.useMonospaced = Preferences.getShell("UseMonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 self.__setMonospaced(self.useMonospaced)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
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
540 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
541
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
542 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
543 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
544 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
545
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 def __setMonospaced(self, on):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 Private method to set/reset a monospaced font.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 @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
551 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 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
553 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
554 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
555 self.monospacedStyles(f)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 if not self.lexer_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 self.clearStyles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 self.setFont(Preferences.getShell("MonospacedFont"))
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.useMonospaced = on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
564 def __setAutoCompletion(self, language='Python'):
0
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 Private method to configure the autocompletion function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 @param language of the autocompletion set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 self.setAutoCompletionCaseSensitivity(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 Preferences.getEditor("AutoCompletionCaseSensitivity"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 self.setAutoCompletionThreshold(-1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 self.racEnabled = Preferences.getShell("AutoCompletionEnabled")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575
6305
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
576 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
577 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
578
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
579 def __setCallTips(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 Private method to configure the calltips function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 @param language of the calltips set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if Preferences.getShell("CallTipsEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 self.setCallTipsBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 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
588 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
589 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
590 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
591 Preferences.getEditorColour("CallTipsHighlight"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 calltipsStyle = Preferences.getEditor("CallTipsStyle")
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
594 if calltipsStyle == QsciScintilla.CallTipsStyle.CallTipsNoContext:
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
595 self.setCallTipsStyle(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
596 QsciScintilla.CallTipsStyle.CallTipsNoContext)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
597 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
598 calltipsStyle ==
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
599 QsciScintilla.CallTipsStyle.CallTipsNoAutoCompletionContext
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
600 ):
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
601 self.setCallTipsStyle(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
602 QsciScintilla.CallTipsStyle
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
603 .CallTipsNoAutoCompletionContext)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
605 self.setCallTipsStyle(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
606 QsciScintilla.CallTipsStyle.CallTipsContext)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
608 self.setCallTipsStyle(QsciScintilla.CallTipsStyle.CallTipsNone)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 def setDebuggerUI(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 Public method to set the debugger UI.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 @param ui reference to the debugger UI object (DebugUI)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 """
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 481
diff changeset
616 ui.exceptionInterrupt.connect(self.__writePrompt)
7408
0d58e708f57b Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7389
diff changeset
617 self.__debugUI = ui
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 def __initialise(self):
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 method to get ready for a new remote interpreter.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 self.buff = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 self.inContinue = False
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
625 self.__inRawMode = False
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
626 self.__echoInput = True
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
627 self.__rawModeDebuggerId = None
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
628 self.__rawModeQueue = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 self.clientCapabilities = 0
1056
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
630 self.inCommandExecution = False
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
631 self.interruptCommandExecution = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
633 def __clientCapabilities(self, cap, clType, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 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
636
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
637 @param cap client capabilities
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
638 @type int
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
639 @param clType type of the debug client
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
640 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
641 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
642 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 self.clientCapabilities = cap
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
645 self.__currentVenv = venvName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 if clType != self.clientType:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 self.clientType = clType
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
648 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
649 self.__setTextDisplay()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 self.__setMargin0()
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
651 self.__setAutoCompletion(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
652 self.__setCallTips(self.clientType)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
653 self.racEnabled = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
654 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
655 (cap & HasCompleter) > 0
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
656 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
658 if self.clientType not in self.__historyLists:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 # load history list
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
660 self.loadHistory(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
661 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
662 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
663
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
664 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
665 Preferences.setShell("LastVirtualEnvironment", venvName)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
666
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
667 def __setHistoryIndex(self, index=None):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
668 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
669 Private method to set the initial history index.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
671 @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
672 @type int or None
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
673 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
674 if index is None:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
675 # determine based on history style
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
676 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
677 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
678 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
679 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
680 idx = int(Preferences.Prefs.settings.value(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
681 "Shell/HistoryIndexes/" + self.clientType, -1))
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
682 if idx >= len(self.__history):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
683 idx = -1
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
684 self.__histidx = idx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
685 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
686 self.__histidx = -1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
687 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
688 self.__histidx = index
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
689 if self.__histidx >= len(self.__history):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
690 self.__histidx = -1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
691 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
692 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
693 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
694 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
695 Preferences.Prefs.settings.setValue(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
696 "Shell/HistoryIndexes/" + self.clientType, self.__histidx)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
697
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
698 def __isHistoryIndexValid(self):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
699 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
700 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
701
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
702 @return flag indicating validity
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
703 @rtype bool
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
704 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
705 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
706
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
707 def getHistoryIndex(self):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
708 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
709 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
710
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
711 @return history index
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
712 @rtype int
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
713 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
714 return self.__histidx
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
715
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 def loadHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 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
719
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 """
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
722 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
723 if hl is not None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
724 self.__historyLists[clientType] = hl[-self.__maxHistoryEntries:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
726 self.__historyLists[clientType] = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 def reloadHistory(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 """
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
730 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
731 type.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 self.loadHistory(self.clientType)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
734 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
735 self.__setHistoryIndex()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 def saveHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 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
740
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
743 if clientType in self.__historyLists:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
744 Preferences.Prefs.settings.setValue(
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
745 "Shell/Histories/" + clientType,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
746 self.__historyLists[clientType])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 def getHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 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
751
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 @param clientType type of the debug client (string).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 If it is None, the current history is returned.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 @return reference to the history list (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 if clientType is None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
757 return self.__history
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
758 elif clientType in self.__historyLists:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
759 return self.__historyLists[clientType]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
763 def clearHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
765 Public slot to clear the current history.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 """
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
767 if self.clientType:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
768 self.__historyLists[self.clientType] = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
769 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
770 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
771 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
772 self.__setHistoryIndex(index=-1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
774 def selectHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
776 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
777 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
778 current = self.__histidx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
779 if current == -1:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
780 current = len(self.__history) - 1
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
781 cmd, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
783 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
784 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
785 " (most recent shown last)."),
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
786 self.__history,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
787 current, False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 self.__insertHistory(cmd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
791 def showHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
793 Public slot to show the shell history dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
795 from .ShellHistoryDialog import ShellHistoryDialog
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
796 dlg = ShellHistoryDialog(self.__history, self.vm, self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8138
diff changeset
797 if dlg.exec() == QDialog.DialogCode.Accepted:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
798 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
799 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
800 self.__setHistoryIndex(index=idx)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
802 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
803 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
804 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
805 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
806 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
807 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
808 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
809 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
810 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
811
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
812 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
813
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 def getClientType(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 Public slot to get the clients type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 @return client type (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 return self.clientType
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 def __getBanner(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 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
825
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 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
827 debug client side.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 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
830 self.__writeBanner('', '', '', '')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 self.dbs.remoteBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833
7412
0a995393d2ba Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7408
diff changeset
834 def __writeBanner(self, version, platform, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 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
837
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
838 @param version interpreter version string
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
839 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
840 @param platform platform of the remote interpreter
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
841 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
842 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
843 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8169
diff changeset
845 super().clear()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 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
847 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
848 self.__write(self.tr('\nNot connected'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 else:
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
850 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
851 version = version.replace("#", self.tr("No."))
7412
0a995393d2ba Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7408
diff changeset
852 if platform != "":
0a995393d2ba Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7408
diff changeset
853 self.__write(self.tr('{0} on {1}').format(version, platform))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 self.__write(version)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
856 if venvName:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
857 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
858
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
859 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
860 Preferences.setShell("LastVirtualEnvironment", venvName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 self.__write('\n')
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 self.__write(sys.ps1)
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 def __writePrompt(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
867 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
868 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
869 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
870
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 def __clientStatement(self, more):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 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
874
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
875 @param more flag indicating that more user input is required
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
876 @type bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 """
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
878 if not self.__inRawMode:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 self.inContinue = more
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 self.__writePrompt()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 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
882
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
883 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
884 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
885 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
886
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
887 @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
888 @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
889 @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
890 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
891 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
892
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
893 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
894 not self.__windowed and
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
895 Preferences.getDebugger("ShowExceptionInShell") and
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
896 exceptionType
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
897 ):
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
898 if stackTrace:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
899 self.__write(
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
900 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n')
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
901 .format(
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
902 exceptionType,
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
903 exceptionMessage,
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
904 stackTrace[0][0],
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
905 stackTrace[0][1]
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
906 )
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
907 )
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
908 else:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
909 self.__write(
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
910 self.tr('Exception "{0}"\n{1}\n')
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
911 .format(
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
912 exceptionType,
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
913 exceptionMessage)
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
914 )
3974
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 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
917 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
918 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
919
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
920 @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
921 @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
922 (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
923 @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
924 @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
925 (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
926 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
927 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
928
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
929 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
930 not self.__windowed and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
931 Preferences.getDebugger("ShowExceptionInShell")
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
932 ):
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
933 if message is None:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
934 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
935 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
936 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
937 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
938 ' character {3}.\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
939 .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
940 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
941
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
942 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
943 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
944 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
945
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
946 @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
947 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
948 @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
949 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
950 @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
951 @type int
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
952 @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
953 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
954 @param funcArgs function arguments
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
955 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
956 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
957 self.__clientError()
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
958
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
959 self.__write(
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
960 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
961 """Function: {3}({4})""")
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
962 .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
963 )
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
964
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 def __clientError(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 Private method to handle an error in the client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 self.inCommandExecution = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 self.interruptCommandExecution = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 def __getEndPos(self):
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 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
976
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 @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
978 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 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
980 return (line, len(self.text(line)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981
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
982 def __writeQueued(self, s):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 """
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
984 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
985
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 """
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
988 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
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 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
991 """
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
992 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
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 @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
995 @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
996 """
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
997 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
998 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
999 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
1000
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
1001 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
1002 # 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
1003 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
1004
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
1005 # Finally process the accumulated text
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1006 self.__flushQueuedText()
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1007
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1008 def __flushQueuedText(self):
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1009 """
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1010 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
1011 """
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
1012 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
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 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
1015 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
1016
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1017 # 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
1018 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
1019 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1020
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
1021 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
1022 """
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
1023 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
1024
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
1025 @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
1026 @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
1027 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 line, col = self.__getEndPos()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 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
1030 self.insert(Utilities.filterAnsiSequences(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 self.prline, self.prcol = self.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 self.ensureLineVisible(self.prline)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 def __writeStdOut(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 Private method to display some text with StdOut label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1041 self.__write(self.tr("StdOut: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 def __writeStdErr(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 Private method to display some text with StdErr label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1049 self.__write(self.tr("StdErr: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1051 def __raw_input(self, prompt, echo, debuggerId):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 Private method to handle raw input.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1055 @param prompt the input prompt
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1056 @type str
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1057 @param echo flag indicating an echoing of the input
7387
2fb33905ff6b Shell: fixed the raw_input method again.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7378
diff changeset
1058 @type bool
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1059 @param debuggerId ID of the debugger backend
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1060 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1061 """
7389
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1062 if self.__inRawMode:
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1063 # we are processing another raw input event already
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1064 self.__rawModeQueue.append((debuggerId, prompt, echo))
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1065 else:
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1066 self.setFocus()
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1067 self.__inRawMode = True
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1068 self.__echoInput = echo
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1069 self.__rawModeDebuggerId = debuggerId
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1070
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1071 # Get all text which is still waiting for output
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1072 QApplication.processEvents()
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1073 self.__flushQueuedText()
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1074
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1075 self.__write(self.tr("<{0}> {1}").format(debuggerId, prompt))
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1076 line, col = self.__getEndPos()
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1077 self.setCursorPosition(line, col)
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1078 buf = self.text(line)
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1079 if buf.startswith(sys.ps1):
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1080 buf = buf.replace(sys.ps1, "")
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1081 if buf.startswith(sys.ps2):
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1082 buf = buf.replace(sys.ps2, "")
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1083 self.prompt = buf
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1084 # move cursor to end of line
770ffcb88be5 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7386
diff changeset
1085 self.moveCursorToEOL()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086
7990
3b865f4b7dff Shell: corrected inserting (pasting) text via the middel mouse button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
1087 def paste(self, lines=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1088 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1089 Public slot to handle the paste action.
7990
3b865f4b7dff Shell: corrected inserting (pasting) text via the middel mouse button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
1090
3b865f4b7dff Shell: corrected inserting (pasting) text via the middel mouse button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
1091 @param lines list of lines to be inserted
3b865f4b7dff Shell: corrected inserting (pasting) text via the middel mouse button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
1092 @type list of str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 """
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1094 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
1095 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
1096 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
1097 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
1098 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
1099 col -= len(sys.ps1)
0ce26b97e2c0 Fixed an issue in the Python shell window executing p