mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
New function 'window-cursor-info'
* src/window.c (Fwindow_cursor_info): New function. (syms_of_window): Defsubr it. * doc/lispref/windows.texi (Window Point): Document it. * etc/NEWS: Announce new function. (Bug#80023)
This commit is contained in:
parent
82e0951bda
commit
48b80a1e2b
3 changed files with 76 additions and 0 deletions
|
|
@ -5927,6 +5927,40 @@ This function returns the cursor type of @var{window}, defaulting to the
|
|||
selected window.
|
||||
@end defun
|
||||
|
||||
@defun window-cursor-info &optional window
|
||||
This function returns information about the cursor of @var{window},
|
||||
defaulting to the selected window.
|
||||
|
||||
The value returned by the function is a vector of the form
|
||||
@w{@code{[@var{type} @var{x} @var{y} @var{width} @var{height}
|
||||
@var{ascent}]}}. Here's the description of each components of this
|
||||
vector:
|
||||
|
||||
@table @var
|
||||
@item type
|
||||
The type of the cursor, a symbol. This is the same value returned by
|
||||
@code{window-cursor-type}.
|
||||
|
||||
@item x
|
||||
@itemx y
|
||||
The pixel coordinates of the cursor's top-left corner, relative to the
|
||||
top-left corner of @var{window}'s text area.
|
||||
|
||||
@item width
|
||||
@itemx height
|
||||
The pixel dimensions of the cursor.
|
||||
|
||||
@item ascent
|
||||
The number of pixels the cursor extends above the baseline.
|
||||
@end table
|
||||
|
||||
If the cursor is not currently displayed for @var{window}, this function
|
||||
returns @code{nil}.
|
||||
|
||||
Any element except the first one in the returned vector may be
|
||||
@code{-1}, meaning the actual value is currently unavailable.
|
||||
@end defun
|
||||
|
||||
@node Window Start and End
|
||||
@section The Window Start and End Positions
|
||||
@cindex window start position
|
||||
|
|
|
|||
6
etc/NEWS
6
etc/NEWS
|
|
@ -440,6 +440,12 @@ adjacent windows and subsequently operate on that parent.
|
|||
'uncombine-window' can then be used to restore the window configuration
|
||||
to the state it had before running 'combine-windows'.
|
||||
|
||||
+++
|
||||
*** New function 'window-cursor-info'.
|
||||
This function returns a vector of pixel-level information about the
|
||||
physical cursor in a given window, including its type, coordinates,
|
||||
dimensions, and ascent.
|
||||
|
||||
** Frames
|
||||
|
||||
+++
|
||||
|
|
|
|||
36
src/window.c
36
src/window.c
|
|
@ -8646,6 +8646,41 @@ WINDOW must be a live window and defaults to the selected one. */)
|
|||
return decode_live_window (window)->cursor_type;
|
||||
}
|
||||
|
||||
DEFUN ("window-cursor-info", Fwindow_cursor_info, Swindow_cursor_info,
|
||||
0, 1, 0,
|
||||
doc: /* Return information about the cursor of WINDOW.
|
||||
WINDOW must be a live window and defaults to the selected one.
|
||||
|
||||
The returned value is a vector of 6 elements:
|
||||
[TYPE X Y WIDTH HEIGHT ASCENT]
|
||||
where
|
||||
TYPE is the symbol representing the type of the cursor. See
|
||||
`cursor-type' for the meaning of the returned value.
|
||||
X and Y are pixel coordinates of the cursor's top-left corner, relative
|
||||
to the top-left corner of WINDOW's text area.
|
||||
WIDTH and HEIGHT are the pixel dimensions of the cursor.
|
||||
ASCENT is the number of pixels the cursor extends above the baseline.
|
||||
|
||||
If the cursor is not currently displayed for WINDOW, return nil.
|
||||
|
||||
Note that any element except the first one in the returned vector may be
|
||||
-1 if the actual value is currently unavailable. */)
|
||||
(Lisp_Object window)
|
||||
{
|
||||
struct window *w = decode_live_window (window);
|
||||
|
||||
if (!w->phys_cursor_on_p)
|
||||
return Qnil;
|
||||
|
||||
return CALLN (Fvector,
|
||||
w->cursor_type,
|
||||
make_fixnum (w->phys_cursor.x),
|
||||
make_fixnum (w->phys_cursor.y),
|
||||
make_fixnum (w->phys_cursor_width),
|
||||
make_fixnum (w->phys_cursor_height),
|
||||
make_fixnum (w->phys_cursor_ascent));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
Scroll bars
|
||||
|
|
@ -9617,5 +9652,6 @@ name to `'ignore'. */);
|
|||
defsubr (&Sset_window_parameter);
|
||||
defsubr (&Swindow_discard_buffer);
|
||||
defsubr (&Swindow_cursor_type);
|
||||
defsubr (&Swindow_cursor_info);
|
||||
defsubr (&Sset_window_cursor_type);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue