Session Manager Editing: Difference between revisions
No edit summary |
(give example) |
||
(9 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
** 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 '''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 '''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, '< | ** 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, '<_lc/>' — 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''' 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. | ** 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. | ||
Line 16: | Line 16: | ||
For example, | For example, | ||
<apll> | <apll><pre> | ||
f←{ | |||
< | <_lc/>⍺ ⍝ Left arg | ||
< | <_lc/>+ ⍝ Function | ||
< | <_lc/>⍵ ⍝ Right arg | ||
< | <_lc/>} | ||
3 f 5 | |||
8 | 8 | ||
h←{s←(+/⍵)÷2 | |||
< | <_lc/> ⋄ √×/s-0,⍵ ⍝ Heron's formula for triangle area | ||
< | <_lc/>} | ||
</apll> | </pre></apll> | ||
<p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function | <p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function/operator/hyperator (AFOH) with comments, where separate physical lines form a single logical line. Note that this is different from a '''multi-line''' AFOH 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 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 (<apll>⋄</apll>).</p> | <p>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 (<apll>⋄</apll>).</p> | ||
==Line Continuations On Output== | |||
<p>This feature is also used on output to indicate that a portion of the output has been folded due to width limitations. For example,</p> | |||
<apll><pre> | |||
⎕PW←120 | |||
2 2 20⍴⍳99 | |||
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |||
⎕PW←30 | |||
2 2 20⍴⍳99 | |||
1 2 3 4 5 6 7 8 9 10 | |||
21 22 23 24 25 26 27 28 29 30 | |||
41 42 43 44 45 46 47 48 49 50 | |||
61 62 63 64 65 66 67 68 69 70 | |||
<_lc/> 11 12 13 14 15 16 17 18 | |||
<_lc/> 31 32 33 34 35 36 37 38 | |||
<_lc/> 51 52 53 54 55 56 57 58 | |||
<_lc/> 71 72 73 74 75 76 77 78 | |||
<_lc/> 19 20 | |||
<_lc/> 39 40 | |||
<_lc/> 59 60 | |||
<_lc/> 79 80 | |||
</pre></apll> | |||
==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== | ==Shortcut Keystrokes for Editing== | ||
Line 37: | Line 79: | ||
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. | 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. | ||
{|class="wikitable" | |||
Deletes the character at the current position. | !Keystroke||Meaning | ||
|- | |||
Deletes the character to the left of the Insert or Replace text cursor. | !Del | ||
|Deletes the character at the current position. (This is the exact opposite of what DEL normally does,i.e. deletes to the right, but, remember, backspace is a valid character in APL, as it is used to create compound characters, e.g. {{thumb}}, the comment symbol, created by ? (backspace) ? | |||
Deletes the characters from the current position to the end of the line. | |- | ||
!Shift-Del | |||
Toggles the Insert vs. Replace state of the text cursor. | |Deletes the character to the left of the Insert or Replace text cursor. | ||
|- | |||
Pastes text from the clipboard into the text to the left of the text cursor. | !Ctrl-Del | ||
|Deletes the characters from the current position to the end of the line. | |||
|- | |||
!Ins | |||
Moves the text cursor to the start of the current line. | |Toggles the Insert vs. Replace state of the text cursor. | ||
|- | |||
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. | !Shift-Ins | ||
|Pastes text from the clipboard into the text to the left of the text cursor. | |||
Move the cursor to the start of the screen buffer, possibly scrolling the screen so that point is visible. | |- | ||
!Ctrl-Ins | |||
Moves the text cursor to the end of the current line. | |Copies selected text into the clipboard. | ||
|- | |||
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. | !Home | ||
|Moves the text cursor to the start of the current line. | |||
Moves the text cursor to the end of the screen buffer, possibly scrolling the screen so that point is visible. | |- | ||
!Shift-Home | |||
Moves the text cursor up one line, possibly moving it to the end of the line if the line is short. | |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. | ||
|- | |||
Selects all of the text from the current position to the column up one line and moves the text cursor to that point. | !Ctrl-Home | ||
|Move the cursor to the start of the screen buffer, possibly scrolling the screen so that point is visible. | |||
Same as Up. | |- | ||
!End | |||
Moves the text cursor down one line, possibly moving it to the end of the line if the line is short. | |Moves the text cursor to the end of the current line. | ||
|- | |||
Selects all of the text from the current position to the column down one line and moves the text cursor to that point. | !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. | |||
Same as Down. | |- | ||
!Ctrl-End | |||
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. | |Moves the text cursor to the end of the screen buffer, possibly scrolling the screen so that point is visible. | ||
|- | |||
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. | !Up | ||
|Moves the text cursor up one line, possibly moving it to the end of the line if the line is short. | |||
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. | |- | ||
!Shift-Up | |||
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. | |Selects all of the text from the current position to the column up one line and moves the text cursor to that point. | ||
|- | |||
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-Up | ||
|Same as Up. | |||
Moves the text cursor to the start of the word to the right. | |- | ||
!Down | |||
Scrolls the screen by one page down. | |Moves the text cursor down one line, possibly moving it to the end of the line if the line is short. | ||
|- | |||
Selects all of the text from the current position to the same column at the end of the current page. | !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. | |||
Moves the text cursor from the current position to the same column at the end of the current page. | |- | ||
!Ctrl-Down | |||
Scrolls the screen by one page up. | |Same as Down. | ||
|- | |||
Selects all of the text from the current position to the same column at the start of the current page. | !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. | |||
Moves the text cursor from the current position to the same column at the start of the current page. | |- | ||
!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. | |||
|} |
Latest revision as of 09:31, 20 October 2024
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/operator/hyperator (AFOH) with comments, where separate physical lines form a single logical line. Note that this is different from a multi-line AFOH 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 (⋄).
Line Continuations On Output
This feature is also used on output to indicate that a portion of the output has been folded due to width limitations. For example,
⎕PW←120 2 2 20⍴⍳99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 ⎕PW←30 2 2 20⍴⍳99 1 2 3 4 5 6 7 8 9 10 21 22 23 24 25 26 27 28 29 30 41 42 43 44 45 46 47 48 49 50 61 62 63 64 65 66 67 68 69 70 ➥ 11 12 13 14 15 16 17 18 ➥ 31 32 33 34 35 36 37 38 ➥ 51 52 53 54 55 56 57 58 ➥ 71 72 73 74 75 76 77 78 ➥ 19 20 ➥ 39 40 ➥ 59 60 ➥ 79 80
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. (This is the exact opposite of what DEL normally does,i.e. deletes to the right, but, remember, backspace is a valid character in APL, as it is used to create compound characters, e.g. Template:Thumb, the comment symbol, created by ? (backspace) ? |
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. |