Package Task :: Module CaretTask
[hide private]
[frames] | no frames]

Source Code for Module Task.CaretTask

  1  ''' 
  2  Defines a Task to execute when the caret changes. 
  3   
  4  @author: Pete Brunet 
  5  @author: Larry Weiss 
  6  @author: Peter Parente 
  7  @organization: IBM Corporation 
  8  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
  9  @license: The BSD License 
 10   
 11  All rights reserved. This program and the accompanying materials are made  
 12  available under the terms of the BSD license which accompanies 
 13  this distribution, and is available at 
 14  U{http://www.opensource.org/licenses/bsd-license.php} 
 15  ''' 
 16  import Base, EventTask 
 17  import AEEvent 
 18   
19 -class CaretTask(EventTask.EventTask):
20 ''' 21 Executed when a caret change occurs. 22 23 This class registers its name and whether it should be monitored by default 24 in an L{AEMonitor} using the L{Base.registerTaskType} function when this 25 module is first imported. The L{AEMonitor} can use this information to build 26 its menus. 27 ''' 28 Base.registerTaskType('CaretTask', True) 29
30 - def getEventType(self):
31 ''' 32 @return: Type of L{AEEvent} this L{Task} wants to handle 33 @rtype: class 34 ''' 35 return AEEvent.CaretChange
36
37 - def update(self, por, text, text_offset, added, layer, **kwargs):
38 ''' 39 Updates this L{Task} in response to a consumed caret change event. Called by 40 L{Tier.Tier._executeTask}. 41 42 @param por: Point of regard for the related accessible 43 @type por: L{POR} 44 @param text: The text inserted, deleted or the line of the caret 45 @type text: string 46 @param text_offset: The offset of the inserted/deleted text or the absolute 47 offset when movement only 48 @type text_offset: integer 49 @param added: True when text added, False when text deleted, and None 50 (the default) when event is for caret movement only 51 @type added: boolean 52 @param layer: Layer on which the event occurred 53 @type layer: integer 54 ''' 55 pass
56
57 - def execute(self, por, text, text_offset, added, layer, **kwargs):
58 ''' 59 Executes this L{Task} in response to a caret change event. Called by 60 L{Tier.Tier._executeTask}. 61 62 @param por: Point of regard for the related accessible 63 @type por: L{POR} 64 @param text: The text inserted, deleted or the line of the caret 65 @type text: string 66 @param text_offset: The offset of the inserted/deleted text or the absolute 67 offset when movement only 68 @type text_offset: integer 69 @param added: True when text added, False when text deleted, and None 70 (the default) when event is for caret movement only 71 @type added: boolean 72 @param layer: Layer on which the event occurred 73 @type layer: integer 74 @return: True to allow other L{Task}s to process this event 75 @rtype: boolean 76 ''' 77 if added is None: 78 return self.executeMoved(por=por, text=text, text_offset=text_offset, 79 layer=layer, **kwargs) 80 elif added: 81 return self.executeInserted(por=por, text=text, text_offset=text_offset, 82 layer=layer, **kwargs) 83 else: 84 return self.executeDeleted(por=por, text=text, text_offset=text_offset, 85 layer=layer, **kwargs)
86
87 - def executeInserted(self, por, text, text_offset, layer, **kwargs):
88 ''' 89 Executes this L{Task} in response to a caret insert event. Called by 90 L{execute}. 91 92 @param por: Point of regard for the related accessible 93 @type por: L{POR} 94 @param text: The text inserted, deleted or the line of the caret 95 @type text: string 96 @param text_offset: The offset of the inserted/deleted text or the absolute 97 offset when movement only 98 @type text_offset: integer 99 @param layer: Layer on which the event occurred 100 @type layer: integer 101 @return: True to allow other L{Task}s to process this event 102 @rtype: boolean 103 ''' 104 return True
105
106 - def executeMoved(self, por, text, text_offset, layer, **kwargs):
107 ''' 108 Executes this L{Task} in response to a caret movement event. Called by 109 L{execute}. 110 111 @param por: Point of regard for the related accessible 112 @type por: L{POR} 113 @param text: The text inserted, deleted or the line of the caret 114 @type text: string 115 @param text_offset: The offset of the inserted/deleted text or the absolute 116 offset when movement only 117 @type text_offset: integer 118 @param layer: Layer on which the event occurred 119 @type layer: integer 120 @return: True to allow other L{Task}s to process this event 121 @rtype: boolean 122 ''' 123 return True
124
125 - def executeDeleted(self, por, text, text_offset, layer, **kwargs):
126 ''' 127 Executes this L{Task} in response to a caret delete event. Called by 128 L{execute}. 129 130 @param por: Point of regard for the related accessible 131 @type por: L{POR} 132 @param text: The text inserted, deleted or the line of the caret 133 @type text: string 134 @param text_offset: The offset of the inserted/deleted text or the absolute 135 offset when movement only 136 @type text_offset: integer 137 @param layer: Layer on which the event occurred 138 @type layer: integer 139 @return: True to allow other L{Task}s to process this event 140 @rtype: boolean 141 ''' 142 return True
143