QScintilla/Editor.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3059
16c93928cfc5
child 3065
070b35dde35e
--- a/QScintilla/Editor.py	Fri Nov 01 15:48:48 2013 +0100
+++ b/QScintilla/Editor.py	Sun Nov 03 15:58:22 2013 +0100
@@ -260,10 +260,10 @@
         # define the margins markers
         self.__changeMarkerSaved = self.markerDefine(
             self.__createChangeMarkerPixmap(
-            "OnlineChangeTraceMarkerSaved"))
+                "OnlineChangeTraceMarkerSaved"))
         self.__changeMarkerUnsaved = self.markerDefine(
             self.__createChangeMarkerPixmap(
-            "OnlineChangeTraceMarkerUnsaved"))
+                "OnlineChangeTraceMarkerUnsaved"))
         self.breakpoint = \
             self.markerDefine(UI.PixmapCache.getPixmap("break.png"))
         self.cbreakpoint = \
@@ -324,11 +324,9 @@
                         self.trUtf8("Open File"),
                         self.trUtf8("""<p>The size of the file <b>{0}</b>"""
                                     """ is <b>{1} KB</b>."""
-                                    """ Do you really want to load it?</p>""")\
-                                    .format(
-                                        self.fileName,
-                                        QFileInfo(self.fileName).size() //
-                                            1024),
+                                    """ Do you really want to load it?</p>""")
+                        .format(self.fileName,
+                                QFileInfo(self.fileName).size() // 1024),
                         icon=E5MessageBox.Warning)
                     if not res:
                         raise IOError()
@@ -1180,8 +1178,8 @@
                     self.trUtf8("Export source"),
                     self.trUtf8(
                         """<p>No exporter available for the """
-                        """export format <b>{0}</b>. Aborting...</p>""")\
-                        .format(exporterFormat))
+                        """export format <b>{0}</b>. Aborting...</p>""")
+                    .format(exporterFormat))
         else:
             E5MessageBox.critical(
                 self,
@@ -1281,11 +1279,13 @@
         self.lexer_ = None
         self.__lexerReset = True
         self.setLexer()
-        self.setMonospaced(self.useMonospaced)
         if self.completer is not None:
             self.completer.setEnabled(False)
             self.completer = None
+        useMonospaced = self.useMonospaced
         self.__setTextDisplay()
+        self.setMonospaced(useMonospaced)
+        self.menuActs["MonospacedFont"].setChecked(self.useMonospaced)
         
         if not self.inLanguageChanged and propagate:
             self.inLanguageChanged = True
@@ -1304,6 +1304,8 @@
         @keyparam propagate flag indicating to propagate the change (boolean)
         @keyparam pyname name of the pygments lexer to use (string)
         """
+        self.menuActs["MonospacedFont"].setChecked(False)
+        
         self.__lexerReset = False
         self.__bindLexer(filename, pyname=pyname)
         self.__bindCompleter(filename)
@@ -1740,8 +1742,8 @@
             # 1) Determine by first line
             line0 = self.text(0)
             if line0.startswith("#!") and \
-               ("python2" in line0 or \
-                ("python" in line0 and not "python3" in line0)):
+               ("python2" in line0 or
+                    ("python" in line0 and not "python3" in line0)):
                 self.filetype = "Python2"
                 return True
             
@@ -2448,13 +2450,13 @@
         from Tasks.Task import Task
         markers = {
             Task.TypeWarning:
-                Preferences.getTasks("TasksWarningMarkers").split(),
+            Preferences.getTasks("TasksWarningMarkers").split(),
             Task.TypeNote:
-                Preferences.getTasks("TasksNoteMarkers").split(),
+            Preferences.getTasks("TasksNoteMarkers").split(),
             Task.TypeTodo:
-                Preferences.getTasks("TasksTodoMarkers").split(),
+            Preferences.getTasks("TasksTodoMarkers").split(),
             Task.TypeFixme:
-                Preferences.getTasks("TasksFixmeMarkers").split(),
+            Preferences.getTasks("TasksFixmeMarkers").split(),
         }
         txtList = self.text().split(self.getLineSeparator())
         
@@ -2690,7 +2692,7 @@
                 self,
                 self.trUtf8("File Modified"),
                 self.trUtf8("<p>The file <b>{0}</b> has unsaved changes.</p>")
-                    .format(fn),
+                .format(fn),
                 self.saveFile)
             if res:
                 self.vm.setEditorName(self, self.fileName)
@@ -2748,7 +2750,7 @@
         modified = False
         if (not Preferences.getEditor("TabForIndentation")) and \
                 Preferences.getEditor("ConvertTabsOnLoad") and \
-                not (self.lexer_ and \
+                not (self.lexer_ and
                      self.lexer_.alwaysKeepTabs()):
             txtExpanded = txt.expandtabs(Preferences.getEditor("TabWidth"))
             if txtExpanded != txt:
@@ -2843,7 +2845,7 @@
                 self.trUtf8('Save File'),
                 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>'
                             'Reason: {1}</p>')
-                    .format(fn, str(why)))
+                .format(fn, str(why)))
             return False
         
     def saveFile(self, saveas=False, path=None):
@@ -3317,13 +3319,13 @@
             # determine the start of the comment block
             begline = line
             while begline > 0 and \
-                  self.__isCommentedLine(self.text(begline - 1), commentStr):
+                    self.__isCommentedLine(self.text(begline - 1), commentStr):
                 begline -= 1
             # determine the end of the comment block
             endline = line
             lines = self.lines()
             while endline < lines and \
-                  self.__isCommentedLine(self.text(endline + 1), commentStr):
+                    self.__isCommentedLine(self.text(endline + 1), commentStr):
                 endline += 1
             
             self.setSelection(begline, 0, endline, self.lineLength(endline))
@@ -4660,8 +4662,8 @@
                     os.path.isfile("{0}.profile".format(basename)) or \
                     os.path.isfile("{0}.profile".format(tbasename))
                 coEnable = (
-                    coEnable or \
-                    os.path.isfile("{0}.coverage".format(basename)) or \
+                    coEnable or
+                    os.path.isfile("{0}.coverage".format(basename)) or
                     os.path.isfile("{0}.coverage".format(tbasename))) and \
                     self.project.isPy3Project()
         
@@ -4675,8 +4677,8 @@
                 os.path.isfile("{0}.profile".format(basename)) or \
                 os.path.isfile("{0}.profile".format(tbasename))
             coEnable = (
-                coEnable or \
-                os.path.isfile("{0}.coverage".format(basename)) or \
+                coEnable or
+                os.path.isfile("{0}.coverage".format(basename)) or
                 os.path.isfile("{0}.coverage".format(tbasename))) and \
                 self.isPy3File()
         
@@ -4935,8 +4937,8 @@
         @return flag indicating this editor should be saved (boolean)
         """
         return self.fileName is not None and \
-               not self.autosaveManuallyDisabled and \
-               not self.isReadOnly()
+            not self.autosaveManuallyDisabled and \
+            not self.isReadOnly()
 
 
     def __autoSyntaxCheck(self):
@@ -5641,7 +5643,7 @@
                 self.trUtf8("Error loading macro"),
                 self.trUtf8(
                     "<p>The macro file <b>{0}</b> could not be read.</p>")
-                    .format(fname))
+                .format(fname))
             return
         
         if len(lines) != 2:
