Browse Source

* New big merge from fixes branch

pierre 25 years ago
parent
commit
de5cef1bc8

+ 0 - 0
ide/text/empty.inc


+ 38 - 0
ide/text/fixes.txt

@@ -1,3 +1,41 @@
+Gabor's log to 18/10/2000 commits
+========================= Improvements ================================
+
+ [+] HTML keyword index file stores now relative paths, thus it can be
+     moved/copied freely as long as relative paths are preserved
+ [+] history lists added at several points (like run parameters, ini
+     file name, compiler conditionals, etc.)
+
+Gabor's log to 18/09/2000 commits
+========================= Already fixed ================================
+
+ [*] editor flags weren't stored in desktop file
+ [*] TFastBufStream contained a bug which showed up when using non-linear
+     (eg. "random") reads, and resulted in returning data from wrong file
+     position
+
+========================= Improvements ================================
+
+ [+] added support for OS/2 help files (.INF) to the help system
+ [+] started implementing fold support (it's not yet fully functional!!!)
+
+     Folds enable you to hide specific parts of the documents (independantly
+     of each other). When a fold is hidden only it's first line (the fold
+     header) is show - all other lines (the fold body) and all subfolds do
+     not appear on screen. Folds can be also nested.
+     This is very useful for ex. to hide the implementation part of a
+     procedure, while leaving the procedure header still visible. This greatly
+     simplyfies navigation in the source file by temporarily hiding currently
+     unused content.
+     Fold information could be (optionally) gerenated automatically by the
+     compiler, according to the control/syntax-tree of the program.
+
+     Folds can be created manually by selecting an area and the pressing
+     Ctrl-K-A. Valids are fold areas that do not cross bounds of already
+     existing folds.
+     Fold bodies can be hidden with Ctrl-Gray-, shown with Ctrl-Gray+.
+     Pressing Ctrl-Gray* toggles the visibility of a fold body.
+
 Gabor's log to 10/8/2000 commits
 ========================= Already fixed ================================
 

+ 43 - 4
ide/text/fpcatch.pas

@@ -26,10 +26,15 @@ uses
 uses
   dpmiexcp;
 {$endif}
+{$ifdef win32}
+uses
+  signals;
+{$endif}
 
 {$ifdef HasSignal}
 Var
-  NewSignal,OldSigSegm,OldSigInt : SignalHandler;
+  NewSignal,OldSigSegm,OldSigILL,
+  OldSigInt,OldSigFPE : SignalHandler;
 {$endif}
 
 Const
@@ -43,7 +48,7 @@ uses
   drivers,
 {$endif FPC}
   app,commands,msgbox,
-  FPString,FPIDE;
+  FPString,FPCompil,FPIDE;
 
 
 {$ifdef HasSignal}
@@ -56,8 +61,32 @@ var MustQuit: boolean;
 begin
   case Sig of
    SIGSEGV : begin
+               if StopJmpValid then
+                 LongJmp(StopJmp,SIGSEGV);
                if Assigned(Application) then IDEApp.Done;
-               Writeln('Internal Error caught');
+               Writeln('Internal SIGSEGV Error caught');
+{$ifndef DEBUG}
+               Halt;
+{$else DEBUG}
+               RunError(216);
+{$endif DEBUG}
+             end;
+    SIGFPE : begin
+                if StopJmpValid then
+                  LongJmp(StopJmp,SIGFPE);
+               if Assigned(Application) then IDEApp.Done;
+               Writeln('Internal SIGFPE Error caught');
+{$ifndef DEBUG}
+               Halt;
+{$else DEBUG}
+               RunError(207);
+{$endif DEBUG}
+             end;
+    SIGILL : begin
+                if StopJmpValid then
+                  LongJmp(StopJmp,SIGILL);
+               if Assigned(Application) then IDEApp.Done;
+               Writeln('Internal SIGILL Error caught');
 {$ifndef DEBUG}
                Halt;
 {$else DEBUG}
@@ -65,6 +94,8 @@ begin
 {$endif DEBUG}
              end;
     SIGINT : begin
+               if StopJmpValid then
+                 LongJmp(StopJmp,SIGINT);
                IF NOT CtrlCPressed and Assigned(Application) then
                  begin
                    MustQuit:=false;
@@ -107,12 +138,20 @@ begin
 {$endif TP}
   OldSigSegm:=Signal (SIGSEGV,NewSignal);
   OldSigInt:=Signal (SIGINT,NewSignal);
+  OldSigFPE:=Signal (SIGFPE,NewSignal);
+  OldSigILL:=Signal (SIGILL,NewSignal);
 {$endif}
 end.
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:34  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/31 07:52:55  pierre
+   * recover gracefully if compiler generates a signal
+
+  Revision 1.1  2000/07/13 09:48:34  michael
   + Initial import
 
   Revision 1.6  2000/06/22 09:07:11  pierre

+ 67 - 8
ide/text/fpcompil.pas

@@ -102,11 +102,24 @@ procedure ParseUserScreen;
 
 procedure RegisterFPCompile;
 
+{$ifndef GABOR}
+var
+  StopJmp : Jmp_Buf;
+const
+  StopJmpValid : boolean = false;
+{$endif}
+
 implementation
 
 uses
 {$ifdef linux}
   Linux,
+{$endif}
+{$ifdef go32v2}
+  dpmiexcp,
+{$endif}
+{$ifdef win32}
+  signals,
 {$endif}
   Dos,Video,
   App,Commands,tokens,
@@ -571,9 +584,14 @@ begin
   CompilerStatus:=false;
 end;
 
-
 procedure CompilerStop; {$ifndef FPC}far;{$endif}
 begin
+{$ifndef GABOR}
+  if StopJmpValid then
+    Longjmp(StopJmp,1)
+  else
+    Halt(1);
+{$endif}
 end;
 
 Function  CompilerGetNamedFileTime(const filename : string) : Longint; {$ifndef FPC}far;{$endif}
@@ -596,7 +614,7 @@ begin
   if Assigned(W) and (W^.Editor^.GetModified) then
     f:=new(PFPInputFile, Init(W^.Editor))
   else
-    f:=def_openinputfile(filename);
+    f:={$ifndef GABOR}def_openinputfile(filename){$else}nil{$endif};
   CompilerOpenInputFile:=f;
 end;
 
@@ -694,7 +712,7 @@ procedure DoCompile(Mode: TCompileMode);
 var
   s,FileName: string;
   ErrFile : Text;
-  Error,LinkErrorCount : longint;
+  JmpRet,Error,LinkErrorCount : longint;
   E : TEvent;
   DummyView: PView;
 const
@@ -749,7 +767,7 @@ begin
   do_status:=CompilerStatus;
   do_stop:=CompilerStop;
   do_comment:=CompilerComment;
-  do_openinputfile:=CompilerOpenInputFile;
+  {$ifndef GABOR}do_openinputfile:=CompilerOpenInputFile;{$endif}
   do_getnamedfiletime:=CompilerGetNamedFileTime;
 {$else not TP}
   do_status:=@CompilerStatus;
@@ -782,11 +800,37 @@ begin
     DeleteFile will just retrun the errorcode }
   DeleteFile(GetExePath+PpasFile+source_os.scriptext);
   SetStatus('Compiling...');
-  FpIntF.Compile(FileName,SwitchesPath);
-  SetStatus('Finished compiling...');
+{$ifndef GABOR}
+  StopJmpValid:=true;
+  JmpRet:=SetJmp(StopJmp);
+  if JmpRet=0 then
+    begin
+      FpIntF.Compile(FileName,SwitchesPath);
+      SetStatus('Finished compiling...');
+    end
+  else
+    begin
+      Inc(status.errorCount);
+{$ifdef HasSignal}
+      Case JmpRet of
+        SIGINT : s := 'Interrupted by Ctrl-C';
+        SIGILL : s := 'Illegal instruction';
+        SIGSEGV : s := 'Signal Segmentation violation';
+        SIGFPE : s:='Floating point signal';
+        else
+          s:='Undetermined signal '+inttostr(JmpRet);
+      end;
+      CompilerMessageWindow^.AddMessage(V_error,s+' during compilation','',0,0);
+{$endif HasSignal}
+      CompilerMessageWindow^.AddMessage(V_error,'Long jumped out of compilation...','',0,0);
+      SetStatus('Long jumped out of compilation...');
+    end;
+  StopJmpValid:=false;
+{$endif}
   { tokens are created and distroed by compiler.compile !! PM }
   InitTokens;
-  if LinkAfter and ExistsFile(GetExePath+PpasFile+source_os.scriptext) and
+  if LinkAfter and
+     ExistsFile(GetExePath+PpasFile+source_os.scriptext) and
      (CompilationPhase<>cpAborted) and
      (status.errorCount=0) then
     begin
@@ -1054,9 +1098,24 @@ end;
 end.
 {
   $Log$
-  Revision 1.4  2000-10-04 15:01:11  pierre
+  Revision 1.5  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.8  2000/10/31 07:51:58  pierre
+   * recover gracefully if compiler generates a signal
+
+  Revision 1.1.2.7  2000/10/18 21:53:26  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.6  2000/10/09 16:28:24  pierre
+   * several linux enhancements
+
+  Revision 1.4  2000/10/04 15:01:11  pierre
    * fix IsExe problem
 
+  Revision 1.1.2.5  2000/10/03 16:15:57  pierre
+   * Use LongJmp in CompilerStop
+
   Revision 1.3  2000/09/01 21:33:25  peter
     * files to finput
 

+ 26 - 2
ide/text/fpconst.pas

@@ -44,6 +44,7 @@ const
      FPErrFileName        = 'fp___.err';
      GDBOutFileName       = 'gdb___.out';
      GDBOutPutFileName    = 'gdb___.txt';
+     GDBPrompt            = 'gdb>';
      DesktopTempName      = 'fp___.dsk';
      GrepOutName          = 'grep$$.out';
      GrepErrName          = 'grep$$.err';
@@ -52,8 +53,9 @@ const
      HTMLExt              = '.htm';
      TemplateExt          = '.pt';
      NGExt                = '.ng';
+     INFExt               = '.inf';
      WinHelpExt           = '.hlp';
-     HelpFileExts         = '*.tph;*.htm*;*'+HTMLIndexExt+';*'+NGExt+';*'+WinHelpExt;
+     HelpFileExts         = '*.tph;*.htm*;*'+HTMLIndexExt+';*'+NGExt+';*'+WinHelpExt+';*'+INFExt;
 
      EnterSign            = #17#196#217;
 
@@ -100,6 +102,16 @@ const
      dlCurrentDir         = $00;
      dlConfigFileDir      = $01;
 
+     { History ids }
+     hidRunParameters     = 200;
+     hidOpenSourceFile    = 201;
+     hidPrimaryFile       = 202;
+     hidOpenIniFile       = 203;
+     hidSaveIniFile       = hidOpenIniFile;
+     hidOpenHelpFile      = 204;
+     hidConditionalDefines= 205;
+     hidCompilerArgs      = 206;
+
      { Command constants }
      cmShowClipboard     = 201;
      cmFindProcedure     = 206;
@@ -408,7 +420,19 @@ implementation
 END.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:39  pierre
+  Revision 1.3  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.5  2000/10/26 00:04:35  pierre
+   + gdb prompt and FPC_BREAK_ERROR stop
+
+  Revision 1.1.2.4  2000/10/18 21:53:26  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.3  2000/09/18 13:20:54  pierre
+   New bunch of Gabor changes
+
+  Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.2  2000/08/16 18:46:14  peter

+ 41 - 3
ide/text/fpdebug.pas

@@ -36,6 +36,7 @@ type
      { no need to switch if using another terminal }
      NoSwitch : boolean;
      RunCount : longint;
+     FPCBreakErrorNumber : longint;
     constructor Init(const exefn:string);
     destructor  Done;
     procedure DoSelectSourceline(const fn:string;line:longint);virtual;
@@ -347,6 +348,9 @@ uses
 {$ifdef win32}
   Windebug,
 {$endif win32}
+{$ifdef linux}
+  Linux,FileCtrl,
+{$endif linux}
   Systems,
   FPString,FPVars,FPUtils,FPConst,FPSwitch,
   FPIntf,FPCompil,FPIde,FPHelp,
@@ -513,6 +517,8 @@ begin
   LoadFile(f);
   SetArgs(GetRunParameters);
   Debugger:=@self;
+  Command('b FPC_BREAK_ERROR');
+  FPCBreakErrorNumber:=stop_breakpoint_number;
 {$ifndef GABOR}
   switch_to_user:=true;
 {$endif}
@@ -605,7 +611,11 @@ begin
       Command('tty '+DebuggeeTTY);
       NoSwitch:= true;
     end
-  else NoSwitch := false;
+  else
+    begin
+      Command('tty '+TTYName(stdin));
+      NoSwitch := false;
+    end;
 {$endif linux}
   { Switch to user screen to get correct handles }
   UserScreen;
@@ -829,8 +839,18 @@ begin
   if BreakIndex>0 then
     begin
       PB:=BreakpointsCollection^.GetGDB(BreakIndex);
+      if (BreakIndex=FPCBreakErrorNumber) then
+        begin
+          { Procedure HandleErrorAddrFrame
+             (Errno : longint;addr,frame : longint);
+             [public,alias:'FPC_BREAK_ERROR']; }
+          {
+          Error:=GetLongintFrom(GetFramePointer+OffsetFirstArg);
+          Addr:=GetPointerFrom(GetFramePointer+OffsetSecondArg);}
+          WarningBox(#3'Run Time Error',nil);
+        end
       { For watch we should get old and new value !! }
-      if (Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive)) and
+      else if (Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive)) and
          (PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) then
         begin
            Command('p '+GetStr(PB^.Name));
@@ -3354,9 +3374,27 @@ end.
 
 {
   $Log$
-  Revision 1.3  2000-10-06 22:58:59  pierre
+  Revision 1.4  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.7  2000/10/31 07:47:54  pierre
+   * start to support FPC_BREAK_ERROR
+
+  Revision 1.1.2.6  2000/10/26 00:04:35  pierre
+   + gdb prompt and FPC_BREAK_ERROR stop
+
+  Revision 1.1.2.5  2000/10/09 19:48:15  pierre
+   * wrong commit corrected
+
+  Revision 1.1.2.4  2000/10/09 16:28:24  pierre
+   * several linux enhancements
+
+  Revision 1.3  2000/10/06 22:58:59  pierre
    * fixes for linux GDB tty command (merged)
 
+  Revision 1.1.2.3  2000/10/06 22:52:34  pierre
+   * fixes for linux GDB tty command
+
   Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 

+ 15 - 4
ide/text/fpdesk.pas

@@ -18,11 +18,9 @@ unit FPDesk;
 interface
 
 const
-     DesktopVersion     = $0007; { <- if you change any Load&Store methods,
+     DesktopVersion     = $0008; { <- if you change any Load&Store methods,
                                       default object properties (Options,State)
                                       then you should also change this }
-     HTMLIndexVersion   = DesktopVersion;
-
      ResDesktopFlags    = 'FLAGS';
      ResVideo           = 'VIDEOMODE';
      ResHistory         = 'HISTORY';
@@ -273,6 +271,7 @@ var W: PWindow;
     SW: PSourceWindow absolute W;
     St: string;
     TP,TP2: TPoint;
+    L: longint;
     R: TRect;
 begin
   XDataOfs:=0;
@@ -291,6 +290,7 @@ begin
           end
         else
         begin
+          GetData(L,sizeof(L)); SW^.Editor^.SetFlags(L);
           GetData(TP,sizeof(TP)); GetData(TP2,sizeof(TP2));
           SW^.Editor^.SetSelection(TP,TP2);
           GetData(TP,sizeof(TP)); SW^.Editor^.SetCurPtr(TP.X,TP.Y);
@@ -388,6 +388,7 @@ var W: PWindow;
     XData: array[0..1024] of byte;
     St: string;
     TP: TPoint;
+    L: longint;
 procedure AddData(const B; Size: word);
 begin
   Move(B,XData[XDataOfs],Size);
@@ -424,6 +425,7 @@ begin
     hcSourceWindow :
       begin
         St:=SW^.Editor^.FileName; AddData(St,length(St)+1);
+        L:=SW^.Editor^.GetFlags; AddData(L,sizeof(L));
         TP:=SW^.Editor^.SelStart; AddData(TP,sizeof(TP));
         TP:=SW^.Editor^.SelEnd; AddData(TP,sizeof(TP));
         TP:=SW^.Editor^.CurPos; AddData(TP,sizeof(TP));
@@ -795,7 +797,16 @@ end;
 END.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:39  pierre
+  Revision 1.3  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.3  2000/10/18 21:53:26  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.2  2000/09/18 13:20:54  pierre
+   New bunch of Gabor changes
+
+  Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.1  2000/07/20 11:02:15  michael

+ 31 - 2
ide/text/fphelp.pas

@@ -66,7 +66,7 @@ const
 implementation
 
 uses Objects,Views,App,MsgBox,Commands,
-     WUtils,WHTMLHlp,WNGHelp,
+     WUtils,WHTMLHlp,WNGHelp,WOS2Help,
      FPString,FPConst,FPVars,FPUtils;
 
 const
@@ -290,6 +290,14 @@ procedure InitHelpSystem;
     {$IFDEF DEBUG}SetStatus(msg_LoadingHelpFile);{$ENDIF}
   end;
 
+  procedure AddOS2File(HelpFile: string);
+  begin
+    {$IFDEF DEBUG}SetStatus(msg_LoadingHelpFile+' ('+SmartPath(HelpFile)+')');{$ENDIF}
+    if HelpFacility^.AddOS2HelpFile(HelpFile)=false then
+      ErrorBox(FormatStrStr(msg_failedtoloadhelpfile,HelpFile),nil);
+    {$IFDEF DEBUG}SetStatus(msg_LoadingHelpFile);{$ENDIF}
+  end;
+
   procedure AddWinHelpFile(HelpFile: string);
   begin
     {$IFDEF DEBUG}SetStatus(msg_LoadingHelpFile+' ('+SmartPath(HelpFile)+')');{$ENDIF}
@@ -325,6 +333,8 @@ begin
           AddHTMLIndexFile(S) else
       if UpcaseStr(ExtOf(S))=UpcaseStr(NGExt) then
           AddNGFile(S) else
+      if UpcaseStr(ExtOf(S))=UpcaseStr(INFExt) then
+          AddOS2File(S) else
       if UpcaseStr(ExtOf(S))=UpcaseStr(WinHelpExt) then
           AddWinHelpFile(S) else
         AddOAFile(S);
@@ -488,10 +498,23 @@ begin
   FPNGGetAttrColor:=OK;
 end;
 
+function FPINFGetAttrColor(TextStyle, TextColor: byte; var Color: byte): boolean;
+var OK: boolean;
+begin
+  OK:=false;
+  case TextColor of
+    1 : OK:=FPHTMLGetSectionColor(hsHeading1,Color);
+    2 : OK:=FPHTMLGetSectionColor(hsHeading2,Color);
+    3 : OK:=FPHTMLGetSectionColor(hsHeading3,Color);
+  end;
+  FPINFGetAttrColor:=OK;
+end;
+
 procedure InitHelpFiles;
 begin
   HTMLGetSectionColor:={$ifdef FPC}@{$endif}FPHTMLGetSectionColor;
   NGGetAttrColor:={$ifdef FPC}@{$endif}FPNGGetAttrColor;
+  INFGetAttrColor:={$ifdef FPC}@{$endif}FPINFGetAttrColor;
   New(HelpFiles, Init(10,10));
 end;
 
@@ -518,7 +541,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:39  pierre
+  Revision 1.3  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.2  2000/09/18 13:20:54  pierre
+   New bunch of Gabor changes
+
+  Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.1  2000/08/15 03:40:53  peter

+ 51 - 3
ide/text/fpide.pas

@@ -157,7 +157,7 @@ uses
   Video,Mouse,Keyboard,
   Dos,Memory,Menus,Dialogs,StdDlg,ColorSel,Commands,HelpCtx,
   Systems,
-  WUtils,WHlpView,WViews,
+  WUtils,WHlpView,WViews,WHTMLHlp,
   FPConst,FPVars,FPUtils,FPSwitch,FPIni,FPIntf,FPCompil,FPHelp,
   FPTemplt,FPCalc,FPUsrScr,FPTools,{$ifndef NODEBUG}FPDebug,{$endif}FPRedir,
   FPDesk,FPCodCmp,FPCodTmp;
@@ -843,6 +843,17 @@ begin
       ExecuteRedir(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params,InFile,OutFile,'stderr');
 {$endif linux}
 
+{$ifdef linux}
+    if (DebuggeeTTY='') and (OutFile='') then
+      begin
+        Write(' Press any key to return to IDE');
+        InitKeyBoard;
+        Keyboard.GetKeyEvent;
+        while (Keyboard.PollKeyEvent<>0) do
+         Keyboard.GetKeyEvent;
+        DoneKeyboard;
+      end;
+{$endif}
     if ExecType<>exNoSwap then
       ShowIDEScreen;
   end;
@@ -975,8 +986,30 @@ begin
 end;
 
 procedure TIDEApp.DosShell;
+var
+  s : string;
 begin
-  DoExecute(GetEnv('COMSPEC'), '', '', '', exDosShell);
+{$ifdef linux}
+  s:=GetEnv('SHELL');
+  if s='' then
+    if ExistsFile('bin/sh') then
+      s:='bin/sh';
+{$else}
+  s:=GetEnv('COMSPEC');
+  if s='' then
+    if ExistsFile('c:\command.com') then
+      s:='c:\command.com'
+    else
+      begin
+        s:='command.com';
+        if Not LocateExeFile(s) then
+          s:='';
+      end;
+{$endif}
+  if s='' then
+    ErrorBox(msg_errorexecutingshell,nil)
+  else
+    DoExecute(s, '', '', '', exDosShell);
 end;
 
 procedure TIDEApp.ShowReadme;
@@ -1082,10 +1115,25 @@ end;
 END.
 {
   $Log$
-  Revision 1.3  2000-09-22 15:24:04  jonas
+  Revision 1.4  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.11  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.10  2000/10/09 16:28:25  pierre
+   * several linux enhancements
+
+  Revision 1.1.2.9  2000/10/04 13:30:50  pierre
+   * DosShell for linux
+
+  Revision 1.3  2000/09/22 15:24:04  jonas
     * Linux now also uses the DosExecute and ExecuteRedir procedures
       (merged from fixes branch)
 
+  Revision 1.1.2.8  2000/09/22 15:19:04  jonas
+    * Linux now also uses the DosExecute and ExecuteRedir procedures
+
   Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 

+ 14 - 1
ide/text/fpini.pas

@@ -313,7 +313,9 @@ begin
     be overruled with the parameter loading }
   SetPrimaryFile(INIFile^.GetEntry(secCompile,iePrimaryFile,PrimaryFile));
   SetRunParameters(INIFile^.GetEntry(secRun,ieRunParameters,GetRunParameters));
+{$ifndef GABOR}
   DebuggeeTTY := INIFile^.GetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
+{$endif}
   { Compile }
   S:=INIFile^.GetEntry(secCompile,ieCompileMode,'');
   for ts:=low(TSwitchMode) to high(TSwitchMode) do
@@ -491,8 +493,10 @@ begin
 *)
   { Run }
   INIFile^.SetEntry(secRun,ieRunParameters,GetRunParameters);
+{$ifndef GABOR}
   If DebuggeeTTY<>'' then
     INIFile^.SetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
+{$endif}
   { Compile }
   INIFile^.SetEntry(secCompile,iePrimaryFile,PrimaryFile);
   INIFile^.SetEntry(secCompile,ieCompileMode,SwitchesModeStr[SwitchesMode]);
@@ -574,12 +578,21 @@ end;
 end.
 {
   $Log$
-  Revision 1.4  2000-10-06 23:00:13  pierre
+  Revision 1.5  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.4  2000/10/06 23:00:13  pierre
    * remove comment conflit
 
+  Revision 1.1.2.4  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
   Revision 1.3  2000/10/06 22:58:59  pierre
    * fixes for linux GDB tty command (merged)
 
+  Revision 1.1.2.3  2000/10/06 22:52:35  pierre
+   * fixes for linux GDB tty command
+
   Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 

+ 8 - 2
ide/text/fpmcomp.inc

@@ -83,7 +83,7 @@ var
   D : PFileDialog;
   FileName : string;
 begin
-  New(D, Init('*.pri;*.pas',label_primaryfile_primaryfile,'*.pri;*.pas',fdOpenButton,0));
+  New(D, Init('*.pri;*.pas',label_primaryfile_primaryfile,'*.pri;*.pas',fdOpenButton,hidPrimaryFile));
   if Desktop^.ExecView(D)<>cmCancel then
   begin
     D^.GetFileName(FileName);
@@ -128,7 +128,13 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:35  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1  2000/07/13 09:48:35  michael
   + Initial import
 
   Revision 1.9  2000/05/02 08:42:28  pierre

+ 9 - 3
ide/text/fpmfile.inc

@@ -99,7 +99,7 @@ begin
        end;
      if FileDir<>'' then
        ChDir(TrimEndSlash(FileDir));
-     New(D, Init(OpenExts,dialog_openafile,label_filetoopen,fdOpenButton,0));
+     New(D, Init(OpenExts,dialog_openafile,label_filetoopen,fdOpenButton,hidOpenSourceFile));
      OpenIt:=Desktop^.ExecView(D)<>cmCancel;
      { if I go to root under go32v2 and there is no
        floppy I get a InOutRes = 152
@@ -138,7 +138,7 @@ begin
    begin
      ClearFormatParams; AddFormatParamStr(FileName);
      FormatStr(S,label_lookingfor,FormatParams);
-     New(D, Init(FileName,dialog_openafile,S,fdOpenButton,0));
+     New(D, Init(FileName,dialog_openafile,S,fdOpenButton,hidOpenSourceFile));
      OpenIt:=Desktop^.ExecView(D)<>cmCancel;
      if OpenIt then
        Begin
@@ -199,7 +199,13 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:35  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1  2000/07/13 09:48:35  michael
   + Initial import
 
   Revision 1.21  2000/06/16 08:50:41  pierre

+ 9 - 6
ide/text/fpmhelp.inc

@@ -112,7 +112,6 @@ var I: integer;
     S: string;
     LS: PFPHTMLFileLinkScanner;
     BS: PBufStream;
-{    Version: word;}
 begin
   case Event.What of
     evKeyDown :
@@ -136,7 +135,7 @@ begin
             New(D, Init(HelpFileExts,
               dialog_installhelpfile,
               label_installhelpfile_filename,
-              fdOpenButton,0));
+              fdOpenButton,hidOpenHelpFile));
             Re:=Desktop^.ExecView(D);
             if Re<>cmCancel then
             begin
@@ -157,7 +156,7 @@ begin
                     ShowMessage(msg_pleasewaitwhilecreatingindex);
                     S:='HTML Index';
                     PushStatus(FormatStrStr(msg_buildingindexfile,FileName));
-                    New(LS, Init);
+                    New(LS, Init(DirOf(FileName)));
                     LS^.ProcessDocument(FileName,[soSubDocsOnly]);
                     if LS^.GetDocumentCount=0 then
                       begin
@@ -181,8 +180,6 @@ begin
                             end
                           else
                             begin
-{                              Version:=HTMLIndexVersion;
-                              BS^.Write(Version,sizeof(Version));}
                               LS^.StoreDocuments(BS^);
                               if BS^.Status<>stOK then
                                 begin
@@ -252,7 +249,13 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:35  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1  2000/07/13 09:48:35  michael
   + Initial import
 
   Revision 1.11  2000/05/29 10:44:57  pierre

+ 27 - 10
ide/text/fpmopts.inc

@@ -60,7 +60,7 @@ begin
 end;
 
 procedure TIDEApp.DoCompilerSwitch;
-var R,R2,TabR,TabIR: TRect;
+var R,R2,R3,TabR,TabIR: TRect;
     D: PCenterDialog;
     CB1,CB2,CB3,CB4,CB5: PCheckBoxes;
     RB1,{RB2,}RB3,RB4,RB5,RB6: PRadioButtons;
@@ -283,10 +283,12 @@ begin
     Insert(Tab);
 
     { conditionnals }
-    R2.Copy(TabR); R2.A.Y:=R2.B.Y+1; R2.B.Y:=R2.A.Y+1;
+    R2.Copy(TabR); R2.A.Y:=R2.B.Y+1; R2.B.Y:=R2.A.Y+1; Dec(R2.B.X,4);
     New(IL, Init(R2, 128));
     IL^.Data^:=ConditionalSwitches^.GetStringItem(0);
     Insert(IL);
+    R3.Copy(R2); R3.A.X:=R2.B.X+1; R3.B.X:=R3.A.X+3;
+    Insert(New(PHistory, Init(R3, IL, hidConditionalDefines)));
     R2.Move(0,-1);
     Insert(New(PLabel, Init(R2,ConditionalSwitches^.ItemName(0), IL)));
   end;
@@ -420,7 +422,7 @@ end;
 
 procedure TIDEApp.DoDebuggerSwitch;
 
-var R,R2: TRect;
+var R,R2,R3: TRect;
     D: PCenterDialog;
     RB : PRadioButtons;
     CB: PCheckBoxes;
@@ -475,9 +477,12 @@ begin
 
     {custom }
     Inc(R2.A.Y,1+DebugInfoSwitches^.ItemCount+1); R2.B.Y:=R2.A.Y+1;
-    New(IL2, Init(R2, 255));
+    R3.Copy(R2); Dec(R3.B.X,4);
+    New(IL2, Init(R3, 255));
     IL2^.Data^:=CustomArg[SwitchesMode];
     Insert(IL2);
+    R3.Copy(R2); R3.A.X:=R3.B.X-3; R3.B.X:=R3.A.X+3;
+    Insert(New(PHistory, Init(R3, IL2, hidCompilerArgs)));
     R2.Move(0,-1);
     Insert(New(PLabel, Init(R2,label_debugger_compilerargs, IL2)));
 {$ifdef win32}
@@ -821,12 +826,13 @@ begin
   if (EFlags and efAutoBrackets      )<>0 then EFValue:=EFValue or (1 shl 11);
   if (EFlags and efKeepTrailingSpaces)<>0 then EFValue:=EFValue or (1 shl 12);
   if (EFlags and efCodeComplete      )<>0 then EFValue:=EFValue or (1 shl 13);
+  if (EFlags and efFolds             )<>0 then EFValue:=EFValue or (1 shl 14);
 
-  R.Assign(0,0,66,19);
+  R.Assign(0,0,66,20);
   New(D, Init(R, Title));
   with D^ do
   begin
-    GetExtent(R); R.Grow(-2,-2); R.B.Y:=R.A.Y+8;
+    GetExtent(R); R.Grow(-2,-2); R.B.Y:=R.A.Y+9;
     R2.Copy(R); Inc(R2.A.Y);
     New(CB, Init(R2,
       NewSItem(label_editor_backupfiles,
@@ -843,7 +849,8 @@ begin
       NewSItem(label_editor_autoclosingbrackets,
       NewSItem(label_editor_keeptrailingspaces,
       NewSItem(label_editor_codecomplete,
-      nil))))))))))))))));
+      NewSItem(label_editor_folds,
+      nil)))))))))))))))));
     CB^.Value:=EFValue;
     Insert(CB);
     R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
@@ -893,6 +900,7 @@ begin
     if (CB^.Value and (1 shl 11))<>0 then EFlags:=EFlags or efAutoBrackets;
     if (CB^.Value and (1 shl 12))<>0 then EFlags:=EFlags or efKeepTrailingSpaces;
     if (CB^.Value and (1 shl 13))<>0 then EFlags:=EFlags or efCodeComplete;
+    if (CB^.Value and (1 shl 14))<>0 then EFlags:=EFlags or efFolds;
     TabSize:=StrToInt(IL^.Data^);
     if Editor=nil then
        begin
@@ -1178,7 +1186,7 @@ procedure TIDEApp.OpenINI;
 var D: PFileDialog;
     FileName: string;
 begin
-  New(D, Init(INIFileName,dialog_openoptions,INIFileName,fdOpenButton,0));
+  New(D, Init(INIFileName,dialog_openoptions,INIFileName,fdOpenButton,hidOpenIniFile));
   if Desktop^.ExecView(D)<>cmCancel then
     begin
       D^.GetFileName(FileName);
@@ -1203,7 +1211,7 @@ var D: PFileDialog;
     FileName: string;
     CanWrite: boolean;
 begin
-  New(D, Init(INIFileName,dialog_saveoptions,INIFileName,fdOpenButton,0));
+  New(D, Init(INIFileName,dialog_saveoptions,INIFileName,fdOpenButton,hidSaveIniFile));
   if Desktop^.ExecView(D)<>cmCancel then
     begin
       D^.GetFileName(FileName);
@@ -1223,7 +1231,16 @@ end;
 
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:39  pierre
+  Revision 1.3  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.4  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.3  2000/09/18 13:20:54  pierre
+   New bunch of Gabor changes
+
+  Revision 1.2  2000/08/22 09:41:39  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.2  2000/08/04 14:05:18  michael

+ 29 - 6
ide/text/fpmrun.inc

@@ -22,7 +22,10 @@ begin
    begin
      InitDebugger;
      if not assigned(Debugger) then
-      exit;
+      begin
+        NoDebugger;
+        exit;
+      end;
    end;
   if not Debugger^.IsRunning then
     Debugger^.StartTrace
@@ -49,7 +52,10 @@ begin
    begin
      InitDebugger;
      if not assigned(Debugger) then
-       exit;
+      begin
+        NoDebugger;
+        exit;
+      end;
    end;
   if not debugger^.IsRunning then
     Debugger^.StartTrace
@@ -77,7 +83,10 @@ begin
    begin
      InitDebugger;
      if not assigned(Debugger) then
-       exit;
+      begin
+        NoDebugger;
+        exit;
+      end;
    end;
   if not debugger^.IsRunning then
     Debugger^.Run
@@ -164,10 +173,12 @@ begin
   with D^ do
   begin
     GetExtent(R); R.Grow(-2,-1); Inc(R.A.Y); R.B.Y:=R.A.Y+1;
-    R2.Copy(R); R2.A.X:=16;
+    R2.Copy(R); R2.A.X:=16; Dec(R2.B.X,4);
     New(IL, Init(R2, 255));
     IL^.Data^:=GetRunParameters;
     Insert(IL);
+    R2.Copy(R); R2.A.X:=R2.B.X-3; R2.B.X:=R2.A.X+3;
+    Insert(New(PHistory, Init(R2, IL, hidRunParameters)));
     R2.Copy(R); R2.B.X:=16;
     Insert(New(PLabel, Init(R2, label_parameters_parameter, IL)));
   end;
@@ -216,7 +227,10 @@ begin
         begin
           InitDebugger;
           if not assigned(Debugger) then
-            exit;
+            begin
+              NoDebugger;
+              exit;
+            end;
         end;
       Debugger^.Command('tbreak '+GDBFileName(NameAndExtOf(FileName))+':'+IntToStr(LineNr));
       Debugger^.Continue;
@@ -270,7 +284,16 @@ end;
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:35  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.2  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.1  2000/10/09 16:28:25  pierre
+   * several linux enhancements
+
+  Revision 1.1  2000/07/13 09:48:35  michael
   + Initial import
 
   Revision 1.32  2000/05/02 08:42:28  pierre

+ 18 - 1
ide/text/fpmwnd.inc

@@ -227,11 +227,28 @@ begin
   New(W,Init);
   ExecView(W);
   Dispose(W,Done);
+  if assigned(Desktop^.Current) then
+    begin
+      Desktop^.Lock;
+      { force correct commands to be enabled }
+      Desktop^.Current^.SetState(sfActive,false);
+      Desktop^.Current^.SetState(sfActive,true);
+      Desktop^.UnLock;
+    end;
 end;
 
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:40  pierre
+  Revision 1.3  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.3  2000/10/31 07:44:33  pierre
+   * Window List problem solved in a different way
+
+  Revision 1.1.2.2  2000/10/24 00:21:59  pierre
+   * fix the greyed save after window list box
+
+  Revision 1.2  2000/08/22 09:41:40  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.1  2000/08/15 03:40:53  peter

+ 16 - 3
ide/text/fpredir.pas

@@ -679,7 +679,14 @@ end;
     SwapVectors;
     { Must use shell() for linux for the wildcard expansion (PFV) }
 {$ifdef linux}
-    Shell(Progname+' '+Comline);
+    IOStatus:=0;
+    ExecuteResult:=Shell(Progname+' '+Comline);
+    { Signal that causes the stop of the shell }
+    IOStatus:=ExecuteResult and $7F;
+    { Exit Code seems to be in the second byte,
+      is this also true for BSD ??
+      $80 bit is a CoreFlag apparently }
+    ExecuteResult:=(ExecuteResult and $ff00) shr 8;
 {$else}
 {$ifdef win32}
     StoreInherit:=ExecInheritsHandles;
@@ -690,9 +697,9 @@ end;
 {$ifdef win32}
     ExecInheritsHandles:=StoreInherit;
 {$endif win32}
-{$endif}
     IOStatus:=DosError;
     ExecuteResult:=DosExitCode;
+{$endif}
     SwapVectors;
 {$IfDef MsDos}
   Fullheap;
@@ -718,7 +725,13 @@ Begin
 End.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:35  michael
+  Revision 1.2  2000-10-31 22:35:54  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/04 13:29:59  pierre
+   * Get ExitCode for DosExecute in linux
+
+  Revision 1.1  2000/07/13 09:48:35  michael
   + Initial import
 
   Revision 1.25  2000/05/17 10:19:53  pierre

+ 18 - 2
ide/text/fpstrh.inc

@@ -378,6 +378,7 @@ const
       label_editor_autoclosingbrackets = 'Aut~o~matikus z r¢jelez‚se';
       label_editor_keeptrailingspaces = 'Z r¢ sz”~k~”z”k megtart sa';
       label_editor_codecomplete = 'Co~d~eComplete enged‚lyezve';
+      label_editor_folds = '"~H~ajtogat s" enged‚lyezve';
       label_editor_editoroptions = 'Sz~e~rkeszt‹ opci¢k';
       label_editor_tabsize = '~T~ab m‚rete';
       label_editor_highlightextensions = 'Kieme~l~‚s a k”vetkez‹ kiterjeszt‚sek eset‚n';
@@ -558,6 +559,8 @@ const
       msg_errorprocessingfilteredoutput = 'Hiba a szûrt kimenet feldolgoz sa k”zben.';
       msg_errorexecutingfilter = 'Hiba a szûr‹ futtat sa k”zben'; {%s}
       msg_errorexecutingtool = 'Hiba a %s eszk”z futtat sa k”zben';
+      msg_errorexecutingshell = 'Nem tudom futtatni a shell-t';
+
       msg_filterexecutionsuccessfulexitcodeis = 'Szûr‹ futtat sa sikeres. Kil‚p‚si k¢d = %d';
       msg_toolexecutionsuccessfulexitcodeis = 'Eszk”z futtat sa sikeres. Kil‚p‚si k¢d = %d';
 
@@ -759,7 +762,7 @@ const
       opt_listsource = 'Forr s ~l~ist z sa';
       opt_listregisterallocation = '~r~egister-foglal s list.';
       opt_listtempallocation = ' ~t~meneti foglal s list.';
-      opt_usedefaultas = 'Use ~d~efault output'; { NOT TRANSLATED }
+      opt_usedefaultas = '~D~efault kimeneti form tum haszn lata';
       opt_usegnuas = '~G~NU as haszn lata';
       opt_usenasmcoff = '~N~ASM coff haszn lata';
       opt_usenasmelf = 'Use NASM ~e~lf haszn lata';
@@ -980,7 +983,20 @@ const
 
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:40  pierre
+  Revision 1.3  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+
+  Revision 1.1.2.6  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.5  2000/10/04 13:30:50  pierre
+   * DosShell for linux
+
+  Revision 1.1.2.4  2000/09/18 13:20:54  pierre
+   New bunch of Gabor changes
+
+  Revision 1.2  2000/08/22 09:41:40  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.3  2000/08/16 18:46:14  peter

+ 10 - 4
ide/text/fpswitch.pas

@@ -624,7 +624,8 @@ function TSwitches.ReadItemsCfg(const s:string):boolean;
   function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
   begin
     { empty items are not equivalent to others !! }
-    CheckItem:=((S='') and (P^.Param='')) or
+    { but -dGDB didn't work because of this PM }
+    CheckItem:=((P^.Param='') and ((S='') or (P^.typ=ot_String))) or
                ((Length(P^.Param)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
   end;
 
@@ -1139,7 +1140,13 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:40  pierre
+  Revision 1.3  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.4  2000/10/26 10:17:10  pierre
+   * fix reading of -dGDB switch in cfg file
+
+  Revision 1.2  2000/08/22 09:41:40  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.3  2000/08/04 14:05:19  michael
@@ -1270,5 +1277,4 @@ end.
     + Switches updated
     + Run program
 
-}
-
+}

+ 8 - 2
ide/text/fpsymbol.pas

@@ -1343,7 +1343,7 @@ begin
       Insert(MemInfoView);
       MemInfoView^.MyBW:=@Self;
     end;
-  if TypeOf(ASym^)=TypeOf(TModuleSymbol) then
+  if Assigned(Asym) and (TypeOf(ASym^)=TypeOf(TModuleSymbol)) then
   with PModuleSymbol(Sym)^ do
     begin
       New(UnitInfo, Init(R));
@@ -1695,7 +1695,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:36  michael
+  Revision 1.2  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/27 21:06:11  pierre
+   * fix GPF in tbrowserwindow.init
+
+  Revision 1.1  2000/07/13 09:48:36  michael
   + Initial import
 
   Revision 1.30  2000/07/05 10:19:07  pierre

+ 18 - 4
ide/text/fpusrscr.pas

@@ -92,6 +92,7 @@ type
       procedure   SwitchBack; virtual;
     private
       IDE_screen: pvideobuf;
+      IDE_size : longint;
     end;
 {$endif}
 
@@ -496,7 +497,8 @@ procedure TLinuxScreen.Capture;
 begin
   if assigned(IDE_screen) then
     dispose(IDE_screen);
-  new(IDE_screen);
+  getmem(IDE_screen,videobufsize);
+  Ide_size:=videobufsize;
   move(videobuf^,IDE_screen^,videobufsize);
 end;
 
@@ -511,7 +513,7 @@ begin
   if IDE_screen = nil then
     exit;
   move(IDE_screen^,videobuf^,videobufsize);
-  dispose(IDE_screen);
+  freemem(IDE_screen,Ide_size);
   IDE_screen := nil;
 end;
 
@@ -727,7 +729,13 @@ end;
 end.
 {
   $Log$
-  Revision 1.4  2000-09-18 16:42:56  jonas
+  Revision 1.5  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.3  2000/10/10 21:24:56  pierre
+   * avoid writing past IDE_screen buffer length
+
+  Revision 1.4  2000/09/18 16:42:56  jonas
     * for some reason, tlinuxscreen.switchto() contained some saving code
       while it should've been empty (like in the fixes branch)
 
@@ -738,7 +746,13 @@ end.
     * IDE screen saving/restoring implemented for Linux (merged from fixes
       branch)
 
+  Revision 1.1.2.2  2000/08/21 12:10:19  jonas
+    * fixed errors in my previous commit, it now works properly
+
+  Revision 1.1.2.1  2000/08/21 10:51:13  jonas
+    * IDE screen saving/restoring implemented for Linux
+
   Revision 1.1  2000/07/13 09:48:36  michael
   + Initial import
 
-}
+}

+ 101 - 17
ide/text/fpviews.pas

@@ -180,6 +180,8 @@ type
       function   Valid(Command: Word): Boolean; virtual;
       procedure  AddLine(const S: string); virtual;
       procedure  AddErrorLine(const S: string); virtual;
+      { Syntax highlight }
+      function  IsReservedWord(const S: string): boolean; virtual;
     private
       Silent,
       AutoRepeat,
@@ -200,6 +202,8 @@ type
       function    GetPalette: PPalette;virtual;
       constructor Load(var S: TStream);
       procedure   Store(var S: TStream);
+      procedure   SetState(AState: Word; Enable: Boolean); virtual;
+      procedure   UpdateCommands; virtual;
       destructor  Done; virtual;
     end;
 
@@ -443,7 +447,7 @@ implementation
 
 uses
   Video,Strings,Keyboard,Validate,
-  Tokens,Version,
+  globtype,Tokens,Version,
 {$ifndef NODEBUG}
   gdbint,
 {$endif NODEBUG}
@@ -641,7 +645,7 @@ begin
 {$ifdef EDITORS}
     S:='';
 {$else}
-    S:=GetLineText(CurPos.Y);
+    S:=GetDisplayText(CurPos.Y);
     PS:=CurPos.X; while (PS>0) and (Upcase(S[PS]) in AlphaNum) do Dec(PS);
     PE:=CurPos.X; while (PE<length(S)) and (Upcase(S[PE+1]) in (AlphaNum+ValidSpecChars)) do Inc(PE);
     S:=Trim(copy(S,PS+1,PE-PS));
@@ -711,7 +715,7 @@ begin
   Count:=0;
   for I:=ord(Low(tToken)) to ord(High(tToken)) do
   with TokenInfo^[TToken(I)] do
-     if (str<>'') and (str[1] in['A'..'Z']) then
+     if (str<>'') and (str[1] in['A'..'Z']) and (keyword=m_all) then
        Inc(Count);
   GetReservedWordCount:=Count;
 end;
@@ -727,7 +731,7 @@ begin
   while (I<=ord(High(tToken))) and (Idx=-1) do
    with TokenInfo^[TToken(I)] do
     begin
-      if (str<>'') and (str[1] in['A'..'Z']) then
+      if (str<>'') and (str[1] in['A'..'Z']) and (keyword=m_all) then
         begin
           Inc(Count);
           if Count=Index then
@@ -804,6 +808,7 @@ begin
   { we have a crash here because of the TStatusLine
     that can also have one of these values
     but is not a Window object PM }
+  if P<>pointer(StatusLine) then
   if IsWindow(P) then
     W:=PWindow(P);
   OK:=(W<>nil);
@@ -815,9 +820,9 @@ begin
 end;
 var W: PView;
 begin
