eric6/QScintilla/Shell.py

Thu, 03 Oct 2019 11:12:10 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 03 Oct 2019 11:12:10 +0200
branch
maintenance
changeset 7286
7eb04391adf7
parent 6989
8b8cadf8d7e9
parent 7267
aedc309827c7
child 7362
028bf21bb5a2
permissions
-rw-r--r--

Merged with default branch to prepare a new release.

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
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
10
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
14 try:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
15 from enum import Enum
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
16 except ImportError:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
17 from ThirdParty.enum import Enum
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
18
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5712
diff changeset
19 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
20 from PyQt5.QtGui import QClipboard, QPalette, QFont
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
22 QDialog, QInputDialog, QApplication, QMenu, QWidget, QHBoxLayout,
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
23 QVBoxLayout, QShortcut, QSizePolicy
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
24 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3631
diff changeset
25 from PyQt5.Qsci import QsciScintilla
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
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
27 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
28 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
30 from .QsciScintillaCompat import QsciScintillaCompat
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 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
33 import Utilities
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
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
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372 self.__historyNavigateByCursor = (
6037
9aec96a3a82a Fixed an issue related to cursor key navigation within completion lists caused by the new history navigation style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6029
diff changeset
373 Preferences.getShell("HistoryNavigateByCursor")
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
376 self.__queuedText = ''
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
377 self.__blockTextProcessing = False
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 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
379
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
380 self.__project = project
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
381 if self.__project:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
382 self.__project.projectOpened.connect(self.__projectOpened)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
383 self.__project.projectClosed.connect(self.__projectClosed)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
384
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
385 self.grabGesture(Qt.PinchGesture)
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
386
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
387 def __showStartMenu(self):
4479
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
388 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
389 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
390 """
fd9ceecf5a65 Changed the shell language menu to be dynamic.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4366
diff changeset
391 self.lmenu.clear()
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
392 venvManager = e5App().getObject("VirtualEnvManager")
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
393 for venvName in sorted(venvManager.getVirtualenvNames()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
394 self.lmenu.addAction(venvName)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
395 if self.__project.isOpen():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
396 self.lmenu.addSeparator()
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
397 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
398
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
399 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
400 """
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 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
402 """
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 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
404 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
405 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
406
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 def closeShell(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
409 Public method to shutdown the shell.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
411 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
412 self.saveHistory(clientType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
414 def __bindLexer(self, language='Python3'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 Private slot to set the lexer.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 @param language lexer language to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.language = language
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 if Preferences.getShell("SyntaxHighlightingEnabled"):
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
422 from . import Lexers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 self.lexer_ = Lexers.getLexer(self.language, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 self.lexer_ = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 if self.lexer_ is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self.setLexer(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 font = Preferences.getShell("MonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 self.monospacedStyles(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 # 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
434 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
435 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
436 if fdesc is not None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 font = QFont(fdesc[0], int(fdesc[1]))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.lexer_.setDefaultFont(font)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.setLexer(self.lexer_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 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
441 if self.lexer_.hasSubstyles():
6845
4680adb641e0 Lexer: implemented basic support for sub-styles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6841
diff changeset
442 self.lexer_.readSubstyles(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 # initialize the lexer APIs settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 api = self.vm.getAPIsManager().getAPIs(self.language)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 api = api.getQsciAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 if api is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 self.lexer_.setAPIs(api)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450
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
451 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
452 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
453
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 def __setMargin0(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 Private method to configure margin 0.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 # set the settings for all margins
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 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
460 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
461 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
462 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
463 Preferences.getEditorColour("MarginsBackground"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 # set margin 0 settings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 linenoMargin = Preferences.getShell("LinenoMargin")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.setMarginLineNumbers(0, linenoMargin)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 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
469 self.__resizeLinenoMargin()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 self.setMarginWidth(0, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 # disable margins 1 and 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 self.setMarginWidth(1, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 self.setMarginWidth(2, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 def __setTextDisplay(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 Private method to configure the text display.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 self.setTabWidth(Preferences.getEditor("TabWidth"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 if Preferences.getEditor("ShowWhitespace"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 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
492 # 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
493 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 if Preferences.getEditor("BraceHighlighting"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.setBraceMatching(QsciScintilla.NoBraceMatch)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 self.setMatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 Preferences.getEditorColour("MatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 self.setMatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 Preferences.getEditorColour("MatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 self.setUnmatchedBraceForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 Preferences.getEditorColour("NonmatchingBrace"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 self.setUnmatchedBraceBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 Preferences.getEditorColour("NonmatchingBraceBack"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
510 self.setSelectionBackgroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 Preferences.getEditorColour("SelectionBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
513 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
514 QApplication.palette().color(QPalette.Highlight))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 if Preferences.getEditor("ColourizeSelText"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 self.resetSelectionForegroundColor()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
518 self.setSelectionForegroundColor(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 Preferences.getEditorColour("SelectionForeground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
521 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
522 QApplication.palette().color(QPalette.HighlightedText))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 self.setCaretForegroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 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
526 self.setCaretLineVisible(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 self.caretWidth = Preferences.getEditor("CaretWidth")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 self.setCaretWidth(self.caretWidth)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 if Preferences.getShell("WrapEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 self.setWrapMode(QsciScintilla.WrapWord)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.setWrapMode(QsciScintilla.WrapNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.useMonospaced = Preferences.getShell("UseMonospacedFont")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 self.__setMonospaced(self.useMonospaced)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535
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
536 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
537
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
538 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
539 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
540 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
541
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 def __setMonospaced(self, on):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 Private method to set/reset a monospaced font.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 @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
547 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 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
549 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
550 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
551 self.monospacedStyles(f)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 if not self.lexer_:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 self.clearStyles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 self.__setMargin0()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 self.setFont(Preferences.getShell("MonospacedFont"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 self.useMonospaced = on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
560 def __setAutoCompletion(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 Private method to configure the autocompletion function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 @param language of the autocompletion set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 self.setAutoCompletionCaseSensitivity(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 Preferences.getEditor("AutoCompletionCaseSensitivity"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 self.setAutoCompletionThreshold(-1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 self.racEnabled = Preferences.getShell("AutoCompletionEnabled")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571
6305
7652b925c25e Resize auto complete list box to fit with contents.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6086
diff changeset
572 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
573 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
574
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 943
diff changeset
575 def __setCallTips(self, language='Python'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 Private method to configure the calltips function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 @param language of the calltips set to set (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 if Preferences.getShell("CallTipsEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 self.setCallTipsBackgroundColor(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 Preferences.getEditorColour("CallTipsBackground"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 calltipsStyle = Preferences.getEditor("CallTipsStyle")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 if calltipsStyle == QsciScintilla.CallTipsNoContext:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
588 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
589 calltipsStyle ==
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
590 QsciScintilla.CallTipsNoAutoCompletionContext
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
591 ):
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
592 self.setCallTipsStyle(
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
593 QsciScintilla.CallTipsNoAutoCompletionContext)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 self.setCallTipsStyle(QsciScintilla.CallTipsContext)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 self.setCallTipsStyle(QsciScintilla.CallTipsNone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 def setDebuggerUI(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 Public method to set the debugger UI.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 @param ui reference to the debugger UI object (DebugUI)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 """
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 481
diff changeset
605 ui.exceptionInterrupt.connect(self.__writePrompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 def __initialise(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 Private method to get ready for a new remote interpreter.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 self.buff = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 self.inRawMode = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 self.echoInput = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 self.clientCapabilities = 0
1056
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
616 self.inCommandExecution = False
a3eb3c9a7e4b Fixed a bug in Shell.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
617 self.interruptCommandExecution = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
619 def __clientCapabilities(self, cap, clType, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 Private slot to handle the reporting of the clients capabilities.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
623 @param cap client capabilities
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
624 @type int
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
625 @param clType type of the debug client
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
626 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
627 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
628 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.clientCapabilities = cap
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
631 self.__currentVenv = venvName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 if clType != self.clientType:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.clientType = clType
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
634 self.__bindLexer(self.clientType)
2010
07ae45dc6986 Fixed an issue in the Shell window causing wrong fonts set when monospaced is active.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1965
diff changeset
635 self.__setTextDisplay()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 self.__setMargin0()
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
637 self.__setAutoCompletion(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
638 self.__setCallTips(self.clientType)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
639 self.racEnabled = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
640 Preferences.getShell("AutoCompletionEnabled") and
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
641 (cap & HasCompleter) > 0
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
642 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
644 if self.clientType not in self.__historyLists:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 # load history list
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
646 self.loadHistory(self.clientType)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
647 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
648 self.__setHistoryIndex()
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
649
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
650 self.virtualEnvironmentChanged.emit(venvName)
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
651 Preferences.setShell("LastVirtualEnvironment", venvName)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
652
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
653 def __setHistoryIndex(self, index=None):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
654 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
655 Private method to set the initial history index.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
657 @param index index value to be set
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
658 @type int or None
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
659 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
660 if index is None:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
661 # determine based on history style
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
662 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
663 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
664 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
665 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
666 idx = int(Preferences.Prefs.settings.value(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
667 "Shell/HistoryIndexes/" + self.clientType, -1))
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
668 if idx >= len(self.__history):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
669 idx = -1
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
670 self.__histidx = idx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
671 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
672 self.__histidx = -1
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
673 else:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
674 self.__histidx = index
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
675 if self.__histidx >= len(self.__history):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
676 self.__histidx = -1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
677 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
678 self.clientType and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
679 self.__historyStyle == ShellHistoryStyle.WindowsStyle
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
680 ):
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
681 Preferences.Prefs.settings.setValue(
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
682 "Shell/HistoryIndexes/" + self.clientType, self.__histidx)
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
683
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
684 def __isHistoryIndexValid(self):
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
685 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
686 Private method to test, if the history index is valid.
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
687
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
688 @return flag indicating validity
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
689 @rtype bool
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
690 """
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
691 return (0 <= self.__histidx < len(self.__history))
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
692
5799
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
693 def getHistoryIndex(self):
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
694 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
695 Public method to get the current value of the history index.
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
696
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
697 @return history index
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
698 @rtype int
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
699 """
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
700 return self.__histidx
e87f52c0374a Finished improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5798
diff changeset
701
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 def loadHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 Public method to load the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 """
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
708 hl = Preferences.Prefs.settings.value("Shell/Histories/" + clientType)
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
709 if hl is not None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
710 self.__historyLists[clientType] = hl[-self.__maxHistoryEntries:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
712 self.__historyLists[clientType] = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 def reloadHistory(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
2940
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
716 Public method to reload the history of the currently selected client
e9348df06994 Fixed an issue in the interpreter shell window causing data to be deleted if it contained the secondary prompt (sys.ps2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2640
diff changeset
717 type.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 self.loadHistory(self.clientType)
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
720 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
721 self.__setHistoryIndex()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 def saveHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 Public method to save the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 @param clientType type of the debug client (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
729 if clientType in self.__historyLists:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
730 Preferences.Prefs.settings.setValue(
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
731 "Shell/Histories/" + clientType,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
732 self.__historyLists[clientType])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 def getHistory(self, clientType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 Public method to get the history for the given client type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 @param clientType type of the debug client (string).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 If it is None, the current history is returned.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 @return reference to the history list (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 if clientType is None:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
743 return self.__history
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
744 elif clientType in self.__historyLists:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
745 return self.__historyLists[clientType]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
749 def clearHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
751 Public slot to clear the current history.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 """
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
753 if self.clientType:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
754 self.__historyLists[self.clientType] = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
755 self.__history = self.__historyLists[self.clientType]
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
756 else:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
757 self.__history = []
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
758 self.__setHistoryIndex(index=-1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
760 def selectHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
762 Public slot to select a history entry to execute.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 """
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
764 current = self.__histidx
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
765 if current == -1:
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
766 current = len(self.__history) - 1
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
767 cmd, ok = QInputDialog.getItem(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
769 self.tr("Select History"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
770 self.tr("Select the history entry to execute"
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
771 " (most recent shown last)."),
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
772 self.__history,
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
773 current, False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 self.__insertHistory(cmd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
777 def showHistory(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 """
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
779 Public slot to show the shell history dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
781 from .ShellHistoryDialog import ShellHistoryDialog
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
782 dlg = ShellHistoryDialog(self.__history, self.vm, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 if dlg.exec_() == QDialog.Accepted:
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
784 self.__historyLists[self.clientType], idx = dlg.getHistory()
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
785 self.__history = self.__historyLists[self.clientType]
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
786 self.__setHistoryIndex(index=idx)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
788 def clearAllHistories(self):
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
789 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
790 Public method to clear all available histories and sync them.
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
791 """
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
792 Preferences.Prefs.settings.beginGroup("Shell/Histories")
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
793 for clientType in Preferences.Prefs.settings.childKeys():
5798
e4f9552f7f93 Started improving the Shell window history handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
794 self.__historyLists[clientType] = []
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
795 self.saveHistory(clientType)
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
796 Preferences.Prefs.settings.endGroup()
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
797
5710
b5809b948010 Continued implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5709
diff changeset
798 self.clearHistory()
5108
f5cb9cb98e6a Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5020
diff changeset
799
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 def getClientType(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 Public slot to get the clients type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 @return client type (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 return self.clientType
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 def __getBanner(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 Private method to get the banner for the remote interpreter.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 It requests the interpreter version and platform running on the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 debug client side.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 if self.passive:
6639
86f10cfa3653 Shell: fixed an issue calling __writeBanner() with too few arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6633
diff changeset
816 self.__writeBanner('', '', '', '')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 self.dbs.remoteBanner()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
820 def __writeBanner(self, version, platform, dbgclient, venvName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 Private method to write a banner with info from the debug client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
824 @param version interpreter version string
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
825 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
826 @param platform platform of the remote interpreter
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
827 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
828 @param dbgclient debug client variant used
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
829 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
830 @param venvName name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
831 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2474
diff changeset
833 super(Shell, self).clear()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 if self.passive and not self.dbs.isConnected():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
835 self.__write(self.tr('Passive Debug Mode'))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
836 self.__write(self.tr('\nNot connected'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 else:
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
838 self.__currentVenv = venvName
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
839 version = version.replace("#", self.tr("No."))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 if platform != "" and dbgclient != "":
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
841 self.__write(
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
842 self.tr('{0} on {1}, {2}')
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
843 .format(version, platform, dbgclient))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.__write(version)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
846 if venvName:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6573
diff changeset
847 self.__write("\n[{0}]".format(venvName))
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
848
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
849 self.virtualEnvironmentChanged.emit(venvName)
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6580
diff changeset
850 Preferences.setShell("LastVirtualEnvironment", venvName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 self.__write('\n')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 self.__write(sys.ps1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 def __writePrompt(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
857 Private method to write the prompt using a write queue.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
859 self.queueText.emit(self.inContinue and sys.ps2 or sys.ps1)
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
860
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 def __clientStatement(self, more):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 Private method to handle the response from the debugger client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 @param more flag indicating that more user input is required (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 if not self.inRawMode:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 self.inContinue = more
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 self.__writePrompt()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 self.inCommandExecution = False
6580
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
871
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
872 def __clientException(self, exceptionType, exceptionMessage, stackTrace):
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
873 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
874 Private method to handle an exception of the client.
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
875
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
876 @param exceptionType type of exception raised (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
877 @param exceptionMessage message given by the exception (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
878 @param stackTrace list of stack entries (list of string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
879 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
880 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
881
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
882 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
883 not self.__windowed and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
884 Preferences.getDebugger("ShowExceptionInShell")
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
885 ):
5126
d28b92dabc2b Fixed two little issues related to wrong parameter types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5108
diff changeset
886 if exceptionType:
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
887 if stackTrace:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
888 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
889 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
890 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
891 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
892 exceptionMessage,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
893 stackTrace[0][0],
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
894 stackTrace[0][1]
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
895 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
896 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
897 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
898 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
899 self.tr('Exception "{0}"\n{1}\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
900 .format(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
901 exceptionType,
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
902 exceptionMessage)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
903 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
904
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
905 def __clientSyntaxError(self, message, filename, lineNo, characterNo):
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
906 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
907 Private method to handle a syntax error in the debugged program.
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
908
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
909 @param message message of the syntax error (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
910 @param filename translated filename of the syntax error position
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
911 (string)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
912 @param lineNo line number of the syntax error position (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
913 @param characterNo character number of the syntax error position
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
914 (integer)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
915 """
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
916 self .__clientError()
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
917
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
918 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
919 not self.__windowed and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
920 Preferences.getDebugger("ShowExceptionInShell")
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
921 ):
3974
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
922 if message is None:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
923 self.__write(self.tr("Unspecified syntax error.\n"))
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
924 else:
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
925 self.__write(
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
926 self.tr('Syntax error "{1}" in file {0} at line {2},'
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
927 ' character {3}.\n')
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
928 .format(filename, message, lineNo, characterNo)
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
929 )
01991e605ba0 Added capability to show exceptions in the shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
930
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
931 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs):
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
932 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
933 Private method to handle a signal generated on the client side.
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
934
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
935 @param message message of the syntax error
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
936 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
937 @param filename translated filename of the syntax error position
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
938 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
939 @param lineNo line number of the syntax error position
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
940 @type int
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
941 @param funcName name of the function causing the signal
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
942 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
943 @param funcArgs function arguments
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
944 @type str
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
945 """
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
946 self.__clientError()
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
947
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
948 self.__write(
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
949 self.tr("""Signal "{0}" generated in file {1} at line {2}.\n"""
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
950 """Function: {3}({4})""")
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
951 .format(message, filename, lineNo, funcName, funcArgs)
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
952 )
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
953
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 def __clientError(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 Private method to handle an error in the client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 self.inCommandExecution = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 self.interruptCommandExecution = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 self.inContinue = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 def __getEndPos(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 Private method to return the line and column of the last character.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 @return tuple of two values (int, int) giving the line and column
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 line = self.lines() - 1
1743
4f9afcd8eb9d Fixed a unicode issue in the terminal and interpreter shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
969 return (line, len(self.text(line)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
971 def __writeQueued(self, s):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 """
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
973 Private method to display some text using a write queue.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 """
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
977 self.queueText.emit(s)
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
978
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
979 def __concatenateText(self, text):
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
980 """
6478
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
981 Private slot to queue text and process it in one step.
6335
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
982
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
983 @param text text to be appended
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
984 @type str
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
985 """
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
986 self.__queuedText += text
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
987 if self.__blockTextProcessing:
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
988 return
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
989
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
990 self.__blockTextProcessing = True
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
991 # Get all text which is still waiting for output
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
992 QApplication.processEvents()
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
993
56d3b6722b3c Shell.py: Added a patch provided by Tobias Rzepka to avoid freeze of eric when printing a lot. Original patch with some modifications and added source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6305
diff changeset
994 # Finally process the accumulated text
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
995 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
996
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 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
998 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
999
082d58e2415e Shell: another attempt to properly fix the 'writing prompt' issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6578
diff changeset
1000 # 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
1001 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
1002 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
1003
f76f5bd81a90 Shell: fixed an issue with the redirected input() method caused by the queued output change done back in June 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6387
diff changeset
1004 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
1005 """
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
1006 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
1007
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
1008 @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
1009 @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
1010 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 line, col = self.__getEndPos()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 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
1013 self.insert(Utilities.filterAnsiSequences(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 self.prline, self.prcol = self.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 self.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 self.ensureLineVisible(self.prline)
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 def __writeStdOut(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 Private method to display some text with StdOut label.
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 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1024 self.__write(self.tr("StdOut: {0}").format(s))
0
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 def __writeStdErr(self, s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 Private method to display some text with StdErr label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 @param s text to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1032 self.__write(self.tr("StdErr: {0}").format(s))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 def __raw_input(self, s, echo):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 Private method to handle raw input.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 @param s prompt to be displayed (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 @param echo Flag indicating echoing of the input (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 """
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
1041 # 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
1042 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
1043
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 self.setFocus()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 self.inRawMode = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 self.echoInput = echo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 self.__write(s)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 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
1049 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
1050 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
1051 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
1052 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
1053 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
1054 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
1055 self.prompt = buf
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1056 # move cursor to end of line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1057 self.moveCursorToEOL()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1059 def paste(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1060 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1061 Public slot to handle the paste action.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062 """
3631
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1063 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
1064 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
1065 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
1066 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 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
1074 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
1075 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
1076 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
1077 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
1078 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
1079
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1080 # 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
1081 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
1082 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
1083 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
1084 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
1085 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
1086 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
1087 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
1088 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
1089 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
1090 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
1091 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
1092 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
1093
6029
0ce26b97e2c0 Fixed an issue in the Python shell window executing pasted lines containing some indentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5991
diff changeset
1094 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
1095 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
1096
2f5169646a4a Shell: Paste at current location and a bug in using history fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3621
diff changeset
1097 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
1098 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
1099 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
1100 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
1101 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
1102 self.setCursorPosition(line, pos)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1103
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1104 def __middleMouseButton(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1105 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1106 Private method to handle the middle mouse button press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1107 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents: