HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/third_party/prompt_toolkit/layout/mouse_handlers.py
from __future__ import unicode_literals

from itertools import product
from collections import defaultdict

__all__ = (
    'MouseHandlers',
)


class MouseHandlers(object):
    """
    Two dimentional raster of callbacks for mouse events.
    """
    def __init__(self):
        def dummy_callback(cli, mouse_event):
            """
            :param mouse_event: `MouseEvent` instance.
            """

        # Map (x,y) tuples to handlers.
        self.mouse_handlers = defaultdict(lambda: dummy_callback)

    def set_mouse_handler_for_range(self, x_min, x_max, y_min, y_max, handler=None):
        """
        Set mouse handler for a region.
        """
        for x, y in product(range(x_min, x_max), range(y_min, y_max)):
            self.mouse_handlers[x,y] = handler