Changeset 4411 for libcaca


Ignore:
Timestamp:
Jul 2, 2010, 10:04:26 PM (9 years ago)
Author:
Alex Foulon
Message:
  • Bind event functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/caca/display.py

    r4408 r4411  
    156156
    157157    def get_event(self, event_mask, event, timeout):
    158         """ Poll the event queue for mouse or keyboard events matching the event mask
    159         and return the first matching event. Non-matching events are discarded.
    160         If event_mask is zero, the function returns immediately.
    161         The timeout value tells how long this function needs to wait for an event.
    162         A value of zero returns immediately and the function returns zero if no more events
    163         are pending in the queue. A negative value causes the function to wait indefinitely
    164         until a matching event is received.
    165         If not null, ev will be filled with information about the event received. If null,
    166         the function will return but no information about the event will be sent.
     158        """ Get the next mouse or keyboard input event.
    167159
    168160            event_mask  -- bitmask of requested events
     
    176168
    177169    def get_mouse_x(self):
    178         """ Return the X coordinate of the mouse position last time it was detected.
    179         This function is not reliable if the ncurses or S-Lang drivers are being used,
    180         because mouse position is only detected when the mouse is clicked.
    181         Other drivers such as X11 work well.
    182         """
    183 
     170        """ Return the X mouse coordinate.
     171        """
    184172        _lib.caca_get_mouse_x.argtypes = [Display]
    185173        _lib.caca_get_mouse_x.restype  = ctypes.c_int
     
    188176
    189177    def get_mouse_y(self):
    190         """ Return the Y coordinate of the mouse position last time it was detected.
    191         This function is not reliable if the ncurses or S-Lang drivers are being used,
    192         because mouse position is only detected when the mouse is clicked.
    193         Other drivers such as X11 work well.
    194         """
    195 
     178        """ Return the Y mouse coordinate.
     179        """
    196180        _lib.caca_get_mouse_y.argtypes = [Display]
    197181        _lib.caca_get_mouse_y.restype  = ctypes.c_int
     
    215199
    216200    def get_type(self):
    217         """ Return the type of an event. This function may always be called
    218             on an event after caca_get_event() was called, and its return value
    219             indicates which other functions may be called.
     201        """ Return an event's type.
    220202        """
    221203        _lib.caca_get_event_type.argtypes = [Event]
    222         _lib.caca_get_event_type.restype = ctypes.c_int
     204        _lib.caca_get_event_type.restype  = ctypes.c_int
    223205
    224206        return _lib.caca_get_event_type(self)
    225207
    226208    def get_key_ch(self):
    227         """ Return either the ASCII value for an event's key, or if the key is not
    228             an ASCII character, an appropriate KEY_* value
     209        """ Return a key press or key release event's value.
    229210        """
    230211        _lib.caca_get_event_key_ch.argtypes = [Event]
    231         _lib.caca_get_event_key_ch.restype = ctypes.c_int
     212        _lib.caca_get_event_key_ch.restype  = ctypes.c_int
    232213
    233214        return _lib.caca_get_event_key_ch(self)
    234215
    235216    def get_key_utf32(self):
    236         """ Return the UTF-32/UCS-4 value for an event's key if it resolves
    237             to a printable character.
    238         """
    239         _lib.caca_get_event_key_utf32.argtypes = [Event]
    240         _lib.caca_get_event_key_utf32.restype = ctypes.c_uint32
    241 
    242         return _lib.caca_get_event_key_utf32(self)
     217        """ Not implemented.
     218        """
     219        raise DisplayError, "Not implemented"
    243220
    244221    def get_key_utf8(self):
    245         """ Write the UTF-8 value for an event's key if it resolves to a
    246             printable character. Up to 6 UTF-8 bytes and a null termination
    247             are written.
     222        """ Return a key press or key release event's UTF-8 value.
    248223        """
    249224        # set buffer for writing utf8 value
    250         buf = ctypes.c_buffer(2)
     225        buf = ctypes.c_buffer(7)
    251226
    252227        _lib.caca_get_event_key_utf8.argtypes = [Event, ctypes.c_char_p]
    253         _lib.caca_get_event_key_utf8.restype = ctypes.c_int
     228        _lib.caca_get_event_key_utf8.restype  = ctypes.c_int
    254229
    255230        _lib.caca_get_event_key_utf8(self, buf)
     
    257232        return buf
    258233
     234    def get_mouse_button(self):
     235        """ Return a mouse press or mouse release event's button.
     236        """
     237        _lib.caca_get_event_mouse_button.argtypes = [Event]
     238        _lib.caca_get_event_mouse_button.restype  = ctypes.c_int
     239
     240        return _lib.caca_get_event_mouse_button(self)
     241
     242    def get_mouse_x(self):
     243        """ Return a mouse motion event's X coordinate.
     244        """
     245        _lib.caca_get_event_mouse_x.argtypes = [Event]
     246        _lib.caca_get_event_mouse_x.restype  = ctypes.c_int
     247
     248        return _lib.caca_get_event_mouse_x(self)
     249
     250    def get_mouse_y(self):
     251        """ Return a mouse motion event's Y coordinate.
     252        """
     253        _lib.caca_get_event_mouse_y.argtypes = [Event]
     254        _lib.caca_get_event_mouse_y.restype  = ctypes.c_int
     255
     256        return _lib.caca_get_event_mouse_y(self)
     257
     258    def get_resize_width(self):
     259        """ Return a resize event's display width value.
     260        """
     261        _lib.caca_get_event_resize_width.argtypes = [Event]
     262        _lib.caca_get_event_resize_width.restype  = ctypes.c_int
     263
     264        return _lib.caca_get_event_resize_width(self)
     265
     266    def get_resize_height(self):
     267        """ Return a resize event's display height value.
     268        """
     269        _lib.caca_get_event_resize_height.argtypes = [Event]
     270        _lib.caca_get_event_resize_height.restype  = ctypes.c_int
     271
     272        return _lib.caca_get_event_resize_height(self)
     273
Note: See TracChangeset for help on using the changeset viewer.