Przeglądaj źródła

+ save ansi dump as text is filename suffix is '.txt'

pierre 24 lat temu
rodzic
commit
066d198d33
2 zmienionych plików z 19 dodań i 6 usunięć
  1. 10 4
      ide/fpdpansi.pas
  2. 9 2
      ide/fpmansi.inc

+ 10 - 4
ide/fpdpansi.pas

@@ -21,7 +21,8 @@ uses
   objects,
   video;
 
-function ExportBufferToAnsiFile(var Buffer : TVideoBuf;xmin,xmax,ymin,ymax,linesize : sw_integer;var f : text) : boolean;
+function ExportBufferToAnsiFile(var Buffer : TVideoBuf;xmin,xmax,ymin,ymax,linesize : sw_integer;
+           SaveAsText : boolean;var f : text) : boolean;
 
 implementation
 
@@ -43,7 +44,8 @@ const ColorTab : array[0..7] of byte =
       (Black,Red,Green,Brown,Blue,Magenta,Cyan,LightGray);
 
 {$i-}
-function ExportBufferToAnsiFile(var Buffer  : TVideoBuf;xmin,xmax,ymin,ymax,linesize : sw_integer;var f : text) : boolean;
+function ExportBufferToAnsiFile(var Buffer  : TVideoBuf;xmin,xmax,ymin,ymax,linesize : sw_integer;
+           SaveAsText : boolean;var f : text) : boolean;
 var
   CurColor : byte;
   CurForColor, CurBackColor : byte;
@@ -91,13 +93,14 @@ var
   textAttr : byte;
   i, j : sw_integer;
 begin
+  CurColor:=0;
   for i:=ymin to ymax do
     begin
       for j:=xmin to xmax do
         begin
           ch:=chr(Buffer[i*linesize+j] and $ff);
           textattr:=Buffer[i*linesize+j] shr 8;
-          if textattr<>CurColor then
+          if (textattr<>CurColor) and not SaveAsText then
             ChangeColor(textattr);
           Write(f,ch);
         end;
@@ -109,7 +112,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.1  2001-08-04 11:30:23  peter
+  Revision 1.2  2001-11-15 13:30:14  pierre
+   + save ansi dump as text is filename suffix is '.txt'
+
+  Revision 1.1  2001/08/04 11:30:23  peter
     * ide works now with both compiler versions
 
   Revision 1.1.2.1  2000/11/21 17:43:24  pierre

+ 9 - 2
ide/fpmansi.inc

@@ -19,7 +19,9 @@ var
    f : text;
    Buf : PVideoBuf;
    re : word;
+   p : longint;
    UL,LR : TPoint;
+   SaveAsText : boolean;
    Name, DefExt : string;
 
    function GetPoint(var P :TPoint) : boolean;
@@ -72,8 +74,10 @@ begin
     begin
       Assign(f,Name);
       Rewrite(f);
+      p:=system.pos('.',Name);
+      SaveAsText:=Copy(Name,p+1,High(Name))='txt';
       ExportBufferToAnsiFile(Buf^,UL.X,LR.X,UL.Y,LR.Y,
-        Size.X,f);
+        Size.X,SaveAsText,f);
       Close(f);
     end;
   PopStatus;
@@ -81,7 +85,10 @@ end;
 
 {
   $Log$
-  Revision 1.2  2001-10-12 14:20:11  pierre
+  Revision 1.3  2001-11-15 13:30:14  pierre
+   + save ansi dump as text is filename suffix is '.txt'
+
+  Revision 1.2  2001/10/12 14:20:11  pierre
    * use correct video buffer size
 
   Revision 1.1  2001/08/04 11:30:23  peter