Mercurial > emacs
comparison lispref/display.texi @ 53467:a18219fcd84d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-12
Add section on button package to lisp reference manual
* lispref/display.texi (Buttons): New section.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 01 Jan 2004 04:20:43 +0000 |
parents | 1246d68686ac |
children | f641b341c5ec |
comparison
equal
deleted
inserted
replaced
53466:45bba74a091f | 53467:a18219fcd84d |
---|---|
18 * Warnings:: Displaying warning messages for the user. | 18 * Warnings:: Displaying warning messages for the user. |
19 * Invisible Text:: Hiding part of the buffer text. | 19 * Invisible Text:: Hiding part of the buffer text. |
20 * Selective Display:: Hiding part of the buffer text (the old way). | 20 * Selective Display:: Hiding part of the buffer text (the old way). |
21 * Overlay Arrow:: Display of an arrow to indicate position. | 21 * Overlay Arrow:: Display of an arrow to indicate position. |
22 * Temporary Displays:: Displays that go away automatically. | 22 * Temporary Displays:: Displays that go away automatically. |
23 * Overlays:: Use overlays to highlight parts of the buffer. | 23 * Overlays:: Use overlays to highlight parts of the buffer. |
24 * Width:: How wide a character or string is on the screen. | 24 * Width:: How wide a character or string is on the screen. |
25 * Faces:: A face defines a graphics style for text characters: | 25 * Faces:: A face defines a graphics style for text characters: |
26 font, colors, etc. | 26 font, colors, etc. |
27 * Fringes:: Controlling window fringes. | 27 * Fringes:: Controlling window fringes. |
28 * Scroll Bars:: Controlling vertical scroll bars. | 28 * Scroll Bars:: Controlling vertical scroll bars. |
29 * Display Property:: Enabling special display features. | 29 * Display Property:: Enabling special display features. |
30 * Images:: Displaying images in Emacs buffers. | 30 * Images:: Displaying images in Emacs buffers. |
31 * Buttons:: Adding clickable buttons to Emacs buffers. | |
31 * Blinking:: How Emacs shows the matching open parenthesis. | 32 * Blinking:: How Emacs shows the matching open parenthesis. |
32 * Inverse Video:: Specifying how the screen looks. | 33 * Inverse Video:: Specifying how the screen looks. |
33 * Usual Display:: The usual conventions for displaying nonprinting chars. | 34 * Usual Display:: The usual conventions for displaying nonprinting chars. |
34 * Display Tables:: How to specify other conventions. | 35 * Display Tables:: How to specify other conventions. |
35 * Beeping:: Audible signal to the user. | 36 * Beeping:: Audible signal to the user. |
36 * Window Systems:: Which window system is being used. | 37 * Window Systems:: Which window system is being used. |
37 @end menu | 38 @end menu |
38 | 39 |
39 @node Refresh Screen | 40 @node Refresh Screen |
964 object that belongs to a particular buffer, and has a specified | 965 object that belongs to a particular buffer, and has a specified |
965 beginning and end. It also has properties that you can examine and set; | 966 beginning and end. It also has properties that you can examine and set; |
966 these affect the display of the text within the overlay. | 967 these affect the display of the text within the overlay. |
967 | 968 |
968 @menu | 969 @menu |
969 * Overlay Properties:: How to read and set properties. | 970 * Overlay Properties:: How to read and set properties. |
970 What properties do to the screen display. | 971 What properties do to the screen display. |
971 * Managing Overlays:: Creating and moving overlays. | 972 * Managing Overlays:: Creating and moving overlays. |
972 * Finding Overlays:: Searching for overlays. | 973 * Finding Overlays:: Searching for overlays. |
973 @end menu | 974 @end menu |
974 | 975 |
1422 | 1423 |
1423 @menu | 1424 @menu |
1424 * Standard Faces:: The faces Emacs normally comes with. | 1425 * Standard Faces:: The faces Emacs normally comes with. |
1425 * Defining Faces:: How to define a face with @code{defface}. | 1426 * Defining Faces:: How to define a face with @code{defface}. |
1426 * Face Attributes:: What is in a face? | 1427 * Face Attributes:: What is in a face? |
1427 * Attribute Functions:: Functions to examine and set face attributes. | 1428 * Attribute Functions:: Functions to examine and set face attributes. |
1428 * Merging Faces:: How Emacs combines the faces specified for a character. | 1429 * Merging Faces:: How Emacs combines the faces specified for a character. |
1429 * Font Selection:: Finding the best available font for a face. | 1430 * Font Selection:: Finding the best available font for a face. |
1430 * Face Functions:: How to define and examine faces. | 1431 * Face Functions:: How to define and examine faces. |
1431 * Auto Faces:: Hook for automatic face assignment. | 1432 * Auto Faces:: Hook for automatic face assignment. |
1432 * Font Lookup:: Looking up the names of available fonts | 1433 * Font Lookup:: Looking up the names of available fonts |
1433 and information about them. | 1434 and information about them. |
1434 * Fontsets:: A fontset is a collection of fonts | 1435 * Fontsets:: A fontset is a collection of fonts |
1435 that handle a range of character sets. | 1436 that handle a range of character sets. |
2637 list or vector containing several display specifications. The rest of | 2638 list or vector containing several display specifications. The rest of |
2638 this section describes several kinds of display specifications and what | 2639 this section describes several kinds of display specifications and what |
2639 they mean. | 2640 they mean. |
2640 | 2641 |
2641 @menu | 2642 @menu |
2642 * Specified Space:: Displaying one space with a specified width. | 2643 * Specified Space:: Displaying one space with a specified width. |
2643 * Other Display Specs:: Displaying an image; magnifying text; moving it | 2644 * Other Display Specs:: Displaying an image; magnifying text; moving it |
2644 up or down on the page; adjusting the width | 2645 up or down on the page; adjusting the width |
2645 of spaces within text. | 2646 of spaces within text. |
2646 * Display Margins:: Displaying text or images to the side of the main text. | 2647 * Display Margins:: Displaying text or images to the side of the main text. |
2647 * Conditional Display:: Making any of the above features conditional | 2648 * Conditional Display:: Making any of the above features conditional |
2648 depending on some Lisp expression. | 2649 depending on some Lisp expression. |
2649 @end menu | 2650 @end menu |
2650 | 2651 |
2651 @node Specified Space | 2652 @node Specified Space |
2652 @subsection Specified Spaces | 2653 @subsection Specified Spaces |
3399 This function clears the image cache. If @var{frame} is non-@code{nil}, | 3400 This function clears the image cache. If @var{frame} is non-@code{nil}, |
3400 only the cache for that frame is cleared. Otherwise all frames' caches | 3401 only the cache for that frame is cleared. Otherwise all frames' caches |
3401 are cleared. | 3402 are cleared. |
3402 @end defun | 3403 @end defun |
3403 | 3404 |
3405 @node Buttons | |
3406 @section Buttons | |
3407 @cindex buttons in buffers | |
3408 @cindex clickable buttons in buffers | |
3409 | |
3410 The @emph{button} package defines functions for inserting and | |
3411 manipulating clickable (with the mouse, or via keyboard commands) | |
3412 buttons in Emacs buffers, such as might be used for help hyperlinks, | |
3413 etc. Emacs uses buttons for the hyperlinks in help text and the like. | |
3414 | |
3415 A button is essentially a set of properties attached (via text | |
3416 properties or overlays) to a region of text in an emacs buffer, which | |
3417 are called its button properties. @xref{Button Properties}. | |
3418 | |
3419 One of the these properties (@code{action}) is a function, which will | |
3420 be called when the user invokes it using the keyboard or the mouse. | |
3421 The invoked function may then examine the button and use its other | |
3422 properties as desired. | |
3423 | |
3424 In some ways the emacs button package duplicates functionality offered | |
3425 by the widget package (@pxref{Top, , Introduction, widget, The Emacs | |
3426 Widget Library}), but the button package has the advantage that it is | |
3427 much faster, much smaller, and much simpler to use (for elisp | |
3428 programmers---for users, the result is about the same). The extra | |
3429 speed and space savings are useful mainly if you need to create many | |
3430 buttons in a buffer (for instance an @code{*Apropos*} buffer uses | |
3431 buttons to make entries clickable, and may contain many thousands of | |
3432 entries). | |
3433 | |
3434 @menu | |
3435 * Button Properties:: Button properties with special meanings. | |
3436 * Button Types:: Defining common properties for classes of buttons. | |
3437 * Making buttons:: Adding buttons to emacs buffers. | |
3438 * Manipulating Buttons:: Getting and setting properties of buttons. | |
3439 * Button Buffer Commands:: Buffer-wide commands and bindings for buttons. | |
3440 * Manipulating Button Types:: | |
3441 @end menu | |
3442 | |
3443 @node Button Properties | |
3444 @subsection Button Properties | |
3445 @cindex button properties | |
3446 | |
3447 Buttons have an associated list of properties defining their | |
3448 appearance and behavior, and other arbitrary properties may be used | |
3449 for application specific purposes. | |
3450 | |
3451 Some properties that have special meaning to the button package | |
3452 include: | |
3453 | |
3454 @table @code | |
3455 | |
3456 @item action | |
3457 The function to call when the user invokes the button, which is passed | |
3458 the single argument @var{button}. By default this is @code{ignore}, | |
3459 which does nothing. | |
3460 | |
3461 @item mouse-action | |
3462 This is similar to @code{action}, and when present, will be used | |
3463 instead of @code{action} for button invocations resulting from | |
3464 mouse-clicks (instead of the user hitting @key{RET}). If not | |
3465 present, mouse-clicks use @code{action} instead. | |
3466 | |
3467 @item face | |
3468 This is an emacs face controlling how buttons of this type are | |
3469 displayed; by default this is the @code{button} face. | |
3470 | |
3471 @item mouse-face | |
3472 This is an additional face which controls appearance during | |
3473 mouse-overs (merged with the usual button face); by default this is | |
3474 the usual emacs @code{highlight} face. | |
3475 | |
3476 @item keymap | |
3477 The button's keymap, defining bindings active within the button | |
3478 region. By default this is the usual button region keymap, stored | |
3479 in the variable @code{button-map}, which defines @key{RET} and | |
3480 @key{down-mouse-1} to invoke the button. | |
3481 | |
3482 @item type | |
3483 The button-type of the button. When creating a button, this is | |
3484 usually specified using the @code{:type} keyword argument. | |
3485 @xref{Button Types}. | |
3486 | |
3487 @item help-echo | |
3488 A string displayed by the emacs tooltip help system; by default, | |
3489 @code{"mouse-2, RET: Push this button"}. | |
3490 | |
3491 @item button | |
3492 All buttons have a non-@code{nil} @code{button} property, which may be useful | |
3493 in finding regions of text that comprise buttons (which is what the | |
3494 standard button functions do). | |
3495 @end table | |
3496 | |
3497 There are other properties defined for the regions of text in a | |
3498 button, but these are not generally interesting for typical uses. | |
3499 | |
3500 @node Button Types | |
3501 @subsection Button Types | |
3502 @cindex button types | |
3503 | |
3504 Every button has a button @emph{type}, which defines default values | |
3505 for the button's properties; button types are arranged in a hierarchy, | |
3506 with specialized types inheriting from more general types, so that | |
3507 it's easy to define special-purpose types of buttons for specific | |
3508 tasks. | |
3509 | |
3510 @defun define-button-type name &rest properties | |
3511 @tindex define-button-type | |
3512 Define a `button type' called @var{name}. The remaining arguments | |
3513 form a sequence of @var{property value} pairs, specifying default | |
3514 property values for buttons with this type (a button's type may be set | |
3515 by giving it a @code{type} property when creating the button, using | |
3516 the @code{:type} keyword argument). | |
3517 | |
3518 In addition, the keyword argument @code{:supertype} may be used to | |
3519 specify a button-type from which @var{name} inherits its default | |
3520 property values. Note that this inheritance happens only when | |
3521 @var{name} is defined; subsequent changes to a supertype are not | |
3522 reflected in its subtypes. | |
3523 @end defun | |
3524 | |
3525 Using @code{define-button-type} to define default properties for | |
3526 buttons is not necessary, but it is is encouraged, since doing so | |
3527 usually makes the resulting code clearer and more efficient. | |
3528 | |
3529 @node Making buttons | |
3530 @subsection Making buttons | |
3531 @cindex making buttons | |
3532 | |
3533 Buttons are associated with a region of text, using an overlay or | |
3534 text-properties to hold button-specific information, all of which are | |
3535 initialized from the button's type (which defaults to the built-in | |
3536 button type @code{button}). Like all emacs text, the appearance of | |
3537 the button is governed by the @code{face} property; by default (via | |
3538 the @code{face} property inherited from the @code{button} button-type) | |
3539 this is a simple underline, like a typical web-page link. | |
3540 | |
3541 For convenience, there are two sorts of button-creation functions, | |
3542 those that add button properties to an existing region of a buffer, | |
3543 called @code{make-...button}, and those also insert the button text, | |
3544 called @code{insert-...button}. | |
3545 | |
3546 The button-creation functions all take the @code{&rest} argument | |
3547 @var{properties}, which should be a sequence of @var{property value} | |
3548 pairs, specifying properties to add to the button; see @ref{Button | |
3549 Properties}. In addition, the keyword argument @code{:type} may be | |
3550 used to specify a button-type from which to inherit other properties; | |
3551 see @ref{Button Types}. Any properties not explicitly specified | |
3552 during creation will be inherited from the button's type (if the type | |
3553 defines such a property). | |
3554 | |
3555 The following functions add a button using an overlay | |
3556 (@pxref{Overlays}) to hold the button properties: | |
3557 | |
3558 @defun make-button beg end &rest properties | |
3559 @tindex make-button | |
3560 Make a button from @var{beg} to @var{end} in the current buffer. | |
3561 @end defun | |
3562 | |
3563 @defun insert-button label &rest properties | |
3564 @tindex insert-button | |
3565 Insert a button with the label @var{label}. | |
3566 @end defun | |
3567 | |
3568 The following functions are similar, but use emacs text-properties | |
3569 (@pxref{Text Properties}) to hold the button properties, making the | |
3570 button actually part of the text instead of being a property of the | |
3571 buffer (using text-properties is usually faster than using overlays, | |
3572 so this may be preferable when creating large numbers of buttons): | |
3573 | |
3574 @defun make-text-button beg end &rest properties | |
3575 @tindex make-text-button | |
3576 Make a button from @var{beg} to @var{end} in the current buffer, using | |
3577 text-properties. | |
3578 @end defun | |
3579 | |
3580 @defun insert-text-button label &rest properties | |
3581 @tindex insert-text-button | |
3582 Insert a button with the label @var{label}, using text-properties. | |
3583 @end defun | |
3584 | |
3585 Buttons using text-properties retain no markers into the buffer are | |
3586 retained, which is important for speed in cases where there are | |
3587 extremely large numbers of buttons. | |
3588 | |
3589 @node Manipulating Buttons | |
3590 @subsection Manipulating Buttons | |
3591 @cindex manipulating buttons | |
3592 | |
3593 These are functions for getting and setting properties of buttons. | |
3594 Often these are used by a button's invocation function to determine | |
3595 what to do. | |
3596 | |
3597 Where a @var{button} parameter is specified, it means an object | |
3598 referring to a specific button, either an overlay (for overlay | |
3599 buttons), or a buffer-position or marker (for text property buttons). | |
3600 Such an object is passed as the first argument to a button's | |
3601 invocation function when it is invoked. | |
3602 | |
3603 @defun button-start button | |
3604 @tindex button-start | |
3605 Return the position at which @var{button} starts. | |
3606 @end defun | |
3607 | |
3608 @defun button-end button | |
3609 @tindex button-end | |
3610 Return the position at which @var{button} ends. | |
3611 @end defun | |
3612 | |
3613 @defun button-get button prop | |
3614 @tindex button-get | |
3615 Get the property of button @var{button} named @var{prop}. | |
3616 @end defun | |
3617 | |
3618 @defun button-put button prop val | |
3619 @tindex button-put | |
3620 Set @var{button}'s @var{prop} property to @var{val}. | |
3621 @end defun | |
3622 | |
3623 @defun button-activate button &optional use-mouse-action | |
3624 @tindex button-activate | |
3625 Call @var{button}'s @code{action} property (i.e., invoke it). If | |
3626 @var{use-mouse-action} is non-@code{nil}, try to invoke the button's | |
3627 @code{mouse-action} property instead of @code{action}, but if the | |
3628 button has no @code{mouse-action} property, use @code{action} as | |
3629 normal. | |
3630 @end defun | |
3631 | |
3632 @defun button-label button | |
3633 @tindex button-label | |
3634 Return @var{button}'s text label. | |
3635 @end defun | |
3636 | |
3637 @defun button-type button | |
3638 @tindex button-type | |
3639 Return @var{button}'s button-type. | |
3640 @end defun | |
3641 | |
3642 @defun button-has-type-p button type | |
3643 @tindex button-has-type-p | |
3644 Return @code{t} if @var{button} has button-type @var{type}, or one of | |
3645 @var{type}'s subtypes. | |
3646 @end defun | |
3647 | |
3648 @defun button-at pos | |
3649 @tindex button-at | |
3650 Return the button at position @var{pos} in the current buffer, or @code{nil}. | |
3651 @end defun | |
3652 | |
3653 @node Button Buffer Commands | |
3654 @subsection Button Buffer Commands | |
3655 @cindex button buffer commands | |
3656 | |
3657 These are commands and functions for locating and operating on | |
3658 buttons in an emacs buffer. | |
3659 | |
3660 @code{push-button} is the command that a user uses to actually `push' | |
3661 a button, and is bound by default in the button itself to @key{RET} | |
3662 and to @key{mouse-down-1} using a region-specific keymap. Commands | |
3663 that are useful outside the buttons itself, such as | |
3664 @code{forward-button} and @code{backward-button} are additionally | |
3665 available in the keymap stored in @code{button-buffer-map}; a mode | |
3666 which uses buttons may want to use @code{button-buffer-map} as a | |
3667 parent keymap for its keymap. | |
3668 | |
3669 @deffn Command push-button &optional pos use-mouse-action | |
3670 @tindex push-button | |
3671 Perform the action specified by a button at location @var{pos}. | |
3672 @var{pos} may be either a buffer position or a mouse-event. If | |
3673 @var{use-mouse-action} is non-@code{nil}, try to invoke the button's | |
3674 @code{mouse-action} property instead of @code{action}, but if the | |
3675 button has no @code{mouse-action} property, use @code{action} as | |
3676 normal. @var{pos} defaults to point, except when `push-button' is | |
3677 invoked interactively as the result of a mouse-event, in which case, | |
3678 the mouse event is used. If there's no button at @var{pos}, do | |
3679 nothing and return @code{nil}, otherwise return @code{t}. | |
3680 @end deffn | |
3681 | |
3682 @deffn Command forward-button n &optional wrap display-message | |
3683 @tindex forward-button | |
3684 Move to the @var{n}th next button, or @var{n}th previous button if | |
3685 @var{n} is negative. If @var{n} is zero, move to the start of any | |
3686 button at point. If @var{wrap} is non-@code{nil}, moving past either | |
3687 end of the buffer continues from the other end. If | |
3688 @var{display-message} is non-@code{nil}, the button's help-echo string | |
3689 is displayed. Any button with a non-@code{nil} `skip' property is | |
3690 skipped over. Returns the button found. | |
3691 @end deffn | |
3692 | |
3693 @deffn Command backward-button n &optional wrap display-message | |
3694 @tindex backward-button | |
3695 Move to the @var{n}th previous button, or @var{n}th next button if | |
3696 @var{n} is negative. If @var{n} is zero, move to the start of any | |
3697 button at point. If @var{wrap} is non-@code{nil}, moving past either | |
3698 end of the buffer continues from the other end. If | |
3699 @var{display-message} is non-@code{nil}, the button's help-echo string | |
3700 is displayed. Any button with a non-@code{nil} `skip' property is | |
3701 skipped over. Returns the button found. | |
3702 @end deffn | |
3703 | |
3704 @defun next-button pos &optional count-current | |
3705 @tindex next-button | |
3706 Return the next button after position @var{pos} in the current buffer. | |
3707 If @var{count-current} is non-@code{nil}, count any button at | |
3708 @var{pos} in the search, instead of starting at the next button. | |
3709 @end defun | |
3710 | |
3711 @defun previous-button pos &optional count-current | |
3712 @tindex previous-button | |
3713 Return the @var{n}th button before position @var{pos} in the current | |
3714 buffer. If @var{count-current} is non-@code{nil}, count any button at | |
3715 @var{pos} in the search, instead of starting at the next button. | |
3716 @end defun | |
3717 | |
3718 @node Manipulating Button Types | |
3719 @subsection Manipulating Button Types | |
3720 @cindex manipulating button types | |
3721 | |
3722 @defun button-type-put type prop val | |
3723 @tindex button-type-put | |
3724 Set the button-type @var{type}'s @var{prop} property to @var{val}. | |
3725 @end defun | |
3726 | |
3727 @defun button-type-get type prop | |
3728 @tindex button-type-get | |
3729 Get the property of button-type @var{type} named @var{prop}. | |
3730 @end defun | |
3731 | |
3732 @defun button-type-subtype-p type supertype | |
3733 @tindex button-type-subtype-p | |
3734 Return @code{t} if button-type @var{type} is a subtype of @var{supertype}. | |
3735 @end defun | |
3736 | |
3404 @node Blinking | 3737 @node Blinking |
3405 @section Blinking Parentheses | 3738 @section Blinking Parentheses |
3406 @cindex parenthesis matching | 3739 @cindex parenthesis matching |
3407 @cindex blinking | 3740 @cindex blinking |
3408 @cindex balancing parentheses | 3741 @cindex balancing parentheses |
3593 Display tables affect how the mode line is displayed; if you want to | 3926 Display tables affect how the mode line is displayed; if you want to |
3594 force redisplay of the mode line using a new display table, call | 3927 force redisplay of the mode line using a new display table, call |
3595 @code{force-mode-line-update} (@pxref{Mode Line Format}). | 3928 @code{force-mode-line-update} (@pxref{Mode Line Format}). |
3596 | 3929 |
3597 @menu | 3930 @menu |
3598 * Display Table Format:: What a display table consists of. | 3931 * Display Table Format:: What a display table consists of. |
3599 * Active Display Table:: How Emacs selects a display table to use. | 3932 * Active Display Table:: How Emacs selects a display table to use. |
3600 * Glyphs:: How to define a glyph, and what glyphs mean. | 3933 * Glyphs:: How to define a glyph, and what glyphs mean. |
3601 @end menu | 3934 @end menu |
3602 | 3935 |
3603 @node Display Table Format | 3936 @node Display Table Format |
3604 @subsection Display Table Format | 3937 @subsection Display Table Format |
3605 | 3938 |