-  { W:=Application^.FirstThat(@Match);
-    This is wrong because TStatusLine is also considered PM }
-  W:=Desktop^.FirstThat(@Match);
+  W:=Application^.FirstThat(@Match);
+{    This is wrong because TStatusLine is also considered PM }
+  if not Assigned(W) then W:=Desktop^.FirstThat(@Match);
   { But why do we need to check all ??
     Probably because of the ones which were not inserted into
     Desktop as the Messages view
@@ -1388,7 +1393,7 @@ begin
   if LoadFile then
     begin
       if Editor^.LoadFile=false then
-        ErrorBox(FormatStrStr(msg_errorreadingfile,''),nil)
+        ErrorBox(FormatStrStr(msg_errorreadingfile,AFileName),nil)
       else if Editor^.GetModified then
         begin
           PA[1]:=@AFileName;
@@ -1485,8 +1490,7 @@ begin
     SetCmdState(SourceCmds+CompileCmds,Active);
     SetCmdState(EditorCmds,Active);
   end;
-  if Active=false then
-     SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
+  SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
   Message(Application,evBroadcast,cmCommandSetChanged,nil);
 end;
 
@@ -1591,27 +1595,61 @@ begin
    LimitsChanged;
 end;
 
+const
+  GDBReservedCount = 6;
+  GDBReservedLongest = 3;
+  GDBReserved : array[1..GDBReservedCount] of String[GDBReservedLongest] =
+  ('gdb','b','n','s','f','bt');
+
+function IsGDBReservedWord(const S : string) : boolean;
+var
+  i : longint;
+begin
+  for i:=1 to GDBReservedCount do
+    if (S=GDBReserved[i]) then
+      begin
+        IsGDBReservedWord:=true;
+        exit;
+      end;
+  IsGDBReservedWord:=false;
+end;
+
+function TGDBSourceEditor.IsReservedWord(const S: string): boolean;
+begin
+  IsReservedWord:=IsGDBReservedWord(S);
+end;
+
 function TGDBSourceEditor.InsertNewLine: Sw_integer;
 Var
   S : string;
+  CommandCalled : boolean;
 
 begin
   if IsReadOnly then begin InsertNewLine:=-1; Exit; end;
   if CurPos.Y<GetLineCount then S:=GetDisplayText(CurPos.Y) else S:='';
   s:=Copy(S,1,CurPos.X);
+  CommandCalled:=false;
+  if Pos(GDBPrompt,S)=1 then
+    Delete(S,1,length(GDBPrompt));
   if assigned(Debugger) then
     if S<>'' then
       begin
         LastCommand:=S;
         { should be true only if we are at the end ! }
         IgnoreStringAtEnd:=(CurPos.Y=GetLineCount-1) and
-          (CurPos.X=length(GetDisplayText(GetLineCount-1)));
+          (CurPos.X>=length(RTrim(GetDisplayText(GetLineCount-1))));
         Debugger^.Command(S);
+        CommandCalled:=true;
         IgnoreStringAtEnd:=false;
       end
-    else if AutoRepeat then
-      Debugger^.Command(LastCommand);
+    else if AutoRepeat and (CurPos.Y=GetLineCount-1) then
+      begin
+        Debugger^.Command(LastCommand);
+        CommandCalled:=true;
+      end;
   InsertNewLine:=inherited InsertNewLine;
+  If CommandCalled then
+    InsertText(GDBPrompt);
 end;
 
 
@@ -1634,6 +1672,7 @@ begin
   GetExtent(R); R.Grow(-1,-1);
   New(Editor, Init(R, HSB, VSB, nil, GDBOutputFile));
   Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
+  Editor^.SetFlags(efInsertMode+efSyntaxHighlight+efNoIndent+efExpandAllTabs);
   if ExistsFile(GDBOutputFile) then
     begin
       if Editor^.LoadFile=false then
@@ -1704,7 +1743,7 @@ procedure TGDBWindow.WriteText(Buf : pchar;IsError : boolean);
 begin
   p:=buf;
   DeskTop^.Lock;
-  While assigned(p) do
+  While assigned(p) and (p^<>#0) do
     begin
        pe:=strscan(p,#10);
        if pe<>nil then
@@ -1721,14 +1760,38 @@ begin
          p:=nil
        else
          begin
-           p:=pe;
-           inc(p);
+           if pe-p > High(s) then
+             p:=p+High(s)-1
+           else
+             begin
+               p:=pe;
+               inc(p);
+             end;
          end;
     end;
   DeskTop^.Unlock;
   Editor^.Draw;
 end;
 
+procedure TGDBWindow.SetState(AState: Word; Enable: Boolean);
+var OldState: word;
+begin
+  OldState:=State;
+  inherited SetState(AState,Enable);
+  if ((AState and sfActive)<>0) and (((OldState xor State) and sfActive)<>0) then
+    UpdateCommands;
+end;
+
+procedure TGDBWindow.UpdateCommands;
+var Active: boolean;
+begin
+  Active:=GetState(sfActive);
+  SetCmdState([cmSaveAs,cmHide],Active);
+  SetCmdState(EditorCmds,Active);
+  SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,Active);
+  Message(Application,evBroadcast,cmCommandSetChanged,nil);
+end;
+
 
 
 constructor TClipboardWindow.Init;
@@ -3501,7 +3564,28 @@ end;
 END.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:41  pierre
+  Revision 1.3  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.12  2000/10/31 07:54:24  pierre
+   enhance GDB Window
+
+  Revision 1.1.2.11  2000/10/26 00:04:36  pierre
+   + gdb prompt and FPC_BREAK_ERROR stop
+
+  Revision 1.1.2.10  2000/10/24 00:21:59  pierre
+   * fix the greyed save after window list box
+
+  Revision 1.1.2.9  2000/10/20 13:29:29  pierre
+   * fix bug 1184, only keyowrd for all mode are highlighted
+
+  Revision 1.1.2.8  2000/10/20 09:55:00  pierre
+   * fix GetEditorCurWord if tabs present
+
+  Revision 1.1.2.7  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.2  2000/08/22 09:41:41  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.6  2000/08/21 21:23:27  pierre

+ 2 - 0
ide/text/globdir.inc

@@ -44,6 +44,7 @@
   {$undef SUPPORTVESA}
   {$define SUPPORTREDIR}
   {$define WinClipSupported}
+  {$define HasSignal}
 {$endif}
 
 { --- Exclude debugger support --- }
@@ -107,6 +108,7 @@
   {$undef EXEDEBUG}
   {$undef USERESSTRINGS}
   {.$define LANG_HUN}
+  {$undef WinClipSupported}
 {$endif}
 
 {$ifdef NOWINCLIP}

+ 2 - 1
ide/text/test.pas

@@ -2,7 +2,6 @@
 {$R-}
 
 program TestProgram;
-
 uses
 {$ifdef go32v2}
   dpmiexcp,
@@ -18,6 +17,8 @@ const A =  1234;
       ConstSet2 = [15..254];
       ConstFloat = 3.1415;
 
+{$i empty.inc}
+
 type
       PObj = ^TObj;
       TObj = object

+ 76 - 15
ide/text/wcedit.pas

@@ -102,7 +102,7 @@ type
       procedure   SetLineText(I: sw_integer;const S: string); virtual;
       procedure   DeleteAllLines; virtual;
       procedure   DeleteLine(I: sw_integer); virtual;
-      procedure   InsertLine(LineNo: sw_integer; const S: string); virtual;
+      function    InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual;
       procedure   AddLine(const S: string); virtual;
       procedure   GetContent(ALines: PUnsortedStringCollection); virtual;
       procedure   SetContent(ALines: PUnsortedStringCollection); virtual;
@@ -130,6 +130,8 @@ type
       CompleteState: TCompleteState;
       ErrorMessage: PString;
       IndicatorDrawCalled  : boolean;
+      Folds      : PFoldCollection;
+      MaxFoldLevel: sw_integer;
       constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
           PScrollBar; AIndicator: PIndicator; ACore: PCodeEditorCore);
     public
@@ -174,7 +176,7 @@ type
       procedure   SetLineFormat(I: sw_integer;const S: string); virtual;
       procedure   DeleteAllLines; virtual;
       procedure   DeleteLine(I: sw_integer); virtual;
-      procedure   InsertLine(LineNo: sw_integer; const S: string); virtual;
+      function    InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual;
       procedure   AddLine(const S: string); virtual;
       function    GetErrorMessage: string; virtual;
       procedure   SetErrorMessage(const S: string); virtual;
@@ -204,6 +206,12 @@ type
       procedure   JumpToLastCursorPos; virtual;
       procedure   Undo; virtual;
       procedure   Redo; virtual;
+     { Fold support }
+      function    GetMaxFoldLevel: sw_integer; virtual;
+      function    GetFoldCount: sw_integer; virtual;
+      function    GetFold(Index: sw_integer): PFold; virtual;
+      procedure   RegisterFold(AFold: PFold); virtual;
+      procedure   UnRegisterFold(AFold: PFold); virtual;
     end;
 
     PFileEditor = ^TFileEditor;
@@ -233,7 +241,7 @@ const
      DefaultCodeEditorFlags : longint =
        efBackupFiles+efInsertMode+efAutoIndent+efPersistentBlocks+
        {efUseTabCharacters+}efBackSpaceUnindents+efSyntaxHighlight+
-       efExpandAllTabs+efCodeComplete;
+       efExpandAllTabs+efCodeComplete{+efFolds};
      DefaultTabSize     : integer = 8;
      UseSyntaxHighlight : function(Editor: PFileEditor): boolean = DefUseSyntaxHighlight;
      UseTabsPattern     : function(Editor: PFileEditor): boolean = DefUseTabsPattern;
@@ -520,7 +528,7 @@ var
 begin
   DF:='';
   DT:='';
-  if LineNo<GetLineCount then
+  if (0<=LineNo) and (LineNo<GetLineCount) then
    begin
      L:=GetLine(LineNo);
      DF:=IGetLineFormat(Binding,LineNo);
@@ -546,7 +554,7 @@ var P: PCustomLine;
     LI: PEditorLineInfo;
     S: string;
 begin
-  if LineNo<GetLineCount then P:=GetLine(LineNo) else P:=nil;
+  if (0<=LineNo) and (LineNo<GetLineCount) then P:=GetLine(LineNo) else P:=nil;
   if P=nil then LI:=nil else
     LI:=P^.GetEditorInfo(Binding^.Editor);
   if LI=nil then S:='' else S:=LI^.GetFormat;
@@ -557,7 +565,7 @@ procedure TCodeEditorCore.ISetLineFormat(Binding: PEditorBinding; LineNo: sw_int
 var P: PCustomLine;
     LI: PEditorLineInfo;
 begin
-  if LineNo<GetLineCount then
+  if (LineNo<GetLineCount) then
   begin
     P:=GetLine(LineNo);
     if P=nil then LI:=nil else LI:=P^.GetEditorInfo(Binding^.Editor);
@@ -586,9 +594,12 @@ begin
     end;
 end;
 
-procedure TCodeEditorCore.InsertLine(LineNo: sw_integer; const S: string);
+function TCodeEditorCore.InsertLine(LineNo: sw_integer; const S: string): PCustomLine;
+var L: PLine;
 begin
-  LinesInsert(LineNo, New(PLine, Init(@Self,S,0)));
+  L:=New(PLine, Init(@Self,S,0));
+  LinesInsert(LineNo, L);
+  InsertLine:=L;
 end;
 
 procedure TCodeEditorCore.AddLine(const S: string);
@@ -776,6 +787,7 @@ constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
           PScrollBar; AIndicator: PIndicator; ACore: PCodeEditorCore);
 begin
   inherited Init(Bounds,AHScrollBar,AVScrollBar);
+  New(Folds, Init(100,100));
   if ACore=nil then ACore:=New(PCodeEditorCore, Init);
   Core:=ACore;
   Core^.BindEditor(@Self);
@@ -939,9 +951,9 @@ begin
   Core^.DeleteLine(I);
 end;
 
-procedure TCodeEditor.InsertLine(LineNo: sw_integer; const S: string);
+function TCodeEditor.InsertLine(LineNo: sw_integer; const S: string): PCustomLine;
 begin
-  Core^.InsertLine(LineNo,S);
+  InsertLine:=Core^.InsertLine(LineNo,S);
 end;
 
 procedure TCodeEditor.AddLine(const S: string);
@@ -949,6 +961,44 @@ begin
   Core^.AddLine(S);
 end;
 
+function TCodeEditor.GetMaxFoldLevel: sw_integer;
+begin
+  GetMaxFoldLevel:=MaxFoldLevel;
+end;
+
+procedure TCodeEditor.RegisterFold(AFold: PFold);
+var L: sw_integer;
+begin
+  if Assigned(Folds) then
+  begin
+    Folds^.Insert(AFold);
+    L:=AFold^.GetLevel+1;
+    if L>MaxFoldLevel then MaxFoldLevel:=L;
+  end;
+end;
+
+procedure TCodeEditor.UnRegisterFold(AFold: PFold);
+begin
+  if Assigned(Folds) then
+  begin
+    Folds^.Delete(AFold);
+    if Folds^.Count=0 then
+      MaxFoldLevel:=0
+    else
+      MaxFoldLevel:=inherited GetMaxFoldLevel+1;
+  end;
+end;
+
+function TCodeEditor.GetFoldCount: sw_integer;
+begin
+  GetFoldCount:=Folds^.Count;
+end;
+
+function TCodeEditor.GetFold(Index: sw_integer): PFold;
+begin
+  GetFold:=Folds^.At(Index);
+end;
+
 {function TCodeEditor.GetLineTextPos(Line,X: integer): integer;
 var
   S: string;
@@ -1206,8 +1256,9 @@ begin
             eaDeleteLine :
               begin
                 SetCurPtr(EndPos.X,EndPos.Y);
-                DelEnd;{ wrong for eaCut at least }
+                SetMinMax(EndPos.Y);
                 InsertNewLine;
+                {DelEnd; wrong for eaCut at least }
                 SetCurPtr(StartPos.X,StartPos.Y);
                 SetLineText(StartPos.Y,Copy(GetDisplayText(StartPos.Y),1,StartPos.X)+GetStr(Text));
                 SetMinMax(StartPos.Y);
@@ -1303,7 +1354,7 @@ begin
           begin
             SetCurPtr(StartPos.X,StartPos.Y);
             InsertNewLine;
-            SetCurPtr(StartPos.X,StartPos.Y);
+            SetCurPtr(0,StartPos.Y+1);
             InsertText(GetStr(Text));
             SetCurPtr(EndPos.X,EndPos.Y);
           end;
@@ -1312,8 +1363,9 @@ begin
             SetCurPtr(StartPos.X,StartPos.Y);
             DeleteLine(StartPos.Y);
             SetCurPtr(EndPos.X,EndPos.Y);
-            SetDisplayText(StartPos.Y,RExpand(
-              copy(GetDisplayText(StartPos.Y),1,StartPos.X),StartPos.X)
+            if EndPos.Y=StartPos.Y-1 then
+            SetDisplayText(EndPos.Y,RExpand(
+              copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X)
               +GetStr(Text));
             SetCurPtr(EndPos.X,EndPos.Y);
           end;
@@ -1517,6 +1569,7 @@ begin
     DisposeStr(CodeCompleteFrag);
   if Assigned(CodeCompleteWord) then
     DisposeStr(CodeCompleteWord);
+  if Assigned(Folds) then Dispose(Folds, Done); Folds:=nil;
 end;
 
 constructor TFileEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
@@ -1753,6 +1806,14 @@ end;
 
 END.
 {
- $Log $
+ $Log$
+ Revision 1.3  2000-10-31 22:35:55  pierre
+  * New big merge from fixes branch
+
+ Revision 1.1.2.4  2000/10/24 23:06:30  pierre
+  * some Undo/redo fixes
+
+ Revision 1.1.2.3  2000/09/18 13:20:55  pierre
+  New bunch of Gabor changes
 
 }

+ 9 - 1
ide/text/wconstse.inc

@@ -61,6 +61,8 @@
     msg_invalidmarkindex = 'Invalid mark index (%d)';
     msg_marknotset = 'Mark %d not set.';
 
+    msg_foldboundsarenotvalid = 'Fold bounds are not valid';
+
     msg_notenoughmemoryforthisoperation = 'Not enough memory for this operation.';
     msg_errorreadingfile = 'Error reading file %s.';
     msg_errorwritingfile = 'Error writing file %s.';
@@ -101,7 +103,13 @@
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 13:20:55  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.1  2000/06/16 09:30:01  pierre

+ 9 - 1
ide/text/wconstsh.inc

@@ -61,6 +61,8 @@
     msg_invalidmarkindex = '�rv‚nytelen pont index (%d)';
     msg_marknotset = 'A %d. pont nincs be ll¡tva.';
 
+    msg_foldboundsarenotvalid = 'A hajt s hat rai nem ‚rv‚nyesek';
+
     msg_notenoughmemoryforthisoperation = 'Nincs el‚g mem¢ria a m‹velet elv‚gz‚s‚hez.';
     msg_errorreadingfile = 'Hiba a  %s f jl olvas sa k”zben.';
     msg_errorwritingfile = 'Hiba a  %s f jl ¡r sa k”zben.';
@@ -101,7 +103,13 @@
 
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:55  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 13:20:55  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.1  2000/06/16 09:30:01  pierre

File diff suppressed because it is too large
+ 652 - 114
ide/text/weditor.pas


+ 44 - 10
ide/text/whelp.pas

@@ -171,6 +171,8 @@ type
         Param         : PString;
         StartNamedMark: integer;
         NamedMarks    : PUnsortedStringCollection;
+        ExtData       : pointer;
+        ExtDataSize   : longint;
         function LinkSize: sw_word;
         function GetNamedMarkIndex(const MarkName: string): sw_integer;
       end;
@@ -203,7 +205,8 @@ type
         IndexEntries : PUnsortedIndexEntryCollection;
         constructor Init(AID: word);
         function    LoadTopic(HelpCtx: THelpCtx): PTopic; virtual;
-        procedure   AddTopic(HelpCtx: THelpCtx; Pos: longint; const Param: string);
+        procedure   AddTopic(HelpCtx: THelpCtx; Pos: longint; const Param: string;
+                    ExtData: pointer; ExtDataSize: longint);
         procedure   AddIndexEntry(const Text: string; AHelpCtx: THelpCtx);
         destructor  Done; virtual;
       public
@@ -250,6 +253,7 @@ type
         function    AddOAHelpFile(const FileName: string): boolean;
         function    AddHTMLHelpFile(const FileName, TOCEntry: string): boolean;
         function    AddNGHelpFile(const FileName: string): boolean;
+        function    AddOS2HelpFile(const FileName: string): boolean;
         function    AddWinHelpFile(const FileName: string): boolean;
         function    AddHTMLIndexHelpFile(const FileName: string): boolean;
         function    LoadTopic(SourceFileID: word; Context: THelpCtx): PTopic; virtual;
@@ -269,7 +273,8 @@ const TopicCacheSize    : sw_integer = 10;
       HelpFacility      : PHelpFacility = nil;
       MaxHelpTopicSize  : sw_word = {$ifdef FPC}3*65520{$else}65520{$endif};
 
-function  NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string): PTopic;
+function  NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string;
+          ExtData: pointer; ExtDataSize: longint): PTopic;
 procedure DisposeTopic(P: PTopic);
 
 procedure RenderTopic(Lines: PUnsortedStringCollection; T: PTopic);
@@ -287,7 +292,7 @@ uses
 {$ifdef Linux}
   linux,
 {$endif Linux}
-  WConsts,WHTMLHlp,WNGHelp,WWinHelp;
+  WConsts,WHTMLHlp,WNGHelp,WWinHelp,WOS2Help;
 
 
 Function GetDosTicks:longint; { returns ticks at 18.2 Hz, just like DOS }
@@ -323,12 +328,19 @@ begin
   FillChar(R, SizeOf(R), 0);
 end;
 
-function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string): PTopic;
+function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string;
+         ExtData: pointer; ExtDataSize: longint): PTopic;
 var P: PTopic;
 begin
   New(P); FillChar(P^,SizeOf(P^), 0);
   P^.HelpCtx:=HelpCtx; P^.FileOfs:=Pos; P^.FileID:=FileID;
   P^.Param:=NewStr(Param);
+  if Assigned(ExtData) and (ExtDataSize>0) then
+  begin
+    P^.ExtDataSize:=ExtDataSize;
+    GetMem(P^.ExtData,ExtDataSize);
+    Move(ExtData^,P^.ExtData^,ExtDataSize);
+  end;
   New(P^.NamedMarks, Init(100,100));
   NewTopic:=P;
 end;
@@ -344,6 +356,8 @@ begin
        FreeMem(P^.Links,P^.LinkSize);
     P^.Links:=nil;
     if P^.Param<>nil then DisposeStr(P^.Param); P^.Param:=nil;
+    if Assigned(P^.ExtData) then
+      FreeMem(P^.ExtData{$ifndef FPC},P^.ExtDataSize{$endif});
     if Assigned(P^.NamedMarks) then Dispose(P^.NamedMarks, Done); P^.NamedMarks:=nil;
     Dispose(P);
   end;
