home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s3.arc / PT4EDIT.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-07  |  6KB  |  190 lines

  1. {.C-}
  2. {.U Word}
  3. {.U LongInt}
  4. {.U UNIT}
  5. {.U INTERFACE}
  6. {.U USES}
  7. {.U Dos}
  8. {.U Crt}
  9. {.U GlobType}
  10. {.U StringMan}
  11. {.U PibMTask}
  12. {.U GlobRout}
  13. {.U PibEditor}
  14. {.U EditFileName}
  15. {.U WriteSXY}
  16. {.U Draw_Menu_Frame}
  17. {.U Press_Any}
  18. {.U PibTerm_Window}
  19. {.U Dupl}
  20. {.U Global_Text_Attribute}
  21. {.U Global_ForeGround_Color}
  22. {.U Global_BackGround_Color}
  23. {.U Status_Line_Attr}
  24. {.U Save_Partial_Screen}
  25. {.U Restore_Screen}
  26. {.U Do_Status_Time}
  27. {.U Wait_For_Retrace}
  28. {.U DesqView_Screen}
  29. {.U TurnOnTimeSharing}
  30. {.U TurnOffTimeSharing}
  31. {.U MultiTasker}
  32. {.U DoubleDos}
  33. {.U Write_Screen_Memory}
  34. {.U CRT_Status}
  35. {.U Max_Screen_Col}
  36. {.U TopView}
  37. {.U Sync_Screen}
  38. {.U Registers}
  39. {.U Scroll}
  40. {.U Set_Text_Attributes}
  41. {.U EGA_Present}
  42. {.U Extended_KeyBoard}
  43. {.U UpperCase}
  44. {.U Get_Screen_Address}
  45. {.U AX}
  46. {.U BX}
  47. {.U CX}
  48. {.U DX}
  49. {.U AL}
  50. {.U BL}
  51. {.U CL}
  52. {.U DL}
  53. {.U AH}
  54. {.U BH}
  55. {.U CH}
  56. {.U DH}
  57. {.U INT24RESULT}
  58. {.U Menu_Type}
  59. {.U Saved_Screen_Ptr}
  60. {.U Make_A_Menu}
  61. {.U PibTerm_KeyPressed}
  62. {.U Clear_Window}
  63. {.U Menu_Display_Choices}
  64. {.U Menu_Get_Choice}
  65. {.U Read_Kbd}
  66. {.U AnyStr}
  67. {.U Save_Screen}
  68. {.U Max_Screen_Line}
  69. {.U Erase_Menu}
  70. {.U MyFreeMem}
  71. {.U WriteCXY}
  72. {.U Menu_Frame_Color}
  73. {.U Menu_Title_Color}
  74. {.U Menu_Text_Color}
  75.  
  76. UNIT PT4EDIT;
  77.  
  78. INTERFACE
  79.  
  80. USES
  81.    Dos, Crt, GlobType, StringMan, PibMTask, GlobRout;
  82.  
  83. PROCEDURE PibEditor( EditFileName : AnyStr );
  84.  
  85. IMPLEMENTATION
  86.                                    (* Editor globals *)
  87. {.C+}
  88. {$I PIBEDITR.GLO }
  89. {.C-}
  90.                                    (* Editor code    *)
  91.                                    
  92. (*----------------------------------------------------------------------*)
  93. (*           PibEditor --- Simple screen editor for PibTerm             *)
  94. (*----------------------------------------------------------------------*)
  95.  
  96. PROCEDURE PibEditor( EditFileName : AnyStr );
  97.  
  98. VAR
  99.    Local_Save   : Saved_Screen_Ptr;
  100.    Local_Save_2 : Saved_Screen_Ptr;
  101.    Name_Given   : BOOLEAN;
  102.    
  103. PROCEDURE Editor( EditFileName : AnyStr );
  104.  
  105. {.C+}
  106. {$I editsub1.mod }
  107. {$I editsub2.mod }
  108. PROCEDURE II1III111II1(II1II1II1I:AnyStr);VAR III11I:INTEGER;III1II1I11:INTEGER;BEGIN III11I:=WHEREX
  109. ;III1II1I11:=(Status_Line_Attr AND $F0) OR WHITE;WriteCXY(II1II1II1I[1],III11I,Max_Screen_Line,
  110. III1II1I11);WriteSXY(COPY(II1II1II1I,2,80),SUCC(III11I),Max_Screen_Line,Status_Line_Attr);GOTOXY(
  111. III11I+LENGTH(II1II1II1I),Max_Screen_Line);END;PROCEDURE II111I;BEGIN PibTerm_Window(1,1,
  112. Max_Screen_Col,Max_Screen_Line);WriteSXY(I1IIII11I1111,1,Max_Screen_Line,Status_Line_Attr);
  113. II1III111II1('1Help ');II1III111II1('2Undo ');II1III111II1('3Find ');II1III111II1('4Replace ');
  114. II1III111II1('5SaveQuit ');II1III111II1('6InsLine ');II1III111II1('7DelLine ');II1III111II1(
  115. '8Startblk ');II1III111II1('9Endblk ');II1III111II1('0Quit');END;PROCEDURE I1II1I1II(IIII111I1:
  116. AnyStr);BEGIN Draw_Menu_Frame(5,10,75,14,Menu_Frame_Color,Menu_Title_Color,Menu_Text_Color,'');
  117. GOTOXY(1,1);WRITELN(IIII111I1);Press_Any;END;VAR IIIIIII1II1I1:I11I1I11;I1I1II11I1:INT;II1111II1:
  118. II1II1I1I;I111111I1I1:ARRAY[0..10] OF INT;IIIII111111I:LongInt;II111II1:Word;BEGIN I1III1II:=
  119. Global_Text_Attribute;I111IIII:=(Global_ForeGround_Color AND 7) SHL 4+(Global_BackGround_Color);
  120. III11III:=Status_Line_Attr;III111I1I:=Status_Line_Attr;I1IIII11I1111:=Dupl(' ',Max_Screen_Col);
  121. II1111II1:=EditFileName;IIIII111111I:=MAXAVAIL;IF (IIIII111111I>$FFE0) THEN II111II1:=$FFE0 ELSE 
  122. II111II1:=IIIII111111I;I1I1II11I1:=III1III1II1I(IIIIIII1II1I1,II111II1,1,1,Max_Screen_Col,
  123. Max_Screen_Line,Wait_For_Retrace,'');IF (I1I1II11I1<>0) THEN BEGIN I1II1I1II(
  124. 'Not enough memory to perform editing.');EXIT;END;I1I1II11I1:=II1I111111I(IIIIIII1II1I1,II1111II1);
  125. CASE I1I1II11I1 OF II:BEGIN Save_Partial_Screen(Local_Save_2,5,10,75,14);I1II1I1II(
  126. 'File to be edited not found, new file will be created.');Restore_Screen(Local_Save_2);II1I11I1III(
  127. IIIIIII1II1I1,II1111II1);END;II111II111:BEGIN I1II1I1II(
  128. 'I/O error occurred while reading file, editing cancelled.');EXIT;END;I1I111I1I:BEGIN I1II1I1II(
  129. 'File is too big to be edited, editing cancelled.');EXIT;END;ELSE;END;I111111I1I1[0]:=1;I111111I1I1[1
  130. ]:=68;I111111I1I1[2]:=0;II111I;I1I1II11I1:=I1I11I1111I1(IIIIIII1II1I1,1,1,Max_Screen_Col,PRED(
  131. Max_Screen_Line),I1I11II1I,0,0,I111111I1I1);IF (I1II1I111II11(IIIIIII1II1I1) AND (I1I1II11I1=0)) 
  132. THEN BEGIN I1I1II11I1:=II1I1II1(IIIIIII1II1I1);IF I1I1II11I1<>0 THEN I1II1I1II(
  133. 'I/O error while writing edited file.');END;II1III1I(IIIIIII1II1I1);III1IIII1(1,1,Max_Screen_Col,
  134. Max_Screen_Line);II1II111I1I(1,Max_Screen_Line);END;{.C-}
  135.  
  136. (*----------------------------------------------------------------------*)
  137. (*           PibEditor --- Main program to get file name for editing    *)
  138. (*----------------------------------------------------------------------*)
  139.  
  140. BEGIN (* PibEditor *)
  141.                                    (* Don't update status Line *)
  142.                                    
  143.    Save_Do_Status_Time := Do_Status_Time;
  144.    Do_Status_Time      := FALSE;
  145.    
  146.                                    (* Save screen *)
  147.                                    
  148.    Draw_Titled_Box( Local_Save, 5, 10, 75, 14, 'Edit File' );
  149.    
  150.                                    (* Get name of file to edit *)
  151.                                    
  152.    Name_Given   := ( LENGTH( EditFileName ) > 0 );
  153.  
  154.    TextColor( Menu_Text_Color_2 );
  155.    WRITELN('Enter name of file to edit: ');
  156.    WRITE('>');
  157.    
  158.    TextColor( Menu_Text_Color );
  159.    
  160.    IF ( NOT Name_Given ) THEN
  161.       Read_Edited_String( EditFileName )
  162.    ELSE
  163.       WRITE( EditFileName );
  164.    WRITELN;
  165.                                    (* Restore screen *)
  166.                                    
  167.    Restore_Screen_And_Colors( Local_Save );
  168.    
  169.                                    (* Save screen *)
  170.                                    
  171.    IF ( ( EditFileName <> CHR( ESC ) ) AND
  172.         ( EditFileName <> ''         ) ) THEN
  173.       BEGIN
  174.       
  175.          Save_Screen( Local_Save );
  176.                                    (* Edit the file *)
  177.          Editor( EditFileName );
  178.                                    (* Restore screen *)
  179.                                    
  180.          Restore_Screen_And_Colors( Local_Save );
  181.          
  182.       END;
  183.                                    (* Restore status Line check *)
  184.                                    
  185.    Do_Status_Time := Save_Do_Status_Time;
  186.    
  187. END   (* PibEditor *);
  188.  
  189. END   (* PT4EDIT *).
  190.