~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/QScintilla/TypingCompleters/CompleterBase.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-01-28 18:02:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128180225-6nrox6yrworh2c4v
Tags: 4.0.4-1ubuntu1
* Add python-qt3 to build-depends becuase that's where Ubuntu puts 
  pyqtconfig
* Change maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Copyright (c) 2007 Detlev Offenbach <detlev@die-offenbachs.de>
 
4
#
 
5
 
 
6
"""
 
7
Module implementing a base class for all typing completers.
 
8
 
 
9
Typing completers are classes that implement some convenience actions,
 
10
that are performed while the user is typing (e.g. insert ')' when the
 
11
user types '(').
 
12
"""
 
13
 
 
14
from PyQt4.QtCore import QObject, SIGNAL
 
15
 
 
16
class CompleterBase(QObject):
 
17
    """
 
18
    Class implementing the base class for all completers.
 
19
    """
 
20
    def __init__(self, editor, parent = None):
 
21
        """
 
22
        Constructor
 
23
        
 
24
        @param editor reference to the editor object (QScintilla.Editor)
 
25
        @param parent reference to the parent object (QObject)
 
26
            If parent is None, we set the editor as the parent.
 
27
        """
 
28
        if parent is None:
 
29
            parent = editor
 
30
        
 
31
        QObject.__init__(self, parent)
 
32
        
 
33
        self.editor = editor
 
34
        self.enabled = False
 
35
    
 
36
    def setEnabled(self, enable):
 
37
        """
 
38
        Public slot to set the enabled state.
 
39
        
 
40
        @param enabled flag indicating the new state (boolean)
 
41
        """
 
42
        if enable:
 
43
            if not self.enabled:
 
44
                self.connect(self.editor, SIGNAL("SCN_CHARADDED(int)"), self.charAdded)
 
45
        else:
 
46
            if self.enabled:
 
47
                self.disconnect(self.editor, SIGNAL("SCN_CHARADDED(int)"), self.charAdded)
 
48
        self.enabled = enable
 
49
    
 
50
    def charAdded(self, charNumber):
 
51
        """
 
52
        Public slot called to handle the user entering a character.
 
53
        
 
54
        Note 1: this slot must be overridden by subclasses implementing the
 
55
        specific behavior for the language.
 
56
        
 
57
        Note 2: charNumber can be greater than 255 because the editor is
 
58
        in UTF-8 mode by default.
 
59
        
 
60
        @param charNumber value of the character entered (integer)
 
61
        """
 
62
        pass    # just do nothing
 
63
    
 
64
    def readSettings(self):
 
65
        """
 
66
        Public slot called to reread the configuration parameters.
 
67
        
 
68
        Note: this slot should be overridden by subclasses having
 
69
        configurable parameters.
 
70
        """
 
71
        pass    # just do nothing