QScintilla/Editor.py

branch
maintenance
changeset 6050
25a4ddb25ca4
parent 6004
548a9ba8c970
parent 6048
82ad8ec9548c
child 6097
bf18415da0c7
--- a/QScintilla/Editor.py	Sat Dec 02 12:40:52 2017 +0100
+++ b/QScintilla/Editor.py	Sun Dec 31 18:27:40 2017 +0100
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2002 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2002 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -1180,6 +1180,9 @@
         self.marginMenuActs["PreviousChangeMarker"] = \
             self.indicMarginMenu.addAction(
                 self.tr('Previous change'), self.previousChange)
+        self.marginMenuActs["ClearChangeMarkers"] = \
+            self.indicMarginMenu.addAction(
+                self.tr('Clear changes'), self.__deleteAllChangeMarkers)
         
         self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
         
@@ -1248,6 +1251,9 @@
         self.marginMenuActs["PreviousChangeMarker"] = \
             self.marginMenu.addAction(
                 self.tr('Previous change'), self.previousChange)
+        self.marginMenuActs["ClearChangeMarkers"] = \
+            self.marginMenu.addAction(
+                self.tr('Clear changes'), self.__deleteAllChangeMarkers)
         self.marginMenu.addSeparator()
         self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction(
             self.tr('LMB toggles bookmarks'), self.__lmBbookmarks)
@@ -1616,7 +1622,6 @@
         self.setLexer(self.lexer_)
         self.__setMarginsDisplay()
         if self.lexer_.lexer() == "container" or self.lexer_.lexer() is None:
-            self.setStyleBits(self.lexer_.styleBitsNeeded())
             self.SCN_STYLENEEDED.connect(self.__styleNeeded)
         
         # get the font for style 0 and set it as the default font
@@ -2796,7 +2801,7 @@
         
     def previousChange(self):
         """
-        Public slot to handle the 'Previous task' context menu action.
+        Public slot to handle the 'Previous change' context menu action.
         """
         line, index = self.getCursorPosition()
         if line == 0:
@@ -4539,6 +4544,8 @@
                 return
             elif char == '(':
                 self.cancelList()
+            else:
+                self.__acTimer.stop()
         
         if self.callTipsStyle() != QsciScintilla.CallTipsNone and \
            self.lexer_ is not None and chr(charNumber) in '()':
@@ -4574,6 +4581,14 @@
         
         return False
     
+    def __autocompletionCancelled(self):
+        """
+        Private slot to handle the cancellation of an auto-completion list.
+        """
+        self.__acWatchdog.stop()
+        
+        self.__acText = ""
+    
     #################################################################
     ## auto-completion hook interfaces
     #################################################################
@@ -4610,6 +4625,7 @@
             if self.autoCompletionThreshold() > 0:
                 self.setAutoCompletionThreshold(0)
             self.SCN_CHARADDED.connect(self.__charAdded)
+            self.SCN_AUTOCCANCELLED.connect(self.__autocompletionCancelled)
         
         if async:
             self.__completionListAsyncHookFunctions[key] = func
@@ -4632,6 +4648,7 @@
         if not self.__completionListHookFunctions and \
            not self.__completionListAsyncHookFunctions:
             self.SCN_CHARADDED.disconnect(self.__charAdded)
+            self.SCN_AUTOCCANCELLED.disconnect(self.__autocompletionCancelled)
             if self.autoCompletionThreshold() == 0:
                 self.setAutoCompletionThreshold(
                     Preferences.getEditor("AutoCompletionThreshold"))
@@ -4660,6 +4677,9 @@
             # auto-completion is disabled
             return
         
+        if self.isListActive():
+            self.cancelList()
+        
         if self.__completionListHookFunctions or \
            self.__completionListAsyncHookFunctions:
             if auto and Preferences.getEditor("AutoCompletionTimeout"):
@@ -4804,6 +4824,7 @@
             if len(lst) > 1:
                 txt = lst[0]
             
+            self.beginUndoAction()
             if Preferences.getEditor("AutoCompletionReplaceWord"):
                 self.selectCurrentWord()
                 self.removeSelectedText()
@@ -4818,6 +4839,7 @@
                 elif wLeft:
                     txt = txt[len(wLeft):]
             self.insert(txt)
+            self.endUndoAction()
             self.setCursorPosition(line, col + len(txt))
         elif listId == TemplateCompletionListID:
             self.__applyTemplate(txt, self.getLanguage())
@@ -5340,9 +5362,12 @@
         if self.__hasChangeMarkers:
             self.marginMenuActs["PreviousChangeMarker"].setEnabled(True)
             self.marginMenuActs["NextChangeMarker"].setEnabled(True)
+            self.marginMenuActs["ClearChangeMarkers"].setEnabled(True)
+            
         else:
             self.marginMenuActs["PreviousChangeMarker"].setEnabled(False)
             self.marginMenuActs["NextChangeMarker"].setEnabled(False)
+            self.marginMenuActs["ClearChangeMarkers"].setEnabled(False)
         
         self.showMenu.emit("Margin", self.sender(), self)
         

eric ide

mercurial