24 QTextEdit, |
24 QTextEdit, |
25 QToolButton, |
25 QToolButton, |
26 QWidget, |
26 QWidget, |
27 ) |
27 ) |
28 |
28 |
29 from eric7 import Globals, Preferences, Utilities |
29 from eric7 import Preferences |
30 from eric7.EricGui import EricPixmapCache |
30 from eric7.EricGui import EricPixmapCache |
31 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
31 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
32 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
32 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
33 from eric7.EricWidgets.EricApplication import ericApp |
33 from eric7.EricWidgets.EricApplication import ericApp |
34 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
34 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
35 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
35 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
36 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
36 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
|
37 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
37 from eric7.UI.Info import BugAddress |
38 from eric7.UI.Info import BugAddress |
38 |
39 |
39 from . import MicroPythonDevices, UF2FlashDialog |
40 from . import MicroPythonDevices, UF2FlashDialog |
40 from .MicroPythonFileManagerWidget import MicroPythonFileManagerWidget |
41 from .MicroPythonFileManagerWidget import MicroPythonFileManagerWidget |
41 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
42 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
538 Private slot to show the REPL context menu. |
539 Private slot to show the REPL context menu. |
539 |
540 |
540 @param pos position to show the menu at |
541 @param pos position to show the menu at |
541 @type QPoint |
542 @type QPoint |
542 """ |
543 """ |
543 if Globals.isMacPlatform(): |
544 if OSUtilities.isMacPlatform(): |
544 copyKeys = QKeySequence("Ctrl+C") |
545 copyKeys = QKeySequence("Ctrl+C") |
545 pasteKeys = QKeySequence("Ctrl+V") |
546 pasteKeys = QKeySequence("Ctrl+V") |
546 selectAllKeys = QKeySequence("Ctrl+A") |
547 selectAllKeys = QKeySequence("Ctrl+A") |
547 else: |
548 else: |
548 copyKeys = QKeySequence("Ctrl+Shift+C") |
549 copyKeys = QKeySequence("Ctrl+Shift+C") |
756 elif key == Qt.Key.Key_Home: |
757 elif key == Qt.Key.Key_Home: |
757 msg = b"\x1B[H" |
758 msg = b"\x1B[H" |
758 elif key == Qt.Key.Key_End: |
759 elif key == Qt.Key.Key_End: |
759 msg = b"\x1B[F" |
760 msg = b"\x1B[F" |
760 elif ( |
761 elif ( |
761 Globals.isMacPlatform() |
762 OSUtilities.isMacPlatform() |
762 and evt.modifiers() == Qt.KeyboardModifier.MetaModifier |
763 and evt.modifiers() == Qt.KeyboardModifier.MetaModifier |
763 ) or ( |
764 ) or ( |
764 not Globals.isMacPlatform() |
765 not OSUtilities.isMacPlatform() |
765 and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
766 and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
766 ): |
767 ): |
767 if Qt.Key.Key_A <= key <= Qt.Key.Key_Z: |
768 if Qt.Key.Key_A <= key <= Qt.Key.Key_Z: |
768 # devices treat an input of \x01 as Ctrl+A, etc. |
769 # devices treat an input of \x01 as Ctrl+A, etc. |
769 msg = bytes([1 + key - Qt.Key.Key_A]) |
770 msg = bytes([1 + key - Qt.Key.Key_A]) |
770 elif evt.modifiers() == ( |
771 elif evt.modifiers() == ( |
771 Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier |
772 Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier |
772 ) or ( |
773 ) or ( |
773 Globals.isMacPlatform() |
774 OSUtilities.isMacPlatform() |
774 and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
775 and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
775 ): |
776 ): |
776 if key == Qt.Key.Key_C: |
777 if key == Qt.Key.Key_C: |
777 self.replEdit.copy() |
778 self.replEdit.copy() |
778 msg = b"" |
779 msg = b"" |
1051 @return path of the port of the selected device |
1052 @return path of the port of the selected device |
1052 @rtype str |
1053 @rtype str |
1053 """ |
1054 """ |
1054 portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
1055 portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
1055 if portName: |
1056 if portName: |
1056 if Globals.isWindowsPlatform(): |
1057 if OSUtilities.isWindowsPlatform(): |
1057 # return it unchanged |
1058 # return it unchanged |
1058 return portName |
1059 return portName |
1059 else: |
1060 else: |
1060 # return with device path prepended |
1061 # return with device path prepended |
1061 return "/dev/{0}".format(portName) |
1062 return "/dev/{0}".format(portName) |
1423 act = self.__superMenu.addAction( |
1424 act = self.__superMenu.addAction( |
1424 self.tr("Show Time"), self.__showLocalAndDeviceTime |
1425 self.tr("Show Time"), self.__showLocalAndDeviceTime |
1425 ) |
1426 ) |
1426 act.setEnabled(self.__connected) |
1427 act.setEnabled(self.__connected) |
1427 self.__superMenu.addSeparator() |
1428 self.__superMenu.addSeparator() |
1428 if not Globals.isWindowsPlatform(): |
1429 if not OSUtilities.isWindowsPlatform(): |
1429 available = self.__mpyCrossAvailable() |
1430 available = self.__mpyCrossAvailable() |
1430 act = self.__superMenu.addAction( |
1431 act = self.__superMenu.addAction( |
1431 self.tr("Compile Python File"), self.__compileFile2Mpy |
1432 self.tr("Compile Python File"), self.__compileFile2Mpy |
1432 ) |
1433 ) |
1433 act.setEnabled(available) |
1434 act.setEnabled(available) |
1696 """ |
1697 """ |
1697 available = False |
1698 available = False |
1698 program = Preferences.getMicroPython("MpyCrossCompiler") |
1699 program = Preferences.getMicroPython("MpyCrossCompiler") |
1699 if not program: |
1700 if not program: |
1700 program = "mpy-cross" |
1701 program = "mpy-cross" |
1701 if Utilities.isinpath(program): |
1702 if FileSystemUtilities.isinpath(program): |
1702 available = True |
1703 available = True |
1703 else: |
1704 else: |
1704 if Utilities.isExecutable(program): |
1705 if FileSystemUtilities.isExecutable(program): |
1705 available = True |
1706 available = True |
1706 |
1707 |
1707 return available |
1708 return available |
1708 |
1709 |
1709 def __crossCompile(self, pythonFile="", title=""): |
1710 def __crossCompile(self, pythonFile="", title=""): |
1716 @type str |
1717 @type str |
1717 """ |
1718 """ |
1718 program = Preferences.getMicroPython("MpyCrossCompiler") |
1719 program = Preferences.getMicroPython("MpyCrossCompiler") |
1719 if not program: |
1720 if not program: |
1720 program = "mpy-cross" |
1721 program = "mpy-cross" |
1721 if not Utilities.isinpath(program): |
1722 if not FileSystemUtilities.isinpath(program): |
1722 EricMessageBox.critical( |
1723 EricMessageBox.critical( |
1723 self, |
1724 self, |
1724 title, |
1725 title, |
1725 self.tr( |
1726 self.tr( |
1726 """The MicroPython cross compiler""" |
1727 """The MicroPython cross compiler""" |