@@ -368,6 +382,12 @@ begin
     New(NT^.NamedMarks, Init(T^.NamedMarks^.Count,10));
     T^.NamedMarks^.ForEach(@CloneMark);
   end;
+  NT^.ExtDataSize:=T^.ExtDataSize;
+  if Assigned(T^.ExtData) and (T^.ExtDataSize>0) then
+  begin
+    GetMem(NT^.ExtData,NT^.ExtDataSize);
+    Move(T^.ExtData^,NT^.ExtData^,NT^.ExtDataSize);
+  end;
   CloneTopic:=NT;
 end;
 
@@ -401,7 +421,8 @@ begin
 end;
 
 procedure BuildTopic(Lines: PUnsortedStringCollection; T: PTopic);
-var Size,CurPtr,I,MSize: sw_word;
+var Size,CurPtr,MSize: sw_word;
+    I: sw_integer;
     S: string;
 begin
   CurPtr:=0;
@@ -563,9 +584,9 @@ begin
   New(IndexEntries, Init(2000,1000));
 end;
 
-procedure THelpFile.AddTopic(HelpCtx: THelpCtx; Pos: longint; const Param: string);
+procedure THelpFile.AddTopic(HelpCtx: THelpCtx; Pos: longint; const Param: string; ExtData: pointer; ExtDataSize: longint);
 begin
-  Topics^.Insert(NewTopic(ID,HelpCtx,Pos,Param));
+  Topics^.Insert(NewTopic(ID,HelpCtx,Pos,Param,ExtData,ExtDataSize));
 end;
 
 procedure THelpFile.AddIndexEntry(const Text: string; AHelpCtx: THelpCtx);
@@ -736,7 +757,7 @@ begin
     if (L=-1) and (Header.MainIndexScreen>0) then
        L:=GetCtxPos(Contexts[Header.MainIndexScreen]);
     if (L>0) then
-      AddTopic(I,L,'');
+      AddTopic(I,L,'',nil,0);
   end;
   DisposeRecord(R);
   TopicsRead:=OK;
@@ -1060,6 +1081,13 @@ begin
   AddNGHelpFile:=AddFile(H);;
 end;
 
+function THelpFacility.AddOS2HelpFile(const FileName: string): boolean;
+var H: PHelpFile;
+begin
+  H:=New(POS2HelpFile, Init(FileName, LastID+1));
+  AddOS2HelpFile:=AddFile(H);;
+end;
+
 function THelpFacility.AddWinHelpFile(const FileName: string): boolean;
 var H: PHelpFile;
 begin
@@ -1213,7 +1241,7 @@ begin
   New(Keywords, Init(5000,5000));
   HelpFiles^.ForEach(@InsertKeywordsOfFile);
   New(Lines, Init((Keywords^.Count div 2)+100,1000));
-  T:=NewTopic(0,0,0,'');
+  T:=NewTopic(0,0,0,'',nil,0);
   if HelpFiles^.Count=0 then
     begin
       AddLine('');
@@ -1267,7 +1295,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 13:20:56  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.26  2000/07/03 08:54:54  pierre

+ 27 - 9
ide/text/whtmlhlp.pas

@@ -618,7 +618,7 @@ begin
             FName:=DefaultFileName
           else
             FName:=TopicLinks^.At(LinkNo-1)^;
-          P:=NewTopic(ID,HelpCtx,0,FName);
+          P:=NewTopic(ID,HelpCtx,0,FName,nil,0);
           Topics^.Insert(P);
         end;
     end;
@@ -709,7 +709,7 @@ begin
       Alias:=Trim(copy(Alias,1,HelpFacility^.IndexTabSize-4-2))+'..';
   FormatAlias:=Alias;
 end;
-procedure AddDoc(P: PHTMLLinkScanDocument); {$ifndef FPC}far;{$endif}
+(*procedure AddDoc(P: PHTMLLinkScanDocument); {$ifndef FPC}far;{$endif}
 var I: sw_integer;
     TLI: THelpCtx;
 begin
@@ -719,21 +719,30 @@ begin
     TLI:=EncodeHTMLCtx(ID,TLI+1);
     IndexEntries^.Insert(NewIndexEntry(FormatAlias(P^.GetAlias(I-1)),ID,TLI));
   end;
-end;
+end;*)
 var S: PBufStream;
-    DC: PHTMLLinkScanDocumentCollection;
+    LS: PHTMLLinkScanner;
     OK: boolean;
+    TLI: THelpCtx;
+    I,J: sw_integer;
 begin
   New(S, Init(IndexFileName,stOpenRead,4096));
   OK:=Assigned(S);
   if OK then
   begin
-    New(DC, Load(S^));
-    OK:=Assigned(DC);
+    New(LS, LoadDocuments(S^));
+    OK:=Assigned(LS);
     if OK then
     begin
-      DC^.ForEach(@AddDoc);
-      Dispose(DC, Done);
+      LS^.SetBaseDir(DirOf(IndexFileName));
+      for I:=0 to LS^.GetDocumentCount-1 do
+       for J:=0 to LS^.GetDocumentAliasCount(I)-1 do
+        begin
+          TLI:=TopicLinks^.AddItem(LS^.GetDocumentURL(I));
+          TLI:=EncodeHTMLCtx(ID,TLI+1);
+          IndexEntries^.Insert(NewIndexEntry(FormatAlias(LS^.GetDocumentAlias(I,J)),ID,TLI));
+        end;
+      Dispose(LS, Done);
     end;
     Dispose(S, Done);
   end;
@@ -743,7 +752,16 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.2  2000/10/18 21:53:27  pierre
+   * several Gabor fixes
+
+  Revision 1.1.2.1  2000/09/18 13:20:56  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.15  2000/06/22 09:07:15  pierre

+ 96 - 13
ide/text/whtmlscn.pas

@@ -20,7 +20,13 @@ interface
 uses Objects,
      WHTML;
 
+const
+     HTMLIndexMagicNo = ord('H')+ord('H') shl 8+ord('I') shl 16+ord('X') shl 24;
+     HTMLIndexVersion = 1;
+
 type
+     PHTMLLinkScanner = ^THTMLLinkScanner;
+
      TCustomHTMLLinkScanner = object(THTMLParser)
        function    DocAddTextChar(C: char): boolean; virtual;
        procedure   DocAnchor(Entered: boolean); virtual;
@@ -52,23 +58,31 @@ type
 
      PHTMLLinkScanDocumentCollection = ^THTMLLinkScanDocumentCollection;
      THTMLLinkScanDocumentCollection = object(TSortedCollection)
-       function Compare(Key1, Key2: Pointer): sw_Integer; virtual;
-       function At(Index: sw_Integer): PHTMLLinkScanDocument;
-       function SearchDocument(const DocName: string): PHTMLLinkScanDocument;
+       constructor Init(AScanner: PHTMLLinkScanner; ALimit, ADelta: Integer);
+       function    Compare(Key1, Key2: Pointer): sw_Integer; virtual;
+       function    At(Index: sw_Integer): PHTMLLinkScanDocument;
+       function    SearchDocument(const DocName: string): PHTMLLinkScanDocument;
+     private
+       Scanner: PHTMLLinkScanner;
      end;
 
      THTMLLinkScanner = object(TCustomHTMLLinkScanner)
-       constructor Init;
+       constructor Init(const ABaseDir: string);
+       procedure   SetBaseDir(const ABaseDir: string);
        function    GetDocumentCount: sw_integer;
        function    GetDocumentURL(DocIndex: sw_integer): string;
        function    GetDocumentAliasCount(DocIndex: sw_integer): sw_integer;
        function    GetDocumentAlias(DocIndex, AliasIndex: sw_integer): string;
+       constructor LoadDocuments(var S: TStream);
        procedure   StoreDocuments(var S: TStream);
        destructor  Done; virtual;
      public
        procedure   AddLink(const LinkText, LinkURL: string); virtual;
      private
        Documents: PHTMLLinkScanDocumentCollection;
+       BaseDir: PString;
+       function    ExpandChildURL(const S: string): string;
+       function    NormalizeChildURL(const S: string): string;
      end;
 
      THTMLLinkScanState = (ssScheduled,ssProcessing,ssScanned);
@@ -96,7 +110,7 @@ type
      THTMLLinkScanOptions = set of THTMLLinkScanOption;
 
      THTMLFileLinkScanner = object(THTMLLinkScanner)
-       constructor Init;
+       constructor Init(const ABaseDir: string);
        procedure   ProcessDocument(const DocumentURL: string; AOptions: THTMLLinkScanOptions);
        destructor  Done; virtual;
      public
@@ -227,13 +241,22 @@ begin
   if Assigned(DocName) then DisposeStr(DocName); DocName:=nil;
 end;
 
+constructor THTMLLinkScanDocumentCollection.Init(AScanner: PHTMLLinkScanner; ALimit, ADelta: Integer);
+begin
+  inherited Init(ALimit,ADelta);
+  Scanner:=AScanner;
+end;
+
 function THTMLLinkScanDocumentCollection.Compare(Key1, Key2: Pointer): sw_Integer;
 var R: sw_integer;
     K1: PHTMLLinkScanDocument absolute Key1;
     K2: PHTMLLinkScanDocument absolute Key2;
     S1,S2: string;
 begin
-  S1:=UpcaseStr(K1^.GetName); S2:=UpcaseStr(K2^.GetName);
+  S1:=K1^.GetName; S2:=K2^.GetName;
+  if Assigned(Scanner) then
+   begin S1:=Scanner^.ExpandChildURL(S1); S2:=Scanner^.ExpandChildURL(S2); end;
+  S1:=UpcaseStr(S1); S2:=UpcaseStr(S2);
   if S1<S2 then R:=-1 else
   if S1>S2 then R:= 1 else
   R:=0;
@@ -256,10 +279,17 @@ begin
   SearchDocument:=P;
 end;
 
-constructor THTMLLinkScanner.Init;
+constructor THTMLLinkScanner.Init(const ABaseDir: string);
 begin
   inherited Init;
-  New(Documents, Init(50,100));
+  New(Documents, Init(@Self,50,100));
+  SetBaseDir(ABaseDir);
+end;
+
+procedure THTMLLinkScanner.SetBaseDir(const ABaseDir: string);
+begin
+  if Assigned(BaseDir) then DisposeStr(BaseDir);
+  BaseDir:=NewStr(CompleteDir(ABaseDir));
 end;
 
 function THTMLLinkScanner.GetDocumentCount: sw_integer;
@@ -267,9 +297,24 @@ begin
   GetDocumentCount:=Documents^.Count;
 end;
 
+function THTMLLinkScanner.ExpandChildURL(const S: string): string;
+begin
+  ExpandChildURL:=CompleteURL(GetStr(BaseDir),S);
+end;
+
+function THTMLLinkScanner.NormalizeChildURL(const S: string): string;
+var URL: string;
+begin
+  URL:=S;
+  if GetStr(BaseDir)<>'' then
+   if copy(UpcaseStr(S),1,length(GetStr(BaseDir)))=UpcaseStr(GetStr(BaseDir)) then
+     URL:=copy(S,length(GetStr(BaseDir))+1,length(S));
+  NormalizeChildURL:=URL;
+end;
+
 function THTMLLinkScanner.GetDocumentURL(DocIndex: sw_integer): string;
 begin
-  GetDocumentURL:=Documents^.At(DocIndex)^.GetName;
+  GetDocumentURL:=ExpandChildURL(Documents^.At(DocIndex)^.GetName);
 end;
 
 function THTMLLinkScanner.GetDocumentAliasCount(DocIndex: sw_integer): sw_integer;
@@ -288,14 +333,45 @@ begin
   D:=Documents^.SearchDocument(LinkURL);
   if D=nil then
   begin
-    New(D, Init(LinkURL));
+    New(D, Init(NormalizeChildURL(LinkURL)));
     Documents^.Insert(D);
   end;
   D^.AddAlias(LinkText);
 end;
 
+constructor THTMLLinkScanner.LoadDocuments(var S: TStream);
+var P,L: longint;
+    OK: boolean;
+    PS: PString;
+begin
+  OK:=false;
+  P:=S.GetPos;
+  S.Read(L,sizeof(L));
+  if (S.Status=stOK) and (L=HTMLIndexMagicNo) then
+  begin
+    S.Read(L,sizeof(L));
+    OK:=(S.Status=stOK);
+  end;
+  if not OK then
+    begin
+      S.Reset;
+      S.Seek(P);
+    end
+  else
+    BaseDir:=S.ReadStr;
+  New(Documents, Load(S));
+  if not Assigned(Documents) then
+    Fail;
+end;
+
 procedure THTMLLinkScanner.StoreDocuments(var S: TStream);
+var L: longint;
 begin
+  L:=HTMLIndexMagicNo;
+  S.Write(L,sizeof(L));
+  L:=HTMLIndexVersion;
+  S.Write(L,sizeof(L));
+  S.WriteStr(BaseDir);
   Documents^.Store(S);
 end;
 
@@ -303,6 +379,7 @@ destructor THTMLLinkScanner.Done;
 begin
   inherited Done;
   if Assigned(Documents) then Dispose(Documents, Done); Documents:=nil;
+  if Assigned(BaseDir) then DisposeStr(BaseDir); BaseDir:=nil;
 end;
 
 constructor THTMLLinkScanFile.Init(const ADocumentURL: string);
@@ -368,9 +445,9 @@ begin
   FindFileWithState:=P;
 end;
 
-constructor THTMLFileLinkScanner.Init;
+constructor THTMLFileLinkScanner.Init(const ABaseDir: string);
 begin
-  inherited Init;
+  inherited Init(ABaseDir);
   New(DocumentFiles, Init(50,100));
 end;
 
