home *** CD-ROM | disk | FTP | other *** search
- $MACRO MAKETEMP;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: MAKETEMP
-
- Description: This macro will create a custom template editing macros.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Def_Int(Active_Window,Code_Window,Work_Window,Indent_Amount,Temp_Integer,
- Cursor_Col,Cursor_Line,More_Templates);
- Def_Str(Temp_String,Language_Type);
- Def_Char(Temp_Char);
-
- Refresh := False;
- Reg_Exp_Stat := False;
- Active_Window := Cur_Window;
- Create_Window;
- Code_Window := Cur_Window;
- Create_Window;
- Window_Attr := 6;
- Work_Window := Cur_Window;
-
- RM('USERIN^DB /PRE=LANG/F=LANGUAGE.DB/LO=1/U=1/TT=1/H=FE_LANGUAGE');
- IF (Return_Int = 0) THEN
- Goto ABORT;
- END;
- RM('SETUP^STRSRC ' + Return_Str);
- Language_Type := Caps(Copy(Return_Str,1,8));
- Call CODE_SHELL;
- More_Templates := True;
-
- While (More_Templates) Do
- {Querybox is a general purpose "boxed" prompt.}
- Return_Int := 0;
- RM('userin^QUERYBOX /N=1/H=IN/C=1/L=3/W=1/NK=1/MIN=0' +
- '/T=ENTER AMOUNT OF TAB STOPS TO INDENT/P= ');
- IF (Return_Str = 'FALSE') THEN
- Kill_Box;
- Goto ABORT;
- END;
- Write(Str(Return_Int),18,4,0,M_B_Color);
- Indent_Amount := Return_Int;
-
- Return_Str := '';
- CHAR_PROMPT:
- RM('userin^QUERYBOX /H=IN/C=6/L=5/W=1/NK=1' +
- '/T=ENTER CHARACTER TO EXPAND/P= ');
- IF (Return_Int = False) THEN
- Kill_Box;
- Kill_Box;
- Goto ABORT;
- END;
- IF (Return_Str = '') THEN
- RM('MEERROR^Beeps /C=1');
- Kill_Box;
- Goto CHAR_PROMPT;
- END;
- Write(Return_Str,18,6,0,M_B_Color);
- Temp_Char := Return_Str;
- Call CREATE_TEMPLATE;
- Kill_Box;
- Kill_Box;
- Call CODE_TEMPLATE;
-
- Put_Box(1,2,48,5,0,M_B_Color,'CREATE ANOTHER TEMPLATE FOR THIS LANGUAGE?',true);
- RM('USERIN^XMENU /X=20/Y=3/T=0/S=1/M=No(TE)Yes()');
- Kill_Box;
- IF (Return_Int <> 2) THEN
- More_Templates := False;
- END;
- End;
-
- Switch_Window(Work_Window);
- File_Changed := False;
- Delete_Window;
- Switch_Window(Code_Window);
- Tof;
- Make_Message('Custom template ''' + File_Name + ''' created.');
- Goto END_OF_MAC;
-
- CREATE_TEMPLATE:
- {This is where the user defines exacly what he wants the expanded construct to
- look like. There is a limited emulation of the editor here}
- Refresh := False;
- Switch_Window(Work_Window);
- File_Changed := False;
- Erase_Window;
- {
- Size_Window(1,11,78,22);
- }
- File_Name := 'WORK.TMP';
- Put_Box(1,8,80,23,0,W_B_Color,'CREATE THE EXPANDED TEMPLATE IN THIS WINDOW',True);
- Write('Place cursor exactly where you want it to be in the expanded template,',4,9,0,W_S_Color);
- Write('then press <ESC>.',4,10,0,W_S_Color);
- Write('├────────────────────────────────────────────────────────────────────────────╢',1,11,0,W_B_Color);
- RM('USERIN^EDITWINDOW /X=1/Y=11/W=77/L=11/NB=1/RM=2048');
- {
- Refresh := True;
- Redraw;
- {This creates partial editor functionality}
- While (Key1 <> 27) Do
- Read_Key;
- If (Key1 = 0) Then
- IF (XPos(Char(Key2),'HPKMGORS',1)) THEN
- Pass_Key(Key1,Key2);
- END;
- ELSE
- IF (Key1 <> 27) THEN
- Pass_Key(Key1,Key2);
- END;
- End;
- End;
- Refresh := False;
- Kill_Box;
- }
- RET;
-
- CODE_SHELL:
- Switch_Window(Code_Window);
- File_Name := Language_Type + '.SRC';
- Tof;
- Undent;
- Put_Line('$MACRO_FILE ' + Language_Type + ';');
- Eol;
- Cr;
- PUT_LINE('$MACRO ' + COPY(LANGUAGE_TYPE,1,3) + 'TEMP;');
- Eol;
- Cr;
- Put_Line(' DEF_INT(Temp_Col,Temp_Insert);');
- Eol;
- Cr;
- Put_Line(' DEF_STR(Key_Chars);');
- Eol;
- Cr;
- Put_Line(' DEF_CHAR(Temp_Char);');
- Eol;
- Cr;
- Put_Line(' Key_Chars := '''';');
- Eol;
- Cr;
- Put_Line(' Temp_Insert := Insert_Mode;');
- Eol;
- Cr;
- Put_Line(' If Not(At_Eol) Then');
- Eol;
- Cr;
- Put_Line(' GOTO END_OF_MAC;');
- Eol;
- Cr;
- Put_Line(' End;');
- Eol;
- Cr;
- Put_Line(' Insert_Mode := True;');
- Eol;
- Cr;
- Put_Line(' Temp_Col := C_COL;');
- Eol;
- Cr;
- Put_Line(' If (C_Col > 1) Then');
- Eol;
- Cr;
- Put_Line(' Left;');
- Eol;
- Cr;
- Put_Line(' If (XPos(Cur_Char,Key_Chars,1) = 0) Then');
- Eol;
- Cr;
- Put_Line(' Goto_Col(Temp_Col);');
- Eol;
- Cr;
- Put_Line(' Goto END_OF_MAC;');
- Eol;
- Cr;
- Put_Line(' End;');
- Eol;
- Cr;
- Put_Line(' Else');
- Eol;
- Cr;
- Put_Line(' Goto END_OF_MAC;');
- Eol;
- Cr;
- Put_Line(' End;');
- Eol;
- Cr;
- Put_Line(' Temp_Col := C_COL;');
- Eol;
- Cr;
- Cr;
- Put_Line('END_OF_MAC:');
- Eol;
- Cr;
- Put_Line(' Insert_Mode := Temp_Insert;');
- Eol;
- Cr;
- PUT_LINE('END_MACRO;');
- RET;
-
- CODE_TEMPLATE:
- Switch_Window(Work_Window);
- Cursor_Line := C_Line;
- Cursor_Col := C_Col - 1;
- Tof;
- Temp_String := Get_Line;
- Down;
- Switch_Window(Code_Window);
- Tof;
- IF (Search_Fwd('Key_Chars := ''',0)) THEN
- Eol;
- Left;
- Left;
- Insert_Mode := True;
- Text(Temp_Char);
- END;
- IF (Search_Fwd('END_OF_MAC:',0)) THEN
- Cr;
- Cr;
- Up;
- Up;
- Put_Line(' If (Cur_Char = ''' + Temp_Char + ''') Then');
- Eol;
- Cr;
- Put_Line(' Insert_Mode := False;');
- Eol;
- Cr;
- WHILE (Indent_Amount > 0) DO
- Put_Line(' Indent;');
- Eol;
- Cr;
- --Indent_Amount;
- END;
- Put_Line(' Goto_Col(Temp_Col);');
- Eol;
- If (Temp_String <> '') Then
- Cr;
- Put_Line(' Text(''' + Temp_String + ''');');
- Eol;
- End;
- Cr;
- Put_Line(' Insert_Mode := True;');
- Eol;
- Switch_Window(Work_Window);
- WHILE Not(At_Eof) DO
- Temp_String := Get_Line;
- Switch_Window(Code_Window);
- Cr;
- Put_Line(' Cr;');
- Eol;
- If (Temp_String <> '') Then
- Cr;
- Put_Line(' Goto_Col(Temp_Col);');
- Eol;
- Cr;
- Put_Line(' Text(''' + Temp_String + ''');');
- Eol;
- End;
- Switch_Window(Work_Window);
- Down;
- END;
- Up;
- WHILE (C_Line > Cursor_Line) DO
- Switch_Window(Code_Window);
- Cr;
- Put_Line(' Up;');
- Eol;
- Switch_Window(Work_Window);
- Up;
- END;
- Switch_Window(Code_Window);
- Cr;
- Put_Line(' Goto_Col(Temp_Col + ' + Str(Cursor_Col) + ');');
- Eol;
- Cr;
- Put_Line(' Goto END_OF_MAC;');
- Eol;
- Cr;
- Put_Line(' End;');
- END;
- RET;
-
- ABORT:
- Switch_Window(Work_Window);
- File_Changed := False;
- Delete_Window;
- Switch_Window(Code_Window);
- File_Changed := False;
- Delete_Window;
- Switch_Window(Active_Window);
- Make_Message('Custom template creating macro terminated by user.');
-
- END_OF_MAC:
- Refresh := True;
- Redraw;
-
- END_MACRO;