home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE MULTI_ED;
- {******************************************************************************
- MULTI-EDIT MACRO FILE
-
- Name: MULTI_ED
-
- Description: Language support for the Multi-Edit macro language.
-
- MUL_IND - Smart Indenting
- MULTEMP - Template Editing
- MULMTCH - Construct matching
- MULHELP - Language sensitive help
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- $MACRO MUL_IND;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MUL_IND
-
- Description: Performs smart indent for the Multi-Edit macro language.
- Is called by the macro CR.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- DEF_INT( ind_count, new_col, paren_count, t_ins, t_undo, jx );
- DEF_STR( fstr[40] );
-
- refresh := FALSE;
- t_undo := undo_stat;
- undo_stat := false;
- reg_exp_stat := TRUE;
- Mark_Pos;
-
- ind_count := 0;
- new_col := c_col;
- t_ins := Insert_Mode;
- left;
- {goto search_again;}
- Find_Comment:
- IF search_bwd('[@{@}'']', 50 ) THEN
- IF found_str = '{' THEN
- word_right;
- new_col := c_col;
- jx := c_line;
- fstr := found_str;
- goto_mark;
- mark_pos;
- IF jx <> c_line THEN
- first_word;
- new_col := c_col;
- END;
- GOTO Do_Indent;
- ELSIF found_str = '''' THEN
- left;
-
- IF search_bwd('{%@$MACRO }||{''}', 50 ) THEN
- IF (found_str = '''') THEN
- left;
- GOTO Find_Comment;
- END;
- END;
- GOTO CR_EXIT;
- {
- IF NOT( search_bwd( '''', 100 )) THEN
- GOTO CR_EXIT;
- END;
- left;
- GOTO Find_Comment;
- }
- END;
- END;
- GOTO_MARK;
- MARK_POS;
- left;
-
- Search_Again:
- IF Search_Bwd(
- '[''()@}]||{%||[|9 ;)]{ELSIF}||{ELSE}||{END}||{IF}||{WHILE}||{@$MACRO}$||[|9 ;.(]}',
- 20 ) THEN
- WHILE NOT(AT_EOL) AND (XPOS( cur_char,'|9|255 ',1 ) <> 0) DO
- right;
- END;
- IF found_str = '''' THEN
- left;
- IF Search_BWD( '''', 20 ) THEN
- left;
- GOTO Search_Again;
- ELSE
- GOTO CR_Exit;
- END;
- END;
- IF found_str = ')' THEN
- left;
- Paren_Count := 1;
- WHILE Paren_Count <> 0 DO
- IF Search_BWD( '[''()]', 20 ) THEN
- IF found_str = '(' THEN
- --Paren_Count;
- ELSIF found_str = ')' THEN
- ++Paren_Count;
- ELSE
- IF NOT(search_bwd( '''', 20 )) THEN
- GOTO CR_Exit;
- END;
- END;
- left;
- ELSE
- GOTO CR_Exit;
- END;
- END;
- Goto Search_Again;
- END;
- IF found_str = '}' THEN
- left;
- Paren_Count := 1;
- WHILE Paren_Count <> 0 DO
- IF Search_BWD( '[''@{@}]', 20 ) THEN
- IF found_str = '{' THEN
- --Paren_Count;
- ELSIF found_str = '}' THEN
- ++Paren_Count;
- ELSE
- IF NOT(search_bwd( '''', 20 )) THEN
- GOTO CR_Exit;
- END;
- END;
- left;
- ELSE
- GOTO CR_Exit;
- END;
- END;
- Goto Search_Again;
- END;
- new_col := c_col;
- fstr := CAPS(Get_Word(' ([{|9;'));
- IF fstr <> 'END' THEN
- ++ind_count;
- END;
- ELSE
- GOTO CR_Exit;
- END;
-
- Do_Indent:
- make_message('Indenting from [' + fstr + ']' );
- Goto_Col( new_col );
- insert_mode := FALSE;
- While ind_count > 0 DO
- tab_right;
- --ind_count;
- END;
- While ind_count < 0 DO
- tab_left;
- ++ind_count;
- END;
- Set_Indent_Level;
- insert_mode := TRUE;
-
- CR_EXIT:
- Goto_Mark;
- undo_stat := t_undo;
- CR;
- EXIT:
- Insert_Mode := t_ins;
- undo_stat := t_undo;
- END_MACRO;
-
- $MACRO MULTEMP;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MULTEMP
-
- Description: Creates language constructs for the Multi-Edit macro language
- based on a single character to the left of the cursor.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- DEF_INT(Temp_Col,Temp_Insert, tc, x, y);
-
- Temp_Insert := Insert_Mode;
- If NOT(AT_EOL) Then
- Goto END_OF_MAC;
- End;
-
- Insert_Mode := True;
- Temp_Col := C_COL;
-
- call calc_xy;
- return_int := 0;
- tc := 0;
- IF c_col > 1 THEN
- left;
- RETURN_INT := XPOS( caps(cur_char), 'IWEM$', 1 );
- IF RETURN_INT <> 0 THEN
- tc := 1;
- IF return_int > 4 THEN
- return_int := 4;
- END;
- ELSE
- goto_col( temp_col );
- END;
- END;
-
-
- RM( 'USERIN^XMENU /L=TEMPLATE/S=' + str(return_int) + '/X=' + str(x) + '/Y=' + str(y) +
- '/T=1/B=1/M=IF...THEN()WHILE...DO()ELSIF THEN()$MACRO...END_MACRO()Complete macro/comment header()' );
-
- Insert_Mode := True;
-
- IF ( return_int > 0 ) THEN
- IF not(at_eol) THEN
- del_char;
- END;
- temp_col := c_col;
- END;
- IF ( RETURN_INT = 1 ) Then
- Goto MAKEIF;
- ELSIF (RETURN_INT = 2) Then
- Goto MAKEWHILE;
- ELSIF (RETURN_INT = 3) Then
- Goto MAKEELSIF;
- ELSIF (RETURN_INT = 4) Then
- Goto MAKEMACRO;
- ELSIF (RETURN_INT = 5) THEN
- Goto MAKEMACHEADER;
- END;
-
- Goto END_OF_MAC;
- MAKEIF:
- goto_col(Temp_Col);
- Text( 'IF () THEN' );
- Cr;
- Cr;
- goto_col(Temp_Col);
- Text( 'END;' );
- Up;
- goto_col(Temp_Col);
- Indent;
- Up;
- goto_col(Temp_Col + 4);
- Goto END_OF_MAC;
-
- MAKEELSIF:
- goto_col(Temp_Col);
- Text( 'ELSIF () THEN' );
- Cr;
- goto_col(Temp_Col);
- Indent;
- Up;
- goto_col(Temp_Col + 7);
- Goto END_OF_MAC;
-
-
- MAKEMACRO:
- goto_col(1);
- TEXT( '$MACRO ;' );
- Cr;
- Cr;
- goto_col(1);
- TEXT( 'END_MACRO;' );
- Up;
- goto_col(1);
- Indent;
- Up;
- goto_col(8);
- Goto END_OF_MAC;
-
-
- MAKEWHILE:
- goto_col(Temp_Col);
- Text( 'WHILE () DO' );
- Cr;
- Cr;
- goto_col(Temp_Col);
- Text( 'END;' );
- Up;
- goto_col(Temp_Col);
- Indent;
- Up;
- goto_col(Temp_Col + 7);
- Goto END_OF_MAC;
-
-
- MAKEMACHEADER:
- Return_Str := '';
- RM('USERSTR /B=1/BL=Input Macro Name:/W=16/X=' + str(wherex) + '/Y=' + str(wherey - 1) );
- goto_col( 1 ); Set_Indent_Level;
- Text('{*******************************MULTI-EDIT MACRO******************************');
- CR; CR;
- Text('Name: '); Mark_Pos; CR; CR;
- Text('Description:'); CR; CR;
- IF global_int('USER_ACI_COPYRIGHT') THEN
- Text('***************(C) Copyright 19' + copy(date,7,2)
- + ' by American Cybernetics, Inc.***************}');
- ELSE
- Text('******************************************************************************}');
- END;
- Cr;
- Text('$MACRO ' + return_str + ';');
- CR; CR;
- Text('$END_MACRO; {' + return_str + '}');
- CR;
- Goto_Mark;
- Text( return_str );
- down; down;
- eol;
- right; right;
- goto end_of_mac;
-
- calc_xy:
- x := (wherex - 9);
- if (x + 18 + 2) > screen_width then
- x := screen_width - ( 20 );
- end;
- if x < 1 then
- x := 1;
- end;
- y := wherey - 7;
- if y < 3 then
- y := wherey + 1;
- if y > (screen_length - 6) then
- y := 3;
- end;
- end;
- ret;
-
-
- END_OF_MAC:
- Insert_Mode := Temp_Insert;
-
- END_MACRO;
-
- $MACRO MULMTCH TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MULMTCH
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- Modified by Kevin Jackson
- ******************************************************************************}
-
- DEF_STR( Str1, {Match strings}
- EStr1,
- T_Str, S_Str, FStr );
-
- DEF_INT( Direction, {1 = search forward, 0 = backward}
- B_Count, {Match count. 0 = match found}
- S_Res, {Search results}
- Second_Time,
- match_line,
- match_col );
-
-
- Second_Time := False;
- Refresh := False; {Turn screen refresh off}
- Str1 := '';
- EStr1 := '';
- mark_pos;
- match_line := 0;
-
- Find_Match_Str:
-
- IF (Cur_Char = '(') THEN {Setup match for '('}
- Str1 := '(';
- EStr1 := ')';
- Direction := 1;
- S_Str := '[()'']';
- GOTO Start_Match;
- ELSIF (Cur_Char = ')') THEN {Setup match for ')'}
- Str1 := ')';
- EStr1 := '(';
- Direction := 0;
- S_Str := '[()'']';
- GOTO Start_Match;
- ELSIF (Cur_Char = '{') THEN {Setup match for '{'}
- Str1 := '{';
- EStr1 := '}';
- Direction := 1;
- S_Str := '[@{@}'']';
- GOTO Start_Match;
- ELSIF (Cur_Char = '}') THEN {Setup match for '}'}
- Str1 := '}';
- EStr1 := '{';
- Direction := 0;
- S_Str := '[@{@}'']';
- GOTO Start_Match;
- END;
-
- IF At_EOL THEN {If we are at the end of a line the go to the first word}
- First_Word;
- END;
-
- IF (XPos(Cur_Char,' |9|255',1)) THEN{If we are on a blank space then find a word}
- Word_Right;
- END;
-
- S_Str := '['']||{%||[|9 ;)]{ELSIF}||{END}||{IF}||{WHILE}$||[|9 ;.(]}||{@{}||{@}}';
-
- T_Str := Caps( Get_Word(';. |9|255') ); {Get the current word}
-
- IF (T_Str = 'IF') OR (T_Str = 'ELSIF') OR (T_Str = 'WHILE') OR (T_Str = 'ELSE') THEN
- Str1 := 'IF WHILE';
- EStr1 := ' END ELSIF';
- Direction := 1;
- GOTO Start_Match;
- END;
-
- IF T_Str = 'END' THEN
- S_Str := '['']||{%||[|9 ;)]{END}||{IF}||{WHILE}$||[|9 ;.(]}||{@{}||{@}}';
- Str1 := 'END';
- Estr1 := ' IF WHILE';
- Direction := 0;
- Word_Left;
- Left;
- GOTO Start_Match;
- END;
-
- {If we didn't find a word to match the first time then try again}
- If NOT( Second_Time ) THEN
- Second_Time := True;
- First_Word;
- GOTO Find_Match_Str;
- END;
-
- Make_Message('NOTHING to Match');
- GOTO Macro_Exit;
-
- Start_Match:
- Reg_Exp_Stat := True;
- Ignore_Case := True;
- B_Count := 1;
- S_Res := 1;
- Make_Message('Matching... Press <ESC> to Stop.');
- Working;
-
- MATCH_LOOP: {Main loop}
- {If the <ESC> key is pressed while matching then abort the search}
- if check_key then
- if key1 = 27 then
- Make_Message('Match Aborted.');
- goto macro_exit;
- end;
- end;
-
- If S_Res = 0 THEN {If last search result was false then exit}
- GOTO Error_Exit;
- END;
-
- If B_Count = 0 THEN {If match count is 0 then success}
- GOTO Found_Exit;
- END;
-
- If Direction = 1 THEN {Perform search based on direction}
- Right;
- While NOT (At_EOL) and ((Cur_CHar = '|255') or (Cur_Char = '|9')) DO
- Right;
- END;
- S_Res := Search_Fwd(S_Str,0);
- ELSE
- Left;
- While (Cur_Char = '|255') or
- (Cur_Char = '|9') DO
- Left;
- END;
- S_Res := Search_Bwd(S_Str,0);
- END;
-
- If S_Res = 0 THEN {If search failed then exit}
- GOTO Macro_Exit;
- END;
-
- FStr := Caps(Found_Str);
-
- IF Length(FStr) > 2 THEN
- IF XPOS(Copy(FStr,1,1),'|9 ;()',1) THEN {If the first char is a space or a ;}
- FStr := Copy(FStr,2,20); { then eliminate it}
- END;
- {If it ended in a space, ; or . then}
- IF XPOS(Copy(FStr,Length(FStr),1),'|9 ;.()',1) THEN
- FStr := Copy(FStr,1,Length(FStr) - 1); {eliminate that char}
- END;
- END;
-
- {If we found the first match string then}
- IF XPOS(FStr,STR1,1) THEN
- ++B_Count; {Inc the match count}
- GOTO Match_Loop;
- END;
-
- IF XPOS(FStr,ESTR1,1) THEN {If we found the second match string then}
- {04-09-90 09:17am I'm leaving this in the file, just in case there was a reason
- for it. It caused the match not to work in many cases.
- IF XPOS(' ' + FStr,ESTR1,1) THEN {If we found the second match string then}
- }
- IF fstr = 'ELSIF' THEN
- IF b_count = 1 THEN
- b_count := 0;
- END;
- ELSE
- --B_Count; { decrement the match count}
- END;
- GOTO Match_Loop;
- END;
-
- {If we found a comment then match it}
- IF (Direction = 1) AND (FStr = '{') THEN
- again_1:
- S_Res := Search_Fwd('[@}'']',0);
- IF (s_res) AND (found_str = '''') THEN
- call match_quote_fwd;
- goto again_1;
- END;
- GOTO Match_Loop;
- END;
-
- {If we found a comment then match it}
- IF (Direction = 0) AND (FStr = '}') THEN
- again_2:
- S_Res := Search_Bwd('[@{'']',0);
- IF (s_res) AND (found_str = '''') THEN
- call match_quote_bwd;
- goto again_2;
- END;
- GOTO Match_Loop;
- END;
-
- If FStr = '''''' THEN {If we found two single quotes the skip it}
- If Direction = 1 THEN
- RIGHT;
- ELSE
- LEFT;
- END;
- GOTO Match_Loop;
- END;
- {If we found a single quote then match it}
- IF FStr = '''' THEN
-
- Quote_Loop:
-
- If Direction = 1 THEN
- RIGHT;
- S_Res := Search_Fwd('''',0);
- ELSE
- LEFT;
- S_Res := Search_Bwd('''',0);
- END;
- If S_Res = 0 THEN
- GOTO Macro_Exit;
- END;
- FStr := Found_Str;
- If FStr = '''''' THEN
- GOTO Quote_Loop;
- END;
- GOTO Match_Loop;
-
- END;
- GOTO error_exit;
-
- Match_Quote_Bwd:
- left;
- IF NOT(search_bwd( '''', 100 )) THEN
- GOTO error_Exit;
- END;
- left;
- RET;
-
- Match_Quote_Fwd:
- right;
- IF NOT(search_fwd( '''', 100 )) THEN
- GOTO error_Exit;
- END;
- right;
- RET;
-
-
- Error_Exit: {Go here for unsucessfull match}
- goto_mark;
- Make_Message('Match NOT Found');
- GOTO Macro_Exit;
-
- Found_Exit: {Go here for successfull match}
- While NOT (At_EOL) and ((Cur_CHar = '|255') or (Cur_Char = '|9')) DO
- Right;
- END;
- match_line := c_line;
- match_col := c_col;
- goto_mark;
- IF (match_line < c_line ) AND ((c_line - match_line) < 50) THEN
- WHILE match_line < c_line DO
- up;
- END;
- ELSIF (c_line < match_line ) AND ((match_line - c_line) < 50) THEN
- WHILE c_line < match_line DO
- down;
- END;
- END;
- goto_line( match_line );
- goto_col( match_col );
-
- Make_Message('Match Found');
- Macro_Exit:
- Refresh := True;
- Redraw;
- END_MACRO;
-
- $MACRO MULHELP;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MULHELP
-
- Description: Attempts to retrieve help on the current word the cursor is
- sitting on from the Multi-Edit macro language reference.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_str( hstr );
-
- right;
- word_left;
- hstr := get_word( '{};|9 |255()[]' );
- rm('mehelp /F=macro/LK=INDEX%' + hstr);
-
- END_MACRO;
-
-
-