Arbortext Command Language > Commands > caret
  
caret
caret { mouse | nextcell | prevcell | nextword | prevword | [ window | nextwindow | prevwindow] [ warp | nowarp] [line,col] [ -c | -noc] [ -e | -noe] [ -t | -not] [ -wrapscan | -nowrapscan] [ -q | -noq] [ -screen | -noscreen] [ -arrow | -noarrow]}
The caret command is used to change the location of the cursor.
caret mouse — Positions the cursor at the current mouse arrow location. Note that if you are mapping a key to caret mouse, it is often desirable to precede the caret command with a clear_mark command. Typically, it is not recommended that you use caret commands in scripts, as the command is affected by the screen position. The absolute form of the caret command is meant to be typed at the command line or mapped to a key.
caret nextcell — Applies only when the cursor is in a table cell. This command moves the cursor to the end of the next cell in the current table. If the cursor is in the last cell of a column, it is moved to the first cell in the next row. If the cursor is in the last row and column of the table, it is moved to the first cell in the table.
caret prevcell — Applies only when the cursor is in a table cell. This command moves the cursor to the end of the previous cell in the current table. If the cursor is in the first cell of a column, it is moved to the last cell in the previous row. If the cursor is in the first row and column of the table, it is moved to the last cell in the table.
caret nextword — Moves the cursor to the beginning of the next word.
caret prevword — Moves the cursor to the beginning of the previous word.
The window command variable can be any of the following:
edit (the default) designates the Edit pane
cmd designates the command line
list moves the focus to the last active list selection dialog (the line,col argument cannot be used with this option)
helpwin (also called helpwin1), helpwin2, helpwin3, helpwin4, msgwin (also called msgwin1), msgwin2, msgwin3, and msgwin4 designate multiple Help windows. The msgwin values display Arbortext Editor messages and output from the show, eval, and other commands.
win-name moves the focus to the specified window. win-name is a string returned by window_name.
nextwindow (used with keymappings) moves the cursor from window to window. next is a synonym for nextwindow.
prevwindow moves the focus (and pointer) to the previous window, in the direction opposite of nextwindow. prev is a synonym for prevwindow.
warp (the default) moves both the cursor and the pointer to the designated window. nowarp moves the cursor without moving the pointer. If click-to-type focus is used, then warp sets the keyboard focus to the specified window instead of moving the pointer.
The caret command positions the cursor immediately in front of the character at the specified screen location line,col where line is an integer representing the number of lines down on the screen (this includes blank lines) and col is an integer representing the number of characters and spaces (that is, columns) over from the left margin.
line and col values can be either absolute or relative to the current cursor position. When line and col are relative values, a plus sign (+) means move right or move down this number and a minus sign () means move up or left. In addition to simple integers, values for line can be:
firstline or first (the first line in the document).
middleline or middle (the middle of the document)
lastline or last (the last line in the document)
topline or top (the first line on the screen)
centerline or center (the middle of the screen)
bottomline or bottom (the last line on the screen)
currentline or current (the line the cursor is presently on)
beginparagraph or begin (the first line of the paragraph in which the cursor is positioned)
endparagraph or end (the last line of the paragraph in which the cursor is positioned)
screensize (the number of lines on the screen)
col can also be
firstcolumn or first
middlecolumn or middle
lastcolumn or last
currentcolumn or current
Values for line and col can also be 0 (zero) or strings, specified in the same manner as for the find command and substitute command. 0 means keep the relative pixel position for this coordinate. When a string is used, Arbortext Editor searches forward from the cursor until it finds the string, then uses the string (if found) as the value. The cursor position following the matched string is used as the location (for example, caret 0,' '+1 moves the cursor one character past the next blank). You can also search backward using a relative location expression (for example, the command caret 0,-'.'+2 might be used to position the cursor at the start of the current sentence).
The operators +, , / (for division), and * (for multiplication) may also be combined with integers and with the line and column variables to form expressions. Thus, the command caret (bottom-top)/2,0 would position the cursor on the middle line of the screen in the same horizontal position. Note how parentheses designate the order of evaluation in the above example.
The -screen and -noscreen modifiers control whether invisible characters (for example, tags) are skipped when they aren't displayed. The -noscreen modifier specifies that no characters are to be skipped. The -screen modifier specifies that invisible characters should be skipped. If neither -screen or -noscreen are specified, the default is -noscreen. For an example of the -screen modifier, consider the following code fragment:
<para>Using the Caret command.</para>
<para>Fun with the -screen option!</para>
Assume that the cursor is between the period and the first para end tag, and the current display mode is Full Tags. If you issued the command caret 0,+1 -screen, the cursor would move one character to the right and appear just to the right of the first para end tag. However, if the current display mode is No Tags, the command caret 0,+1 -screen would skip the invisible tag characters and place the cursor just to the left of the “F” in “Fun”.
The -arrow and -noarrow modifiers are only used when -screen is set and the Edit window has tag display turned off. Setting -arrow specifies that invisible characters are not skipped (like -noscreen), however, invisible generated text and the contents of collapsed items are skipped (like -screen). If neither -arrow nor -noarrow are specified, the default -noarrow is assumed.
The remaining modifiers (c, noc, e, noe, t, not, q, noq, wrapscan, and nowrapscan) work like the modifiers for the find command.
Examples
# position caret at current mouse location
car mouse
car nextcell
car prevwindow
# second line, tenth column
car 2,10
# down two lines, right ten columns
car +2,+10
# this command moves the cursor to the next paragraph
# in the edit window without moving the mouse pointer
car edit nowarp 0,/<para>/ -t
car bottom+1,first
car -2,0
car current-2,current
car bottom,last
car last,last
car begin,current
car current,/ /
car cmd 1,1
car (bottom-top)/2,0
car 0,/apples|oranges/ -e
car 0,/Doctor/ -c
Related Topics
Using regular expressions
window command