home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE EXIT;
- {******************************************************************************
- MULTI-EDIT MACRO FILE EXIT
-
- EXIT - Standard exit routine
- RESTORE - Restores editor according to file created by STATUS
- STATUS - Creates restore file.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- $MACRO EXIT FROM EDIT TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: EXIT
-
- Description: If any files are changed and not saved this macro displays them
- and asks for user verification. The user is given the choice of
- quitting without saving, saving and then quitting, or cancelling
- the operation.
-
- This macro also takes care of deleting any .TMP files created by
- disk swapping. There should only be .TMP files left if the
- quit without saving option was selected, since the SAVE_FILE
- function automatically deletes the .TMP file for that buffer.
-
- Parameters:
- /BC= Only relevant when called via the menu system. Tells EXIT
- how many boxes to kill.
- /NP= If 1, and there are modified files in memory, the usual
- "Do you want to save these files?" prompt will not appear,
- but the files will be unconditionally saved.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Def_Int(Old_Refresh,Temp_Integer,Not_Saved,Temp_Window,X1,X2,Y1,Y2,Str_X,
- t_bc, jx, jy );
- Def_Str(Temp_String);
-
- Old_Refresh := Refresh;
- Refresh := False;
- Temp_Window := CUR_WINDOW;
- working;
-
- IF global_str('@ME_EXIT_MACRO@') <> '' THEN
- RM( global_str('@ME_EXIT_MACRO@') );
- IF return_int = 0 THEN
- goto end_of_mac;
- END;
- END;
-
- t_bc := Parse_Int('/BC=', mparm_str);
- while box_count > t_bc DO
- kill_box;
- END;
-
- {Check to see how many files are not saved}
- Temp_Integer := 1;
- Not_Saved := 0;
- While (Temp_Integer <= Window_Count) Do
- Switch_Window(Temp_Integer);
- IF (window_attr and $80) = 0 THEN
-
- { START OF ASV MODIFICATION NO 1 }
- IF (global_int(Truncate_Extension(Truncate_Path(File_Name)) + '.' +
- global_str('autosave_ext'))) THEN
- File_Changed := TRUE;
- END;
- { END OF ASV MODIFICATION NO 1 }
-
- If (File_Changed) Then
- Not_Saved := Not_Saved + 1;
- End;
- END;
- ++Temp_Integer;
- End;
-
-
- If (Not_Saved > 13) Then
- Not_Saved := 13;
- End;
-
- {If there are any unsaved files, make a warning box}
- If (Not_Saved) Then
- IF (parse_int('/NP=',mparm_str)) THEN
- goto skip_prompt;
- END;
- X1 := 5;
- Y1 := 4;
- X2 := X1 + 56;
- Y2 := Y1 + 6 + Not_Saved;
- Put_Box(X1,Y1,X2,Y2,0,m_b_color,'FILES NOT SAVED! ARE YOU SURE YOU WANT TO QUIT?',True);
- Write('The following files are not saved:',X1 + 2,Y1 + 3,0,m_t_Color);
- Write('WINDOW FILE NAME',X1 + 2,Y1 + 4,0,m_s_Color);
- Temp_Integer := 1;
- Not_Saved := 0;
- While (Temp_Integer <= Window_Count) and (Not_Saved < 13) DO
- Switch_Window(Temp_Integer);
- IF (window_attr and $80) = 0 THEN
- If (File_Changed) Then
- Write(window_name + ' ' + File_Name,X1 + 5,Y1 + 5 + Not_Saved,0,m_t_Color);
- ++Not_Saved;
- End;
- END;
- ++Temp_Integer;
- End;
- update_status_line;
- RM('USERIN^XMENU /X=' + str(x1 + 14) +
- '/Y=' + str(y1 + 1) +
- '/S=1/M=No(EXIT)Yes()Save-files-and-quit()');
-
- Temp_Integer := return_int;
- Kill_Box;
- If (Temp_Integer = 3) THEN
- skip_prompt:
- working;
- Make_Message('Saving files...');
-
- { START OF ASV MODIFICATION NO 2 }
- RM('MESYS^AUTOSAVE /EX=1');
- { END OF ASV MODIFICATION NO 2 }
-
- IF (Return_Int <> 0) THEN
- Goto END_OF_MAC;
- END;
- Goto Go_Quit;
- END;
- If (Temp_Integer = 1) THEN
- Goto End_OF_Mac;
- END;
- If (Temp_Integer = 2) Then
- Goto Go_Quit;
- End;
- ELSE
- Goto Go_Quit;
- END;
- Goto End_OF_Mac;
- GO_QUIT:
-
- { START OF ASV MODIFICATION NO 3 }
- {RM('MESYS^AUTOSAVE /EX=2');}
- RM('autosave^AUTOSAVE /EX=2');
- { END OF ASV MODIFICATION NO 3 }
-
- Switch_Window(Temp_Window);
-
- rm('setup^check_setup /X=10/Y=3');
- IF return_int < 1 THEN
- goto End_Of_Mac;
- END;
- working;
- If Global_Int('RESTORE') THEN
- Set_Global_Str('@TREE_PARMS@', '');
- Set_Global_Str('COM_LINE_PARAMS', '');
-
-
- {Clear out unneeded globals}
-
- JX := 12;
- temp_string := '0ISTR_';
- CALL CLEAR_GLOBAL_LIST;
-
- JX := 12;
- temp_string := 'X0ISTR_';
- CALL CLEAR_GLOBAL_LIST;
-
- jx := global_int('@KEYMACRO_COUNT@');
- temp_string := '@KM!#';
- CALL CLEAR_GLOBAL_LIST;
-
- set_global_int('@KEYMACRO_COUNT@', 0 );
- set_global_str('@KMTEMP!#','');
-
-
- RM('STATUS');
-
- END;
- Quit2:
-
- refresh := false;
-
- status_row := 0;
- Rest_Dos_Screen;
- QUIT(0);
-
- goto end_of_mac;
-
- CLEAR_GLOBAL_LIST:
- JY := 0;
- WHILE JY < JX DO
- ++JY;
- SET_GLOBAL_STR( temp_string + STR(JY), '' );
- END;
- RET;
-
-
- END_OF_MAC:
- Switch_Window(Temp_Window);
- Refresh := Old_Refresh;
-
- END_MACRO;
-
- $MACRO RESTORE TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: RESTORE
-
- Description: This macro uses the file STATUS.ME and restores the editor exactly
- to the conditions contained therein.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- Def_Int(Temp_Integer,Status_Window,Active_Window,Temp_Window,X1,Y1,X2,Y2, count);
- Def_Str( TStr );
-
- Refresh := False;
- Messages := False;
- Error_Level := 0;
- working;
- Call CLEAR_LINK_GLOBALS;
- IF Global_Int('@RESTORE_USE_ME_PATH') THEN
- Load_File(me_path + user_id + 'STATUS.ME');
- ELSE
- Load_File(user_id + 'STATUS.ME');
- END;
- Status_Window := Cur_Window;
- If (ERROR_LEVEL <> 0) Then
- Temp_Integer := error_level;
- refresh := TRUE;
- {
- Make_Message( '3002 error. Cur_window=' + Str(Cur_Window) + ' Window_Id=' + Str(Window_Id) + ' Window_Count=' + STr(Window_Count));
- Read_Key;
- There is a bug in DELWIN, or a macro that DELWIN runs that behaves differently
- if ERROR_LEVEL <> 0 upon entry.}
- Error_Level := 0;
- rm('WINDOW^DELWIN');
- {
- Make_Message( 'After DELWIN. Cur_window=' + Str(Cur_Window) + ' Window_Id=' + Str(Window_Id) + ' Window_Count=' + STr(Window_Count));
- Read_Key;
- }
-
- IF (temp_integer = 3002) THEN
- {
- IF (ERROR_LEVEL = 3002) THEN
- }
- Error_Level := 0;
- ELSE
- RM('MEERROR^Beeps /C=1');
- Make_Message('ERROR OCCURRED DURING RESTORE MACRO! Press any key for error message.');
- Error_level := temp_integer;
- Read_Key;
-
- END;
- Goto END_OF_MAC;
- End;
- IF remove_Space(get_line) <> remove_space('@MULTI-EDIT VERSION ' + version) THEN
- refresh := TRUE;
- {
- Make_Message( 'Different version. Cur_window=' + Str(Cur_Window) + ' Window_Id=' + Str(Window_Id) + ' Window_Count=' + STr(Window_Count));
- Read_Key;
- }
- rm('WINDOW^DELWIN');
- {
- Make_Message( 'After DELWIN. Cur_window=' + Str(Cur_Window) + ' Window_Id=' + Str(Window_Id) + ' Window_Count=' + STr(Window_Count));
- Read_Key;
- }
- Make_Message( ' STATUS FILE CREATED WITH DIFFERENT VERSION. RESTORE ABORTED.');
- Goto END_OF_MAC;
- END;
- Make_Message('Restoring previous status of the editor.');
-
- Set_Virtual_Display;
- count := 0;
- While NOT( At_EOF ) Do
- TStr := Get_Line;
- IF Parse_Int('/W=',Tstr) <> 0 THEN
- WORKING;
- Temp_Integer := (Parse_Int('/A=',TStr) = 1);
- Switch_Window( Window_Count );
- Create_Window;
- IF temp_integer THEN
- active_window := window_id;
- END;
- Temp_Window := Cur_Window;
- temp_integer := XPOS('/ZOOM=', tstr, 1 );
- IF temp_integer <> 0 THEN
- set_global_str('!WINZOOM#' + str(window_id),
- copy(tstr,temp_integer + 6, 80 ) );
- tstr := copy(tstr, 1, temp_integer - 1);
- IF global_str('!WINZOOM#' + str(window_id)) <> '' THEN
- zoom_char := parse_str( '/ZC=', Global_Str('!WINZOOM#' + str(window_id)) );
- END;
- END;
- File_Name := Parse_Str('/FN=',TStr);
- {Restore window coordinates while checking for out of bounds}
- X1 := Parse_Int('/X1=',TStr);
- IF (X1 < Min_Window_Col) THEN
- X1 := Min_Window_Col;
- END;
- Y1 := Parse_Int('/Y1=',TStr);
- IF (Y1 < Min_Window_Row) THEN
- Y1 := Min_Window_Row;
- END;
- X2 := Parse_Int('/X2=',TStr);
- IF (X2 > Max_Window_Col) THEN
- X2 := Max_Window_Col;
- END;
- Y2 := Parse_Int('/Y2=',TStr);
- IF (Y2 > Max_Window_Row) THEN
- Y2 := Max_Window_Row;
- END;
- IF x2 <> 0 THEN
- Size_Window(X1,Y1,X2,Y2);
- END;
- IF (Parse_Int('/LS=',TStr)) THEN
- {It doesn't look like link_status and buffer_Id work right. The following code
- is written for if it works right. Following that is some "work around" code.}
- {
- {If file is linked to another see if it is the first occurance or not}
- IF (Global_Int('Buffer_Id' + Parse_Str('/BI',Tstr))) THEN
- {If not, link it to the window with the first occurance but don't load a file}
- Link_Window(Global_Int('Buffer_Id' + Parse_Str('/BI',Tstr)));
- ELSE
- {If so, set a global integer to indicate a first occurance and to store the
- window number of that one and then load the file}
- Set_Global_Int('Buffer_Id' + Parse_Str('/BI',Tstr),Cur_Window);
- Goto LOAD_IT;
- END;
- }
- {If file is linked to another see if it is the first occurance or not}
- IF (Global_Int('Buffer_Id' + Parse_Str('/LS',Tstr))) THEN
- {If not, link it to the window with the first occurance but don't load a file}
- Link_Window(Global_Int('Buffer_Id' + Parse_Str('/LS',Tstr)));
- ELSE
- {If so, set a global integer to indicate a first occurance and to store the
- window number of that one and then load the file}
- Set_Global_Int('Buffer_Id' + Parse_Str('/LS',Tstr),Cur_Window);
- Goto LOAD_IT;
- END;
- ELSE
- LOAD_IT:
- If (File_Name <> '?No-File?') Then
- XLoad_File(File_Name);
- End;
- RM( 'EXTSETUP');
- END;
- File_Changed := False;
- Goto_Col( Parse_int('/IL=',TStr));
- Set_Indent_Level;
- X1 := Parse_Int('/R=',TStr);
- While C_Row < X1 DO
- X2 := C_ROW;
- Down;
- IF X2 = C_Row THEN
- Goto WEX;
- END;
- END;
- WEX:
- Wrap_Stat := Parse_Int('/WS=',TStr);
- Right_Margin := Parse_Int('/RM=', tstr );
- Indent_Style := Parse_Int('/IS=',TStr);
- x1 := Parse_Int('/D=', tstr);
- IF x1 > 0 THEN
- Doc_Mode := x1;
- END;
- Temp_Integer := Parse_Int('/BS=',TStr);
- If (Temp_Integer = 1) Then
- Block_Begin;
- Block_End;
- block_line1 := Parse_Int('/BL1=',TStr);
- block_line2 := Parse_Int('/BL2=',TStr);
- End;
- If (Temp_Integer = 2) OR (Temp_Integer = 3) THEN
- IF Temp_Integer = 2 THEN
- Col_Block_Begin;
- ELSE
- STR_Block_Begin;
- END;
- right;
- Block_End;
- block_line1 := Parse_Int('/BL1=',TStr);
- block_line2 := Parse_Int('/BL2=',TStr);
- block_col1 := Parse_Int('/BC1=',TStr);
- block_col2 := Parse_Int('/BC2=',TStr);
- End;
- Goto_Col( Parse_Int('/C=',TStr));
- Goto_Line( Parse_Int('/L=',TStr));
- Window_Attr := Parse_Int('/WA=',TStr);
- w_Bottom_line := Parse_int('/BTML=', tstr);
- window_name := Parse_Str('/WNM=', tstr);
- screen_num := parse_int('/SN=', tstr );
- Switch_Window(Status_Window);
- Goto MainLoop;
- END;
- IF Parse_Int('/MISC=',TStr) THEN
- Insert_Mode := Parse_Int('/I=',TStr);
- IF ((Video_Mode) <> (Parse_Int('/V=',TStr))) THEN
- Reset_Virtual_Display;
- Toggle_Video;
- RM('SETSCRN');
- Make_Message('Restoring previous status of the editor.');
- Set_Virtual_Display;
- END;
- Goto MAINLOOP;
- END;
- TStr := Copy(TStr,1,7);
- IF (TStr = '/G_STR=') OR (tstr = '/G_INT=') THEN
- goto do_globals;
- END;
- MAINLOOP:
- Down;
- End;
-
- WHILE NOT( AT_EOF ) DO
-
- DO_GLOBALS:
- TStr := Copy(Get_Line,1,7);
- IF TStr = '/G_STR=' THEN
- TStr := Copy(Get_Line,8,20);
- Down;
- Set_Global_Str(TStr,reconvert_string(Get_Line));
- ELSIF TStr = '/G_INT=' THEN
- TStr := Copy(Get_Line,8,20);
- Down;
- IF Val(Temp_Integer, Get_Line) = 0 THEN
- Set_Global_Int(TStr,Temp_Integer);
- END;
- END;
- DOWN;
- END;
-
- Call CLEAR_LINK_GLOBALS;
-
- Switch_Window(Status_Window);
- IF (Window_Count > 2) THEN
- {This is a "just in case" thing so that if there are no /W= commands in
- STATUS.ME, you will at least have one open window}
- Delete_Window;
- Switch_Win_Id(Active_Window);
- ELSE
- Erase_Window;
- END;
- RM('WINDOW^FindWin');
- set_global_int('MENU_LEVEL', 0 );
- set_global_int('SETUP_CHANGED', 0 );
- {RM('SETSCRN');}
-
- Refresh := True;
- New_Screen;
- Make_Message('Previous status of the editor restored.');
- Goto END_OF_MAC;
-
-
- CLEAR_LINK_GLOBALS:
- Temp_Integer := 1;
- WHILE (Temp_Integer < Window_Count) DO
- Set_Global_Int('Buffer_Id' + Str(Temp_Integer),0);
- ++ Temp_Integer;
- END;
- RET;
-
- END_OF_MAC:
- update_virtual_display;
- reset_virtual_display;
- Messages := True;
-
- END_MACRO;
-
- $MACRO STATUS TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: STATUS
-
- Description: This macro saves the current status of the editor for the purpose
- of restoring the editor to exactly the state it was in.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Def_Int( JY,jx, Active_Window, Status_Window, Temp_Window, temp_backup );
- Def_Str( TStr );
-
- temp_backup := backups;
- backups := false;
- Undo_Stat := False;
- Refresh := False;
- Messages := False;
- Active_Window := Cur_Window;
-
- {Find the numerically highest window}
- Switch_Window(Window_Count);
- {Create a window to store all status data}
- Create_Window;
- Status_Window := Cur_Window;
- IF Global_Int('@RESTORE_USE_ME_PATH') THEN
- File_Name := me_path + user_id + 'STATUS.ME';
- ELSE
- File_Name := user_id + 'STATUS.ME';
- END;
- Put_Line( '@MULTI-EDIT VERSION ' + remove_space(version) );
- down;
-
- TStr := '/MISC=1' +
- '/I=' + Str(Insert_Mode) +
- '/V=' + Str(Video_Mode);
- Put_Line(Tstr);
- Down;
-
- Switch_Window(1);
- While (Cur_Window < Status_Window) Do
- Temp_Window := Cur_Window;
- IF (window_attr and $80) = 0 THEN
- TStr := '/W=' + Str(Cur_Window) +
- '/WNM=' + window_name +
- '/A=' + Str( Cur_Window = Active_Window ) +
- '/WA=' + Str( Window_Attr ) +
- '/FN=' + File_Name +
- '/C=' + Str(C_Col) +
- '/L=' + Str(C_Line) +
- '/R=' + Str(C_Row) +
- '/IL=' + Str(Indent_Level) +
- '/WS=' + Str(Wrap_Stat) +
- '/IS=' + Str(Indent_Style) +
- '/D=' + Str(Doc_Mode) +
- '/LS=' + Str(Link_Stat) +
- '/BI=' + Str(Buffer_Id) +
- '/BTML=' + Str(w_bottom_line) +
- '/RM=' + Str( right_margin ) +
- '/SN=' + str(screen_num);
-
- IF (win_x1 <> min_window_col) OR (win_x2 <> max_window_col) OR
- (win_y1 <> min_window_row) OR (win_y2 <> max_window_row) THEN
- tstr := tstr +
- '/X1=' + Str(Win_X1) +
- '/Y1=' + Str(Win_Y1) +
- '/X2=' + Str(Win_X2) +
- '/Y2=' + Str(Win_Y2);
- END;
- IF block_stat <> 0 THEN
- tstr := tstr +
- '/BS=' + Str(Block_Stat) +
- '/BC1=' + Str(Block_Col1) +
- '/BC2=' + Str(Block_Col2) +
- '/BL1=' + Str(Block_Line1) +
- '/BL2=' + Str(Block_Line2);
- END;
-
- {This MUST be the last item!!!!!}
- IF global_str('!WINZOOM#' + str(window_id)) <> '' THEN
- Tstr := tstr + '/ZOOM=' + global_str('!WINZOOM#' + str(window_id ) );
- END;
- Switch_Window( Status_Window );
- Put_Line(Tstr);
- down;
- END;
- Switch_Window(Temp_Window + 1);
- End;
-
- {Save some misc. general stuff at the end}
- Switch_Window(Status_Window);
-
- TStr := First_Global( jx );
- Loop:
- IF (TStr <> '') THEN
- IF str_char(tstr,1) <> '!' THEN
- IF jx = 1 then
- Put_Line('/G_INT=' + TStr); DOWN;
- Put_Line(Str(Global_int(tstr))); DOWN;
- ELSE
- Put_Line('/G_STR=' + TStr); DOWN;
- Put_Line(convert_string(Global_str(tstr))); DOWN;
- END;
- END;
- TStr := Next_Global(jx);
- Goto Loop;
- END;
-
- Save_File;
- IF parse_int('/NDEL=',mparm_str) = 0 THEN
- Delete_Window;
- END;
-
- Switch_Window(Active_Window);
-
- Refresh := True;
- Messages := true;
- Undo_Stat := true;
- GOTO END_OF_MAC;
-
-
-
- END_OF_MAC:
- backups := temp_backup;
- END_MACRO;
-