Skip to main content

mouse_pixel_to_cell

Function mouse_pixel_to_cell 

Source
pub fn mouse_pixel_to_cell(
    m: Mouse,
    pixel_width: u16,
    pixel_height: u16,
    cols: u16,
    rows: u16,
) -> Mouse
Expand description

Convert an SGR-Pixel mouse payload to cell coordinates.

pixel_width and pixel_height are the terminal’s pixel dimensions (for example from Event::WindowPixelSize); cols and rows are the terminal grid dimensions. The returned Mouse keeps the original button and modifiers with x/y scaled into cell coordinates using integer division.

If either pixel dimension is zero, the corresponding output coordinate is zero. The function does not clamp to cols - 1 / rows - 1 and never panics.