@@ -453,7 +530,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/10/18 21:53:28  pierre
+   * several Gabor fixes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.7  2000/06/22 09:07:15  pierre

+ 1 - 1
ide/text/windebug.pas

@@ -67,7 +67,7 @@ uses
 
  procedure  ChangeDebuggeeWindowTitleTo(State : DebuggeeState);
    begin
-     EnumThreadWindows(inferior_pid,EnumWindowsProc(@GetWindowHandle),longint(State));
+     EnumWindows(EnumWindowsProc(@GetWindowHandle),longint(State));
    end;
 
 end.

+ 8 - 2
ide/text/wnghelp.pas

@@ -360,7 +360,7 @@ begin
     begin
 {      Inc(NextHelpCtx);}
       AddIndexEntry(S,P^.FilePos);
-      AddTopic(P^.FilePos,P^.FilePos,'');
+      AddTopic(P^.FilePos,P^.FilePos,'',nil,0);
     end;
 end;
 var OK: boolean;
@@ -508,7 +508,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 13:20:56  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.3  2000/07/03 08:54:54  pierre

+ 611 - 0
ide/text/wos2help.pas

@@ -0,0 +1,611 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 2000 by Berczi Gabor
+
+    Help support for OS/2 (.INF) help files
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$R-}
+unit WOS2Help;
+
+interface
+
+uses Objects,
+     WUtils,WHelp;
+
+const
+      INFFileSignature = 'HS';
+
+      { TOCEntry flags }
+      inf_tef_HasChildren    = $80; { following nodes are a higher level }
+      inf_tef_Hidden         = $40; { this entry doesn't appear in VIEW.EXE's presentation of the toc }
+      inf_tef_Extended       = $20; { extended entry format }
+      inf_tef_LevelMask      = $0f;
+
+type
+      TINFFileHeader = packed record
+        Signature   : array[1..2] of char;{ ID magic word (5348h = "HS")                 }
+        Unknown1    : byte;      { unknown purpose, could be third letter of ID }
+        Flags       : byte;      { probably a flag word...                      }
+                                 {  bit 0: set if INF style file                }
+                                 {  bit 4: set if HLP style file                }
+                                 { patching this byte allows reading HLP files  }
+                                 { using the VIEW command, while help files     }
+                                 { seem to work with INF settings here as well. }
+        HeaderSize  : word;      { total size of header                         }
+        Unknown2    : word;      { unknown purpose                              }
+        NumTOC      : word;      { 16 bit number of entries in the tocarray     }
+        TOCStrTabOfs: longint;   { 32 bit file offset of the start of the       }
+                                 { strings for the table-of-contents            }
+        TOCStrTabSize: longint;  { number of bytes in file occupied by the      }
+                                 { table-of-contents strings                    }
+        TOCArrayOfs : longint;   { 32 bit file offset of the start of tocarray  }
+        NumResPanels: word;      { number of panels with ressource numbers      }
+        ResTabOfs   : longint;   { 32 bit file offset of ressource number table }
+        NumNames    : word;      { number of panels with textual name           }
+        NameTabOfs  : longint;   { 32 bit file offset to panel name table       }
+        NumIndexes  : word;      { number of index entries                      }
+        IndexTabOfs : longint;   { 32 bit file offset to index table            }
+        IndexTabSize: longint;   { size of index table                          }
+        Unknown3: array[1..10] of byte; { unknown purpose                       }
+        SearchTabOfs: longint;   { 32 bit file offset of full text search table }
+        SearchTabSize:longint;   { size of full text search table               }
+        NumSlots    : word;      { number of "slots"                            }
+        SlotTabOfs  : longint;   { file offset of the slots array               }
+        DictSize    : longint;   { number of bytes occupied by the "dictionary" }
+        NumDictEntries: word;    { number of entries in the dictionary          }
+        DictOfs     : longint;   { file offset of the start of the dictionary   }
+        ImageOfs    : longint;   { file offset of image data                    }
+        Unknown4    : byte;      { unknown purpose                              }
+        NLSTabOfs   : longint;   { 32 bit file offset of NLS table              }
+        NLSTabSize  : longint;   { size of NLS table                            }
+        ExtBlockOfs : longint;   { 32 bit file offset of extended data block    }
+        Unknown5: array[1..12] of byte;{ unknown purpose                        }
+        Title       : array[1..48] of char;{ ASCII title of database            }
+      end;
+
+      PINFTOCArray = ^TINFTOCArray;
+      TINFTOCArray = packed array[0..16382] of longint;
+
+      PINFSlotArray = ^TINFSlotArray;
+      TINFSlotArray = packed array[0..32766] of word;
+
+      PSlotArray = ^TSlotArray;
+      TSlotArray = packed array[0..16382] of longint;
+
+      TINFTOCEntry = packed record
+        Size     : byte; { length of the entry including this byte    }
+        Flags    : byte; { flag byte, description folows (MSB first)  }
+        NumSlots : byte; { number of "slots" occupied by the text for }
+                         { this toc entry                             }
+        Slots    : record end;
+      end;
+
+      TINFTopicHeader = packed record
+        Stuff        : byte;      { ??                                   }
+        LocalDictPos : longint;   { file offset of the local dictionary  }
+        NumLocalDict : byte;      { number of entries in the local dict  }
+        TextSize     : word;      { number of bytes in the text          }
+        Text         : record end;{ encoded text of the article          }
+      end;
+
+      TINFEscHeader = packed record
+        EscLen : byte;  { length of the sequence (including esclen but excluding FF) }
+        EscCode: byte;  { which escape function }
+      end;
+
+      POS2HelpFile = ^TOS2HelpFile;
+      TOS2HelpFile = object(THelpFile)
+        constructor Init(AFileName: string; AID: word);
+        destructor  Done; virtual;
+      public
+        function    LoadIndex: boolean; virtual;
+        function    ReadTopic(T: PTopic): boolean; virtual;
+      private
+        F: PStream;
+        Header: TINFFileHeader;
+        Dictionary: PUnsortedStringCollection;
+        Slots: PSlotArray;
+        SlotsSize: longint;
+        function ReadHeader: boolean;
+        function ReadSlots: boolean;
+        function ReadDictionary: boolean;
+        function ReadTOC: boolean;
+        function ReadTopicRec(FileOfs: longint; Topic: PTopic; Lines: PUnsortedStringCollection): boolean;
+      end;
+
+      TINFGetAttrColorProc = function(TextStyle, TextColor: byte; var Color: byte): boolean;
+
+function DefINFGetAttrColor(TextStyle, TextColor: byte; var Color: byte): boolean;
+
+const INFGetAttrColor : TINFGetAttrColorProc = DefINFGetAttrColor;
+
+implementation
+
+uses CallSpec;
+
+function DefINFGetAttrColor(TextStyle, TextColor: byte; var Color: byte): boolean;
+{
+          style;    // 1,2,3: same as :hp#.
+                    // 4,5,6: same as :hp5,6,7.
+                    // 0 returns to plain text
+          color;   // 1,2,3: same as :hp4,8,9.
+                   // 0: default color
+
+          :hp4 text is light blue
+          :hp8 text is red
+          :hp9 text is magenta
+
+          :hp1 is italic font
+          :hp2 is bold font
+          :hp3 is bold italic font
+          :hp5 is normal underlined font
+          :hp6 is italic underlined font
+          :hp7 is bold underlined font
+}
+begin
+  DefINFGetAttrColor:=false;
+end;
+
+function KillNonASCII(S: string): string;
+var I: sw_integer;
+begin
+  for I:=1 to length(S) do
+    if S[I]<#32 then
+      S[I]:='.';
+  KillNonASCII:=S;
+end;
+
+function ContainsNonASCIIChar(const S: string): boolean;
+var I: sw_integer;
+begin
+  ContainsNonASCIIChar:=false;
+  for I:=1 to length(S) do
+    if S[I]<#32 then
+      begin
+        ContainsNonASCIIChar:=true;
+        Break;
+      end;
+end;
+
+constructor TOS2HelpFile.Init(AFileName: string; AID: word);
+var OK: boolean;
+begin
+  if inherited Init(AID)=false then Fail;
+  New(Dictionary, Init(100,1000));
+  F:=New(PFastBufStream, Init(AFileName, stOpenRead, HelpStreamBufSize));
+  OK:=F<>nil;
+  if OK then OK:=(F^.Status=stOK);
+  if OK then OK:=ReadHeader;
+  if OK=false then
+  begin
+    Done;
+    Fail;
+  end;
+end;
+
+function TOS2HelpFile.ReadHeader: boolean;
+var OK: boolean;
+begin
+  F^.Read(Header,sizeof(Header));
+  OK:=(F^.Status=stOK);
+  OK:=OK and (Header.Signature=INFFileSignature);
+  ReadHeader:=OK;
+end;
+
+function TOS2HelpFile.LoadIndex: boolean;
+var OK: boolean;
+begin
+  OK:=ReadDictionary;
+  if OK then OK:=ReadSlots;
+  if OK then OK:=ReadTOC;
+  LoadIndex:=OK;
+end;
+
+function TOS2HelpFile.ReadDictionary: boolean;
+var OK: boolean;
+    I: longint;
+    C: array[0..255] of char;
+    B: byte;
+begin
+  F^.Seek(Header.DictOfs);
+  OK:=(F^.Status=stOK);
+  I:=0;
+  while OK and (I<Header.NumDictEntries) do
+  begin
+    FillChar(C,sizeof(C),0);
+    F^.Read(B,sizeof(B)); F^.Read(C,B-1);
+    OK:=(F^.Status=stOK);
+    if OK then
+      Dictionary^.InsertStr(StrPas(@C));
+    Inc(I);
+  end;
+  ReadDictionary:=OK;
+end;
+
+function TOS2HelpFile.ReadSlots: boolean;
+var OK: boolean;
+begin
+  SlotsSize:=Header.NumSlots*sizeof(Slots^[0]);
+  GetMem(Slots,SlotsSize);
+  F^.Seek(Header.SlotTabOfs);
+  OK:=(F^.Status=stOK);
+  if OK then
+  begin
+    F^.Read(Slots^,SlotsSize);
+    OK:=(F^.Status=stOK);
+  end;
+  ReadSlots:=OK;
+end;
+
+function TOS2HelpFile.ReadTOC: boolean;
+var OK: boolean;
+    I,J,L,Count: longint;
+    TE: TINFTOCEntry;
+    W: word;
+    C: array[0..255] of char;
+    StartOfs: longint;
+    S: string;
+    SubSlots: PWordArray;
+    SubSlotsSize: longint;
+    TOC: PINFTOCArray;
+    TOCSize: longint;
+begin
+  F^.Seek(Header.TOCArrayOfs); TOCSize:=Header.TOCStrTabSize;
+  OK:=(F^.Status=stOK);
+  if OK then
+  begin
+    GetMem(TOC,TOCSize);
+    F^.Read(TOC^,TOCSize);
+    OK:=(F^.Status=stOK);
+    I:=0;
+    while OK and (I<Header.NumTOC) do
+    begin
+      F^.Seek(TOC^[I]);
+      OK:=(F^.Status=stOK);
+      if OK then
+      begin
+        StartOfs:=F^.GetPos;
+        F^.Read(TE,sizeof(TE));
+        OK:=(F^.Status=stOK);
+      end;
+      if OK and ((TE.Flags and inf_tef_Extended)<>0) then
+      begin
+        F^.Read(W,sizeof(W));
+        Count:=0;
+        if (W and 1)<>0 then Inc(Count,5);
+        if (W and 2)<>0 then Inc(Count,5);
+        if (W and 4)<>0 then Inc(Count,2);
+        if (W and 8)<>0 then Inc(Count,2);
+        F^.Seek(F^.GetPos+Count);
+        OK:=(F^.Status=stOK);
+      end;
+      if OK then
+      begin
+        SubSlotsSize:=sizeof(SubSlots^[0])*TE.NumSlots;
+        GetMem(SubSlots,SubSlotsSize);
+        F^.Read(SubSlots^,SubSlotsSize);
+        FillChar(C,sizeof(C),0);
+        F^.Read(C,Max(0,TE.Size-(F^.GetPos-StartOfs)));
+        OK:=(F^.Status=stOK);
+        if OK then
+        begin
+          S:=StrPas(@C);
+          AddTopic(I,StartOfs,S,SubSlots,SubSlotsSize);
+          if (S<>'') and (not ContainsNonASCIIChar(S)) then
+           AddIndexEntry(S,I);
+ {         !}
+        end;
+        FreeMem(SubSlots,SubSlotsSize);
+      end;
+      Inc(I);
+    end;
+    FreeMem(TOC,TOCSize); TOC:=nil;
+  end;
+  ReadTOC:=OK;
+end;
+
+function TOS2HelpFile.ReadTopicRec(FileOfs: longint; Topic: PTopic; Lines: PUnsortedStringCollection): boolean;
+var Line: string;
+    LastTextChar: char;
+    CharsInLine: sw_integer;
+    LeftMargin,RightMargin: byte;
+    TextStyle,TextColor: byte;
+    InMonospace: boolean;
+    Align: (alLeft,alRight,alCenter);
+    LineNo: longint;
+procedure FlushLine;
+begin
+  if Line<>'' then Lines^.InsertStr(Line);
+  Line:='';
+end;
+procedure AddChar(C: char);
+begin
+  if length(Line)>=255 then FlushLine;
+  Line:=Line+C;
+end;
+procedure AddString(const S: string);
+var I: sw_integer;
+begin
+  for I:=1 to length(S) do
+    AddChar(S[I]);
+end;
+procedure AddTextChar(C: char);
+begin
+  if (C=hscLineBreak) then
+  begin
+    case Align of
+      alRight : AddChar(hscRight);
+      alCenter: AddChar(hscCenter);
+    end;
+  end;
+  if (CharsInLine=0) and (C<>hscLineBreak) then
+  begin
+    if (LeftMargin>0) then
+      begin
+        AddString(CharStr(#255,LeftMargin)+hscLineStart);
+        Inc(CharsInLine,LeftMargin);
+      end else
+    if InMonospace then
+      begin
+        AddChar(' ');
+        Inc(CharsInLine);
+      end;
+  end;
+  AddChar(C);
+  LastTextChar:=C;
+  if C=hscLineBreak then
+    begin
+      CharsInLine:=0;
+      Inc(LineNo);
+    end
+  else
+    Inc(CharsInLine);
+end;
+procedure AddText(const S: string);
+var I: sw_integer;
+begin
+  for I:=1 to length(S) do
+    AddTextChar(S[I]);
+end;
+var H: TINFTopicHeader;
+    Text: PByteArray;
+    TextOfs: longint;
+    Dict: PWordArray;
+    Spacing: boolean;
+function NextByte: byte;
+var B: byte;
+begin
+  NextByte:=Text^[TextOfs];
+  Inc(TextOfs);
+end;
+procedure ReadBytes(DataPtr: pointer; NumBytes: sw_integer);
+var I: sw_integer;
+begin
+  for I:=1 to NumBytes do
+    if Assigned(DataPtr) then
+      PByteArray(DataPtr)^[I-1]:=NextByte
+    else
+      NextByte;
+end;
+procedure AddWord(LocalIndex: word);
+begin
+  AddText(GetStr(Dictionary^.At(Dict^[LocalIndex])));
+  if Spacing and not InMonospace then AddTextChar(' ');
+end;
+var
+    DictSize,EscStartOfs: longint;
+    OK: boolean;
+    EH: TINFEscHeader;
+    B,Color: byte;
+    W: word;
+    CurLinkCtx: longint;
+    InTempMargin: boolean;
+begin
+  F^.Reset;
+  F^.Seek(FileOfs);
+  OK:=(F^.Status=stOK);
+  if OK then
+  begin
+    F^.Read(H,sizeof(H));
+    OK:=(F^.Status=stOK);
+  end;
+  if OK then
+  begin
+    LineNo:=0;
+    Line:=''; LeftMargin:=0; RightMargin:=0; LastTextChar:=hscLineBreak;
+    CharsInLine:=0; TextStyle:=0; TextColor:=0; Align:=alLeft;
+    CurLinkCtx:=-1; InMonospace:=false;
+    DictSize:=H.NumLocalDict*sizeof(Dict^[0]);
+    GetMem(Text,H.TextSize);
+    GetMem(Dict,DictSize);
+    F^.Read(Text^,H.TextSize);
+    F^.Seek(H.LocalDictPos);
+    F^.Read(Dict^,DictSize);
+    OK:=(F^.Status=stOK);
+
+    TextOfs:=0; Spacing:=true;
+    while OK and (TextOfs<H.TextSize) do
+    begin
+      B:=NextByte;
+      if (B<H.NumLocalDict) then
+      begin
+        AddWord(B);
+      end else
+      case B of
+        $fa : begin
+                if (LineNo>0) then
+                  AddTextChar(hscLineBreak);
+                if InTempMargin then
+                  LeftMargin:=0;
+                AddTextChar(hscLineBreak);
+                Spacing:=true;
+              end;
+        $fb : { ??? };
+        $fc : Spacing:=not Spacing;
+        $fd : begin
+                AddTextChar(hscLineBreak);
+                Spacing:=true;
+              end;
+        $fe : AddChar(' ');
+        $ff : begin
+                EscStartOfs:=TextOfs;
+                ReadBytes(@EH,sizeof(EH));
+                case EH.EscCode of
+                  $02,$11,$12 :
+                    begin
+                      { set left margin }
+                      if EH.EscCode=$11 then
+                        AddTextChar(hscLineBreak);
+                      LeftMargin:=NextByte;
+                    end;
+                  $03 :
+                    RightMargin:=NextByte;
+                  $04 :
+                    begin
+                      TextStyle:=NextByte;
+                      if (TextStyle=0) or (not INFGetAttrColor(TextStyle,TextColor,Color)) then
+                        AddChar(hscNormText)
+                      else
+                        AddText(hscTextColor+chr(Color));
+                    end;
+                  $05 :
+                    begin
+                      W:=word(NextByte)*256+NextByte;
+                      AddChar(hscLink);
+                      CurLinkCtx:=W;
+                    end;
+                  $08 :
+                    if CurLinkCtx<>-1 then
+                    begin
+                      AddChar(hscLink);
+                      AddLinkToTopic(Topic,ID,CurLinkCtx);
+                    end;
+                  $0b :
+                    begin
+                      if CharsInLine>0 then
+                        AddTextChar(hscLineBreak);
+                      AddTextChar(hscLineBreak);
+                      AddChar(hscCode);
+                      InMonospace:=true;
+                    end;
+                  $0c :
+                    begin
+                      AddChar(hscCode);
+                      InMonospace:=false;
+                    end;
+                  $0d :
+                    begin
+                      TextColor:=NextByte;
+                      if (TextColor=0) or (not INFGetAttrColor(TextStyle,TextColor,Color)) then
+                        AddChar(hscNormText)
+                      else
+                        AddText(hscTextColor+chr(Color));
+                    end;
+                  $0e :
+                    begin
+                      AddText(hscLineBreak+'[img]'+hscLineBreak);
+                    end;
+                  $1a :
+                    begin
+                      if CharsInLine>0 then AddText(hscLineBreak);
+                      case NextByte of
+                        1 : Align:=alLeft;
+                        2 : Align:=alRight;
+                        4 : Align:=alCenter;
+                      end;
+                      Spacing:=false;
+                    end;
+                  $1b :
+                    begin
+                      Spacing:=true;
+                    end;
+                  $1c :
+                    begin
+                      LeftMargin:=CharsInLine;
+                      InTempMargin:=true;
+                    end;
+                end;
+                TextOfs:=EscStartOfs+EH.EscLen;
+              end;
+      end;
+    end;
+    if CharsInLine>0 then
+      AddTextChar(hscLineBreak);
+    AddTextChar(hscLineBreak);
+    FlushLine;
+
+    FreeMem(Dict,DictSize);
+    FreeMem(Text,H.TextSize);
+  end;
+  F^.Reset;
+  ReadTopicRec:=OK;
+end;
+
+function TOS2HelpFile.ReadTopic(T: PTopic): boolean;
+var OK: boolean;
+    I,NumSlots,Idx: sw_integer;
+    TopicOfs: longint;
+    L: PUnsortedStringCollection;
+    Title: string;
+begin
+  OK:=false;
+  NumSlots:=T^.ExtDataSize div 2; { extdata is array of word }
+  New(L, Init(100,100));
+  Title:=GetStr(T^.Param);
+  if Title<>'' then
+  begin
+    L^.InsertStr('  '+Title+' Ü'+hscLineBreak);
+    L^.InsertStr(' '+CharStr('ß',length(Title)+3)+hscLineBreak);
+  end;
+  if 0<T^.HelpCtx then
+  begin
+    L^.InsertStr(hscLink+'[previous topic]'+hscLink+'  ');
+    AddLinkToTopic(T,ID,T^.HelpCtx-1);
+  end;
+  if T^.HelpCtx<Header.NumTOC then
+  begin
+    L^.InsertStr(hscLink+'[next topic]'+hscLink);
+    AddLinkToTopic(T,ID,T^.HelpCtx+1);
+  end;
+  L^.InsertStr(hscLineBreak);
+  for I:=0 to NumSlots-1 do
+  begin
+    Idx:=PWordArray(T^.ExtData)^[I];
+    TopicOfs:=Slots^[Idx];
+    OK:=ReadTopicRec(TopicOfs,T,L);
+    if not OK then
+      Break;
+  end;
+  if OK then BuildTopic(L,T);
+  Dispose(L, Done);
+  ReadTopic:=OK;
+end;
+
+destructor TOS2HelpFile.Done;
+begin
+  if Assigned(Slots) then FreeMem(Slots, SlotsSize); Slots:=nil;
+  if Assigned(Dictionary) then Dispose(Dictionary, Done); Dictionary:=nil;
+  if Assigned(F) then Dispose(F, Done); F:=nil;
+  inherited Done;
+end;
+
+END.
+{
+  $Log$
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 19:50:37  pierre
+   New file from Gabor
+
+
+}

+ 39 - 6
ide/text/wutils.pas

@@ -21,9 +21,19 @@ interface
 
 
 uses
+{$ifdef win32}
+  windows,
+{$endif win32}
+{$ifdef linux}
+  linux,
+{$endif linux}
   Dos,Objects;
 
 const
+      kbCtrlGrayPlus         = $9000;
+      kbCtrlGrayMinus        = $8e00;
+      kbCtrlGrayMul          = $9600;
+
   TempFirstChar = {$ifndef Linux}'~'{$else}'_'{$endif};
   TempExt       = '.tmp';
   TempNameLen   = 8;
@@ -169,9 +179,6 @@ procedure RegisterWUtils;
 implementation
 
 uses
-{$ifdef win32}
-  windows,
-{$endif win32}
 {$IFDEF OS2}
   DosCalls,
 {$ENDIF OS2}
@@ -757,7 +764,7 @@ begin
   if (RelOfs<0) or (RelOfs>=BufEnd) or (BufEnd=0) then
     begin
       inherited Seek(Pos);
-      BasePos:=Pos;
+      BasePos:=Pos-BufPtr;
     end
   else
     begin
@@ -1114,7 +1121,12 @@ begin
 end;
 {$endif}
 {$ifdef Linux}
+  var
+    req,rem : timespec;
 begin
+  req.tv_sec:=0;
+  req.tv_nsec:=10000000;{ 10 ms }
+  nanosleep(req,rem);
 end;
 {$endif}
 {$IFDEF OS2}
@@ -1124,6 +1136,15 @@ end;
 {$ENDIF}
 {$ifdef Win32}
 begin
+  { if the return value of this call is non zero then
+    it means that a ReadFileEx or WriteFileEx have completed
+    unused for now ! }
+  { wait for 10 ms }
+  if SleepEx(10,true)=WAIT_IO_COMPLETION then
+    begin
+      { here we should handle the completion of the routines
+        if we use them }
+    end;
 end;
 {$endif}
 {$undef DOS}
@@ -1140,12 +1161,24 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.4  2000-10-28 17:20:42  hajny
+  Revision 1.5  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.4  2000/10/28 17:20:42  hajny
     * lower the CPU use on OS/2
 
+  Revision 1.1.2.6  2000/10/24 12:31:40  pierre
+   * fix the last commit for linux
+
+  Revision 1.1.2.5  2000/10/24 12:24:03  pierre
+   + GiveUpTimeSlice for linux and win32
+
   Revision 1.3  2000/10/11 20:07:23  hajny
     * compilable for the OS/2 target now
 
+  Revision 1.1.2.4  2000/09/18 13:20:56  pierre
+   New bunch of Gabor changes
+
   Revision 1.2  2000/08/22 09:41:42  pierre
    * first big merge from fixes branch
 
@@ -1264,4 +1297,4 @@ END.
   Revision 1.1  1999/03/01 15:51:43  peter
     + Log
 
-}
+}

