Instruction set reference
HIPE_OP_EDIT_ACTION
Performs a cut/copy/paste or other edit action on the text the user has selected, or at the text cursor, in the element that has keyboard focus.
Every application inside a top-level window is a frame of the same document hierarchy, so an edit action always applies to the frame that currently has keyboard focus. To stop one application acting on another's content, the rules depend on who sends the instruction:
- A top-level client (normally the framing manager) may always perform edit actions. If it names a child frame in location and the keyboard focus isn't inside that frame, focus is first moved to that frame, so the action applies to that application (for example, to its selection or its own undo history).
- Any other client may perform edit actions only while the keyboard focus is inside its own frame (or inside the child frame it names, or a frame nested within it). Otherwise the instruction is ignored. Setting the focus first, e.g. with HIPE_OP_SET_FOCUS, satisfies this. Paste (v and V) has an extra condition, described below.
- location: 0 to act on the current frame (including frames nested within it), or the location of a child frame to act on that frame instead.
- arg[0]: The "action code" character for the function required. See below.
- arg[1]: For the t action only, the text to insert. Empty to delete the selected text.
Action codes
| Character | Editing operation |
|---|---|
| z | Undo |
| Z | Redo |
| a | Select all |
| x | Cut selected text to clipboard |
| c | Copy selected text to clipboard |
| v | Paste selected text from clipboard, matching destination formatting |
| V | Paste selected text from clipboard, preserving source formatting if applicable |
| b | Toggles bold if applicable |
| i | Toggles italic if applicable |
| u | Toggles underline if applicable |
| k | Toggles strikethrough if applicable |
| l | Align left if applicable |
| C | Align center if applicable |
| r | Align right if applicable |
| j | Align justified if applicable |
| d | Set text direction default |
| > | Set text direction left to right |
| < | Set text direction right to left |
| t | Insert the text given in arg[1], or delete the selected text if arg[1] is empty |
Notes
This operation will succeed or fail silently. There is no response from the server. Use HIPE_OP_EDIT_STATUS to find out which actions are currently available.
Paste from a non-top-level client. Pasting gives the clipboard's contents to the client that receives them, so a client that isn't top-level may only paste in response to the user: within a few seconds after the user clicked or pressed a key in its frame, or after the framing manager relayed the user's answer to a dialog (HIPE_OP_DIALOG_RETURN) to it or to a frame containing it. In practice, send the paste instruction as soon as you receive the click, key press or dialog answer that asked for it. At other times it is ignored. The user can always paste with the keyboard shortcut, which doesn't use this instruction.
Insert text (t) puts the text in arg[1] at the text cursor, replacing any selected text, as if the user had typed it. Nothing happens unless the text cursor is in editable content (a text input, a <textarea>, or an element with the contenteditable attribute). The text is never treated as HTML: characters such as < and & are shown as typed. Each newline in the text becomes a line break, as when the user presses Enter in plain text (a single-line text input can't hold line breaks, so each newline becomes a space there), and the text cursor is left after the inserted text. The whole insertion is undone by a single undo; as with ordinary typing, that undo also removes anything the user typed immediately before it. A typical use is inserting a tab or indentation when the user presses Tab, after cancelling the key's default action (see HIPE_OP_EVENT_REQUEST).
If arg[1] is empty, t deletes the selected text instead, as the Delete key would, and leaves the text cursor where the selection was. This is one step for undo. If no text is selected (there is only a text cursor), nothing is deleted. To remove a particular range, select it first with HIPE_OP_CARAT_POSITION.
Undo and redo act on the undo history of the focused frame's document. Each frame has its own undo history, so undoing in one application never reverts an edit made in another.
