home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-3.ZIP / WORDSTAR.SRC < prev   
Encoding:
Text File  |  1990-05-09  |  13.8 KB  |  558 lines

  1. $MACRO_FILE WORDSTAR;
  2. {******************************************************************************
  3.                                                         MULTI-EDIT MACRO FILE
  4.  
  5. Name:        WORDSTAR
  6.  
  7. Description:  This macro file contains macros to emulate a subset of common
  8.                             Wordstar key commands.  It is not our intention to completely
  9.                             mimic Wordstar, but to provide a less painful transition from
  10.                             Wordstar to Multi-Edit.
  11.  
  12. WORDSTAR    - Initializes the editor for Wordstar emulation
  13. CTRLQ            - Traps <CtrlQ> and process the second keystroke
  14. CTRLK            - Traps <CtrlK> and process the second keystroke
  15. CTRLO            - Traps <CtrlO> and process the second keystroke
  16. CTRLW            - Traps <CtrlW> and process the second keystroke
  17. CTRLZ            - Traps <CtrlZ> and process the second keystroke
  18. DELWORDR    - Delete word right
  19. HOMEKEY        - Special processing for the home key
  20. ENDKEY        - Special processing for the end key
  21. RIGHTMAR    - Sets right margin
  22. LEFTMAR        - Sets left margin
  23. RESETMAR    - Resets margin
  24. INDENT        - Performs Wordstar like indent
  25. UNDENT        - Performs Wordstar like undent
  26. WSHELP        - Calls the Wordstar help
  27.  
  28.                              (C) Copyright 1990 by American Cybernetics, Inc.
  29. ******************************************************************************}
  30.  
  31. $MACRO WORDSTAR;
  32. {******************************************************************************
  33.                                                             MULTI-EDIT MACRO
  34.  
  35. Name:        WORDSTAR
  36.  
  37. Description:  Initializes the editor for Wordstar emulation
  38.  
  39.                              (C) Copyright 1990 by American Cybernetics, Inc.
  40. ******************************************************************************}
  41.  
  42.     Right_Margin := 80;
  43.     Set_Global_Int('Margin_Released',FALSE);
  44.     Set_Global_Int('Left_Margin',1);
  45.     Set_Global_Int('Right_Margin',Right_Margin);
  46.     Set_Global_Int('Name_La',0);
  47.     Set_Global_Int('Stat_La',0);
  48.     Word_Delimits := ' .,:;!?';
  49.     Indent_Style := 0;
  50.     Goto_Col(1);
  51.     Set_Indent_Level;
  52.  
  53. END_MACRO;
  54.  
  55. $MACRO CTRLQ;
  56.     Def_Char(Temp_Char);
  57.     Def_Str(Temp_String);
  58.     Def_Int(Temp_Integer);
  59.  
  60.  
  61.     IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
  62.         Make_Message('<CtrlQ>');
  63.         Read_Key;
  64.         Make_Message('');
  65.     ELSE
  66.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
  67.         Put_Box(2,2,47,9,0,M_B_Color,'<CtrlQ>',true);
  68.         Write('E - Top of screen',4,3,0,M_T_Color);
  69.         Draw_Attr(4,3,M_S_Color,1);
  70.         Write('X - Bottom of screen',4,4,0,M_T_Color);
  71.         Draw_Attr(4,4,M_S_Color,1);
  72.         Write('R - Beginning of file',4,5,0,M_T_Color);
  73.         Draw_Attr(4,5,M_S_Color,1);
  74.         Write('C - End of file',4,6,0,M_T_Color);
  75.         Draw_Attr(4,6,M_S_Color,1);
  76.         Write('S - Beginning of line',4,7,0,M_T_Color);
  77.         Draw_Attr(4,7,M_S_Color,1);
  78.  
  79.         Write('D - End of line',27,3,0,M_T_Color);
  80.         Draw_Attr(27,3,M_S_Color,1);
  81.         Write('B - Block begin',27,4,0,M_T_Color);
  82.         Draw_Attr(27,4,M_S_Color,1);
  83.         Write('K - Block end',27,5,0,M_T_Color);
  84.         Draw_Attr(27,5,M_S_Color,1);
  85.         Write('P - Undo',27,6,0,M_T_Color);
  86.         Draw_Attr(27,6,M_S_Color,1);
  87.         Write('L - Spell checker',27,7,0,M_T_Color);
  88.         Draw_Attr(27,7,M_S_Color,1);
  89.  
  90.         Read_Key;
  91.         Kill_Box;
  92.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
  93.     END;
  94.  
  95.     If (Key1 <> 0) Then
  96.         Temp_Char := Caps(Char(Key1));
  97.         If ((Temp_Char = 'S') OR (Temp_Char = Char(19))) Then
  98.             Goto_Col(1);
  99.         End;
  100.         If ((Temp_Char = 'Y') OR (Temp_Char = Char(25))) Then
  101. {Delete to EOL}
  102.             Push_Undo;
  103.             Def_Int(jx);
  104.             Jx := Length(Get_Line);
  105.             Del_Chars(jx - c_col + 1);
  106.             Pop_Undo;
  107.         End;
  108.         If ((Temp_Char = 'D') OR (Temp_Char = Char(04))) Then
  109. {Move to end of line or column 80 whichever is less}
  110.             Refresh := FALSE;
  111.             Push_Undo;
  112.             Eol;
  113.             If C_Col > 80 Then
  114.                 Goto_Col(1);
  115.                 Goto_Col(80);
  116.             End;
  117.             Pop_Undo;
  118.             Refresh := TRUE;
  119.             Redraw;
  120.         End;
  121.         If ((Temp_Char = 'E') OR (Temp_Char = Char(05))) Then
  122.             RM('TopWin');
  123.             If At_Eol Then
  124.                 Eol;
  125.             End;
  126.         End;
  127.         If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
  128.             RM('BotWin');
  129.             If At_Eol Then
  130.                 Eol;
  131.             End;
  132.         End;
  133.         If ((Temp_Char = 'L') OR (Temp_Char = Char(12))) Then
  134.             RM('SPELL');
  135.         End;
  136.         If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
  137.             Tof;
  138.         End;
  139.         If ((Temp_Char = 'C') OR (Temp_Char = Char(03))) Then
  140.             Eof;
  141.         End;
  142.         If (Block_Stat) Then
  143.             If ((Temp_Char = 'B') OR (Temp_Char = Char(02))) Then
  144.                 RM('TOPBLOCK');
  145.                 Redraw;
  146.             End;
  147.             If ((Temp_Char = 'K') OR (Temp_Char = Char(11))) Then
  148.                 RM('ENDBLOCK');
  149.             End;
  150.         End;
  151.         If ((Temp_Char = 'F') OR (Temp_Char = Char(06))) Then
  152.             RM('Meutil2^Search');
  153.         End;
  154.         If ((Temp_Char = 'A') OR (Temp_Char = Char(01))) Then
  155.             RM('Meutil2^S_Repl');
  156.         End;
  157.         If ((Temp_Char = 'P') OR (Temp_Char = Char(16))) Then
  158.             Undo;
  159.         End;
  160.     Else
  161.         If ((Key2 = 83) or (Key2 = 147)) Then
  162. {Delete all chars left of cursor}
  163.             Push_Undo;
  164.             Put_Line(Copy(Get_Line,C_Col,2048));
  165.             Goto_Col(1);
  166.             Redraw;
  167.             Pop_Undo;
  168.         End;
  169.     End;
  170. END_MACRO;
  171.  
  172. $MACRO CTRLK;
  173.     Def_Char(Temp_Char);
  174.     Def_Str(Temp_String, FName);
  175.     Def_Int(Temp_Integer, Status);
  176.  
  177.  
  178.     IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
  179.         Make_Message('<CtrlK>');
  180.         Read_Key;
  181.         Make_Message('');
  182.     ELSE
  183.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
  184.         Put_Box(2,2,53,11,0,M_B_Color,'<CtrlK>',true);
  185.         Write('D - Save - done',4,3,0,M_T_Color);
  186.         Draw_Attr(4,3,M_S_Color,1);
  187.         Write('Q - Quit',4,4,0,M_T_Color);
  188.         Draw_Attr(4,4,M_S_Color,1);
  189.         Write('S - Save file',4,5,0,M_T_Color);
  190.         Draw_Attr(4,5,M_S_Color,1);
  191.         Write('X - Save and quit',4,6,0,M_T_Color);
  192.         Draw_Attr(4,6,M_S_Color,1);
  193.         Write('J - Delete file',4,7,0,M_T_Color);
  194.         Draw_Attr(4,7,M_S_Color,1);
  195.         Write('R - Merge file from disk',4,8,0,M_T_Color);
  196.         Draw_Attr(4,8,M_S_Color,1);
  197.         Write('K - Mark block end',4,9,0,M_T_Color);
  198.         Draw_Attr(4,9,M_S_Color,1);
  199.  
  200.         Write('B - Mark block begin',30,3,0,M_T_Color);
  201.         Draw_Attr(30,3,M_S_Color,1);
  202.         Write('C - Copy block',30,4,0,M_T_Color);
  203.         Draw_Attr(30,4,M_S_Color,1);
  204.         Write('V - Move block',30,5,0,M_T_Color);
  205.         Draw_Attr(30,5,M_S_Color,1);
  206.         Write('W - Save block',30,6,0,M_T_Color);
  207.         Draw_Attr(30,6,M_S_Color,1);
  208.         Write('Y - Delete Block',30,7,0,M_T_Color);
  209.         Draw_Attr(30,7,M_S_Color,1);
  210.         Write('P - Print',30,8,0,M_T_Color);
  211.         Draw_Attr(30,8,M_S_Color,1);
  212.  
  213.         Read_Key;
  214.         Kill_Box;
  215.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
  216.     END;
  217.  
  218.     If (Key1 <> 0) Then
  219.         Temp_Char := Caps(Char(Key1));
  220.         If ((Temp_Char = 'Y') OR (Temp_Char = Char(25))) Then
  221. {Delete block}
  222.             RM('MEUTIL2^BLOCKOP /BT=2');
  223.         End;
  224.         If ((Temp_Char = 'J') OR (Temp_Char = Char(10))) Then
  225. {Delete file from disk}
  226.             FName := '';
  227.             Return_Str := '';
  228.             RM('userin^QUERYBOX /C=3/W=60/ML=80/T=NAME OF FILE TO DELETE?/L=4');
  229.             If Return_Int Then
  230.                 FName := Return_Str;
  231.                 If File_Exists(FName) Then
  232.                     Del_File(FName);
  233.                     IF (Error_Level) THEN
  234.                         RM('MEERROR');
  235.                     ELSE
  236.                         Make_Message(Caps(FName)+' Deleted.');
  237.                     END;
  238.                 Else
  239.                     RM('MEERROR^MessageBox /B=1/T=ERROR/M=FILE ' + Caps(FName) + ' NOT FOUND!');
  240.                 End;
  241.             End;
  242.         End;
  243.         If ((Temp_Char = 'D') OR (Temp_Char = Char(04))) Then
  244.             RM('MEUTIL1^SAVEFILE');
  245.             IF (Return_Int = 1) THEN
  246.                 RM('MEUTIL1^LOADFILE');
  247.             END;
  248.         End;
  249.         If ((Temp_Char = 'Q') OR (Temp_Char = Char(17))) Then
  250.             RM('EXIT');
  251.         End;
  252.         If ((Temp_Char = 'S') OR (Temp_Char = Char(19))) Then
  253.             Save_File;
  254. {If you want to be prompted, which is not the way Wordstar does it, replace
  255. the above line with this one.
  256.             RM('MEUTIL1^SAVEFILE');
  257. }
  258.         End;
  259.         If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
  260.             RM('EXIT^AutoSave');
  261.             RM('EXIT');
  262.         End;
  263.         If ((Temp_Char = 'P') OR (Temp_Char = Char(16))) Then
  264.             RM('MEUTIL3^Print');
  265.         End;
  266.         If ((Temp_Char = 'N') OR (Temp_Char = Char(14))) Then
  267.             {????????????????????????????}
  268.         End;
  269.         If ((Temp_Char = 'B') OR (Temp_Char = Char(02))) Then
  270.             Make_Message('Stream Block marking on.  Press Block End to stop.');
  271.             Str_Block_Begin;
  272.         End;
  273.         If ((Temp_Char = 'K') OR (Temp_Char = Char(11))) Then
  274.             Make_Message('Block marked.');
  275.             Block_End;
  276.         End;
  277.         If ((Temp_Char = 'H') OR (Temp_Char = Char(08))) Then
  278. {Hide block not supported}
  279.             help('WORDSTAR^*%<CtrlK> H');
  280.         End;
  281.         If ((Temp_Char = 'C') OR (Temp_Char = Char(03))) Then
  282. {Block copy}
  283.             RM('MEUTIL2^BLOCKOP /BT=0');
  284.         End;
  285.         If ((Temp_Char = 'V') OR (Temp_Char = Char(22))) Then
  286. {Block move}
  287.             RM('MEUTIL2^BLOCKOP /BT=1');
  288.         End;
  289.         If ((Temp_Char = 'W') OR (Temp_Char = Char(23))) Then
  290.             RM('MEUTIL1^SaveBlck');
  291.         End;
  292.         If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
  293. {Load block}
  294.             RM('MEUTIL1^Splice');
  295.         End;
  296.     End;
  297. END_MACRO;
  298.  
  299. $MACRO CTRLO;
  300.     Def_Char(Temp_Char);
  301.     Def_Str(Temp_String);
  302.     Def_Int(J2,J3);
  303.  
  304.     IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
  305.         Make_Message('<CtrlO>');
  306.         Read_Key;
  307.         Make_Message('');
  308.     ELSE
  309.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
  310.         Put_Box(2,2,43,7,0,M_B_Color,'<CtrlO>',true);
  311.         Write('C - Center line',4,3,0,M_T_Color);
  312.         Draw_Attr(4,3,M_S_Color,1);
  313.         Write('W - Word wrap ' + COPY('offon',(Not(Wrap_Stat) * 3) + 1,3),4,4,0,M_T_Color);
  314.         Draw_Attr(4,4,M_S_Color,1);
  315.         Write('R - Right margin',4,5,0,M_T_Color);
  316.         Draw_Attr(4,5,M_S_Color,1);
  317.  
  318.         Write('L - Left margin',22,3,0,M_T_Color);
  319.         Draw_Attr(22,3,M_S_Color,1);
  320.         Write('X - Margin release',22,4,0,M_T_Color);
  321.         Draw_Attr(22,4,M_S_Color,1);
  322.         Write('G - Indent',22,5,0,M_T_Color);
  323.         Draw_Attr(22,5,M_S_Color,1);
  324.         Read_Key;
  325.         Kill_box;
  326.         Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
  327.     END;
  328.  
  329.     If (Key1 <> 0) Then
  330.         Temp_Char := Caps(Char(Key1));
  331.         If ((Temp_Char = 'C') OR (Temp_Char = Char(3))) Then
  332.             RM('TEXT^Center');
  333.         End;
  334.         If ((Temp_Char = 'W') OR (Temp_Char = Char(23))) Then
  335.             Wrap_Stat := NOT(Wrap_Stat);
  336.         End;
  337.         If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
  338.             RM('RightMar');
  339.         End;
  340.         If ((Temp_Char = 'L') OR (Temp_Char = Char(12))) Then
  341.             RM('LeftMar');
  342.         End;
  343.         If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
  344.             RM('ResetMar');
  345.         End;
  346.         If ((Temp_Char = 'G') OR (Temp_Char = Char(7))) Then
  347.             RM('Indent');
  348.         End;
  349.     END;
  350. END_MACRO;
  351.  
  352. $MACRO CTRLW;
  353.     Push_Undo;
  354.     RM('ScrollDn');
  355.     If WhereY < (Win_Y2 - 1) Then
  356.         Down;
  357.     End;
  358.     Pop_Undo;
  359. END_MACRO;
  360.  
  361. $MACRO CTRLZ;
  362.     Push_Undo;
  363.     RM('ScrollUp');
  364.     If WhereY > (Win_Y1 + 1) Then
  365.         Up;
  366.     End;
  367.     Pop_Undo;
  368. END_MACRO;
  369.  
  370. $MACRO DELWORDR;
  371.     Def_Str(Temp_Line);
  372.     Messages := FALSE;
  373.     Push_Undo;
  374.     If Cur_Char = ' ' Then
  375.         While Cur_Char = ' ' Do
  376.             Del_Char;
  377.         End;
  378.         Goto Macro_Exit;
  379.     End;
  380.     If XPos(Cur_Char,'.,:;!?',1) Then
  381.         Del_Char;
  382.         Goto Macro_Exit;
  383.     End;
  384.     While ((XPos(Cur_Char,' .,:;!?',1) = 0) AND (NOT(At_Eol) OR NOT(At_Eof))) Do
  385.         If (NOT(At_Eol AND (Cur_Char = char(255)))) Then
  386.             Del_Char;
  387.         Else
  388.             Down;
  389.             Temp_Line := Get_Line;
  390.             Del_Line;
  391.             Up;
  392.             Eol;
  393.             Mark_Pos;
  394.             Text(Temp_Line);
  395.             Goto_Mark;
  396.             Goto Macro_Exit;
  397.         End;
  398.     End;
  399.     If XPos(Cur_Char,'.,:;!?',1) Then
  400.         Del_Char;
  401.     End;
  402. Macro_Exit:
  403.     Pop_Undo;
  404.     Refresh := TRUE;
  405.     Messages := TRUE;
  406. END_MACRO;
  407.  
  408. $MACRO HOMEKEY;
  409.     Push_Undo;
  410.     If Global_Int('WS_Mode') Then
  411.         RM('^TopWin');
  412.         Goto_Col(1);
  413.     Else
  414.         If C_Col <> 1 Then
  415.             Goto_Col(1);
  416.         Else
  417.             RM('^TopWin');
  418.             Goto_Col(1);
  419.         End;
  420.     End;
  421.     Pop_Undo;
  422. END_MACRO;
  423.  
  424. $MACRO ENDKEY;
  425.     Push_Undo;
  426.     If Global_Int('WS_Mode') Then
  427.         RM('^BotWin');
  428.         If At_Eol Then
  429.             Eol;
  430.         End;
  431.     Else
  432.         If NOT(At_Eol) Then
  433.             Eol;
  434.         Else
  435.             RM('^BotWin');
  436.             If At_Eol Then
  437.                 Eol;
  438.             End;
  439.         End;
  440.     End;
  441.     Pop_Undo;
  442. END_MACRO;
  443.  
  444. $MACRO RIGHTMAR;
  445.     Def_Int(J2,J3);
  446.     Def_Str(Temp_String);
  447.     Put_Box(6,2,69,5,0,Stat_Color,'RIGHT MARGIN',true);
  448. RmAgain:
  449.     Temp_String := Str(Right_Margin);
  450.     return_str := temp_string;
  451.     RM('USERIN^UserStr /P=RIGHT MARGIN COLUMN NUMBER (Escape for cursor column)? /W=3/X=8/Y=3/H=WP');
  452.     temp_string := return_str;
  453.     IF return_int THEN
  454.         If Val(J2,Temp_String) <> 0 Then
  455.             RM('MEERROR^Beeps /C=1');
  456.             Goto RmAgain;
  457.         End;
  458.         If (J2 < 1) or (J2 > 254) Then
  459.             RM('MEERROR^Beeps /C=1');
  460.             Goto RmAgain;
  461.         End;
  462.         Kill_Box;
  463.     Else
  464.         Kill_Box;
  465.         J2 := C_Col;
  466.     End;
  467.     Temp_String := Format_Line;
  468.     J3 := Pos('R',Format_Line);
  469.     If J3 = 0 Then
  470.         J3 := Pos('r',Format_Line);
  471.     End;
  472.     If J3 <> 0 Then
  473.         Format_Line := Str_Del(Format_Line,J3,1);
  474.         Format_Line := Str_Ins(' ',Format_Line,J3);
  475.     End;
  476.     Format_Line := Str_Del(Format_Line,J2,1);
  477.     Format_Line := Str_Ins('R',Format_Line,J2);
  478.     Right_Margin := J2;
  479.     Set_Global_Int('Right_Margin',J2);
  480. END_MACRO;
  481.  
  482. $MACRO LEFTMAR;
  483.     Def_Int(J2);
  484.     Def_Str(Temp_String);
  485.     Push_Undo;
  486.     Put_Box(6,2,68,5,0,Stat_Color,'LEFT MARGIN',true);
  487. LmAgain:
  488.     Temp_String := Str(Indent_Level);
  489.     return_str := temp_string;
  490.     RM('USERIN^UserStr /P=LEFT MARGIN COLUMN NUMBER (Escape for cursor column)? /W=3/X=8/Y=3/H=WP');
  491.     temp_string := return_str;
  492.     IF return_int THEN
  493.         If Val(J2,Temp_String) <> 0 Then
  494.             RM('MEERROR^Beeps /C=1');
  495.             Goto LmAgain;
  496.         End;
  497.         If (J2 < 1) or (J2 > 254) Then
  498.             RM('MEERROR^Beeps /C=1');
  499.             Goto LmAgain;
  500.         End;
  501.         Kill_Box;
  502.         Refresh := FALSE;
  503.         Messages := FALSE;
  504.         Mark_Pos;
  505.         Goto_Col(J2);
  506.         Set_Indent_Level;
  507.         Goto_Mark;
  508.         Messages := True;
  509.         Refresh := TRUE;
  510.     Else
  511.         Kill_Box;
  512.         Set_Indent_Level;
  513.         J2 := C_Col;
  514.     End;
  515.     Set_Global_Int('Left_Margin',J2);
  516.     Pop_Undo;
  517. END_MACRO;
  518.  
  519. $MACRO RESETMAR;
  520.     Refresh := FALSE;
  521.     Messages := FALSE;
  522.     Mark_Pos;
  523.     If NOT(Global_Int('Margin_Released')) Then
  524.         Set_Global_Int('Margin_Released',TRUE);
  525.         Right_Margin := 254;
  526.         Goto_Col(1);
  527.     Else
  528.         Set_Global_Int('Margin_Released',FALSE);
  529.         Goto_Col(Global_Int('Left_Margin'));
  530.         Right_Margin := Global_Int('Right_Margin');
  531.     End;
  532.     Set_Indent_Level;
  533.     Goto_Mark;
  534.     Refresh := TRUE;
  535.     Redraw;
  536.     Messages := TRUE;
  537. END_MACRO;
  538.  
  539. $MACRO INDENT;
  540.     Indent;
  541.     Set_Global_Int('Left_Margin',C_Col);
  542. END_MACRO;
  543.  
  544. $MACRO UNDENT;
  545.     Undent;
  546.     Set_Global_Int('Left_Margin',C_Col);
  547. END_MACRO;
  548.  
  549. $MACRO WSHELP;
  550.     help('WORDSTAR^*');
  551. END_MACRO;
  552.  
  553.  
  554. $MACRO WSInstall;
  555.     Set_Global_Int('SETUP_CHANGED',Global_Int('SETUP_CHANGED') or $02);
  556.     Set_Global_Str('@KEYMAP_NAME@','KN=WORDSTARFN=WORDSTAR');
  557. END_MACRO;
  558.