All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries

set-rich-text-pane-character-format Function

Summary

Sets the character format.

Package

capi

Signature

set-rich-text-pane-character-format pane &key selection attributes-plist => result

Arguments
pane
selection
Must be t. This argument is deprecated.
attributes-plist
A plist or :default.
Values
result
A plist.
Description

The function set-rich-text-pane-character-format sets current character attributes for text in pane.

If there is a current selection in the pane, then the attributes are set for the selected text. If there is no selection, then it sets the "typing attributes", which are applied to characters that are typed by the user. Note that any cursor movement changes these attributes, so the setting is ephemeral.

Supplying selection is deprecated. If selection is nil an error is signalled. The default value of selection is t.

If attributes-plist is the symbol :default then the default character format of the pane (that is, the value of the rich-text-pane initarg :character-format) is used. Otherwise attributes-plist is a plist of keywords and values. These are the valid keywords on Microsoft Windows and Cocoa:

:bold
A boolean.
:italic
A boolean.
:underline
A boolean.
:face
A string naming a font.
:color
A color spec or alias specifying the foreground color.
:size
The size of the font.

Additionally these attributes-plist keywords are valid on Microsoft Windows only:

:strikeout
A boolean.
:offset
An integer specifying the vertical offset of characters from the line (a positive value makes them superscript and a negative value makes them subscript).
:protected
A boolean. See the description of protected-callback in rich-text-pane.
:charset
A cons (charset . pitch-and-family) where charset has the value of a Microsoft Windows charset identifier, and pitch-and-family is the value of (logior pitch family) where pitch and family have the value of a Windows pitch and a Windows font family respectively.
Compatibility note

The value nil for the keyword argument :selection is not supported in LispWorks 6.1 and later. See the description above for details of the current behavior with respect to the current selection in the rich-text-pane.

Examples

Note: This example uses some features which are supported only on Microsoft Windows:

(defun ok-to-edit-p (pane start end s)
  (declare (ignore pane))
  (capi:prompt-for-confirmation 
   (format nil "Editing~:[ ~; selection ~]from ~a to ~a"
           s start end)))
 
(setq rtp 
      (capi:contain 
       (make-instance 
        'capi:rich-text-pane 
        :protected-callback 'ok-to-edit-p
        :character-format 
        '(:size 14  :color :red)
        :visible-min-height 300
        :visible-min-width 400
        :paragraph-format 
        '(:start-indent 20 :offset -15)
        :text-limit 160
        :text (format nil "First paragraph.~%Second paragraph, a little longer.~%Another paragraph, which should be long long enough that it spans more than one line. ~%" ))))

Enter some characters in the rich text window and select a range.

Set the selection to blue:

(capi:set-rich-text-pane-character-format 
 rtp
 :attributes-plist '(:color :blue))

Make it protected:

(capi:set-rich-text-pane-character-format
 rtp :attributes-plist '(:protected t))

Now try to delete a character, and also to delete the selection. In both cases the ok-to-edit-p callback is called.

See also

rich-text-pane
rich-text-pane-character-format


CAPI User Guide and Reference Manual (Unix version) - 01 Dec 2021 19:32:42