src/eric7/QScintilla/Editor.py

branch
eric7
changeset 9624
b47dfa7a137d
parent 9619
7033f25b1462
child 9643
10839ab864e0
equal deleted inserted replaced
9623:9c1f429cb56b 9624:b47dfa7a137d
38 QPrinter, 38 QPrinter,
39 QPrintPreviewDialog, 39 QPrintPreviewDialog,
40 ) 40 )
41 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit, QMenu 41 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit, QMenu
42 42
43 from eric7 import Preferences, Utilities 43 from eric7 import Globals, Preferences, Utilities
44 from eric7.CodeFormatting.BlackFormattingAction import BlackFormattingAction 44 from eric7.CodeFormatting.BlackFormattingAction import BlackFormattingAction
45 from eric7.CodeFormatting.BlackUtilities import aboutBlack 45 from eric7.CodeFormatting.BlackUtilities import aboutBlack
46 from eric7.CodeFormatting.IsortFormattingAction import IsortFormattingAction 46 from eric7.CodeFormatting.IsortFormattingAction import IsortFormattingAction
47 from eric7.CodeFormatting.IsortUtilities import aboutIsort 47 from eric7.CodeFormatting.IsortUtilities import aboutIsort
48 from eric7.EricGui import EricPixmapCache 48 from eric7.EricGui import EricPixmapCache
49 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor 49 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor
50 from eric7.EricUtilities.EricCache import EricCache 50 from eric7.EricUtilities.EricCache import EricCache
51 from eric7.EricWidgets import EricFileDialog, EricMessageBox 51 from eric7.EricWidgets import EricFileDialog, EricMessageBox
52 from eric7.EricWidgets.EricApplication import ericApp 52 from eric7.EricWidgets.EricApplication import ericApp
53 from eric7.Globals import recentNameBreakpointConditions 53 from eric7.Globals import recentNameBreakpointConditions
54 from eric7.SystemUtilities import OSUtilities, PythonUtilities
54 from eric7.UI import PythonDisViewer 55 from eric7.UI import PythonDisViewer
55 from eric7.Utilities import MouseUtilities 56 from eric7.Utilities import MouseUtilities
56 57
57 from . import Exporters, Lexers, TypingCompleters 58 from . import Exporters, Lexers, TypingCompleters
58 from .EditorMarkerMap import EditorMarkerMap 59 from .EditorMarkerMap import EditorMarkerMap
1856 bindName = self.__bindName(self.text(0)) 1857 bindName = self.__bindName(self.text(0))
1857 if bindName: 1858 if bindName:
1858 language = Preferences.getEditorLexerAssoc(bindName) 1859 language = Preferences.getEditorLexerAssoc(bindName)
1859 if language == "Python": 1860 if language == "Python":
1860 # correction for Python 1861 # correction for Python
1861 pyVer = Utilities.determinePythonVersion(filename, self.text(0), self) 1862 pyVer = PythonUtilities.determinePythonVersion(
1863 filename, self.text(0), self
1864 )
1862 language = "Python{0}".format(pyVer) 1865 language = "Python{0}".format(pyVer)
1863 if language in [ 1866 if language in [
1864 "Python3", 1867 "Python3",
1865 "MicroPython", 1868 "MicroPython",
1866 "Cython", 1869 "Cython",
2162 Private method to return the Python main version or 0 if it's 2165 Private method to return the Python main version or 0 if it's
2163 not a Python file at all. 2166 not a Python file at all.
2164 2167
2165 @return Python version or 0 if it's not a Python file (int) 2168 @return Python version or 0 if it's not a Python file (int)
2166 """ 2169 """
2167 return Utilities.determinePythonVersion(self.fileName, self.text(0), self) 2170 return PythonUtilities.determinePythonVersion(self.fileName, self.text(0), self)
2168 2171
2169 def isPyFile(self): 2172 def isPyFile(self):
2170 """ 2173 """
2171 Public method to return a flag indicating a Python (2 or 3) file. 2174 Public method to return a flag indicating a Python (2 or 3) file.
2172 2175
3414 path = self.project.getProjectPath() 3417 path = self.project.getProjectPath()
3415 3418
3416 if not path and self.fileName: 3419 if not path and self.fileName:
3417 path = os.path.dirname(self.fileName) 3420 path = os.path.dirname(self.fileName)
3418 if not path: 3421 if not path:
3419 path = Preferences.getMultiProject("Workspace") or Utilities.getHomeDir() 3422 path = Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir()
3420 3423
3421 if self.fileName: 3424 if self.fileName:
3422 filterPattern = "(*{0})".format(os.path.splitext(self.fileName)[1]) 3425 filterPattern = "(*{0})".format(os.path.splitext(self.fileName)[1])
3423 for fileFilter in Lexers.getSaveFileFiltersList(True): 3426 for fileFilter in Lexers.getSaveFileFiltersList(True):
3424 if filterPattern in fileFilter: 3427 if filterPattern in fileFilter:
6909 6912
6910 def macroLoad(self): 6913 def macroLoad(self):
6911 """ 6914 """
6912 Public method to load a macro from a file. 6915 Public method to load a macro from a file.
6913 """ 6916 """
6914 configDir = Utilities.getConfigDir() 6917 configDir = Globals.getConfigDir()
6915 fname = EricFileDialog.getOpenFileName( 6918 fname = EricFileDialog.getOpenFileName(
6916 self, 6919 self,
6917 self.tr("Load macro file"), 6920 self.tr("Load macro file"),
6918 configDir, 6921 configDir,
6919 self.tr("Macro files (*.macro)"), 6922 self.tr("Macro files (*.macro)"),
6948 6951
6949 def macroSave(self): 6952 def macroSave(self):
6950 """ 6953 """
6951 Public method to save a macro to a file. 6954 Public method to save a macro to a file.
6952 """ 6955 """
6953 configDir = Utilities.getConfigDir() 6956 configDir = Globals.getConfigDir()
6954 6957
6955 name, ok = self.__getMacroName() 6958 name, ok = self.__getMacroName()
6956 if not ok or not name: 6959 if not ok or not name:
6957 return # user abort 6960 return # user abort
6958 6961
8841 else: 8844 else:
8842 value = None 8845 value = None
8843 elif option == "DefaultEncoding": 8846 elif option == "DefaultEncoding":
8844 value = config["charset"] 8847 value = config["charset"]
8845 elif option == "InsertFinalNewline": 8848 elif option == "InsertFinalNewline":
8846 value = Utilities.toBool(config["insert_final_newline"]) 8849 value = Globals.toBool(config["insert_final_newline"])
8847 elif option == "StripTrailingWhitespace": 8850 elif option == "StripTrailingWhitespace":
8848 value = Utilities.toBool(config["trim_trailing_whitespace"]) 8851 value = Globals.toBool(config["trim_trailing_whitespace"])
8849 elif option == "TabWidth": 8852 elif option == "TabWidth":
8850 value = int(config["tab_width"]) 8853 value = int(config["tab_width"])
8851 elif option == "IndentWidth": 8854 elif option == "IndentWidth":
8852 value = config["indent_size"] 8855 value = config["indent_size"]
8853 if value == "tab": 8856 if value == "tab":

eric ide

mercurial