home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE WORDSTAR;
- {******************************************************************************
- MULTI-EDIT MACRO FILE
-
- Name: WORDSTAR
-
- Description: This macro file contains macros to emulate a subset of common
- Wordstar key commands. It is not our intention to completely
- mimic Wordstar, but to provide a less painful transition from
- Wordstar to Multi-Edit.
-
- WORDSTAR - Initializes the editor for Wordstar emulation
- CTRLQ - Traps <CtrlQ> and process the second keystroke
- CTRLK - Traps <CtrlK> and process the second keystroke
- CTRLO - Traps <CtrlO> and process the second keystroke
- CTRLW - Traps <CtrlW> and process the second keystroke
- CTRLZ - Traps <CtrlZ> and process the second keystroke
- DELWORDR - Delete word right
- HOMEKEY - Special processing for the home key
- ENDKEY - Special processing for the end key
- RIGHTMAR - Sets right margin
- LEFTMAR - Sets left margin
- RESETMAR - Resets margin
- INDENT - Performs Wordstar like indent
- UNDENT - Performs Wordstar like undent
- WSHELP - Calls the Wordstar help
-
- (C) Copyright 1990 by American Cybernetics, Inc.
- ******************************************************************************}
-
- $MACRO WORDSTAR;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: WORDSTAR
-
- Description: Initializes the editor for Wordstar emulation
-
- (C) Copyright 1990 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Right_Margin := 80;
- Set_Global_Int('Margin_Released',FALSE);
- Set_Global_Int('Left_Margin',1);
- Set_Global_Int('Right_Margin',Right_Margin);
- Set_Global_Int('Name_La',0);
- Set_Global_Int('Stat_La',0);
- Word_Delimits := ' .,:;!?';
- Indent_Style := 0;
- Goto_Col(1);
- Set_Indent_Level;
-
- END_MACRO;
-
- $MACRO CTRLQ;
- Def_Char(Temp_Char);
- Def_Str(Temp_String);
- Def_Int(Temp_Integer);
-
-
- IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
- Make_Message('<CtrlQ>');
- Read_Key;
- Make_Message('');
- ELSE
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
- Put_Box(2,2,47,9,0,M_B_Color,'<CtrlQ>',true);
- Write('E - Top of screen',4,3,0,M_T_Color);
- Draw_Attr(4,3,M_S_Color,1);
- Write('X - Bottom of screen',4,4,0,M_T_Color);
- Draw_Attr(4,4,M_S_Color,1);
- Write('R - Beginning of file',4,5,0,M_T_Color);
- Draw_Attr(4,5,M_S_Color,1);
- Write('C - End of file',4,6,0,M_T_Color);
- Draw_Attr(4,6,M_S_Color,1);
- Write('S - Beginning of line',4,7,0,M_T_Color);
- Draw_Attr(4,7,M_S_Color,1);
-
- Write('D - End of line',27,3,0,M_T_Color);
- Draw_Attr(27,3,M_S_Color,1);
- Write('B - Block begin',27,4,0,M_T_Color);
- Draw_Attr(27,4,M_S_Color,1);
- Write('K - Block end',27,5,0,M_T_Color);
- Draw_Attr(27,5,M_S_Color,1);
- Write('P - Undo',27,6,0,M_T_Color);
- Draw_Attr(27,6,M_S_Color,1);
- Write('L - Spell checker',27,7,0,M_T_Color);
- Draw_Attr(27,7,M_S_Color,1);
-
- Read_Key;
- Kill_Box;
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
- END;
-
- If (Key1 <> 0) Then
- Temp_Char := Caps(Char(Key1));
- If ((Temp_Char = 'S') OR (Temp_Char = Char(19))) Then
- Goto_Col(1);
- End;
- If ((Temp_Char = 'Y') OR (Temp_Char = Char(25))) Then
- {Delete to EOL}
- Push_Undo;
- Def_Int(jx);
- Jx := Length(Get_Line);
- Del_Chars(jx - c_col + 1);
- Pop_Undo;
- End;
- If ((Temp_Char = 'D') OR (Temp_Char = Char(04))) Then
- {Move to end of line or column 80 whichever is less}
- Refresh := FALSE;
- Push_Undo;
- Eol;
- If C_Col > 80 Then
- Goto_Col(1);
- Goto_Col(80);
- End;
- Pop_Undo;
- Refresh := TRUE;
- Redraw;
- End;
- If ((Temp_Char = 'E') OR (Temp_Char = Char(05))) Then
- RM('TopWin');
- If At_Eol Then
- Eol;
- End;
- End;
- If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
- RM('BotWin');
- If At_Eol Then
- Eol;
- End;
- End;
- If ((Temp_Char = 'L') OR (Temp_Char = Char(12))) Then
- RM('SPELL');
- End;
- If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
- Tof;
- End;
- If ((Temp_Char = 'C') OR (Temp_Char = Char(03))) Then
- Eof;
- End;
- If (Block_Stat) Then
- If ((Temp_Char = 'B') OR (Temp_Char = Char(02))) Then
- RM('TOPBLOCK');
- Redraw;
- End;
- If ((Temp_Char = 'K') OR (Temp_Char = Char(11))) Then
- RM('ENDBLOCK');
- End;
- End;
- If ((Temp_Char = 'F') OR (Temp_Char = Char(06))) Then
- RM('Meutil2^Search');
- End;
- If ((Temp_Char = 'A') OR (Temp_Char = Char(01))) Then
- RM('Meutil2^S_Repl');
- End;
- If ((Temp_Char = 'P') OR (Temp_Char = Char(16))) Then
- Undo;
- End;
- Else
- If ((Key2 = 83) or (Key2 = 147)) Then
- {Delete all chars left of cursor}
- Push_Undo;
- Put_Line(Copy(Get_Line,C_Col,2048));
- Goto_Col(1);
- Redraw;
- Pop_Undo;
- End;
- End;
- END_MACRO;
-
- $MACRO CTRLK;
- Def_Char(Temp_Char);
- Def_Str(Temp_String, FName);
- Def_Int(Temp_Integer, Status);
-
-
- IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
- Make_Message('<CtrlK>');
- Read_Key;
- Make_Message('');
- ELSE
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
- Put_Box(2,2,53,11,0,M_B_Color,'<CtrlK>',true);
- Write('D - Save - done',4,3,0,M_T_Color);
- Draw_Attr(4,3,M_S_Color,1);
- Write('Q - Quit',4,4,0,M_T_Color);
- Draw_Attr(4,4,M_S_Color,1);
- Write('S - Save file',4,5,0,M_T_Color);
- Draw_Attr(4,5,M_S_Color,1);
- Write('X - Save and quit',4,6,0,M_T_Color);
- Draw_Attr(4,6,M_S_Color,1);
- Write('J - Delete file',4,7,0,M_T_Color);
- Draw_Attr(4,7,M_S_Color,1);
- Write('R - Merge file from disk',4,8,0,M_T_Color);
- Draw_Attr(4,8,M_S_Color,1);
- Write('K - Mark block end',4,9,0,M_T_Color);
- Draw_Attr(4,9,M_S_Color,1);
-
- Write('B - Mark block begin',30,3,0,M_T_Color);
- Draw_Attr(30,3,M_S_Color,1);
- Write('C - Copy block',30,4,0,M_T_Color);
- Draw_Attr(30,4,M_S_Color,1);
- Write('V - Move block',30,5,0,M_T_Color);
- Draw_Attr(30,5,M_S_Color,1);
- Write('W - Save block',30,6,0,M_T_Color);
- Draw_Attr(30,6,M_S_Color,1);
- Write('Y - Delete Block',30,7,0,M_T_Color);
- Draw_Attr(30,7,M_S_Color,1);
- Write('P - Print',30,8,0,M_T_Color);
- Draw_Attr(30,8,M_S_Color,1);
-
- Read_Key;
- Kill_Box;
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
- END;
-
- If (Key1 <> 0) Then
- Temp_Char := Caps(Char(Key1));
- If ((Temp_Char = 'Y') OR (Temp_Char = Char(25))) Then
- {Delete block}
- RM('MEUTIL2^BLOCKOP /BT=2');
- End;
- If ((Temp_Char = 'J') OR (Temp_Char = Char(10))) Then
- {Delete file from disk}
- FName := '';
- Return_Str := '';
- RM('userin^QUERYBOX /C=3/W=60/ML=80/T=NAME OF FILE TO DELETE?/L=4');
- If Return_Int Then
- FName := Return_Str;
- If File_Exists(FName) Then
- Del_File(FName);
- IF (Error_Level) THEN
- RM('MEERROR');
- ELSE
- Make_Message(Caps(FName)+' Deleted.');
- END;
- Else
- RM('MEERROR^MessageBox /B=1/T=ERROR/M=FILE ' + Caps(FName) + ' NOT FOUND!');
- End;
- End;
- End;
- If ((Temp_Char = 'D') OR (Temp_Char = Char(04))) Then
- RM('MEUTIL1^SAVEFILE');
- IF (Return_Int = 1) THEN
- RM('MEUTIL1^LOADFILE');
- END;
- End;
- If ((Temp_Char = 'Q') OR (Temp_Char = Char(17))) Then
- RM('EXIT');
- End;
- If ((Temp_Char = 'S') OR (Temp_Char = Char(19))) Then
- Save_File;
- {If you want to be prompted, which is not the way Wordstar does it, replace
- the above line with this one.
- RM('MEUTIL1^SAVEFILE');
- }
- End;
- If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
- RM('EXIT^AutoSave');
- RM('EXIT');
- End;
- If ((Temp_Char = 'P') OR (Temp_Char = Char(16))) Then
- RM('MEUTIL3^Print');
- End;
- If ((Temp_Char = 'N') OR (Temp_Char = Char(14))) Then
- {????????????????????????????}
- End;
- If ((Temp_Char = 'B') OR (Temp_Char = Char(02))) Then
- Make_Message('Stream Block marking on. Press Block End to stop.');
- Str_Block_Begin;
- End;
- If ((Temp_Char = 'K') OR (Temp_Char = Char(11))) Then
- Make_Message('Block marked.');
- Block_End;
- End;
- If ((Temp_Char = 'H') OR (Temp_Char = Char(08))) Then
- {Hide block not supported}
- help('WORDSTAR^*%<CtrlK> H');
- End;
- If ((Temp_Char = 'C') OR (Temp_Char = Char(03))) Then
- {Block copy}
- RM('MEUTIL2^BLOCKOP /BT=0');
- End;
- If ((Temp_Char = 'V') OR (Temp_Char = Char(22))) Then
- {Block move}
- RM('MEUTIL2^BLOCKOP /BT=1');
- End;
- If ((Temp_Char = 'W') OR (Temp_Char = Char(23))) Then
- RM('MEUTIL1^SaveBlck');
- End;
- If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
- {Load block}
- RM('MEUTIL1^Splice');
- End;
- End;
- END_MACRO;
-
- $MACRO CTRLO;
- Def_Char(Temp_Char);
- Def_Str(Temp_String);
- Def_Int(J2,J3);
-
- IF (Global_Int('@WS_CTRL_HLP_OFF@')) THEN
- Make_Message('<CtrlO>');
- Read_Key;
- Make_Message('');
- ELSE
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') + 1);
- Put_Box(2,2,43,7,0,M_B_Color,'<CtrlO>',true);
- Write('C - Center line',4,3,0,M_T_Color);
- Draw_Attr(4,3,M_S_Color,1);
- Write('W - Word wrap ' + COPY('offon',(Not(Wrap_Stat) * 3) + 1,3),4,4,0,M_T_Color);
- Draw_Attr(4,4,M_S_Color,1);
- Write('R - Right margin',4,5,0,M_T_Color);
- Draw_Attr(4,5,M_S_Color,1);
-
- Write('L - Left margin',22,3,0,M_T_Color);
- Draw_Attr(22,3,M_S_Color,1);
- Write('X - Margin release',22,4,0,M_T_Color);
- Draw_Attr(22,4,M_S_Color,1);
- Write('G - Indent',22,5,0,M_T_Color);
- Draw_Attr(22,5,M_S_Color,1);
- Read_Key;
- Kill_box;
- Set_Global_Int('MENU_LEVEL',Global_Int('MENU_LEVEL') - 1);
- END;
-
- If (Key1 <> 0) Then
- Temp_Char := Caps(Char(Key1));
- If ((Temp_Char = 'C') OR (Temp_Char = Char(3))) Then
- RM('TEXT^Center');
- End;
- If ((Temp_Char = 'W') OR (Temp_Char = Char(23))) Then
- Wrap_Stat := NOT(Wrap_Stat);
- End;
- If ((Temp_Char = 'R') OR (Temp_Char = Char(18))) Then
- RM('RightMar');
- End;
- If ((Temp_Char = 'L') OR (Temp_Char = Char(12))) Then
- RM('LeftMar');
- End;
- If ((Temp_Char = 'X') OR (Temp_Char = Char(24))) Then
- RM('ResetMar');
- End;
- If ((Temp_Char = 'G') OR (Temp_Char = Char(7))) Then
- RM('Indent');
- End;
- END;
- END_MACRO;
-
- $MACRO CTRLW;
- Push_Undo;
- RM('ScrollDn');
- If WhereY < (Win_Y2 - 1) Then
- Down;
- End;
- Pop_Undo;
- END_MACRO;
-
- $MACRO CTRLZ;
- Push_Undo;
- RM('ScrollUp');
- If WhereY > (Win_Y1 + 1) Then
- Up;
- End;
- Pop_Undo;
- END_MACRO;
-
- $MACRO DELWORDR;
- Def_Str(Temp_Line);
- Messages := FALSE;
- Push_Undo;
- If Cur_Char = ' ' Then
- While Cur_Char = ' ' Do
- Del_Char;
- End;
- Goto Macro_Exit;
- End;
- If XPos(Cur_Char,'.,:;!?',1) Then
- Del_Char;
- Goto Macro_Exit;
- End;
- While ((XPos(Cur_Char,' .,:;!?',1) = 0) AND (NOT(At_Eol) OR NOT(At_Eof))) Do
- If (NOT(At_Eol AND (Cur_Char = char(255)))) Then
- Del_Char;
- Else
- Down;
- Temp_Line := Get_Line;
- Del_Line;
- Up;
- Eol;
- Mark_Pos;
- Text(Temp_Line);
- Goto_Mark;
- Goto Macro_Exit;
- End;
- End;
- If XPos(Cur_Char,'.,:;!?',1) Then
- Del_Char;
- End;
- Macro_Exit:
- Pop_Undo;
- Refresh := TRUE;
- Messages := TRUE;
- END_MACRO;
-
- $MACRO HOMEKEY;
- Push_Undo;
- If Global_Int('WS_Mode') Then
- RM('^TopWin');
- Goto_Col(1);
- Else
- If C_Col <> 1 Then
- Goto_Col(1);
- Else
- RM('^TopWin');
- Goto_Col(1);
- End;
- End;
- Pop_Undo;
- END_MACRO;
-
- $MACRO ENDKEY;
- Push_Undo;
- If Global_Int('WS_Mode') Then
- RM('^BotWin');
- If At_Eol Then
- Eol;
- End;
- Else
- If NOT(At_Eol) Then
- Eol;
- Else
- RM('^BotWin');
- If At_Eol Then
- Eol;
- End;
- End;
- End;
- Pop_Undo;
- END_MACRO;
-
- $MACRO RIGHTMAR;
- Def_Int(J2,J3);
- Def_Str(Temp_String);
- Put_Box(6,2,69,5,0,Stat_Color,'RIGHT MARGIN',true);
- RmAgain:
- Temp_String := Str(Right_Margin);
- return_str := temp_string;
- RM('USERIN^UserStr /P=RIGHT MARGIN COLUMN NUMBER (Escape for cursor column)? /W=3/X=8/Y=3/H=WP');
- temp_string := return_str;
- IF return_int THEN
- If Val(J2,Temp_String) <> 0 Then
- RM('MEERROR^Beeps /C=1');
- Goto RmAgain;
- End;
- If (J2 < 1) or (J2 > 254) Then
- RM('MEERROR^Beeps /C=1');
- Goto RmAgain;
- End;
- Kill_Box;
- Else
- Kill_Box;
- J2 := C_Col;
- End;
- Temp_String := Format_Line;
- J3 := Pos('R',Format_Line);
- If J3 = 0 Then
- J3 := Pos('r',Format_Line);
- End;
- If J3 <> 0 Then
- Format_Line := Str_Del(Format_Line,J3,1);
- Format_Line := Str_Ins(' ',Format_Line,J3);
- End;
- Format_Line := Str_Del(Format_Line,J2,1);
- Format_Line := Str_Ins('R',Format_Line,J2);
- Right_Margin := J2;
- Set_Global_Int('Right_Margin',J2);
- END_MACRO;
-
- $MACRO LEFTMAR;
- Def_Int(J2);
- Def_Str(Temp_String);
- Push_Undo;
- Put_Box(6,2,68,5,0,Stat_Color,'LEFT MARGIN',true);
- LmAgain:
- Temp_String := Str(Indent_Level);
- return_str := temp_string;
- RM('USERIN^UserStr /P=LEFT MARGIN COLUMN NUMBER (Escape for cursor column)? /W=3/X=8/Y=3/H=WP');
- temp_string := return_str;
- IF return_int THEN
- If Val(J2,Temp_String) <> 0 Then
- RM('MEERROR^Beeps /C=1');
- Goto LmAgain;
- End;
- If (J2 < 1) or (J2 > 254) Then
- RM('MEERROR^Beeps /C=1');
- Goto LmAgain;
- End;
- Kill_Box;
- Refresh := FALSE;
- Messages := FALSE;
- Mark_Pos;
- Goto_Col(J2);
- Set_Indent_Level;
- Goto_Mark;
- Messages := True;
- Refresh := TRUE;
- Else
- Kill_Box;
- Set_Indent_Level;
- J2 := C_Col;
- End;
- Set_Global_Int('Left_Margin',J2);
- Pop_Undo;
- END_MACRO;
-
- $MACRO RESETMAR;
- Refresh := FALSE;
- Messages := FALSE;
- Mark_Pos;
- If NOT(Global_Int('Margin_Released')) Then
- Set_Global_Int('Margin_Released',TRUE);
- Right_Margin := 254;
- Goto_Col(1);
- Else
- Set_Global_Int('Margin_Released',FALSE);
- Goto_Col(Global_Int('Left_Margin'));
- Right_Margin := Global_Int('Right_Margin');
- End;
- Set_Indent_Level;
- Goto_Mark;
- Refresh := TRUE;
- Redraw;
- Messages := TRUE;
- END_MACRO;
-
- $MACRO INDENT;
- Indent;
- Set_Global_Int('Left_Margin',C_Col);
- END_MACRO;
-
- $MACRO UNDENT;
- Undent;
- Set_Global_Int('Left_Margin',C_Col);
- END_MACRO;
-
- $MACRO WSHELP;
- help('WORDSTAR^*');
- END_MACRO;
-
-
- $MACRO WSInstall;
- Set_Global_Int('SETUP_CHANGED',Global_Int('SETUP_CHANGED') or $02);
- Set_Global_Str('@KEYMAP_NAME@','KN=WORDSTARFN=WORDSTAR');
- END_MACRO;
-