eric6/QScintilla/Shell.py

Thu, 02 May 2019 19:07:48 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 02 May 2019 19:07:48 +0200
changeset 6987
3371a03ed0a7
parent 6942
2602857055c5
child 6989
8b8cadf8d7e9
child 7198
684261ef2165
permissions
-rw-r--r--

Performed some interface cleanups.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6639
diff changeset
3 # Copyright (c) 2002 - 2019 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
11
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
15 try:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
16 from enum import Enum
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
17 except ImportError:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
18 from ThirdParty.enum import Enum
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
19
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5712
diff changeset
20 from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
21 from PyQt5.QtGui import QClipboard, QPalette, QFont
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
22 from PyQt5.QtWidgets import QDialog, QInputDialog, QApplication, QMenu, \
6387
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6377
diff changeset
23 QWidget, QHBoxLayout, QVBoxLayout, QShortcut, QSizePolicy
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
24 from PyQt5.Qsci import QsciScintilla
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
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
26 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
27 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
29 from .QsciScintillaCompat import QsciScintillaCompat
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 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
32 import Utilities
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5712
diff changeset
33 from Globals import qVersionTuple
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
34
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
37 from Debugger.DebugClientCapabilities import HasCompleter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
39
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
40 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
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 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
43 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
44 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
45 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
46 Constructor
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
47
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
48 @param dbs reference to the debug server object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
49 @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
50 @param vm reference to the viewmanager object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
51 @type ViewManager
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
52 @param project reference to the project object
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
53 @type Project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
54 @param horizontal flag indicating a horizontal layout
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
55 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
56 @param parent parent widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
57 @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
58 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
59 super(ShellAssembly, self).__init__(parent)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
60
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
61 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
62
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
63 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
64 self.__searchWidget = SearchWidget(self.__shell, self, horizontal)
6387
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6377
diff changeset
65 self.__searchWidget.setSizePolicy(QSizePolicy.Fixed,
a168b5f26a14 Shell, ShellWindow, LogViewer: fixed the layouts, an ambigous shortcut and added a missing method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6377
diff changeset
66 QSizePolicy.Preferred)
1833
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
67 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
68
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
69 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
70 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
71 else:
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
72 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
73 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
74 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
75 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
76
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
77 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
78 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
79 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
80 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
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 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
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 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
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 @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
87 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
88 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
89
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
90 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
91 """
6987
3371a03ed0a7 Performed some interface cleanups.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
92 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
93
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
94 @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
95 """
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
96 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
97
f7cd855680f1 Added the capability to search in the output of the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1743
diff changeset
98
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
99 class ShellHistoryStyle(Enum):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
100 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
101 Class defining the shell history styles.
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 Disabled = 0
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
104 LinuxStyle = 1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
105 WindowsStyle = 2
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
106
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
107
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 class Shell(QsciScintillaCompat):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 Class implementing a graphical Python shell.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
112 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
113 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
114
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
115 @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
116 result
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
117 @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
118 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
119 @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
120 @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
121 environment of the shell
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
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 searchStringFound = pyqtSignal(bool)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
124 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
125 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
126 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
127
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
128 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
129 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @param dbs reference to the debug server object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
133 @type DebugServer
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @param vm reference to the viewmanager object
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
135 @type ViewManager
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
136 @param project reference to the project object
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
137 @type Project
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
138 @param windowedVariant flag indicating the shell window variant
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
139 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
140 @param parent parent widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
141 @type QWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
143 super(Shell, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.setUtf8(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 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
147 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
148 self.__lastSearch = ()
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
149 self.__windowed = windowedVariant
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
150 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
151 self.__currentWorkingDirectory = ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.linesepRegExp = r"\r\n|\n|\r"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
155 self.passive = ((not self.__windowed) and
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
156 Preferences.getDebugger("PassiveDbgEnabled"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 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
158 self.setWindowTitle(self.tr('Shell - Passive'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
160 self.setWindowTitle(self.tr('Shell'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
162 if self.__windowed:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
163 self.setWhatsThis(self.tr(
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
164 """<b>The Shell Window</b>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
165 """<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
166 """ 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
167 """ 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
168 """ 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
169 """ 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
170 """ 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
171 """ entered will start an incremental search.</p>"""
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
172 """<p>The shell has some special commands. 'restart' kills"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
173 """ the shell and starts a new one. 'clear' clears the"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
174 """ display of the shell window. 'start' is used to start a"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
175 """ shell for a virtual environment and should be followed"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
176 """ by a virtual environment name. start' without a virtual"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
177 """ environment name starts the default shell. Available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
178 """ virtual environments may be listed with the 'envs' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
179 """ 'environments' commands. The active virtual environment"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
180 """ can be questioned by the 'which' command. 'quit' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
181 """ 'exit' is used to exit the application. These commands"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
182 """ (except environments', 'envs' and 'which') are available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
183 """ through the window menus as well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
184 """<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
185 """ 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
186 """ 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
187 """ 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
188 ))
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
189 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
190 self.setWhatsThis(self.tr(
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
191 """<b>The Shell Window</b>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
192 """<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
193 """ 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
194 """ 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
195 """ 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
196 """<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
197 """ 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
198 """ 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
199 """ 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
200 """ 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
201 """ 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
202 """ entered will start an incremental search.</p>"""
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
203 """<p>The shell has some special commands. 'restart' kills"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
204 """ the shell and starts a new one. 'clear' clears the"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
205 """ display of the shell window. 'start' is used to start a"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
206 """ shell for a virtual environment and should be followed"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
207 """ by a virtual environment name. start' without a virtual"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
208 """ environment name starts the default shell. Available"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
209 """ virtual environments may be listed with the 'envs' or"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
210 """ 'environments' commands. The active virtual environment"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
211 """ can be questioned by the 'which' command. These commands"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
212 """ (except environments' and 'envs') are available through"""
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
213 """ the context menu as well.</p>"""
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
214 """<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
215 """ 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
216 """ 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
217 """ 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
218 """<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
219 """ 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
220 """ 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
221 """ 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
222 """ caption.</p>"""
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
223 ))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
225 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
226 self.linesChanged.connect(self.__resizeLinenoMargin)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
228 if self.__windowed:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
229 self.__showStdOutErr = True
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
230 else:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
231 self.__showStdOutErr = Preferences.getShell("ShowStdOutErr")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 if self.__showStdOutErr:
481
ad71812ba395 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 dbs.clientSignal.connect(self.__clientSignal)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.dbs = dbs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
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
247 # Initialize instance variables.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.__initialise()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 self.prline = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.prcol = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 self.inDragDrop = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.completionText = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
255 self.clientType = ''
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
256
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 # Initialize history
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
258 self.__historyLists = {}
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
259 self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
260 self.__historyStyle = Preferences.getShell("HistoryStyle")
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
261 self.__historyWrap = Preferences.getShell("HistoryWrap")
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
262 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
263 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
264 # 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
265 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
266 Preferences.Prefs.settings.remove("Shell/Histories/" + clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 # clear QScintilla defined keyboard commands
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 # we do our own handling through the view manager
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 self.clearAlternateKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.clearKeys()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 self.__actionsAdded = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 # Make sure we have prompts.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 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
276 sys.ps1 = self.tr("Passive >>> ")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 sys.ps1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 sys.ps1 = ">>> "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 sys.ps2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 sys.ps2 = "... "
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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
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
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
372 self.__historyNavigateByCursor = \
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")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
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
375 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
376 self.__blockTextProcessing = False
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
377 self.queueText.connect(self.__concatenateText, Qt.QueuedConnection)
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
378
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
379 self.__project = project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
380 if self.__project:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
381 self.__project.projectOpened.connect(self.__projectOpened)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
382 self.__project.projectClosed.connect(self.__projectClosed)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
383
1518
e6e21910210d Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
384 self.grabGesture(Qt.PinchGesture)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
385
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
386 def __showStartMenu(self):
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
387 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
388 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
389 """
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
390 self.lmenu.clear()
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
391 venvManager = e5App().getObject("VirtualEnvManager")
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
392 for venvName in sorted(venvManager.getVirtualenvNames()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
393 self.lmenu.addAction(venvName)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
394 if self.__project.isOpen():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
395 self.lmenu.addSeparator()
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
396 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
397
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
398 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
399 """
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 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
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 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
403 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
404 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
405
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 def closeShell(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
408 Public method to shutdown the shell.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
410 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
411 self.saveHistory(clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
413 def __bindLexer(self, language='Python3'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 Private slot to set the lexer.
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 @param language lexer language to set (string)
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 self.language = language
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 if Preferences.getShell("SyntaxHighlightingEnabled"):
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
421 from . import Lexers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 self.lexer_ = Lexers.getLexer(self.language, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 if self.lexer_ is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.setLexer(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 font = Preferences.getShell("MonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 self.monospacedStyles(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 # 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
433 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
434 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
435 if fdesc is not None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 font = QFont(fdesc[0], int(fdesc[1]))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.lexer_.setDefaultFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.setLexer(self.lexer_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 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
440 if self.lexer_.hasSubstyles():
6845
4680adb641e0 Lexer: implemented basic support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6841
diff changeset
441 self.lexer_.readSubstyles(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 # initialize the lexer APIs settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 api = self.vm.getAPIsManager().getAPIs(self.language)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 api = api.getQsciAPIs()
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 self.lexer_.setAPIs(api)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449
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
450 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
451 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
452
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 def __setMargin0(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 Private method to configure margin 0.
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 # set the settings for all margins
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 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
459 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
460 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
461 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
462 Preferences.getEditorColour("MarginsBackground"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 # set margin 0 settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 linenoMargin = Preferences.getShell("LinenoMargin")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 self.setMarginLineNumbers(0, linenoMargin)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 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
468 self.__resizeLinenoMargin()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 self.setMarginWidth(0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 # disable margins 1 and 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 self.setMarginWidth(1, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 self.setMarginWidth(2, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 def __setTextDisplay(self):
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 Private method to configure the text display.
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 self.setTabWidth(Preferences.getEditor("TabWidth"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 if Preferences.getEditor("ShowWhitespace"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.setWhitespaceVisibility(QsciScintilla.WsVisible)
943
1246bd8280a6 Added configuration options for visible whitespace (as of QScintilla 2.5) (for shell and terminal).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 # 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
492 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 if Preferences.getEditor("BraceHighlighting"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.setBraceMatching(QsciScintilla.NoBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.setMatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 Preferences.getEditorColour("MatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 self.setMatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 Preferences.getEditorColour("MatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 self.setUnmatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 Preferences.getEditorColour("NonmatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 self.setUnmatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 Preferences.getEditorColour("NonmatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
509 self.setSelectionBackgroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 Preferences.getEditorColour("SelectionBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
512 self.setSelectionBackgroundColor(
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
513 QApplication.palette().color(QPalette.Highlight))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 if Preferences.getEditor("ColourizeSelText"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 self.resetSelectionForegroundColor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
517 self.setSelectionForegroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 Preferences.getEditorColour("SelectionForeground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
520 self.setSelectionForegroundColor(
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
521 QApplication.palette().color(QPalette.HighlightedText))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 self.setCaretForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 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
525 self.setCaretLineVisible(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 self.caretWidth = Preferences.getEditor("CaretWidth")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 self.setCaretWidth(self.caretWidth)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 if Preferences.getShell("WrapEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 self.setWrapMode(QsciScintilla.WrapWord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.setWrapMode(QsciScintilla.WrapNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.useMonospaced = Preferences.getShell("UseMonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.__setMonospaced(self.useMonospaced)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
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
535 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
536
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
537 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
538 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
539 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
540
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 def __setMonospaced(self, on):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 Private method to set/reset a monospaced font.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 @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
546 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 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
548 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
549 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
550 self.monospacedStyles(f)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 if not self.lexer_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.clearStyles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 self.setFont(Preferences.getShell("MonospacedFont"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 self.useMonospaced = on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
559 def __setAutoCompletion(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 Private method to configure the autocompletion function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 @param language of the autocompletion set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 self.setAutoCompletionCaseSensitivity(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 Preferences.getEditor("AutoCompletionCaseSensitivity"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 self.setAutoCompletionThreshold(-1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 self.racEnabled = Preferences.getShell("AutoCompletionEnabled")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570
6305
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
571 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
572 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
573
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
574 def __setCallTips(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 Private method to configure the calltips function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 @param language of the calltips set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 if Preferences.getShell("CallTipsEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 self.setCallTipsBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 Preferences.getEditorColour("CallTipsBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 calltipsStyle = Preferences.getEditor("CallTipsStyle")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if calltipsStyle == QsciScintilla.CallTipsNoContext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext)
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
587 elif calltipsStyle == \
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
588 QsciScintilla.CallTipsNoAutoCompletionContext:
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
589 self.setCallTipsStyle(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
590 QsciScintilla.CallTipsNoAutoCompletionContext)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 self.setCallTipsStyle(QsciScintilla.CallTipsContext)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 self.setCallTipsStyle(QsciScintilla.CallTipsNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 def setDebuggerUI(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 Public method to set the debugger UI.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 @param ui reference to the debugger UI object (DebugUI)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 """
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 481
diff changeset
602 ui.exceptionInterrupt.connect(self.__writePrompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 def __initialise(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 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
607 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 self.buff = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 self.inRawMode = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 self.echoInput = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 self.clientCapabilities = 0
1056
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
613 self.inCommandExecution = False
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
614 self.interruptCommandExecution = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
616 def __clientCapabilities(self, cap, clType, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 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
619
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
620 @param cap client capabilities
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
621 @type int
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
622 @param clType type of the debug client
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
623 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
624 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
625 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self.clientCapabilities = cap
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
628 self.__currentVenv = venvName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 if clType != self.clientType:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.clientType = clType
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
631 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
632 self.__setTextDisplay()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.__setMargin0()
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
634 self.__setAutoCompletion(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
635 self.__setCallTips(self.clientType)
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
636 self.racEnabled = \
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
637 Preferences.getShell("AutoCompletionEnabled") and \
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
638 (cap & HasCompleter) > 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
640 if self.clientType not in self.__historyLists:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 # load history list
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
642 self.loadHistory(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
643 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
644 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
645
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
646 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
647 Preferences.setShell("LastVirtualEnvironment", venvName)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
648
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
649 def __setHistoryIndex(self, index=None):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
650 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
651 Private method to set the initial history index.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
653 @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
654 @type int or None
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
655 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
656 if index is None:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
657 # determine based on history style
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
658 if self.clientType and \
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
659 self.__historyStyle == ShellHistoryStyle.WindowsStyle:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
660 idx = int(Preferences.Prefs.settings.value(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
661 "Shell/HistoryIndexes/" + self.clientType, -1))
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
662 if idx >= len(self.__history):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
663 idx = -1
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
664 self.__histidx = idx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
665 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
666 self.__histidx = -1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
667 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
668 self.__histidx = index
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
669 if self.__histidx >= len(self.__history):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
670 self.__histidx = -1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
671 if self.clientType and \
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
672 self.__historyStyle == ShellHistoryStyle.WindowsStyle:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
673 Preferences.Prefs.settings.setValue(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
674 "Shell/HistoryIndexes/" + self.clientType, self.__histidx)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
675
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
676 def __isHistoryIndexValid(self):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
677 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
678 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
679
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
680 @return flag indicating validity
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
681 @rtype bool
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
682 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
683 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
684
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
685 def getHistoryIndex(self):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
686 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
687 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
688
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
689 @return history index
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
690 @rtype int
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
691 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
692 return self.__histidx
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
693
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 def loadHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 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
697
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 """
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
700 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
701 if hl is not None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
702 self.__historyLists[clientType] = hl[-self.__maxHistoryEntries:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
704 self.__historyLists[clientType] = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 def reloadHistory(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 """
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
708 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
709 type.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 self.loadHistory(self.clientType)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
712 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
713 self.__setHistoryIndex()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 def saveHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 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
718
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
721 if clientType in self.__historyLists:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
722 Preferences.Prefs.settings.setValue(
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
723 "Shell/Histories/" + clientType,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
724 self.__historyLists[clientType])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 def getHistory(self, clientType):
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 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
729
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 @param clientType type of the debug client (string).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 If it is None, the current history is returned.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 @return reference to the history list (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 if clientType is None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
735 return self.__history
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
736 elif clientType in self.__historyLists:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
737 return self.__historyLists[clientType]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
741 def clearHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
743 Public slot to clear the current history.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 """
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
745 if self.clientType:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
746 self.__historyLists[self.clientType] = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
747 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
748 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
749 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
750 self.__setHistoryIndex(index=-1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
752 def selectHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
754 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
755 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
756 current = self.__histidx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
757 if current == -1:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
758 current = len(self.__history) - 1
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
759 cmd, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
761 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
762 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
763 " (most recent shown last)."),
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
764 self.__history,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
765 current, False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 self.__insertHistory(cmd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
769 def showHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
771 Public slot to show the shell history dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
773 from .ShellHistoryDialog import ShellHistoryDialog
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
774 dlg = ShellHistoryDialog(self.__history, self.vm, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 if dlg.exec_() == QDialog.Accepted:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
776 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
777 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
778 self.__setHistoryIndex(index=idx)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
780 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
781 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
782 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
783 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
784 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
785 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
786 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
787 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
788 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
789
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
790 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
791
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 def getClientType(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 Public slot to get the clients type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 @return client type (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 return self.clientType
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 def __getBanner(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 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
803
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 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
805 debug client side.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 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
808 self.__writeBanner('', '', '', '')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 self.dbs.remoteBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
812 def __writeBanner(self, version, platform, dbgclient, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 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
815
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
816 @param version interpreter version string
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
817 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
818 @param platform platform of the remote interpreter
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
819 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
820 @param dbgclient debug client variant used
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
821 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
822 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
823 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
825 super(Shell, self).clear()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 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
827 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
828 self.__write(self.tr('\nNot connected'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 else:
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
830 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
831 version = version.replace("#", self.tr("No."))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 if platform != "" and dbgclient != "":
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
833 self.__write(
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
834 self.tr('{0} on {1}, {2}')
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
835 .format(version, platform, dbgclient))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 self.__write(version)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
838 if venvName:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
839 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
840
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
841 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
842 Preferences.setShell("LastVirtualEnvironment", venvName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 self.__write('\n')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.__write(sys.ps1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 def __writePrompt(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
849 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
850 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
851 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
852
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 def __clientStatement(self, more):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 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
856
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 @param more flag indicating that more user input is required (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 if not self.inRawMode:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 self.inContinue = more
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 self.__writePrompt()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 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
863
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
864 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
865 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
866 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
867
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
868 @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
869 @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
870 @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
871 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
872 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
873
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
874 if not self.__windowed and \
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
875 Preferences.getDebugger("ShowExceptionInShell"):
5126
d28b92dabc2b Fixed two little issues related to wrong parameter types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5108
diff changeset
876 if exceptionType:
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
877 if stackTrace:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
878 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
879 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
880 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
881 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
882 exceptionMessage,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
883 stackTrace[0][0],
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
884 stackTrace[0][1]
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
885 )
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 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
888 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
889 self.tr('Exception "{0}"\n{1}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
890 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
891 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
892 exceptionMessage)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
893 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
894
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
895 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
896 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
897 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
898
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
899 @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
900 @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
901 (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
902 @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
903 @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
904 (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
905 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
906 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
907
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
908 if not self.__windowed and \
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5631
diff changeset
909 Preferences.getDebugger("ShowExceptionInShell"):
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
910 if message is None:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
911 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
912 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
913 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
914 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
915 ' character {3}.\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
916 .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
917 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
918
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
919 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
920 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
921 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
922
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
923 @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
924 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
925 @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
926 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
927 @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
928 @type int
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
929 @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
930 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
931 @param funcArgs function arguments
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
932 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
933 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
934 self.__clientError()
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
935
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
936 self.__write(
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
937 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
938 """Function: {3}({4})""")
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
939 .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
940 )
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
941
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 def __clientError(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 Private method to handle an error in the client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 self.inCommandExecution = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 self.interruptCommandExecution = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 def __getEndPos(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 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
953
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 @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
955 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 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
957 return (line, len(self.text(line)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958
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
959 def __writeQueued(self, s):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 """
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
961 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
962
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 """
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
965 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
966
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
967 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
968 """
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
969 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
970
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
971 @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
972 @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
973 """
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
974 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
975 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
976 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
977
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
978 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
979 # 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
980 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
981
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
982 # Finally process the accumulated text
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
983 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
984
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
985 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
986 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
987
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
988 # 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
989 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
990 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
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
991
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 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
993 """
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
994 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
995
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
996 @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
997 @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
998 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 line, col = self.__getEndPos()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 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
1001 self.insert(Utilities.filterAnsiSequences(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002 self.prline, self.prcol = self.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1003 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 self.ensureLineVisible(self.prline)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 def __writeStdOut(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 Private method to display some text with StdOut label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1012 self.__write(self.tr("StdOut: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 def __writeStdErr(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 Private method to display some text with StdErr label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1020 self.__write(self.tr("StdErr: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 def __raw_input(self, s, echo):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 Private method to handle raw input.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 @param s prompt to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 @param echo Flag indicating echoing of the input (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 """
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
1029 # Get all text which is still waiting for output
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 QApplication.processEvents()
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
1031
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 self.setFocus()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 self.inRawMode = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 self.echoInput = echo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 self.__write(s)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 line, col = self.__getEndPos()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
1037 self.setCursorPosition(line, col)
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1038 buf = self.text(line)
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1039 if buf.startswith(sys.ps1):
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1040 buf = buf.replace(sys.ps1, "")
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1041 if buf.startswith(sys.ps2):
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1042 buf = buf.replace(sys.ps2, "")
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
1043 self.prompt = buf
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 # move cursor to end of line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 self.moveCursorToEOL()
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 def paste(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1049 Public slot to handle the paste action.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 """
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1051 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
1052 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
1053 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
1054 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
1055 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
1056 col -= len(sys.ps1)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1057 prompt = sys.ps1
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1058 elif lastLine.startswith(sys.ps2):
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1059 lastLine = lastLine[len(sys.ps2):]
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1060 col -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1061 prompt = sys.ps2
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1062 else:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1063 prompt = ""
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1064 if col < 0:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1065 col = 0
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1066 prompt = ""
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1067
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1068 # Remove if text is selected
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1069 if self.hasSelectedText():
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1070 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1071 if self.text(lineFrom).startswith(sys.ps1):
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1072 indexFrom -= len(sys.ps1)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1073 indexTo -= len(sys.ps1)
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1074 elif self.text(lineFrom).startswith(sys.ps2):
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1075 indexFrom -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1076 indexTo -= len(sys.ps2)
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1077 if indexFrom < 0:
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1078 indexFrom = 0
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1079 lastLine = lastLine[:indexFrom] + lastLine[indexTo:]
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1080 col = indexFrom
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1081
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
1082 self.setCursorPosition(line, len(prompt))
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1083 self.deleteLineRight()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1084
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1085 lines = QApplication.clipboard().text()
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1086 lines = lastLine[:col] + lines + lastLine[col:]
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1087 self.executeLines(lines)
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1088 line, _ = 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
1089 pos = len(self.text(line)) - (len(lastLine) - col)
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1090 self.setCursorPosition(line, pos)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092 def __middleMouseButton(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1094 Private method to handle the middle mouse button press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1095 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1096 lines = QApplication.clipboard().text(QClipboard.Selection)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1097 self.executeLines(lines)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1098
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1099 def executeLines(self, lines, historyIndex=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1100 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1101 Public method to execute a set of lines as multiple commands.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1102
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1103 @param lines multiple lines of text to be executed as
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1104 single commands
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1105 @type str
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1106 @param historyIndex history index to be set
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
1107 @type int
0