+ 19 - 4
ide/text/wviews.pas

@@ -1535,9 +1535,18 @@ begin
   while (P<>nil) do
   begin
     if IsSubMenu(P) then
-       P^.Disabled:=not UpdateMenu(P^.SubMenu);
-    if (IsSeparator(P)=false) and (P^.Disabled=false) and (Application^.CommandEnabled(P^.Command)=true) then
-       IsEnabled:=true;
+       begin
+         P^.Disabled:=not UpdateMenu(P^.SubMenu);
+         if not P^.Disabled then
+           IsEnabled:=true;
+       end
+    else if (IsSeparator(P)=false) {and (P^.Disabled=false)} and
+       (Application^.CommandEnabled(P^.Command)=true) then
+       begin
+         p^.disabled:=not Application^.CommandEnabled(P^.Command);
+         if not p^.disabled then
+           IsEnabled:=true;
+       end;
     P:=P^.Next;
   end;
   UpdateMenu:=IsEnabled;
@@ -2416,7 +2425,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.2  2000-08-22 09:41:42  pierre
+  Revision 1.3  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.3  2000/10/24 00:21:59  pierre
+   * fix the greyed save after window list box
+
+  Revision 1.2  2000/08/22 09:41:42  pierre
    * first big merge from fixes branch
 
   Revision 1.1.2.2  2000/08/16 18:46:15  peter

+ 8 - 2
ide/text/wwinhelp.pas

@@ -857,7 +857,7 @@ begin
     if (TopicTitle<>'') and (FileOfs>=0) then
     begin
       AddIndexEntry(TopicTitle,FileOfs);
-      AddTopic(FileOfs,FileOfs,'');
+      AddTopic(FileOfs,FileOfs,'',nil,0);
     end;
   end;
   TTLBProcessTopicEntry:=OK;
@@ -1665,7 +1665,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  2000-07-13 09:48:37  michael
+  Revision 1.2  2000-10-31 22:35:56  pierre
+   * New big merge from fixes branch
+
+  Revision 1.1.2.1  2000/09/18 13:20:56  pierre
+   New bunch of Gabor changes
+
+  Revision 1.1  2000/07/13 09:48:37  michael
   + Initial import
 
   Revision 1.2  2000/07/03 08:54:54  pierre

Some files were not shown because too many files changed in this diff