@@ -5649,7 +5651,7 @@
                 self,
                 self.trUtf8("Error loading macro"),
                 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>")
-                    .format(fname))
+                .format(fname))
             return
         
         macro = QsciMacro(lines[1], self)
@@ -5703,7 +5705,7 @@
                 self.trUtf8("Error saving macro"),
                 self.trUtf8(
                     "<p>The macro file <b>{0}</b> could not be written.</p>")
-                    .format(fname))
+                .format(fname))
             return
         
     def macroRecordingStart(self):
@@ -6134,7 +6136,7 @@
                             self,
                             self.trUtf8("Drop Error"),
                             self.trUtf8("""<p><b>{0}</b> is not a file.</p>""")
-                                .format(fname))
+                            .format(fname))
             event.acceptProposedAction()
         else:
             super(Editor, self).dropEvent(event)
@@ -6234,7 +6236,7 @@
                 relFile)
             if ok and alias:
                 line, index = self.getCursorPosition()
-                self.insert('  <file alias="{1}">{0}</file>\n'\
+                self.insert('  <file alias="{1}">{0}</file>\n'
                             .format(relFile, alias))
                 self.setCursorPosition(line + 1, index)
         
@@ -6388,7 +6390,7 @@
                     elif len(templateNames) > 1:
                         self.showUserList(
                             TemplateCompletionListID,
-                            ["{0}?{1:d}".format(t, self.TemplateImageID) \
+                            ["{0}?{1:d}".format(t, self.TemplateImageID)
                              for t in templateNames])
                         return
         
@@ -6544,7 +6546,7 @@
             style = self.styleAt(pos)
             if self.lexer_ is not None:
                 return self.lexer_.isCommentStyle(style) or \
-                       self.lexer_.isStringStyle(style)
+                    self.lexer_.isStringStyle(style)
         return True
     
     @pyqtSlot(int)
@@ -6690,9 +6692,9 @@
             (boolean, boolean, boolean, boolean)
         """
         return self.fileName is not None and \
-                self.project.isOpen() and \
-                self.project.isProjectFile(self.fileName), \
-               self.__isShared, self.__inSharedEdit, self.__inRemoteSharedEdit
+            self.project.isOpen() and \
+            self.project.isProjectFile(self.fileName), \
+            self.__isShared, self.__inSharedEdit, self.__inRemoteSharedEdit
     
     def shareConnected(self, connected):
         """

eric ide

mercurial