Session Manager Editing: Difference between revisions
No edit summary |
|||
Line 16: | Line 16: | ||
For example, | For example, | ||
<apll> | <apll><pre> | ||
f←{ | |||
<span style="color:blue;">➥</span>⍺ ⍝ Left arg | <span style="color:blue;">➥</span>⍺ ⍝ Left arg | ||
<span style="color:blue;">➥</span>+ ⍝ Function | <span style="color:blue;">➥</span>+ ⍝ Function | ||
<span style="color:blue;">➥</span>⍵ ⍝ Right arg | <span style="color:blue;">➥</span>⍵ ⍝ Right arg | ||
<span style="color:blue;">➥</span>} | <span style="color:blue;">➥</span>} | ||
3 f 5 | |||
8 | 8 | ||
h←{s←(+/⍵)÷2 | |||
<span style="color:blue;">➥</span> ⋄ √×/s-0,⍵ ⍝ Heron's formula for triangle area | <span style="color:blue;">➥</span> ⋄ √×/s-0,⍵ ⍝ Heron's formula for triangle area | ||
<span style="color:blue;">➥</span>}< | <span style="color:blue;">➥</span>} | ||
</apll> | </pre></apll> | ||
<p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line. Note that this is different from a '''multi-line''' AFO where separate physical lines form separate logical lines — we don't support that in Session Manager Editing, but we do in [[Function_Editing|Function Editing]]. In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially). If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with <apll>f←</apll>), not a new statement.</p> | <p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line. Note that this is different from a '''multi-line''' AFO where separate physical lines form separate logical lines — we don't support that in Session Manager Editing, but we do in [[Function_Editing|Function Editing]]. In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially). If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with <apll>f←</apll>), not a new statement.</p> |
Revision as of 11:01, 28 April 2018
The session manager in NARS2000 provides a wide variety of techniques to perform common tasks.
- The Session manager window consists of a mixture of input and output.
- Input typically starts after a six space indent, output typically appears starting at the left edge.
- Both input and output are subject to editing and re-execution.
- The cursor may move about the screen changing text as desired.
- If you press Enter on a line, the original text of that line is restored, the changed line is copied to a new line at the bottom of the screen buffer and executed.
- If you press Ctrl-Enter on a line, the original text of that line is restored, the changed line is copied to a new line at the bottom of the screen buffer but is not executed — instead it may be further edited before pressing Enter and executed.
- If you press Shift-Enter on a line, a new physical line is inserted on the screen immediately below the original line and starts with a Line Continuation marker (by default, '➥' — U+27A5). If Shift-Enter is pressed while the text cursor is in the middle of a line, the line is split in two at that point. To undo this action use the Backspace key at the start of the new line or the Delete key at the end of the preceding line. This action changes the number of physical lines, but not the number of logical lines.
- The default Line Continuation marker may be changed by selecting the menu item "Edit | Customize..." then selecting "User Preferences" and then "Line Continuation".
- The default Line Continuation foreground and background color may be changed by selecting the menu item "Edit | Customize..." then selecting "Syntax Coloring" and then "Line Continuation" either Foreground or Background.
- Multiple adjacent continued lines form a block which is treated as a single logical line.
- If you press Enter on any line in a block, the block is copied to the bottom of the screen buffer and executed. If the block is already at the end of the buffer, the block is not copied; instead it is just executed.
- If you press Ctrl-Enter on any line in a block, the block is copied to the bottom of the screen buffer but it is not executed — instead it may be further edited before pressing Enter and then executed. If the block is already at the end of the buffer, the block is not copied and not executed — in this case, Ctrl-Enter has no effect.
For example,
f←{ ➥⍺ ⍝ Left arg ➥+ ⍝ Function ➥⍵ ⍝ Right arg ➥} 3 f 5 8 h←{s←(+/⍵)÷2 ➥ ⋄ √×/s-0,⍵ ⍝ Heron's formula for triangle area ➥}
The above example (starting with h←) also illustrates how to create a multi-statement anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line. Note that this is different from a multi-line AFO where separate physical lines form separate logical lines — we don't support that in Session Manager Editing, but we do in Function Editing. In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially). If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with f←), not a new statement.
The only syntax elements that can't be continued to the next line are names and comments — splitting a name in two creates two separate names; splitting a comment in two does not create one continued comment nor does it create two separate comments. Instead use a comment symbol to start each comment on separate physical lines. To create a new statement, use the statement separator (⋄).
Drag and Move vs. Drag and Copy
In both the function and session editors, the mouse may Drag and Move or Drag and Copy a selection to another location in the same window. The former is equivalent to Cut and Paste, while the latter is equivalent to Copy and Paste, both in a single atomic operation.
After selecting the text (which may span multiple lines), release the left mouse button. Then move the mouse back to any point within the selected text, press and hold the left mouse button and Move/Copy the text to its new location. Release the left mouse button at the appropriate insertion point.
During the Move/Copy, the text caret shows exactly the position of the insertion point, and the mouse cursor indicates whether or not the Ctrl-key is pressed. When the left mouse button is released, the state of the Ctrl-key is significant. If it is not pressed, the operation becomes Drag and Move which both Copies and Cuts the selected text; otherwise, the operation becomes Drag and Copy which Copies the selected text (without Cutting it) — in both case the selected text is Pasted at the insertion point. The Undo key (Ctrl-Z) restores all of the Cut/Copy/Pasted text to its previous state.
Shortcut Keystrokes for Editing
The text cursor takes one of two forms: Insert or Replace. The Insert cursor appears as a vertical bar between two chars; the Replace cursor appears as an underline beneath the character to be replaced. The current position is the character to the right of the Insert text cursor or underneath the Replace text cursor.
Keystroke | Meaning |
---|---|
Del | Deletes the character at the current position. |
Shift-Del | Deletes the character to the left of the Insert or Replace text cursor. |
Ctrl-Del | Deletes the characters from the current position to the end of the line. |
Ins | Toggles the Insert vs. Replace state of the text cursor. |
Shift-Ins | Pastes text from the clipboard into the text to the left of the text cursor. |
Ctrl-Ins | Copies selected text into the clipboard. |
Home | Moves the text cursor to the start of the current line. |
Shift-Home | Selects the text from the start of the current line to the character to the left of the Insert or Replace text cursor and moves the text cursor to the start of the line. |
Ctrl-Home | Move the cursor to the start of the screen buffer, possibly scrolling the screen so that point is visible. |
End | Moves the text cursor to the end of the current line. |
Shift-End | Selects the text to the end of the current line from the character to the right of the Insert text cursor or underneath the Replace text cursor and moves the text cursor to the end of the line. |
Ctrl-End | Moves the text cursor to the end of the screen buffer, possibly scrolling the screen so that point is visible. |
Up | Moves the text cursor up one line, possibly moving it to the end of the line if the line is short. |
Shift-Up | Selects all of the text from the current position to the column up one line and moves the text cursor to that point. |
Ctrl-Up | Same as Up. |
Down | Moves the text cursor down one line, possibly moving it to the end of the line if the line is short. |
Shift-Down | Selects all of the text from the current position to the column down one line and moves the text cursor to that point. |
Ctrl-Down | Same as Down. |
Left | Moves the text cursor left one position. If the text cursor is at the start of the current line, the text cursor moves to the end of the previous line. |
Shift-Left | Selects the character to the left of the text cursor and moves the text cursor one position to that point extending any selection already set. |
Ctrl-Left | Moves the text cursor to the start of the word to the left. If the text cursor was within a word, the text cursor moves to the start of that word. |
Right | Moves the text cursor one character to the right. If the text cursor is at the end of the current line, the text cursor moves to the start of the next line. |
Shift-Right | Selects the character to the right of the text cursor and moves the text cursor one position to that point extending any selection already set. |
Ctrl-Right | Moves the text cursor to the start of the word to the right. |
PgDn | Scrolls the screen by one page down. |
Shift-PgDn | Selects all of the text from the current position to the same column at the end of the current page. |
Ctrl-PgDn | Moves the text cursor from the current position to the same column at the end of the current page. |
PgUp | Scrolls the screen by one page up. |
Shift-PgUp | Selects all of the text from the current position to the same column at the start of the current page. |
Ctrl-PgUp | Moves the text cursor from the current position to the same column at the start of the current page. |