# $mouse-pos(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

$mouse-pos - Mouse position information

## SYNOPSIS

$mouse-pos integer

## DESCRIPTION

$mouse-pos is generated by invocation of the command set-cursor-to-mouse(2). The variable is set to a value that indicates the position of the mouse within a window. The values to the mouse intersection are interpreted as follows:-

0 - Text area

Intersection with the window text area.

1 - Message Line

Intersection with the message line.

2 - Mode Line

Intersection with the mode line.

3 - Horizontal Separator

Intersection with the horizontal window separator. This value is only set if a scroll bar is not present.

4 - Up Arrow

Intersection with the scroll bar up-arrow character.

5 - Upper Shaft

Intersection with the scroll bar upper shaft (above the scroll box).

6 - Scroll Box

Intersection with the scroll bar scroll box.

7 - Lower Shaft

Intersection with the scroll bar lower shaft (below the scroll box).

8 - Down Arrow

Intersection with the scroll bar down-arrow character.

9 - Corner

Intersection with the window corner, that is the character at the intersection of the scroll bar (or separator) and the mode line.

10 - Menu Line

Intersection with the menu line.

255 - Error

The position of the mouse could not be determined. This value should not arise, if it does then it is an indication that the window structure is probably corrupted. A delete-other-windows(2) is suggested or rapid exit from the editor after a save-some-buffers(2) command to save any edits (latter option is preferred).

Bit 4 - 2nd Column

Bit 4 (16) is set if 2 character column scroll bar or vertical window separator is in effect and the cursor exists in the second column This value is bitwise OR'ed with the aforementioned intersection values.

## EXAMPLE

The following macro can be used to print out the current position of the mouse, try binding the macro to the "`mouse-move`" key:

    define-macro print-mouse-position
        !force set-cursor-to-mouse
        set-variable #l0 &band $mouse-pos 15
        !if &equ #l0 0
            ml-write "Mouse in text window"
        !elif &equ #l0 1
            ml-write "Mouse on message line"
        !elif &equ #l0 2
            ml-write "Mouse on Mode line"
        !elif &and &gre #l0 2 &les #l0 10
            ml-write "Mouse on scroll bar"
        !elif &equ #l0 10
            ml-write "Mouse on corner"
        !elif &equ #l0 11
            ml-write "Mouse on menu line"
        !endif
    !emacro

    global-bind-key print-mouse-position mouse-move

$mouse-pos is utilized by the mouse picking code, found in macro file `mouse.emf`.

## SEE ALSO

$mouse-x(5), $mouse-y(5), set-cursor-to-mouse(2), set-scroll-with-mouse(2).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>