home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-6.ZIP / SRC / MAKETEMP.SRC < prev    next >
Encoding:
Text File  |  1990-03-29  |  6.4 KB  |  297 lines

  1. $MACRO MAKETEMP;
  2. {*******************************MULTI-EDIT MACRO******************************
  3.  
  4. Name: MAKETEMP
  5.  
  6. Description:  This macro will create a custom template editing macros.
  7.  
  8.                              (C) Copyright 1989 by American Cybernetics, Inc.
  9. ******************************************************************************}
  10.  
  11.     Def_Int(Active_Window,Code_Window,Work_Window,Indent_Amount,Temp_Integer,
  12.                     Cursor_Col,Cursor_Line,More_Templates);
  13.     Def_Str(Temp_String,Language_Type);
  14.     Def_Char(Temp_Char);
  15.  
  16.     Refresh := False;
  17.     Reg_Exp_Stat := False;
  18.     Active_Window := Cur_Window;
  19.     Create_Window;
  20.     Code_Window := Cur_Window;
  21.     Create_Window;
  22.     Window_Attr := 6;
  23.     Work_Window := Cur_Window;
  24.  
  25.     RM('USERIN^DB /PRE=LANG/F=LANGUAGE.DB/LO=1/U=1/TT=1/H=FE_LANGUAGE');
  26.     IF (Return_Int = 0) THEN
  27.         Goto ABORT;
  28.     END;
  29.     RM('SETUP^STRSRC ' + Return_Str);
  30.     Language_Type := Caps(Copy(Return_Str,1,8));
  31.     Call CODE_SHELL;
  32.     More_Templates := True;
  33.  
  34.     While (More_Templates) Do
  35. {Querybox is a general purpose "boxed" prompt.}
  36.         Return_Int := 0;
  37.         RM('userin^QUERYBOX /N=1/H=IN/C=1/L=3/W=1/NK=1/MIN=0' +
  38.                             '/T=ENTER AMOUNT OF TAB STOPS TO INDENT/P=                ');
  39.         IF (Return_Str = 'FALSE') THEN
  40.             Kill_Box;
  41.             Goto ABORT;
  42.         END;
  43.         Write(Str(Return_Int),18,4,0,M_B_Color);
  44.         Indent_Amount := Return_Int;
  45.  
  46.         Return_Str := '';
  47. CHAR_PROMPT:
  48.         RM('userin^QUERYBOX /H=IN/C=6/L=5/W=1/NK=1' +
  49.                             '/T=ENTER CHARACTER TO EXPAND/P=           ');
  50.         IF (Return_Int = False) THEN
  51.             Kill_Box;
  52.             Kill_Box;
  53.             Goto ABORT;
  54.         END;
  55.         IF (Return_Str = '') THEN
  56.             RM('MEERROR^Beeps /C=1');
  57.             Kill_Box;
  58.             Goto CHAR_PROMPT;
  59.         END;
  60.         Write(Return_Str,18,6,0,M_B_Color);
  61.         Temp_Char := Return_Str;
  62.         Call CREATE_TEMPLATE;
  63.         Kill_Box;
  64.         Kill_Box;
  65.         Call CODE_TEMPLATE;
  66.  
  67.         Put_Box(1,2,48,5,0,M_B_Color,'CREATE ANOTHER TEMPLATE FOR THIS LANGUAGE?',true);
  68.         RM('USERIN^XMENU /X=20/Y=3/T=0/S=1/M=No(TE)Yes()');
  69.         Kill_Box;
  70.         IF (Return_Int <> 2) THEN
  71.             More_Templates := False;
  72.         END;
  73.     End;
  74.  
  75.     Switch_Window(Work_Window);
  76.     File_Changed := False;
  77.     Delete_Window;
  78.     Switch_Window(Code_Window);
  79.     Tof;
  80.     Make_Message('Custom template ''' + File_Name + ''' created.');
  81.     Goto END_OF_MAC;
  82.  
  83. CREATE_TEMPLATE:
  84. {This is where the user defines exacly what he wants the expanded construct to
  85. look like.  There is a limited emulation of the editor here}
  86.     Refresh := False;
  87.     Switch_Window(Work_Window);
  88.     File_Changed := False;
  89.     Erase_Window;
  90. {
  91.     Size_Window(1,11,78,22);
  92. }
  93.     File_Name := 'WORK.TMP';
  94.     Put_Box(1,8,80,23,0,W_B_Color,'CREATE THE EXPANDED TEMPLATE IN THIS WINDOW',True);
  95.     Write('Place cursor exactly where you want it to be in the expanded template,',4,9,0,W_S_Color);
  96.     Write('then press <ESC>.',4,10,0,W_S_Color);
  97.     Write('├────────────────────────────────────────────────────────────────────────────╢',1,11,0,W_B_Color);
  98.     RM('USERIN^EDITWINDOW /X=1/Y=11/W=77/L=11/NB=1/RM=2048');
  99. {
  100.     Refresh := True;
  101.     Redraw;
  102. {This creates partial editor functionality}
  103.     While (Key1 <> 27) Do
  104.         Read_Key;
  105.         If (Key1 = 0) Then
  106.             IF (XPos(Char(Key2),'HPKMGORS',1)) THEN
  107.                 Pass_Key(Key1,Key2);
  108.             END;
  109.         ELSE
  110.             IF (Key1 <> 27) THEN
  111.                 Pass_Key(Key1,Key2);
  112.             END;
  113.         End;
  114.     End;
  115.     Refresh := False;
  116.     Kill_Box;
  117. }
  118.     RET;
  119.  
  120. CODE_SHELL:
  121.     Switch_Window(Code_Window);
  122.     File_Name := Language_Type + '.SRC';
  123.     Tof;
  124.     Undent;
  125.     Put_Line('$MACRO_FILE ' + Language_Type + ';');
  126.     Eol;
  127.     Cr;
  128.     PUT_LINE('$MACRO ' + COPY(LANGUAGE_TYPE,1,3) + 'TEMP;');
  129.     Eol;
  130.     Cr;
  131.     Put_Line('  DEF_INT(Temp_Col,Temp_Insert);');
  132.     Eol;
  133.     Cr;
  134.     Put_Line('  DEF_STR(Key_Chars);');
  135.     Eol;
  136.     Cr;
  137.     Put_Line('  DEF_CHAR(Temp_Char);');
  138.     Eol;
  139.     Cr;
  140.     Put_Line('  Key_Chars := '''';');
  141.     Eol;
  142.     Cr;
  143.     Put_Line('  Temp_Insert := Insert_Mode;');
  144.     Eol;
  145.     Cr;
  146.     Put_Line('  If Not(At_Eol) Then');
  147.     Eol;
  148.     Cr;
  149.     Put_Line('    GOTO END_OF_MAC;');
  150.     Eol;
  151.     Cr;
  152.     Put_Line('  End;');
  153.     Eol;
  154.     Cr;
  155.     Put_Line('  Insert_Mode := True;');
  156.     Eol;
  157.     Cr;
  158.     Put_Line('  Temp_Col := C_COL;');
  159.     Eol;
  160.     Cr;
  161.     Put_Line('  If (C_Col > 1) Then');
  162.     Eol;
  163.     Cr;
  164.     Put_Line('    Left;');
  165.     Eol;
  166.     Cr;
  167.     Put_Line('    If (XPos(Cur_Char,Key_Chars,1) = 0) Then');
  168.     Eol;
  169.     Cr;
  170.     Put_Line('      Goto_Col(Temp_Col);');
  171.     Eol;
  172.     Cr;
  173.     Put_Line('      Goto END_OF_MAC;');
  174.     Eol;
  175.     Cr;
  176.     Put_Line('    End;');
  177.     Eol;
  178.     Cr;
  179.     Put_Line('  Else');
  180.     Eol;
  181.     Cr;
  182.     Put_Line('    Goto END_OF_MAC;');
  183.     Eol;
  184.     Cr;
  185.     Put_Line('  End;');
  186.     Eol;
  187.     Cr;
  188.     Put_Line('  Temp_Col := C_COL;');
  189.     Eol;
  190.     Cr;
  191.     Cr;
  192.     Put_Line('END_OF_MAC:');
  193.     Eol;
  194.     Cr;
  195.     Put_Line('  Insert_Mode := Temp_Insert;');
  196.     Eol;
  197.     Cr;
  198.     PUT_LINE('END_MACRO;');
  199.     RET;
  200.  
  201. CODE_TEMPLATE:
  202.     Switch_Window(Work_Window);
  203.     Cursor_Line := C_Line;
  204.     Cursor_Col := C_Col - 1;
  205.     Tof;
  206.     Temp_String := Get_Line;
  207.     Down;
  208.     Switch_Window(Code_Window);
  209.     Tof;
  210.     IF (Search_Fwd('Key_Chars := ''',0)) THEN
  211.         Eol;
  212.         Left;
  213.         Left;
  214.         Insert_Mode := True;
  215.         Text(Temp_Char);
  216.     END;
  217.     IF (Search_Fwd('END_OF_MAC:',0)) THEN
  218.         Cr;
  219.         Cr;
  220.         Up;
  221.         Up;
  222.         Put_Line('  If (Cur_Char = ''' + Temp_Char + ''') Then');
  223.         Eol;
  224.         Cr;
  225.         Put_Line('    Insert_Mode := False;');
  226.         Eol;
  227.         Cr;
  228.         WHILE (Indent_Amount > 0) DO
  229.             Put_Line('    Indent;');
  230.             Eol;
  231.             Cr;
  232.             --Indent_Amount;
  233.         END;
  234.         Put_Line('    Goto_Col(Temp_Col);');
  235.         Eol;
  236.         If (Temp_String <> '') Then
  237.             Cr;
  238.             Put_Line('    Text(''' + Temp_String + ''');');
  239.             Eol;
  240.         End;
  241.         Cr;
  242.         Put_Line('    Insert_Mode := True;');
  243.         Eol;
  244.         Switch_Window(Work_Window);
  245.         WHILE Not(At_Eof) DO
  246.             Temp_String := Get_Line;
  247.             Switch_Window(Code_Window);
  248.             Cr;
  249.             Put_Line('    Cr;');
  250.             Eol;
  251.             If (Temp_String <> '') Then
  252.                 Cr;
  253.                 Put_Line('    Goto_Col(Temp_Col);');
  254.                 Eol;
  255.                 Cr;
  256.                 Put_Line('    Text(''' + Temp_String + ''');');
  257.                 Eol;
  258.             End;
  259.             Switch_Window(Work_Window);
  260.             Down;
  261.         END;
  262.         Up;
  263.         WHILE (C_Line > Cursor_Line) DO
  264.             Switch_Window(Code_Window);
  265.             Cr;
  266.             Put_Line('    Up;');
  267.             Eol;
  268.             Switch_Window(Work_Window);
  269.             Up;
  270.         END;
  271.         Switch_Window(Code_Window);
  272.         Cr;
  273.         Put_Line('    Goto_Col(Temp_Col + ' + Str(Cursor_Col) + ');');
  274.         Eol;
  275.         Cr;
  276.         Put_Line('    Goto END_OF_MAC;');
  277.         Eol;
  278.         Cr;
  279.         Put_Line('  End;');
  280.     END;
  281.     RET;
  282.  
  283. ABORT:
  284.     Switch_Window(Work_Window);
  285.     File_Changed := False;
  286.     Delete_Window;
  287.     Switch_Window(Code_Window);
  288.     File_Changed := False;
  289.     Delete_Window;
  290.     Switch_Window(Active_Window);
  291.     Make_Message('Custom template creating macro terminated by user.');
  292.  
  293. END_OF_MAC:
  294.     Refresh := True;
  295.     Redraw;
  296.  
  297. END_MACRO;