home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-31 | 3.9 KB | 162 lines | [TEXT/TCEd] |
- #
- # Key Assignment Examples
- #
- # Last Modified: Friday, June 27, 1991 at 11:46 PM
- # Macro Files for Preditor
- #
- #
- # © Copyright Evatac Software 1988-1991
- # All rights reserved
- #
-
- # The following are some example macros that you would commonly
- # assign to a keystroke. They demonstrate how you can write
- # simple macros to maniuplate the cursor position, insert
- # text etc.
- #
- # You can changes the key assignments by using the 'Assign
- # Menus & Keys' command in the Special Menu to obtain the
- # keycode and modifier value, and replace the ones given below
- # (after the AddMenu command)
-
- #
- # Electric {
- #
- # Electrically insert a left bracket for C source code.
- # There are two methods, uncomment/comment the one you want.
- #
- # Method #1: if () {
- # | <-- Insertion Point
- # Method #2: if ()
- # {
- # | <-- Insertion Point
- #
- # Assigned to: '{'
-
- AddMenu "Electric {" # 33 2
- saveHighlight = ~Highlighting
- ~Highlighting = 0
-
- If (Position("p", "start", §, ~Active) == ∂
- Position("p", "end", §, ~Active) && ∂
- (!Valid(§:[§]≥1, ~Active) || Select(§, ~Active) == "\n"))
-
- /* Get the space/tabs at the beginning of the current */
- /* line. */
-
- Mark("y", [§]≤0, "_LB_", ~Active)
- Search("bp", "^[ \\t]+", NULL, ~Active)
- Copy(§, ~Active)
-
- /* There are two methods for placing the left bracket. */
- /* Comment/Uncomment them based on your preference */
-
- /* Method #1 : Place left bracket on same line as */
- /* the conditional statement */
-
- Insert("{\n" + Clipboard(~Clipboard) + "\t", @"_LB_", ~Active)
-
- /* Method #2: Place left bracket on the next line, lined */
- /* up with the left edge of the current line, then tab */
- /* in on the next line to begin inserting text */
-
- # Insert("\n" + Clipboard(~Clipboard) + "{\n" ∂
- # + Clipboard(~Clipboard) + "\t", @"_LB_", ~Active)
- Else
- Key(123, [§]≤0, ~Active)
- End
-
- Unmark("", "_LB_", ~Active)
- ~Highlighting = saveHighlight
- EndMenu
-
- #
- # Electric }
- #
- # Electrically line up the right bracket with the matching
- # line containing the left bracket for C source code. For example
- #
- # if () {
- # x = 3; ( Typing '}' will place )
- # } <-- ( '}' here )
- #
- # Assigned to: '}'
-
- AddMenu "Electric }" # 30 2
- saveHighlight = ~Highlighting
- ~Highlighting = 0
-
- If (Position("p", "start", §, ~Active) == ∂
- Position("p", "end", §, ~Active) && ∂
- (!Valid(§:[§]≥1, ~Active) || Select(§, ~Active) == "\n"))
-
- Mark("y", §, "_RB_", ~Active)
- Insert("}", [§]≤0, ~Active)
- Select(§:[§]≤1, ~Active)
- Match(NULL, §, ~Active)
- Search("bp", "^[ \\t]+", NULL, ~Active)
- Copy(§, ~Active)
- Select(@"_RB_", ~Active)
-
- /* Now see if there is any previous text on the line. If */
- /* so, insert the bracket on the next line */
-
- origPos = Position("p", "start", §, ~Active)
- Search("pb", "^[ \\t]+", NULL, ~Active)
-
- If (origPos != Position("p", "end", §, ~Active))
-
- /* Place on new line */
-
- Select([@"_RB_"]≤0, ~Active)
- Insert("\n" + Clipboard(~Clipboard), §, ~Active)
-
- Else
- Paste(§, ~Active)
- End
-
- Insert("\n" + Clipboard(~Clipboard), [§]≥1, ~Active)
-
- Else
- Key(125, [§]≤0, ~Active)
- End
-
- Unmark("", "_RB_", ~Active)
- ~Highlighting = saveHighlight
- EndMenu
-
- #
- # Electric ;
- #
- # Electrically place a semi colon, insert a new line and
- # indent to the proper insertion point. For Example
- #
- # x = 3; (Typing the ';' here will
- # | <-- (place the insertion point here
- #
- # Assigned to: ';'
-
- AddMenu "Electric ;"
- /* These lines can be commented out if you normally */
- /* have auto indent on */
- NewFormat("y", "U", NULL, NULL, NULL, "current", ~Active)
- Format("d", "current", ~Active)
- DeleteFormat("current")
-
- Insert(";", §, ~Active)
- Key(13, §, ~Active)
- EndMenu
-
-
- #
- # Goto SelectedMarker
- #
- # Jumps to the marker in the activate document that has the name
- # of the current selection
- #
- # Assigned to: <control> M
-
- AddMenu "Goto Selected Marker" 46 16
- selection = Select(§, ~Active)
- Select(@selection, ~Active)
- EndMenu