Browse Source

+ Added user screen support, display & window
+ Implemented Editor,Mouse Options dialog
+ Added location of .INI and .CFG file
+ Option (INI) file managment implemented (see bottom of Options Menu)
+ Switches updated
+ Run program

peter 27 years ago
parent
commit
9788af7f08

+ 113 - 26
ide/text/fp.pas

@@ -16,10 +16,13 @@
 program FreePascal;
 
 uses
-  Dos,Objects,Memory,Drivers,Views,Menus,Dialogs,App,StdDlg,ColorSel,
+  Video,Mouse,Keyboard,
+  Dos,Objects,Memory,Drivers,Views,Menus,Dialogs,App,StdDlg,
+  ColorSel,
   Systems,Commands,HelpCtx,
-  WHelp,WHlpView,WINI,
-  FPConst,FPUtils,FPCfgs,FPIntf,FPCompile,FPHelp,FPViews,FPTemplt,FPCalc;
+  WHelp,WHlpView,WINI,{$ifdef EDITORS}Editors,{$else}WEditor,{$endif}
+  FPConst,FPVars,FPUtils,FPSwitches,FPIni,FPIntf,FPCompile,FPHelp,FPViews,
+  FPTemplt,FPCalc,FPUsrScr;
 
 type
     TIDEApp = object(TApplication)
@@ -28,6 +31,7 @@ type
       procedure   InitStatusLine; virtual;
       procedure   HandleEvent(var Event: TEvent); virtual;
       function    GetPalette: PPalette; virtual;
+      procedure   DosShell; virtual;
       destructor  Done; virtual;
     private
       function  OpenEditorWindow(FileName: string; CurX,CurY: integer): PSourceWindow;
@@ -39,18 +43,27 @@ type
       procedure ChangeDir;
       procedure ShowClipboard;
       procedure Parameters;
+      procedure DoRun;
       procedure Target;
       procedure PrimaryFile_;
       procedure ClearPrimary;
+      procedure ShowUserScreen;
       procedure Information;
       procedure Calculator;
+      procedure SetSwitchesMode;
       procedure Compiler;
       procedure MemorySizes;
       procedure Linker;
       procedure Debugger;
       procedure Directories;
+      procedure EditorOptions(Editor: PEditor);
+      procedure Mouse;
       procedure Colors;
+      procedure OpenINI;
+      procedure SaveINI;
+      procedure SaveAsINI;
       procedure CloseAll;
+      procedure ShowScreenWindow;
       procedure WindowList;
       procedure HelpContents;
       procedure HelpHelpIndex;
@@ -67,20 +80,10 @@ type
       procedure Update;
       procedure CurDirChanged;
       procedure UpdatePrimaryFile;
+      procedure UpdateINIFile;
       procedure UpdateRecentFileList;
     end;
 
-    TRecentFileEntry = record
-      FileName  : PathStr;
-      LastPos   : TPoint;
-    end;
-
-const ClipboardWindow  : PClipboardWindow = nil;
-      CalcWindow       : PCalculator = nil;
-      RecentFileCount  : integer = 0;
-
-var   RecentFiles      : array[1..5] of TRecentFileEntry;
-
 constructor TIDEApp.Init;
 begin
   inherited Init;
@@ -89,6 +92,7 @@ begin
   New(CalcWindow, Init); CalcWindow^.Hide;
   Desktop^.Insert(CalcWindow);
   New(ProgramInfoWindow, Init); ProgramInfoWindow^.Hide; Desktop^.Insert(ProgramInfoWindow);
+  New(UserScreenWindow, Init(UserScreen)); UserScreenWindow^.Hide; Desktop^.Insert(UserScreenWindow);
   Message(@Self,evBroadcast,cmUpdate,nil);
   InitTemplates;
   CurDirChanged;
@@ -152,13 +156,15 @@ begin
       NewItem('~I~nformation...','', kbNoKey, cmInformation, hcInformation,
       nil)))))))))),
     NewSubMenu('~D~ebug', hcDebugMenu, NewMenu(
-      nil),
+      NewItem('~U~ser screen','Alt+F5', kbAltF5, cmUserScreen, hcUserScreen,
+      nil)),
     NewSubMenu('~T~ools', hcToolsMenu, NewMenu(
       NewItem('~M~essages', '', kbNoKey, cmToolsMessages, hcToolsMessages,
       NewLine(
       NewItem('~C~alculator', '', kbNoKey, cmCalculator, hcCalculator,
       nil)))),
     NewSubMenu('~O~ptions', hcOptionsMenu, NewMenu(
+      NewItem('Mode...','', kbNoKey, cmSetSwitchesMode, hcSetSwitchesMode,
       NewItem('~C~ompiler...','', kbNoKey, cmCompiler, hcCompiler,
       NewItem('~M~emory sizes...','', kbNoKey, cmMemorySizes, hcMemorySizes,
       NewItem('~L~inker...','', kbNoKey, cmLinker, hcLinker,
@@ -173,7 +179,11 @@ begin
         NewItem('~S~tartup...','', kbNoKey, cmStartup, hcStartup,
         NewItem('~C~olors...','', kbNoKey, cmColors, hcColors,
         nil)))))),
-      nil))))))))),
+      NewLine(
+      NewItem('~O~pen...','', kbNoKey, cmOpenINI, hcOpenINI,
+      NewItem('~S~ave','', kbNoKey, cmSaveINI, hcSaveINI,
+      NewItem('Save ~a~s...','', kbNoKey, cmSaveAsINI, hcSaveAsINI,
+      nil)))))))))))))),
     NewSubMenu('~W~indow', hcWindowMenu, NewMenu(
       NewItem('~T~ile','', kbNoKey, cmTile, hcTile,
       NewItem('C~a~scade','', kbNoKey, cmCascade, hcCascade,
@@ -186,8 +196,9 @@ begin
       NewItem('~C~lose','Alt+F3', kbAltF3, cmClose, hcClose,
       NewLine(
       NewItem('~L~ist...','Alt+0', kbAlt0, cmWindowList, hcWindowList,
+      NewItem('~U~ser screen window','', kbNoKey, cmUserScreenWindow, hcUserScreenWindow,
       NewItem('~R~efresh display','', kbNoKey, cmUpdate, hcUpdate,
-      nil))))))))))))),
+      nil)))))))))))))),
     NewSubMenu('~H~elp', hcHelpMenu, NewMenu(
       NewItem('~C~ontents','', kbNoKey, cmHelpContents, hcHelpContents,
       NewItem('~I~ndex','Shift+F1', kbShiftF1, cmHelpIndex, hcHelpIndex,
@@ -259,11 +270,14 @@ begin
              cmNew           : NewEditor;
              cmNewFromTemplate: NewFromTemplate;
              cmOpen          : begin
+                                 if (DirOf(OpenFileName)='') or (Pos(ListSeparator,OpenFileName)<>0) then
+                                   OpenFileName:=LocateFile(OpenFileName);
                                  Open(OpenFileName);
                                  OpenFileName:='';
                                end;
              cmSaveAll       : SaveAll;
              cmChangeDir     : ChangeDir;
+             cmDOSShell      : DOSShell;
              cmRecentFileBase..
              cmRecentFileBase+10
                              : OpenRecentFile(Event.Command-cmRecentFileBase);
@@ -271,6 +285,7 @@ begin
              cmShowClipboard : ShowClipboard;
            { -- Run menu -- }
              cmParameters    : Parameters;
+             cmRun           : DoRun;
            { -- Compile menu -- }
              cmCompile       : DoCompile(cCompile);
              cmBuild         : DoCompile(cBuild);
@@ -279,18 +294,28 @@ begin
              cmPrimaryFile   : PrimaryFile_;
              cmClearPrimary  : ClearPrimary;
              cmInformation   : Information;
+           { -- Debug menu -- }
+             cmUserScreen    : ShowUserScreen;
            { -- Options menu -- }
+             cmSetSwitchesMode : SetSwitchesMode;
              cmCompiler      : Compiler;
              cmMemorySizes   : MemorySizes;
              cmLinker        : Linker;
              cmDebugger      : Debugger;
              cmDirectories   : Directories;
+             cmEditor        : EditorOptions(nil);
+             cmEditorOptions : EditorOptions(Event.InfoPtr);
+             cmMouse         : Mouse;
              cmColors        : Colors;
+             cmOpenINI       : OpenINI;
+             cmSaveINI       : SaveINI;
+             cmSaveAsINI     : SaveAsINI;
            { -- Tools menu -- }
              cmCalculator    : Calculator;
            { -- Window menu -- }
              cmCloseAll      : CloseAll;
              cmWindowList    : WindowList;
+             cmUserScreenWindow: ShowScreenWindow;
            { -- Help menu -- }
              cmHelpContents  : HelpContents;
              cmHelpIndex     : HelpHelpIndex;
@@ -322,6 +347,7 @@ begin
   SetCmdState([cmCloseAll,cmTile,cmCascade,cmWindowList],IsThereAnyWindow);
   SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals{,cmInformation}],IsEXECompiled);
   UpdatePrimaryFile;
+  UpdateINIFile;
   Message(MenuBar,evBroadcast,cmUpdate,nil);
   UpdateRecentFileList;
   Message(Application,evBroadcast,cmCommandSetChanged,nil);
@@ -331,6 +357,7 @@ procedure TIDEApp.CurDirChanged;
 begin
   Message(Application,evBroadcast,cmUpdateTitle,nil);
   UpdatePrimaryFile;
+  UpdateINIFile;
   UpdateMenu(MenuBar^.Menu);
 end;
 
@@ -343,6 +370,11 @@ begin
   UpdateMenu(MenuBar^.Menu);
 end;
 
+procedure TIDEApp.UpdateINIFile;
+begin
+  SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(INIPath));
+end;
+
 procedure TIDEApp.UpdateRecentFileList;
 var P: PMenuItem;
     ID,I: word;
@@ -351,9 +383,23 @@ begin
   ID:=cmRecentFileBase;
   FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
   repeat
-    Inc(ID);
+{    Inc(ID);
     P:=SearchMenuItem(FileMenu^.SubMenu,ID);
-    if P<>nil then RemoveMenuItem(FileMenu^.SubMenu,P);
+    if FileMenu^.SubMenu^.Default=P then
+      FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
+    if P<>nil then RemoveMenuItem(FileMenu^.SubMenu,P);}
+    P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
+    if (P<>nil) then
+    begin
+      if (cmRecentFileBase<P^.Command) and (P^.Command<=cmRecentFileBase+MaxRecentFileCount) then
+        begin
+          RemoveMenuItem(FileMenu^.SubMenu,P);
+          if FileMenu^.SubMenu^.Default=P then
+            FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
+        end
+      else
+        P:=nil;
+    end;
   until P=nil;
   P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
   if (P<>nil) and IsSeparator(P) then
@@ -369,12 +415,37 @@ begin
   end;
 end;
 
+procedure TIDEApp.DosShell;
+begin
+  DoneSysError;
+  DoneEvents;
+  DoneVideo;
+  DoneDosMem;
+  if UserScreen<>nil then UserScreen^.SwitchTo;
+  WriteShellMsg;
+  SwapVectors;
+  Exec(GetEnv('COMSPEC'), '');
+  SwapVectors;
+  if UserScreen<>nil then UserScreen^.SwitchBack;
+  InitDosMem;
+  InitVideo;
+  InitEvents;
+  InitSysError;
+  Redraw;
+  CurDirChanged;
+  Message(Application,evBroadcast,cmUpdate,nil);
+end;
+
 {$I FPMFILE.INC}
 
 {$I FPMEDIT.INC}
 
+{$I FPMRUN.INC}
+
 {$I FPMCOMP.INC}
 
+{$I FPMDEBUG.INC}
+
 {$I FPMTOOLS.INC}
 
 {$I FPMOPTS.INC}
@@ -442,27 +513,43 @@ begin
 end;
 
 BEGIN
+  writeln('þ Free Pascal IDE  Version '+VersionStr);
+  StartupDir:=CompleteDir(FExpand('.'));
+
   InitReservedWords;
+  InitHelpFiles;
+  InitSwitches;
+  InitINIFile;
+  InitUserScreen;
 
 { load old options }
-  InitOptions;
-  ReadOptions('fp.cfg');
+  ReadINIFile;
+  ReadSwitches(SwitchesPath);
 
   MyApp.Init;
   InitApp;
   MyApp.Run;
   MyApp.Done;
 
-  WriteOptions('fp.cfg');
-  DoneOptions;
+  WriteSwitches(SwitchesPath);
+  WriteINIFile;
+
+  DoneUserScreen;
+  DoneSwitches;
+  DoneHelpFiles;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:40  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.3  1998/12/22 10:39:38  peter
     + options are now written/read
     + find and replace routines
 
-}
+}

+ 0 - 502
ide/text/fpcfgs.pas

@@ -1,502 +0,0 @@
-{
-    $Id$
-    This file is part of the Free Pascal Integrated Development Environment
-    Copyright (c) 1998 by Berczi Gabor
-
-    Options/config routines for the IDE
-
-    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.
-
- **********************************************************************}
-unit FPCfgs;
-
-interface
-
-uses
-  Objects,
-  Systems;
-
-const
-     MinStackSize    = 1024;
-     MaxStackSize    = 67107840;
-     MinHeapSize     = 1024;
-     MaxHeapSize     = 67107840;
-
-type
-    TOptionMode = (om_Normal,om_Debug,om_Release);
-
-    TOptionToggle = array[TOptionMode] of boolean;
-    TOptionString = array[TOptionMode] of string;
-    TOptionValue  = array[TOptionMode] of longint;
-
-    POptionItem = ^TOptionItem;
-    TOptionItem = record
-      Name      : string[30];
-      Param     : string[10];
-      IsSet     : TOptionToggle;
-    end;
-
-    POptionItemCollection = ^TOptionItemCollection;
-    TOptionItemCollection = object(TCollection)
-      function  At(Index: Integer): POptionItem;
-      procedure FreeItem(Item: Pointer); virtual;
-    end;
-
-    POptions = ^TOptions;
-    TOptions = object
-      constructor InitToggle(ch:char);
-      constructor InitSel(ch:char);
-      destructor  Done;
-      { items }
-      procedure AddItem(const name,param:string);
-      function  ItemCount:integer;
-      function  ItemName(index:integer):string;
-      function  ItemParam(index:integer):string;
-      function  ItemIsSet(index:integer):boolean;
-      procedure ItemSet(index:integer;b:boolean);
-      function  GetCurrSel:integer;
-      procedure SetCurrSel(index:integer);
-      { read / write to cfgfile which must be open }
-      procedure WriteItemsCfg;
-      function  ReadItemsCfg(const s:string):boolean;
-    private
-      IsSel  : boolean;
-      Prefix : char;
-      SelNr  : integer;
-      Items  : POptionItemCollection;
-    end;
-
-    PDirectories = ^TDirectories;
-    TDirectories = record
-      LibraryDirs,
-      IncludeDirs,
-      UnitDirs,
-      ObjectDirs  : TOptionString;
-    end;
-
-const
-    OptionMode : TOptionMode = om_Normal;
-
-var
-    SyntaxOptions,
-    VerboseOptions,
-    CodegenOptions,
-    OptimizationOptions,
-    ProcessorOptions,
-    AsmReaderOptions,
-    TargetOptions : POptions;
-    Dirs          : PDirectories;
-    CondDefs      : TOptionString;
-
-{ other settings }
-function GetConditionalDefines: string;
-procedure SetConditionalDefines(const Defs: string);
-
-{ write/read the options to ppc.cfg file }
-procedure WriteOptions(const fn:string);
-procedure ReadOptions(const fn:string);
-
-{ initialize }
-procedure InitOptions;
-procedure DoneOptions;
-
-
-implementation
-
-uses
-  GlobType,Tokens,Compiler;
-
-var
-  CfgFile : text;
-
-
-{*****************************************************************************
-                             TOptionItemCollection
-*****************************************************************************}
-
-function  TOptionItemCollection.At(Index: Integer): POptionItem;
-begin
-  At:=inherited At(Index);
-end;
-
-procedure TOptionItemCollection.FreeItem(Item: Pointer);
-begin
-  if assigned(Item) then
-   Dispose(POptionItem(Item));
-end;
-
-
-{*****************************************************************************
-                                   TOption
-*****************************************************************************}
-
-function NewOptionItem(const Name,Param:string):POptionItem;
-var
-  P : POptionItem;
-begin
-  New(P);
-  P^.Name:=Name;
-  P^.Param:=Param;
-  FillChar(P^.IsSet,sizeof(P^.IsSet),0);
-  NewOptionItem:=P;
-end;
-
-
-constructor TOptions.InitToggle(ch:char);
-begin
-  new(Items,Init(10,5));
-  Prefix:=ch;
-  SelNr:=0;
-  IsSel:=false;
-end;
-
-
-constructor TOptions.InitSel(ch:char);
-begin
-  new(Items,Init(10,5));
-  Prefix:=ch;
-  SelNr:=0;
-  IsSel:=true;
-end;
-
-
-destructor  TOptions.Done;
-begin
-  dispose(Items,Done);
-end;
-
-
-procedure TOptions.AddItem(const name,param:string);
-begin
-  Items^.Insert(NewOptionItem(name,Param));
-end;
-
-
-function TOptions.ItemCount:integer;
-begin
-  ItemCount:=Items^.Count;
-end;
-
-
-function TOptions.ItemName(index:integer):string;
-var
-  P : POptionItem;
-begin
-  P:=Items^.At(Index);
-  if assigned(P) then
-   ItemName:=P^.Name
-  else
-   ItemName:='';
-end;
-
-
-function TOptions.ItemParam(index:integer):string;
-var
-  P : POptionItem;
-begin
-  P:=Items^.At(Index);
-  if assigned(P) then
-   ItemParam:='-'+Prefix+P^.Param
-  else
-   ItemParam:='';
-end;
-
-
-function TOptions.ItemIsSet(index:integer):boolean;
-var
-  P : POptionItem;
-begin
-  if not IsSel then
-   begin
-     P:=Items^.At(Index);
-     if assigned(P) then
-      ItemIsSet:=P^.IsSet[OptionMode]
-     else
-      ItemIsSet:=false;
-   end
-  else
-   ItemIsSet:=false;
-end;
-
-
-procedure TOptions.ItemSet(index:integer;b:boolean);
-var
-  P : POptionItem;
-begin
-  if not IsSel then
-   begin
-     P:=Items^.At(Index);
-     if assigned(P) then
-      P^.IsSet[OptionMode]:=b;
-   end;
-end;
-
-
-function TOptions.GetCurrSel:integer;
-begin
-  if IsSel then
-   GetCurrSel:=SelNr
-  else
-   GetCurrSel:=-1;
-end;
-
-
-procedure TOptions.SetCurrSel(index:integer);
-begin
-  if IsSel then
-   SelNr:=index;
-end;
-
-
-procedure TOptions.WriteItemsCfg;
-var
-  Pref : char;
-
-  procedure writeitem(P:POptionItem);{$ifndef FPC}far;{$endif}
-  begin
-    if (P^.Param<>'') and (P^.IsSet[OptionMode]) then
-      Writeln(CfgFile,'-'+Pref+P^.Param)
-  end;
-
-begin
-  Pref:=Prefix;
-  if IsSel then
-   begin
-     writeln(CfgFile,ItemParam(SelNr));
-   end
-  else
-   begin
-     Items^.ForEach(@writeitem);
-   end;
-end;
-
-
-function TOptions.ReadItemsCfg(const s:string):boolean;
-var
-  FoundP : POptionItem;
-
-  function checkitem(P:POptionItem):boolean;{$ifndef FPC}far;{$endif}
-  begin
-    CheckItem:=(P^.Param=s);
-  end;
-
-begin
-  FoundP:=Items^.FirstThat(@checkitem);
-  if assigned(FoundP) then
-   begin
-     if IsSel then
-      SelNr:=Items^.IndexOf(FoundP)
-     else
-      FoundP^.IsSet[OptionMode]:=true;
-     ReadItemsCfg:=true;
-   end
-  else
-   ReadItemsCfg:=false;
-end;
-
-
-{*****************************************************************************
-                                    Others
-*****************************************************************************}
-
-function GetConditionalDefines: string;
-begin
-  GetConditionalDefines:=CondDefs[OptionMode];
-end;
-
-
-procedure SetConditionalDefines(const Defs: string);
-begin
-  CondDefs[OptionMode]:=Defs;
-end;
-
-
-procedure WriteConditionalDefines;
-var
-  s,s1 : string;
-  i : integer;
-begin
-  s:=CondDefs[OptionMode];
-  repeat
-    i:=pos(' ',s);
-    if i=0 then
-     i:=255;
-    s1:=Copy(s,1,i-1);
-    if s1<>'' then
-     writeln(CfgFile,'-d'+s1);
-    Delete(s,1,i);
-  until s='';
-end;
-
-
-procedure ReadConditionalDefines(const s:string);
-begin
-  CondDefs[OptionMode]:=CondDefs[OptionMode]+s;
-end;
-
-
-{*****************************************************************************
-                                 Read / Write
-*****************************************************************************}
-
-procedure WriteOptions(const fn:string);
-begin
-{ create the switches }
-  assign(CfgFile,fn);
-  {$I-}
-   rewrite(CfgFile);
-  {$I+}
-  if ioresult<>0 then
-   exit;
-  writeln(CfgFile,'# Automaticly created file, don''t edit.');
-  TargetOptions^.WriteItemsCfg;
-  VerboseOptions^.WriteItemsCfg;
-  SyntaxOptions^.WriteItemsCfg;
-  CodegenOptions^.WriteItemsCfg;
-  OptimizationOptions^.WriteItemsCfg;
-  ProcessorOptions^.WriteItemsCfg;
-  AsmReaderOptions^.WriteItemsCfg;
-  WriteConditionalDefines;
-  close(CfgFile);
-end;
-
-
-procedure ReadOptions(const fn:string);
-var
-  c : char;
-  s : string;
-begin
-  assign(CfgFile,fn);
-  {$I-}
-   reset(CfgFile);
-  {$I+}
-  if ioresult<>0 then
-   exit;
-  while not eof(CfgFile) do
-   begin
-     readln(CfgFile,s);
-     if (length(s)>2) and (s[1]='-') then
-      begin
-        c:=s[2];
-        Delete(s,1,2);
-        case c of
-         'd' : ReadConditionalDefines(s);
-         'S' : SyntaxOptions^.ReadItemsCfg(s);
-         'T' : TargetOptions^.ReadItemsCfg(s);
-         'R' : AsmReaderOptions^.ReadItemsCfg(s);
-         'C' : CodegenOptions^.ReadItemsCfg(s);
-         'v' : VerboseOptions^.ReadItemsCfg(s);
-         'O' : begin
-                 if not OptimizationOptions^.ReadItemsCfg(s) then
-                  ProcessorOptions^.ReadItemsCfg(s);
-               end;
-        end;
-      end;
-   end;
-  close(CfgFile);
-end;
-
-
-
-{*****************************************************************************
-                                 Initialize
-*****************************************************************************}
-
-procedure InitOptions;
-begin
-  New(SyntaxOptions,InitToggle('S'));
-  with SyntaxOptions^ do
-   begin
-     AddItem('~D~elphi 2 extensions on','2');
-     AddItem('~C~-like operators','c');
-     AddItem('S~t~op after first error','e');
-     AddItem('Allo~w~ LABEL and GOTO','g');
-     AddItem('C++ styled ~i~nline','i');
-     AddItem('Global C ~m~acros','m');
-     AddItem('TP/BP ~7~.0 compatibility','o');
-     AddItem('Del~p~hi compatibility','d');
-     AddItem('A~l~low STATIC in objects','s');
-   end;
-  New(VerboseOptions,InitToggle('v'));
-  with VerboseOptions^ do
-   begin
-     AddItem('~W~arnings','w');
-     AddItem('~N~otes','n');
-     AddItem('~H~ints','h');
-     AddItem('General ~I~nfo','i');
-     AddItem('~U~sed,tried info','ut');
-     AddItem('~A~ll','a');
-     AddItem('Show all ~P~rocedures if error','b');
-   end;
-  New(CodegenOptions,InitToggle('C'));
-  with CodegenOptions^ do
-   begin
-     AddItem('~R~ange checking','r');
-     AddItem('~S~tack checking','t');
-     AddItem('~I~/O checking','i');
-     AddItem('Integer ~o~verflow checking','o');
-   end;
-  New(OptimizationOptions,InitToggle('O'));
-  with OptimizationOptions^ do
-   begin
-     AddItem('Generate ~s~maller code','g');
-     AddItem('Generate ~f~aster code','G');
-     AddItem('Use register-~v~ariables','r');
-     AddItem('~U~ncertain optimizations','u');
-     AddItem('Level ~1~ optimizations','1');
-     AddItem('Level ~2~ optimizations','2');
-   end;
-  New(ProcessorOptions,InitSel('O'));
-  with ProcessorOptions^ do
-   begin
-     AddItem('i~3~86/i486','p1');
-     AddItem('Pentium/PentiumMM~X~ (tm)','p2');
-     AddItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
-   end;
-  New(TargetOptions,InitSel('T'));
-  with TargetOptions^ do
-   begin
-     AddItem('DOS (GO32V~1~)','go32v1');
-     AddItem('~D~OS (GO32V2)','go32v2');
-     AddItem('~L~inux','linux');
-     AddItem('~O~S/2','os2');
-     AddItem('~W~IN32','win32');
-   end;
-  New(AsmReaderOptions,InitSel('R'));
-  with AsmReaderOptions^ do
-   begin
-     AddItem('No preprocessin~g~','direct');
-     AddItem('~A~T&T style assembler','att');
-     AddItem('Int~e~l style assembler','intel');
-   end;
-end;
-
-
-procedure DoneOptions;
-begin
-  dispose(SyntaxOptions,Done);
-  dispose(VerboseOptions,Done);
-  dispose(CodegenOptions,Done);
-  dispose(OptimizationOptions,Done);
-  dispose(ProcessorOptions,Done);
-  dispose(TargetOptions,Done);
-  dispose(AsmReaderOptions,Done);
-end;
-
-
-end.
-{
-  $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
-
-  Revision 1.1  1998/12/22 10:39:40  peter
-    + options are now written/read
-    + find and replace routines
-
-}

+ 32 - 47
ide/text/fpcompil.pas

@@ -20,10 +20,7 @@ interface
 uses FPViews;
 
 type
-    TCompileMode = (cBuild,cMake,cCompile);
-
-{$ifdef OLDCOMPSTAT}
-    TCompPhase = (cpCompiling,cpLinking,cpDone);
+    TCompileMode = (cBuild,cMake,cCompile,cRun);
 
     PCompileStatusDialog = ^TCompileStatusDialog;
     TCompileStatusDialog = object(TCenterDialog)
@@ -31,39 +28,26 @@ type
       KeyST : PColorStaticText;
       constructor Init;
       procedure   Update;
+    private
+      MsgLB: PMessageListBox;
     end;
-{$endif}
-
-const
-      PrimaryFile    : string = '';
-      IsEXECompiled  : boolean = false;
-      MainFile         : string = '';
-
-{$ifdef OLDCOMPSTAT}
-      CompilationPhase : TCompPhase = cpDone;
-{$endif}
-      ProgramInfoWindow : PProgramInfoWindow = nil;
-
 
 procedure DoCompile(Mode: TCompileMode);
 
-
 implementation
 
 uses
-  Video,
+  Video,CRt,
   Objects,Drivers,Views,App,
   CompHook,
-  FPConst,FPUtils,FPIntf;
-
-{$ifdef OLDCOMPSTAT}
+  FPConst,FPVars,FPUtils,FPIntf,FPSwitches;
 
 const SD: PCompileStatusDialog = nil;
 
 constructor TCompileStatusDialog.Init;
 var R: TRect;
 begin
-  R.Assign(0,0,50,11{+7});
+  R.Assign(0,0,50,11+7);
   inherited Init(R, 'Compiling');
   GetExtent(R); R.B.Y:=11;
   R.Grow(-3,-2);
@@ -73,10 +57,10 @@ begin
   R.Grow(-1,-1); R.A.Y:=R.B.Y-1;
   New(KeyST, Init(R, '', Blue*16+White+longint($80+Blue*16+White)*256));
   Insert(KeyST);
-{  GetExtent(R); R.Grow(-1,-1); R.A.Y:=10;
-  New(MsgLB, Init(R, 1, nil));
+  GetExtent(R); R.Grow(-1,-1); R.A.Y:=10;
+  New(MsgLB, Init(R, nil, nil));
   MsgLB^.NewList(New(PUnsortedStringCollection, Init(100,100)));
-  Insert(MsgLB);}
+  Insert(MsgLB);
 end;
 
 
@@ -106,7 +90,7 @@ begin
   ST^.SetText(
     'Main file: '+MainFile+#13+
     StatusS+#13#13+
-    'Target: '+LExpand(KillTilde(GetTargetOSName(GetTargetOS)),12)+'    '+
+    'Target: '+LExpand(KillTilde(TargetSwitches^.ItemName(TargetSwitches^.GetCurrSel)),12)+'    '+
     'Line number: '+IntToStrL(Status.CurrentLine,7)+#13+
     'Free memory: '+IntToStrL(MemAvail div 1024,6)+'K'+ '    '+
     'Total lines: '+IntToStrL(Status.CompiledLines,7)+#13+
@@ -115,8 +99,6 @@ begin
   KeyST^.SetText(^C+KeyS);
 end;
 
-{$endif}
-
 
 {****************************************************************************
                                Compiler Hooks
@@ -124,9 +106,7 @@ end;
 
 function CompilerStatus: boolean; {$ifndef FPC}far;{$endif}
 begin
-{$ifdef OLDCOMPSTAT}
   SD^.Update;
-{$endif}
   CompilerStatus:=false;
 end;
 
@@ -138,8 +118,12 @@ end;
 
 function CompilerComment(Level:Longint; const s:string):boolean; {$ifndef FPC}far;{$endif}
 begin
-  ProgramInfoWindow^.AddMessage(Level,S,SmartPath(status.currentmodule),status.currentline);
   CompilerComment:=false;
+  if (status.verbosity and Level)=Level then
+   begin
+     ProgramInfoWindow^.AddMessage(Level,S,SmartPath(status.currentmodule),status.currentline);
+     SD^.MsgLB^.AddItem(New(PCompilerMessage, Init(Level, S, SmartPath(status.currentmodule),status.currentline)));
+   end;
 end;
 
 
@@ -160,7 +144,7 @@ var
   P: PSourceWindow;
   FileName: string;
   E: TEvent;
-  WasVisible: boolean;
+{  WasVisible: boolean;}
 begin
 { Get FileName }
   P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
@@ -184,18 +168,17 @@ begin
 { Reset }
   CtrlBreakHit:=false;
 { Show Program Info }
-  WasVisible:=ProgramInfoWindow^.GetState(sfVisible);
+{  WasVisible:=ProgramInfoWindow^.GetState(sfVisible);
   ProgramInfoWindow^.LogLB^.Clear;
   if WasVisible=false then
     ProgramInfoWindow^.Show;
-  ProgramInfoWindow^.MakeFirst;
+  ProgramInfoWindow^.MakeFirst;}
 
-{$ifdef OLDCOMPSTAT}
   CompilationPhase:=cpCompiling;
   New(SD, Init);
+  SD^.SetState(sfModal,true);
   Application^.Insert(SD);
   SD^.Update;
-{$endif}
 
   do_status:=CompilerStatus;
   do_stop:=CompilerStop;
@@ -203,32 +186,34 @@ begin
 
   Compile(FileName);
 
-{$ifdef OLDCOMPSTAT}
   CompilationPhase:=cpDone;
   SD^.Update;
-{$endif}
 
-  if status.errorcount=0 then
+  if ((status.errorcount=0) or (ShowStatusOnError)) and (Mode<>cRun) then
    repeat
-     Application^.GetEvent(E);
+     SD^.GetEvent(E);
      if IsExitEvent(E)=false then
-      Application^.HandleEvent(E);
+      SD^.HandleEvent(E);
    until IsExitEvent(E);
 
-{$ifdef OLDCOMPSTAT}
   Application^.Delete(SD);
+  SD^.SetState(sfModal,false);
   Dispose(SD, Done);
-{$endif}
 
-  if (WasVisible=false) and (status.errorcount=0) then
-   ProgramInfoWindow^.Hide;
+{  if (WasVisible=false) and (status.errorcount=0) then
+   ProgramInfoWindow^.Hide;}
 end;
 
 end.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:42  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.3  1998/12/22 10:39:40  peter
     + options are now written/read

+ 66 - 17
ide/text/fpconst.pas

@@ -20,7 +20,12 @@ interface
 uses Views,App,Commands;
 
 const
-     VersionStr      = '0.9';
+     VersionStr           = '0.9';
+
+     MaxRecentFileCount   = 5;
+
+     ININame              = 'fp.ini';
+     SwitchesName         = 'fp.cfg';
 
      { Strings/Messages }
      strLoadingHelp       = 'Loading help files...';
@@ -30,6 +35,17 @@ const
      { Main menu submenu indexes }
      menuFile             = 0;
 
+     { MouseAction constants }
+     acNone               = 0;
+     acTopicSearch        = 1;
+     acGotoCursor         = 2;
+     acBreakpoint         = 3;
+     acEvaluate           = 4;
+     acAddWatch           = 5;
+     acBrowseSymbol       = 6;
+     acFirstAction        = acTopicSearch;
+     acLastAction         = acBrowseSymbol;
+
      { Command constants }
      cmShowClipboard     = 201;
      cmFindProcedure     = 206;
@@ -38,16 +54,20 @@ const
      cmGlobals           = 209;
      cmRun               = 210;
      cmParameters        = 211;
-     cmUserScreen        = 212;
-     cmCompile           = 213;
-     cmMake              = 214;
-     cmBuild             = 215;
-     cmTarget            = 216;
-     cmPrimaryFile       = 217;
-     cmClearPrimary      = 218;
-     cmInformation       = 219;
-     cmWindowList        = 220;
-     cmHelpTopicSearch   = 221;
+     cmCompile           = 212;
+     cmMake              = 213;
+     cmBuild             = 214;
+     cmTarget            = 215;
+     cmPrimaryFile       = 216;
+     cmClearPrimary      = 217;
+     cmInformation       = 218;
+     cmWindowList        = 219;
+     cmHelpTopicSearch   = 220;
+     cmMsgGotoSource     = 221;
+     cmMsgTrackSource    = 222;
+     cmGotoCursor        = 223;
+     cmToggleBreakpoint  = 224;
+     cmAddWatch          = 225;
 
      cmNotImplemented    = 1000;
      cmNewFromTemplate   = 1001;
@@ -58,6 +78,14 @@ const
      cmDeleteWnd         = 1602;
      cmLocalMenu         = 1603;
      cmCalculatorPaste   = 1604;
+     cmAddTPH            = 1605;
+     cmDeleteTPH         = 1606;
+     cmMsgClear          = 1607;
+
+     cmUserScreen        = 1650;
+     cmUserScreenWindow  = 1651;
+     cmEvaluate          = 1652;
+     cmCalculator        = 1653;
 
      cmToolsMessages     = 1700;
      cmToolsBase         = 1800;
@@ -74,14 +102,17 @@ const
      cmMouse             = 2008;
      cmStartup           = 2009;
      cmColors            = 2010;
-     cmCalculator        = 2011;
-     cmAbout             = 2050;
+     cmOpenINI           = 2011;
+     cmSaveINI           = 2012;
+     cmSaveAsINI         = 2013;
+     cmSetSwitchesMode   = 2014;
 
      cmHelpContents      = 2100;
      cmHelpIndex         = 2101;
      cmHelpPrevTopic     = 2103;
      cmHelpUsingHelp     = 2104;
      cmHelpFiles         = 2105;
+     cmAbout             = 2106;
 
      cmOpenAtCursor      = 2200;
      cmBrowseAtCursor    = 2201;
@@ -104,6 +135,9 @@ const
      hcSearchAgain       = hcShift+cmSearchAgain;
      hcGotoLine          = hcShift+cmJumpLine;
 
+     hcUserScreen        = hcShift+cmUserScreen;
+     hcUserScreenWindow  = hcShift+cmUserScreenWindow;
+
      hcToolsMessages     = hcShift+cmToolsMessages;
      hcToolsBase         = hcShift+cmToolsBase;
      hcRecentFileBase    = hcShift+cmRecentFileBase;
@@ -119,7 +153,11 @@ const
      hcMouse             = hcShift+cmMouse;
      hcStartup           = hcShift+cmStartup;
      hcColors            = hcShift+cmColors;
+     hcOpenINI           = hcShift+cmOpenINI;
+     hcSaveINI           = hcShift+cmSaveINI;
+     hcSaveAsINI         = hcShift+cmSaveAsINI;
      hcCalculator        = hcShift+cmCalculator;
+     hcSetSwitchesMode   = hcShift+cmSetSwitchesMode;
      hcAbout             = hcShift+cmAbout;
 
      hcSystemMenu        = 9000;
@@ -145,7 +183,6 @@ const
      hcGlobals           = hcShift+cmGlobals;
      hcRun               = hcShift+cmRun;
      hcParameters        = hcShift+cmParameters;
-     hcUserScreen        = hcShift+cmUserScreen;
      hcCompile           = hcShift+cmCompile;
      hcMake              = hcShift+cmMake;
      hcBuild             = hcShift+cmBuild;
@@ -162,6 +199,13 @@ const
      hcHelpUsingHelp     = hcShift+cmHelpUsingHelp;
      hcHelpFiles         = hcShift+cmHelpFiles;
      hcUpdate            = hcShift+cmUpdate;
+     hcMsgClear          = hcShift+cmMsgClear;
+     hcMsgGotoSource     = hcShift+cmMsgGotoSource;
+     hcMsgTrackSource    = hcShift+cmMsgTrackSource;
+     hcGotoCursor        = hcShift+cmGotoCursor;
+     hcToggleBreakpoint  = hcShift+cmToggleBreakpoint;
+     hcEvaluate          = hcShift+cmEvaluate;
+     hcAddWatch          = hcShift+cmAddWatch;
 
      hcOpenAtCursor      = hcShift+cmOpenAtCursor;
      hcBrowseAtCursor    = hcShift+cmBrowseAtCursor;
@@ -181,7 +225,7 @@ const
         #183#184#185#186#187#188#189#190#191#192#193#194#195#196#197#198 +
         #199#200#201#202#203#204#205#206#207#208#209#210#211#212#213#214 ;
 
-     CIDEAppColor        = CAppColor +
+     CIDEAppColor = CAppColor +
          { CIDEHelpDialog }
 {128-143}#$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 + { 1-16}
 {144-159}#$3F#$3E#$1F#$2F#$1A#$20#$72#$31#$31#$30#$2F#$3E#$31#$13#$38#$00 + {17-32}
@@ -197,8 +241,13 @@ implementation
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:43  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.3  1998/12/22 10:39:41  peter
     + options are now written/read

+ 29 - 7
ide/text/fphelp.pas

@@ -36,9 +36,13 @@ type
 procedure Help(FileID, Context: word; Modal: boolean);
 procedure HelpIndex(Keyword: string);
 procedure HelpTopicSearch(Editor: PEditor);
+
 procedure InitHelpSystem;
 procedure DoneHelpSystem;
 
+procedure InitHelpFiles;
+procedure DoneHelpFiles;
+
 procedure PushStatus(S: string);
 procedure SetStatus(S: string);
 procedure ClearStatus;
@@ -52,7 +56,7 @@ implementation
 
 uses Objects,Views,App,MsgBox,
      WHelp,
-     FPConst,FPUtils;
+     FPConst,FPVars,FPUtils;
 
 var StatusStack : array[0..10] of string[MaxViewWidth];
 
@@ -86,6 +90,7 @@ begin
 
     hcFileMenu      : S:='File managment commands (Open, New, Save, etc.)';
     hcNew           : S:='Create a new file in a new edit window';
+    hcNewFromTemplate:S:='Create a new file using a code template';
     hcOpen          : S:='Locate and open a file in an edit window';
     hcSave          : S:='Save the file in the active edit window';
     hcSaveAs        : S:='Save the current file under a different name, directory or drive';
@@ -146,6 +151,10 @@ begin
     hcEditor        : S:='Specify default editor settings';
     hcMouse         : S:='Specify mouse settings';
     hcStartup       : S:='Permanently change default startup options';
+    hcColors        : S:='Costumize IDE colors for windows, menus, editors, etc.';
+    hcOpenINI       : S:='Load a previously saved options file';
+    hcSaveINI       : S:='Save all the changes made in the options menu';
+    hcSaveAsINI     : S:='Save all the changes made under a different name';
 
     hcWindowMenu    : S:='Windows managment commands';
     hcTile          : S:='Arrange windows on desktop by tiling';
@@ -181,13 +190,12 @@ begin
   HelpFacility^.AddHelpFile(HelpFile);
   {$IFDEF DEBUG}SetStatus(strLoadingHelp);{$ENDIF}
 end;
+var I: integer;
 begin
   New(HelpFacility, Init);
   PushStatus(strLoadingHelp);
-  AddFile('C:\BP\BIN\TURBO.TPH');
-{  AddFile('C:\BP\BIN\TVISION.TPH');
-  AddFile('C:\BP\BIN\OWL.TPH');
-  AddFile('C:\BP\BIN\WINDOWS.TPH');}
+  for I:=0 to HelpFiles^.Count-1 do
+    AddFile(HelpFiles^.At(I)^);
   PopStatus;
 end;
 
@@ -293,12 +301,26 @@ begin
   PAdvancedStatusLine(StatusLine)^.ClearStatusText;
 end;
 
+procedure InitHelpFiles;
+begin
+  New(HelpFiles, Init(10,10));
+end;
+
+procedure DoneHelpFiles;
+begin
+  if HelpFiles<>nil then Dispose(HelpFiles, Done);
+end;
 
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:44  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.3  1998/12/22 10:39:42  peter
     + options are now written/read

+ 234 - 0
ide/text/fpini.pas

@@ -0,0 +1,234 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Write/Read Options to INI File
+
+    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.
+
+ **********************************************************************}
+unit FPIni;
+interface
+
+uses
+  FPUtils;
+
+const
+    ININame = 'fp.ini';
+
+    ConfigDir  : string = '.'+DirSep;
+    INIFileName: string = ININame;
+
+
+procedure InitINIFile;
+function  ReadINIFile: boolean;
+function  WriteINIFile: boolean;
+
+
+implementation
+
+uses
+  Dos,Objects,Drivers,
+  WINI,{$ifndef EDITORS}WEditor{$else}Editors{$endif},
+  FPConst,FPVars,FPIntf;
+
+const
+  { INI file sections }
+  secFiles           = 'Files';
+  secRun             = 'Run';
+  secCompile         = 'Compile';
+  secColors          = 'Colors';
+  secHelp            = 'Help';
+  secEditor          = 'Editor';
+  secHighlight       = 'Highlight';
+  secMouse           = 'Mouse';
+
+  { INI file tags }
+  ieRecentFile       = 'RecentFile';
+  ieRunParameters    = 'Parameters';
+  iePrimaryFile      = 'PrimaryFile';
+  iePalette          = 'Palette';
+  ieHelpFiles        = 'Files';
+  ieDefaultTabSize   = 'DefaultTabSize';
+  ieDefaultEditorFlags='DefaultFlags';
+  ieHighlightExts    = 'Exts';
+  ieDoubleClickDelay = 'DoubleDelay';
+  ieReverseButtons   = 'ReverseButtons';
+  ieAltClickAction   = 'AltClickAction';
+  ieCtrlClickAction  = 'CtrlClickAction';
+
+procedure InitINIFile;
+begin
+  INIPath:=LocateFile(ININame);
+  if INIPath='' then
+    INIPath:=ININame;
+  INIPath:=FExpand(INIPath);
+end;
+
+function PaletteToStr(S: string): string;
+var C: string;
+    I: integer;
+begin
+  C:='';
+  for I:=1 to length(S) do
+    begin
+      C:=C+'#$'+IntToHexL(ord(S[I]),2);
+    end;
+  PaletteToStr:=C;
+end;
+
+function StrToPalette(S: string): string;
+var I,P,X: integer;
+    C: string;
+    Hex: boolean;
+    OK: boolean;
+begin
+  C:=''; I:=1;
+  OK:=S<>'';
+  while OK and (I<=length(S)) and (S[I]='#') do
+  begin
+    Inc(I); Hex:=false;
+    if S[I]='$' then begin Inc(I); Hex:=true; end;
+    P:=Pos('#',copy(S,I,255)); if P>0 then P:=I+P-1 else P:=length(S)+1;
+    if Hex=false then
+      begin
+        X:=StrToInt(copy(S,I,P-I));
+        OK:=(LastStrToIntResult=0) and (0<=X) and (X<=255);
+      end
+    else
+      begin
+        X:=HexToInt(copy(S,I,P-I));
+        OK:=(LastHexToIntResult=0) and (0<=X) and (X<=255);
+      end;
+    if OK then C:=C+chr(X);
+    Inc(I,P-I);
+  end;
+  StrToPalette:=C;
+end;
+
+function ReadINIFile: boolean;
+var INIFile: PINIFile;
+    S,PS: string;
+    I,P: integer;
+    OK: boolean;
+begin
+  OK:=ExistsFile(INIPath);
+  if OK=false then
+ begin
+  New(INIFile, Init(INIPath));
+  RecentFileCount:=High(RecentFiles);
+  for I:=Low(RecentFiles) to High(RecentFiles) do
+    begin
+      S:=INIFile^.GetEntry(secFiles,ieRecentFile+IntToStr(I),'');
+      if (S='') and (RecentFileCount>I-1) then RecentFileCount:=I-1;
+      with RecentFiles[I] do
+      begin
+        P:=Pos(',',S); if P=0 then P:=length(S)+1;
+        FileName:=copy(S,1,P-1); Delete(S,1,P);
+        P:=Pos(',',S); if P=0 then P:=length(S)+1;
+        LastPos.X:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
+        P:=Pos(',',S); if P=0 then P:=length(S)+1;
+        LastPos.Y:=Max(0,StrToInt(copy(S,1,P-1))); Delete(S,1,P);
+      end;
+    end;
+  SetRunParameters(INIFile^.GetEntry(secRun,ieRunParameters,GetRunParameters));
+  PrimaryFile:=INIFile^.GetEntry(secCompile,iePrimaryFile,PrimaryFile);
+  S:=INIFile^.GetEntry(secHelp,ieHelpFiles,'');
+  repeat
+    P:=Pos(';',S); if P=0 then P:=length(S)+1;
+    PS:=copy(S,1,P-1);
+    if PS<>'' then HelpFiles^.Insert(NewStr(PS));
+    Delete(S,1,P);
+  until S='';
+{$ifndef EDITORS}
+  DefaultTabSize:=INIFile^.GetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
+  DefaultCodeEditorFlags:=INIFile^.GetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
+{$endif}
+  HighlightExts:=INIFile^.GetEntry(secHighlight,ieHighlightExts,HighlightExts);
+  DoubleDelay:=INIFile^.GetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
+  MouseReverse:=boolean(INIFile^.GetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse)));
+  AltMouseAction:=INIFile^.GetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
+  CtrlMouseAction:=INIFile^.GetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
+  S:=AppPalette;
+  PS:=StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40))));
+  PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40))));
+  PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40))));
+  PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40))));
+  PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40))));
+  PS:=PS+StrToPalette(INIFile^.GetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40))));
+  AppPalette:=PS;
+  Dispose(INIFile, Done);
+ end;
+  ReadINIFile:=OK;
+end;
+
+function WriteINIFile: boolean;
+var INIFile: PINIFile;
+    S: string;
+    I: integer;
+    OK: boolean;
+procedure ConcatName(P: PString); {$ifndef FPC}far;{$endif}
+begin
+  if (S<>'') then S:=S+';';
+  S:=S+P^;
+end;
+begin
+  New(INIFile, Init(INIPath));
+  for I:=1 to High(RecentFiles) do
+    begin
+      if I<=RecentFileCount then
+         with RecentFiles[I] do S:=FileName+','+IntToStr(LastPos.X)+','+IntToStr(LastPos.Y)
+      else
+         S:='';
+      INIFile^.SetEntry(secFiles,ieRecentFile+IntToStr(I),S);
+    end;
+  INIFile^.SetEntry(secRun,ieRunParameters,GetRunParameters);
+  INIFile^.SetEntry(secCompile,iePrimaryFile,PrimaryFile);
+  S:='';
+  HelpFiles^.ForEach(@ConcatName);
+  INIFile^.SetEntry(secHelp,ieHelpFiles,'"'+S+'"');
+{$ifndef EDITORS}
+  INIFile^.SetIntEntry(secEditor,ieDefaultTabSize,DefaultTabSize);
+  INIFile^.SetIntEntry(secEditor,ieDefaultEditorFlags,DefaultCodeEditorFlags);
+{$endif}
+  INIFile^.SetEntry(secHighlight,ieHighlightExts,HighlightExts);
+  INIFile^.SetIntEntry(secMouse,ieDoubleClickDelay,DoubleDelay);
+  INIFile^.SetIntEntry(secMouse,ieReverseButtons,byte(MouseReverse));
+  INIFile^.SetIntEntry(secMouse,ieAltClickAction,AltMouseAction);
+  INIFile^.SetIntEntry(secMouse,ieCtrlClickAction,CtrlMouseAction);
+  if AppPalette<>CIDEAppColor then
+  begin
+    { this has a bug. if a different palette has been read on startup, and
+      then changed back to match the default, this will not update it in the
+      ini file, eg. the original (non-default) will be left unmodified... }
+    S:=AppPalette;
+    INIFile^.SetEntry(secColors,iePalette+'_1_40',PaletteToStr(copy(S,1,40)));
+    INIFile^.SetEntry(secColors,iePalette+'_41_80',PaletteToStr(copy(S,41,40)));
+    INIFile^.SetEntry(secColors,iePalette+'_81_120',PaletteToStr(copy(S,81,40)));
+    INIFile^.SetEntry(secColors,iePalette+'_121_160',PaletteToStr(copy(S,121,40)));
+    INIFile^.SetEntry(secColors,iePalette+'_161_200',PaletteToStr(copy(S,161,40)));
+    INIFile^.SetEntry(secColors,iePalette+'_201_240',PaletteToStr(copy(S,201,40)));
+  end;
+  OK:=INIFile^.Update;
+  Dispose(INIFile, Done);
+  WriteINIFile:=OK;
+end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:45  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+}

+ 12 - 4
ide/text/fpintf.pas

@@ -27,7 +27,7 @@ implementation
 
 uses
   Compiler,
-  FPCfgs;
+  FPSwitches;
 
 {****************************************************************************
                                    Run
@@ -53,15 +53,23 @@ end;
 
 procedure Compile(const FileName: string);
 begin
-  WriteOptions('fp.cfg');
+{   WriteSwitches('fp.cfg'); }
 { call the compiler }
-  Compiler.Compile('[fp.cfg] '+FileName);
+  Compiler.Compile('[fp.cfg] -d'+SwitchesModeStr[SwitchesMode]+' '+FileName);
 end;
 
 end.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
+  Revision 1.2  1998-12-28 15:47:45  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.1  1998/12/22 14:27:54  peter
     * moved
 
   Revision 1.4  1998/12/22 10:39:43  peter

+ 14 - 32
ide/text/fpmcomp.inc

@@ -14,32 +14,6 @@
 
  **********************************************************************}
 
-procedure TIDEApp.Parameters;
-var R,R2: TRect;
-    D: PCenterDialog;
-    IL: PInputLine;
-begin
-  R.Assign(0,0,54,4);
-  New(D, Init(R, 'Program parameters'));
-  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:=14;
-    New(IL, Init(R2, 255));
-    IL^.Data^:=GetRunParameters;
-    Insert(IL);
-    R2.Copy(R); R2.B.X:=14;
-    Insert(New(PLabel, Init(R2, '~P~arameter', IL)));
-  end;
-  InsertButtons(D);
-  IL^.Select;
-  if Desktop^.ExecView(D)=cmOK then
-  begin
-    SetRunParameters(IL^.Data^);
-  end;
-  Dispose(D, Done);
-end;
-
 procedure TIDEApp.Target;
 var R,R2: TRect;
     D: PCenterDialog;
@@ -48,7 +22,7 @@ var R,R2: TRect;
     LastItem: PSItem;
     L: longint;
 begin
-  TargetCount:=TargetOptions^.ItemCount;
+  TargetCount:=TargetSwitches^.ItemCount;
   R.Assign(0,0,36,4+TargetCount);
   New(D, Init(R, 'Target'));
   with D^ do
@@ -57,9 +31,9 @@ begin
     R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+TargetCount;
     LastItem:=nil;
     for I:=TargetCount-1 downto 0 do
-      LastItem:=NewSItem(TargetOptions^.ItemName(I), LastItem);
+      LastItem:=NewSItem(TargetSwitches^.ItemName(I), LastItem);
     New(RB, Init(R2, LastItem));
-    L:=ord(TargetOptions^.GetCurrSel);
+    L:=ord(TargetSwitches^.GetCurrSel);
     RB^.SetData(L);
     Insert(RB);
     R2.Copy(R);
@@ -69,7 +43,7 @@ begin
   InsertButtons(D);
   RB^.Select;
   if Desktop^.ExecView(D)=cmOK then
-    TargetOptions^.SetCurrSel(RB^.Value);
+    TargetSwitches^.SetCurrSel(RB^.Value);
   Dispose(D, Done);
 end;
 
@@ -107,11 +81,19 @@ end;
 
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
+  Revision 1.2  1998-12-28 15:47:46  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.1  1998/12/22 14:27:54  peter
     * moved
 
   Revision 1.3  1998/12/22 10:39:44  peter
-    + options are now written/read
+    + Switches are now written/read
     + find and replace routines
 
 }

+ 49 - 0
ide/text/fpmdebug.inc

@@ -0,0 +1,49 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Debug menu entries
+
+    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.
+
+ **********************************************************************}
+
+procedure TIDEApp.ShowUserScreen;
+begin
+  if UserScreen=nil then
+   begin
+     ErrorBox('Sorry, user screen not available.',nil);
+     Exit;
+   end;
+  DoneMouse;
+  DoneVideo;
+
+  UserScreen^.SwitchTo;
+  Keyboard.GetKeyEvent;
+  while (Keyboard.PollKeyEvent<>0) do
+   Keyboard.GetKeyEvent;
+  UserScreen^.SwitchBack;
+
+  InitVideo;
+  InitMouse;
+  ReDraw;
+  UpdateScreen(true);
+end;
+
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:47  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+}

+ 36 - 7
ide/text/fpmfile.inc

@@ -18,6 +18,7 @@ function TIDEApp.OpenEditorWindow(FileName: string; CurX,CurY: integer): PSource
 var P: PView;
     R: TRect;
     W: PSourceWindow;
+    B,SH: boolean;
 begin
   P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
   if P=nil then Desktop^.GetExtent(R) else
@@ -25,6 +26,7 @@ begin
        P^.GetBounds(R);
        Inc(R.A.X); Inc(R.A.Y);
      end;
+  PushStatus('Opening source file... ('+SmartPath(FileName)+')');
   New(W, Init(R, FileName));
   if W<>nil then
   begin
@@ -35,17 +37,32 @@ begin
          TrackCursor(true);
        end;
     W^.HelpCtx:=hcSourceWindow;
+    SH:=MatchesFileList(NameAndExtOf(FileName),HighlightExts);
+    with W^.Editor^ do
+     begin
+       b:=(Flags and efSyntaxHighlight)<>0;
+       if SH<>B then
+        begin
+          if SH then
+           SetFlags(Flags or efSyntaxHighlight)
+          else
+           SetFlags(Flags and not efSyntaxHighlight);
+        end;
+     end;
     Desktop^.Insert(W);
     Message(Application,evBroadcast,cmUpdate,nil);
   end;
+  PopStatus;
   OpenEditorWindow:=W;
 end;
 
+
 procedure TIDEApp.NewEditor;
 begin
   OpenEditorWindow('',0,0);
 end;
 
+
 procedure TIDEApp.NewFromTemplate;
 var D: PCenterDialog;
     R,R2: TRect;
@@ -98,6 +115,7 @@ begin
   Dispose(C, Done);
 end;
 
+
 procedure TIDEApp.Open(FileName: string);
 var D: PFileDialog;
     OpenIt: boolean;
@@ -117,6 +135,7 @@ begin
   Dispose(D, Done);
 end;
 
+
 procedure TIDEApp.OpenRecentFile(RecentIndex: integer);
 begin
   with RecentFiles[RecentIndex] do
@@ -125,14 +144,17 @@ begin
 end;
 
 procedure TIDEApp.SaveAll;
-procedure SendSave(P: PView); {$ifndef FPC}far;{$endif}
-begin
-  Message(P,evCommand,cmSave,nil);
-end;
+
+  procedure SendSave(P: PView); {$ifndef FPC}far;{$endif}
+  begin
+    Message(P,evCommand,cmSave,nil);
+  end;
+
 begin
   Desktop^.ForEach(@SendSave);
 end;
 
+
 procedure TIDEApp.ChangeDir;
 begin
   ExecuteDialog(New(PChDirDialog, Init(cdNormal, hisChDirDialog)),nil);
@@ -141,9 +163,16 @@ end;
 
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
-
+  Revision 1.2  1998-12-28 15:47:47  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.4  1998/12/24 08:27:12  gabor
+    + displaying 'opening source file...' text while reading
   Revision 1.3  1998/12/22 10:39:46  peter
     + options are now written/read
     + find and replace routines

+ 119 - 2
ide/text/fpmhelp.inc

@@ -41,8 +41,120 @@ begin
   Help(0,hcUsingHelp,false);
 end;
 
+type
+    PHelpFilesDialog = ^THelpFilesDialog;
+    THelpFilesDialog = object(TCenterDialog)
+      constructor Init;
+      procedure   HandleEvent(var Event: TEvent); virtual;
+      destructor  Done; virtual;
+    private
+      LB: PListBox;
+      C : PUnsortedStringCollection;
+    end;
+
+constructor THelpFilesDialog.Init;
+var R,R2: TRect;
+    SB: PScrollBar;
+    I: integer;
+begin
+  R.Assign(0,0,50,15);
+  inherited Init(R, 'Install Help Files');
+
+  New(C, Init(20,10));
+
+  GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=37;
+  R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
+  New(SB, Init(R2)); Insert(SB);
+  New(LB, Init(R, 1, SB));
+
+  for I:=0 to HelpFiles^.Count-1 do
+    begin
+      C^.Insert(NewStr(HelpFiles^.At(I)^));
+    end;
+
+  LB^.NewList(C);
+  Insert(LB);
+  R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
+  Insert(New(PLabel, Init(R2, '~H~elp files', LB)));
+
+  GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=38; R.B.Y:=R.A.Y+2;
+  Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault)));
+  R.Move(0,2);
+  Insert(New(PButton, Init(R, '~N~ew', cmAddTPH, bfNormal)));
+  R.Move(0,2);
+  Insert(New(PButton, Init(R, '~D~elete', cmDeleteTPH, bfNormal)));
+  R.Move(0,2);
+  Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
+
+  LB^.Select;
+end;
+
+procedure THelpFilesDialog.HandleEvent(var Event: TEvent);
+var I: integer;
+    D: PFileDialog;
+    FileName: string;
+begin
+  case Event.What of
+    evKeyDown :
+      case Event.KeyCode of
+        kbIns :
+          begin
+            Message(@Self,evCommand,cmAddTPH,nil);
+            ClearEvent(Event);
+          end;
+        kbDel :
+          begin
+            Message(@Self,evCommand,cmDeleteTPH,nil);
+            ClearEvent(Event);
+          end;
+      end;
+    evCommand :
+      case Event.Command of
+        cmAddTPH :
+          begin
+            New(D, Init('*.tph','Install a help file','*.tph',fdOpenButton,0));
+            if Desktop^.ExecView(D)<>cmCancel then
+            begin
+              D^.GetFileName(FileName);
+              LB^.List^.Insert(NewStr(FileName));
+              LB^.SetRange(LB^.List^.Count);
+              ReDraw;
+            end;
+            Dispose(D, Done);
+            ClearEvent(Event);
+          end;
+        cmDeleteTPH :
+          if LB^.Range>0 then
+          begin
+            LB^.List^.AtFree(LB^.Focused);
+            LB^.SetRange(LB^.List^.Count);
+            ReDraw;
+            ClearEvent(Event);
+          end;
+        cmOK :
+          begin
+            HelpFiles^.FreeAll;
+            for I:=0 to LB^.List^.Count-1 do
+              HelpFiles^.Insert(NewStr(C^.At(I)^));
+          end;
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+destructor THelpFilesDialog.Done;
+begin
+  if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
+  inherited Done;
+end;
+
 procedure TIDEApp.HelpFiles;
 begin
+  if Desktop^.ExecView(New(PHelpFilesDialog, Init))=cmOK then
+  begin
+    DoneHelpSystem;
+    InitHelpSystem;
+  end;
 end;
 
 procedure TIDEApp.About;
@@ -70,8 +182,13 @@ end;
 
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:48  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.2  1998/12/22 10:39:47  peter
     + options are now written/read

+ 300 - 81
ide/text/fpmopts.inc

@@ -14,6 +14,43 @@
 
  **********************************************************************}
 
+procedure TIDEApp.SetSwitchesMode;
+var R,R2: TRect;
+    D: PCenterDialog;
+    RB: PRadioButtons;
+    i : TSwitchMode;
+    SwitchesCount : integer;
+    LastItem: PSItem;
+    L: longint;
+begin
+  SwitchesCount:=ord(high(TSwitchMode))-ord(low(TSwitchMode))+1;
+  R.Assign(0,0,36,4+SwitchesCount);
+  New(D, Init(R, 'SwitchesMode'));
+  with D^ do
+  begin
+    GetExtent(R);
+    R.Grow(-3,-1);
+    Inc(R.A.Y);
+    R2.Copy(R);
+    Inc(R2.A.Y);
+    R2.B.Y:=R2.A.Y+SwitchesCount;
+    LastItem:=nil;
+    for I:=high(TSwitchMode) downto low(TSwitchMode) do
+      LastItem:=NewSItem(SwitchesModeName[I], LastItem);
+    New(RB, Init(R2, LastItem));
+    RB^.SetData(SwitchesMode);
+    Insert(RB);
+    R2.Copy(R);
+    R2.B.Y:=R2.A.Y+1;
+    Insert(New(PLabel, Init(R2, 'Switches Mode', RB)));
+  end;
+  InsertButtons(D);
+  RB^.Select;
+  if Desktop^.ExecView(D)=cmOK then
+   SwitchesMode:=TSwitchMode(RB^.Value);
+  Dispose(D, Done);
+end;
+
 procedure TIDEApp.Compiler;
 var R,R2,TabR,TabIR: TRect;
     D: PCenterDialog;
@@ -27,7 +64,7 @@ var R,R2,TabR,TabIR: TRect;
     Label11,Label21,Label22,Label23,Label24,Label31: PLabel;
 begin
   R.Assign(0,0,72,18);
-  New(D, Init(R, 'Compiler Options'));
+  New(D, Init(R, 'Compiler Switches'));
   with D^ do
   begin
     GetExtent(R);
@@ -39,101 +76,101 @@ begin
     TabIR.Grow(0,-1);
 
     { --- Sheet 1 --- }
-    Count:=SyntaxOptions^.ItemCount;
+    Count:=SyntaxSwitches^.ItemCount;
     R.Copy(TabIR);
     R2.Copy(R);
     R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2;
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(SyntaxOptions^.ItemName(I), Items);
+      Items:=NewSItem(SyntaxSwitches^.ItemName(I), Items);
     New(CB1, Init(R2, Items));
     for I:=0 to Count-1 do
-      if SyntaxOptions^.ItemIsSet(I) then
+      if SyntaxSwitches^.GetBooleanItem(I) then
         CB1^.Press(I);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
-    New(Label11, Init(R2, 'Syntax options', CB1));
+    New(Label11, Init(R2, 'Syntax Switches', CB1));
 
     { --- Sheet 2 --- }
-    Count:=CodegenOptions^.ItemCount;
+    Count:=CodegenSwitches^.ItemCount;
     R2.Copy(TabIR);
     R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2-2;
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(CodegenOptions^.ItemName(I), Items);
+      Items:=NewSItem(CodegenSwitches^.ItemName(I), Items);
     New(CB3, Init(R2, Items));
     for I:=0 to Count-1 do
-      if CodegenOptions^.ItemIsSet(I) then
+      if CodegenSwitches^.GetBooleanItem(I) then
         CB3^.Press(I);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
     New(Label21, Init(R2, 'Run-time checks', CB3));
 
-    Count:=OptimizationOptions^.ItemCount;
+    Count:=OptimizationSwitches^.ItemCount;
     R2.Copy(TabIR);
     R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2;
     Dec(R2.B.X,4);
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(OptimizationOptions^.ItemName(I), Items);
+      Items:=NewSItem(OptimizationSwitches^.ItemName(I), Items);
     New(CB2, Init(R2, Items));
     for I:=0 to Count-1 do
-      if OptimizationOptions^.ItemIsSet(I) then
+      if OptimizationSwitches^.GetBooleanItem(I) then
         CB2^.Press(I);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
     New(Label22, Init(R2, 'Optimizations', CB2));
 
-    Count:=ProcessorOptions^.ItemCount;
+    Count:=ProcessorSwitches^.ItemCount;
     R2.Copy(TabIR);
     R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2-2;
-    Inc(R2.A.Y,1+CodegenOptions^.ItemCount);
+    Inc(R2.A.Y,1+CodegenSwitches^.ItemCount);
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(ProcessorOptions^.ItemName(I), Items);
+      Items:=NewSItem(ProcessorSwitches^.ItemName(I), Items);
     New(RB1, Init(R2, Items));
-    L:=ProcessorOptions^.GetCurrSel;
+    L:=ProcessorSwitches^.GetCurrSel;
     RB1^.SetData(L);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
     New(Label23, Init(R2, 'Target processor', RB1));
 
-    Count:=AsmReaderOptions^.ItemCount;
+    Count:=AsmReaderSwitches^.ItemCount;
     R2.Copy(TabIR);
     R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2;
     Dec(R2.B.X,4);
-    Inc(R2.A.Y, 1+OptimizationOptions^.ItemCount+1+ProcessorOptions^.ItemCount);
+    Inc(R2.A.Y, 1+OptimizationSwitches^.ItemCount+1+ProcessorSwitches^.ItemCount);
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(AsmReaderOptions^.ItemName(I), Items);
+      Items:=NewSItem(AsmReaderSwitches^.ItemName(I), Items);
     New(RB2, Init(R2, Items));
-    L:=AsmReaderOptions^.GetCurrSel;
+    L:=AsmReaderSwitches^.GetCurrSel;
     RB2^.SetData(L);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
     New(Label24, Init(R2, 'Assembler format', RB2));
 
     { --- Sheet 3 --- }
-    Count:=VerboseOptions^.ItemCount;
+    Count:=VerboseSwitches^.ItemCount;
     R.Copy(TabIR);
     R2.Copy(R);
     R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2;
     R2.B.Y:=R2.A.Y+Count;
     Items:=nil;
     for I:=Count-1 downto 0 do
-      Items:=NewSItem(VerboseOptions^.ItemName(I), Items);
+      Items:=NewSItem(VerboseSwitches^.ItemName(I), Items);
     New(CB4, Init(R2, Items));
     for I:=0 to Count-1 do
-      if VerboseOptions^.ItemIsSet(I) then
+      if VerboseSwitches^.GetBooleanItem(I) then
         CB4^.Press(I);
     Dec(R2.A.Y);
     R2.B.Y:=R2.A.Y+1;
-    New(Label31, Init(R2, 'Verbose options', CB4));
+    New(Label31, Init(R2, 'Verbose Switches', CB4));
 
     { create tabs }
     New(Tab, Init(TabR,
@@ -161,25 +198,25 @@ begin
 
     R2.Copy(TabR); R2.A.Y:=R2.B.Y+1; R2.B.Y:=R2.A.Y+1;
     New(IL, Init(R2, 128));
-    IL^.Data^:=GetConditionalDefines;
+    IL^.Data^:=ConditionalSwitches^.GetStringItem(0);
     Insert(IL);
     R2.Move(0,-1);
-    Insert(New(PLabel, Init(R2, 'Conditio~n~al defines', IL)));
+    Insert(New(PLabel, Init(R2,ConditionalSwitches^.ItemName(0), IL)));
   end;
   InsertButtons(D);
   if Desktop^.ExecView(D)=cmOK then
   begin
-    for I:=0 to SyntaxOptions^.ItemCount-1 do
-      SyntaxOptions^.ItemSet(I,CB1^.Mark(I));
-    for I:=0 to CodeGenOptions^.ItemCount-1 do
-      CodegenOptions^.ItemSet(I,CB3^.Mark(I));
-    for I:=0 to OptimizationOptions^.ItemCount-1 do
-      OptimizationOptions^.ItemSet(I,CB2^.Mark(I));
-    for I:=0 to VerboseOptions^.ItemCount-1 do
-      VerboseOptions^.ItemSet(I,CB4^.Mark(I));
-    ProcessorOptions^.SetCurrSel(RB1^.Value);
-    AsmReaderOptions^.SetCurrSel(RB2^.Value);
-    SetConditionalDefines(IL^.Data^);
+    for I:=0 to SyntaxSwitches^.ItemCount-1 do
+      SyntaxSwitches^.SetBooleanItem(I,CB1^.Mark(I));
+    for I:=0 to CodeGenSwitches^.ItemCount-1 do
+      CodegenSwitches^.SetBooleanItem(I,CB3^.Mark(I));
+    for I:=0 to OptimizationSwitches^.ItemCount-1 do
+      OptimizationSwitches^.SetBooleanItem(I,CB2^.Mark(I));
+    for I:=0 to VerboseSwitches^.ItemCount-1 do
+      VerboseSwitches^.SetBooleanItem(I,CB4^.Mark(I));
+    ProcessorSwitches^.SetCurrSel(RB1^.Value);
+    AsmReaderSwitches^.SetCurrSel(RB2^.Value);
+    ConditionalSwitches^.SetStringItem(0,IL^.Data^);
   end;
   Dispose(D, Done);
 end;
@@ -310,7 +347,7 @@ begin
     RB2^.SetData(L);
     Insert(RB2);
     R2.Copy(R); Inc(R2.A.Y,6); R2.B.Y:=R2.A.Y+1;
-    Insert(New(PLabel, Init(R2, 'Profiling options', RB2)));
+    Insert(New(PLabel, Init(R2, 'Profiling Switches', RB2)));
   end;
   InsertButtons(D);
   RB1^.Select;
@@ -323,63 +360,189 @@ begin
 {$endif}
 end;
 
+
 procedure TIDEApp.Directories;
 var R,R2: TRect;
     D: PCenterDialog;
-    IL1,IL2,IL3,IL4: PInputLine;
-{    Dirs: TDirectoryCfg; }
-const LW = 25;
+    IL : array[0..11] of PInputLine;
+    Count,I : integer;
+const
+  LW = 25;
 begin
-{$ifdef NOTYET}
-  GetDirectoryCfg(Dirs);
   R.Assign(0,0,64,10);
   New(D, Init(R, 'Directories'));
   with D^ do
   begin
-    GetExtent(R); R.Grow(-2,-2); Dec(R.B.X); R.B.Y:=R.A.Y+1;
-    R2.Copy(R); R2.A.X:=LW;
-    New(IL1, Init(R2, 128));
-    IL1^.Data^:=Dirs.EXETPUDir;
-    Insert(IL1);
-    R2.Copy(R); R2.B.X:=LW;
-    Insert(New(PLabel, Init(R2, '~E~XE & unit directory', IL1)));
+    GetExtent(R);
+    R.Grow(-2,-2);
+    Dec(R.B.X);
+    R.B.Y:=R.A.Y+1;
+    Count:=DirectorySwitches^.ItemCount;
+    for i:=Count-1 downto 0 do
+     begin
+       R2.Copy(R);
+       R2.A.X:=LW;
+       New(IL[i], Init(R2, 255));
+       IL[i]^.Data^:=DirectorySwitches^.GetStringItem(i);
+       Insert(IL[i]);
+       R2.Copy(R);
+       R2.B.X:=LW;
+       Insert(New(PLabel, Init(R2, DirectorySwitches^.ItemName(i), IL[i])));
+       R.Move(0,2);
+     end;
+  end;
+  InsertButtons(D);
+  IL[0]^.Select;
+  if Desktop^.ExecView(D)=cmOK then
+   begin
+     for i:=Count-1 downto 0 do
+      DirectorySwitches^.SetStringItem(i,IL[i]^.Data^);
+   end;
+  Dispose(D, Done);
+end;
 
-    R.Move(0,2);
-    R2.Copy(R); R2.A.X:=LW;
-    New(IL2, Init(R2, 128));
-    IL2^.Data^:=Dirs.IncludeDirs;
-    Insert(IL2);
-    R2.Copy(R); R2.B.X:=LW;
-    Insert(New(PLabel, Init(R2, '~I~nclude directories', IL2)));
-
-    R.Move(0,2);
-    R2.Copy(R); R2.A.X:=LW;
-    New(IL3, Init(R2, 128));
-    IL3^.Data^:=Dirs.UnitDirs;
-    Insert(IL3);
-    R2.Copy(R); R2.B.X:=LW;
-    Insert(New(PLabel, Init(R2, '~U~nit directories', IL3)));
-
-    R.Move(0,2);
-    R2.Copy(R); R2.A.X:=LW;
-    New(IL4, Init(R2, 128));
-    IL4^.Data^:=Dirs.ObjectDirs;
-    Insert(IL4);
-    R2.Copy(R); R2.B.X:=LW;
-    Insert(New(PLabel, Init(R2, '~O~bject directories', IL4)));
+
+procedure TIDEApp.EditorOptions(Editor: PEditor);
+var D: PCenterDialog;
+    R,R2,R3: TRect;
+    CB: PCheckBoxes;
+    IL: PIntegerLine;
+    ExtIL: PInputLine;
+    TabSize: Integer;
+    EFlags: Longint;
+begin
+  if Editor=nil
+     then begin TabSize:=DefaultTabSize; EFlags:=DefaultCodeEditorFlags; end
+     else begin TabSize:=Editor^.TabSize; EFlags:=Editor^.Flags; end;
+  R.Assign(0,0,56,15);
+  New(D, Init(R, 'Editor Options'));
+  with D^ do
+  begin
+    GetExtent(R); R.Grow(-2,-2); R.B.Y:=R.A.Y+7;
+    R2.Copy(R); Inc(R2.A.Y);
+    New(CB, Init(R2,
+      NewSItem('Create backup ~f~iles',
+      NewSItem('~I~nsert mode',
+      NewSItem('~A~uto indent mode',
+      NewSItem('~U~se tab characters',
+      NewSItem('~B~ackspace unindents',
+      NewSItem('~P~ersistent blocks',
+      NewSItem('~S~yntax highlight',
+      NewSItem('~B~lock insert cursor',
+      NewSItem('~V~ertical blocks',
+      NewSItem('Highlight ~c~olumn',
+      NewSItem('Highlight ~r~ow',
+      NewSItem('Aut~o~-closing brackets',
+      nil))))))))))))));
+    CB^.Value:=EFlags;
+    Insert(CB);
+    R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
+    Insert(New(PLabel, Init(R2, 'Editor options', CB)));
+
+    R.Move(0,(R.B.Y-R.A.Y)+1); R.B.Y:=R.A.Y+1;
+    R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y;
+    R3.Copy(R); Inc(R3.A.X,10); R3.B.X:=R3.A.X+5;
+    New(IL, Init(R3, 0,100));
+    IL^.Data^:=IntToStr(TabSize);
+    Insert(IL);
+    R3.Copy(R); R3.B.X:=R3.A.X+10;
+    Insert(New(PLabel, Init(R3, '~T~ab size', IL)));
+
+    R.Move(0,(R.B.Y-R.A.Y)+1); R.B.Y:=R.A.Y+2;
+    R2.Copy(R); Inc(R2.A.Y);
+    New(ExtIL, Init(R2, 128));
+    ExtIL^.SetData(HighlightExts);
+    Insert(ExtIL);
+    R2.Move(0,-1);
+    Insert(New(PLabel, Init(R2, '~H~ighlight extensions', ExtIL)));
   end;
   InsertButtons(D);
-  IL1^.Select;
+  CB^.Select;
+  if Desktop^.ExecView(D)=cmOK then
+  begin
+    TabSize:=StrToInt(IL^.Data^); EFlags:=CB^.Value;
+    if Editor=nil then
+       begin
+         DefaultTabSize:=TabSize;
+         DefaultCodeEditorFlags:=EFlags;
+       end
+    else
+       begin
+         Editor^.TabSize:=TabSize;
+         Editor^.SetFlags(EFlags);
+       end;
+    ExtIL^.GetData(HighlightExts);
+  end;
+  Dispose(D, Done);
+end;
+
+procedure TIDEApp.Mouse;
+var R,R2,R3: TRect;
+    D: PCenterDialog;
+    SB: PScrollBar;
+    CB: PCheckBoxes;
+    RB1,RB2: PRadioButtons;
+begin
+  R.Assign(0,0,62,15);
+  New(D, Init(R, 'Mouse Options'));
+  with D^ do
+  begin
+    GetExtent(R); R.Grow(-3,-2); R.B.Y:=R.A.Y+3;
+    R2.Copy(R); Inc(R2.A.Y,2); R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2 -1;
+    New(SB, Init(R2)); SB^.GrowMode:=0; SB^.Options:=SB^.Options or ofSelectable;
+    SB^.SetParams(DoubleDelay,1,20,1,1);
+    Insert(SB);
+    R2.Move(0,-1);
+    Insert(New(PStaticText, Init(R2, 'Fast       Medium      Slow')));
+    R2.Move(-1,-1);
+    Insert(New(PLabel, Init(R2, '~M~ouse double click', SB)));
+
+    R2.Copy(R); Inc(R2.A.Y,2); R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2 +1;
+    New(CB, Init(R2, NewSItem('~R~everse mouse buttons', nil) ));
+    if MouseReverse then CB^.Press(0);
+    Insert(CB);
+
+    R.Move(0,(R.B.Y-R.A.Y)+1); R.B.Y:=R.A.Y+8;
+    R2.Copy(R); Inc(R2.A.Y); R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2 -1;
+    New(RB1, Init(R2,
+      NewSItem('~N~othing',
+      NewSItem('~T~opic search',
+      NewSItem('~G~o to cursor',
+      NewSItem('~B~reakpoint',
+      NewSItem('~E~valuate',
+      NewSItem('~A~dd watch',
+      NewSItem('Browse ~s~ymbol',
+      nil)))))))));
+    RB1^.Press(CtrlMouseAction);
+    Insert(RB1);
+    R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
+    Insert(New(PLabel, Init(R2, 'Ctrl+Right mouse button', RB1)));
+
+    R2.Copy(R); Inc(R2.A.Y); R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2 +1;
+    New(RB2, Init(R2,
+      NewSItem('N~o~thing',
+      NewSItem('To~p~ic search',
+      NewSItem('Go to ~c~ursor',
+      NewSItem('Brea~k~point',
+      NewSItem('E~v~aluate',
+      NewSItem('Add ~w~atch',
+      NewSItem('Browse s~y~mbol',
+      nil)))))))));
+    RB2^.Press(AltMouseAction);
+    Insert(RB2);
+    R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
+    Insert(New(PLabel, Init(R2, 'Alt+Right mouse button', RB2)));
+  end;
+  InsertButtons(D);
+  RB1^.Select;
   if Desktop^.ExecView(D)=cmOK then
   begin
-    Dirs.EXETPUDir:=IL1^.Data^;
-    Dirs.IncludeDirs:=IL2^.Data^;
-    Dirs.UnitDirs:=IL3^.Data^;
-    Dirs.ObjectDirs:=IL4^.Data^;
-    SetDirectoryCfg(Dirs);
+    MouseReverse:=CB^.Mark(0);
+    DoubleDelay:=SB^.Value;
+    CtrlMouseAction:=RB1^.Value;
+    AltMouseAction:=RB2^.Value;
   end;
   Dispose(D, Done);
-{$endif NOTYET}
 end;
 
 procedure TIDEApp.Colors;
@@ -429,16 +592,72 @@ begin
       DoneMemory;
       Message(Application,evBroadcast,cmUpdate,nil);
       ReDraw;
+      UpdateScreen(true);
+    end;
+end;
+
+procedure TIDEApp.OpenINI;
+var D: PFileDialog;
+    FileName: string;
+begin
+  New(D, Init(ININame,'Open Options',ININame,fdOpenButton,0));
+  if Desktop^.ExecView(D)<>cmCancel then
+    begin
+      D^.GetFileName(FileName);
+      if ExistsFile(FileName)=false then ErrorBox('Can''t open config file.',nil) else
+        begin
+          INIPath:=FileName;
+          ReadINIFile;
+          Message(Application,evBroadcast,cmUpdate,nil);
+        end;
     end;
+  Dispose(D, Done);
+end;
+
+procedure TIDEApp.SaveINI;
+begin
+  if WriteINIFile=false then
+    ErrorBox('Error saving config file.',nil);
+end;
+
+procedure TIDEApp.SaveAsINI;
+var D: PFileDialog;
+    FileName: string;
+    CanWrite: boolean;
+begin
+  New(D, Init(ININame,'Save Options',ININame,fdOpenButton,0));
+  if Desktop^.ExecView(D)<>cmCancel then
+    begin
+      D^.GetFileName(FileName);
+      CanWrite:=(ExistsFile(FileName)=false);
+      if CanWrite=false then
+        CanWrite:=ConfirmBox('File '+SmartPath(FileName)+' already exists. Overwrite?',nil,false)=cmYes;
+      if CanWrite then
+        begin
+          INIPath:=FileName;
+          if WriteINIFile=false then
+            ErrorBox('Error saving config file.',nil);
+          Message(Application,evBroadcast,cmUpdate,nil);
+        end;
+    end;
+  Dispose(D, Done);
 end;
 
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
+  Revision 1.2  1998-12-28 15:47:49  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.1  1998/12/22 14:27:54  peter
     * moved
 
   Revision 1.3  1998/12/22 10:39:48  peter
-    + options are now written/read
+    + Switches are now written/read
     + find and replace routines
 
 }

+ 86 - 0
ide/text/fpmrun.inc

@@ -0,0 +1,86 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Run menu entries
+
+    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.
+
+ **********************************************************************}
+
+procedure TIDEApp.DoRun;
+var
+  ExeFile : string;
+begin
+  if (MainFile='') or (CompilationPhase<>cpDone) then
+   DoCompile(cRun);
+  if (MainFile='') or (CompilationPhase<>cpDone) then
+   begin
+     ErrorBox('Oooops, nothing to run.',nil);
+     Exit;
+   end;
+  ExeFile:=MakeExeName(MainFile);
+
+  if UserScreen=nil then
+   begin
+     ErrorBox('Sorry, user screen not available.',nil);
+     Exit;
+   end;
+  DoneMouse;
+  DoneVideo;
+
+  UserScreen^.SwitchTo;
+
+  Exec(ExeFile,GetRunParameters);
+
+  UserScreen^.SwitchBack;
+
+  InitVideo;
+  InitMouse;
+  ReDraw;
+  UpdateScreen(true);
+end;
+
+procedure TIDEApp.Parameters;
+var R,R2: TRect;
+    D: PCenterDialog;
+    IL: PInputLine;
+begin
+  R.Assign(0,0,54,4);
+  New(D, Init(R, 'Program parameters'));
+  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:=14;
+    New(IL, Init(R2, 255));
+    IL^.Data^:=GetRunParameters;
+    Insert(IL);
+    R2.Copy(R); R2.B.X:=14;
+    Insert(New(PLabel, Init(R2, '~P~arameter', IL)));
+  end;
+  InsertButtons(D);
+  IL^.Select;
+  if Desktop^.ExecView(D)=cmOK then
+  begin
+    SetRunParameters(IL^.Data^);
+  end;
+  Dispose(D, Done);
+end;
+
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:50  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+}

+ 20 - 1
ide/text/fpmwnd.inc

@@ -148,9 +148,28 @@ begin
   Dispose(W,Done);
 end;
 
+procedure TIDEApp.ShowScreenWindow;
+begin
+  if UserScreenWindow=nil then Exit;
+  with UserScreenWindow^ do
+   begin
+     if not GetState(sfVisible) then
+       Show;
+     MakeFirst;
+   end;
+end;
+
 {
   $Log$
-  Revision 1.2  1998-12-23 22:58:19  peter
+  Revision 1.3  1998-12-28 15:47:50  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.2  1998/12/23 22:58:19  peter
     * fixed windowlist for fpc
 
   Revision 1.1  1998/12/22 14:27:54  peter

+ 73 - 0
ide/text/fprun.pas

@@ -0,0 +1,73 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Compiler call routines for the IDE
+
+    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.
+
+ **********************************************************************}
+unit FPRun;
+interface
+
+procedure DoRun;
+
+
+implementation
+
+uses
+  Dos,Mouse,Video,
+  FPViews,FPVars,FPUtils,FPIntf,
+  FPCompile,FPUsrScr;
+
+procedure TIDEApp.DoRun;
+var
+  ExeFile : string;
+begin
+  if (MainFile='') or (CompilationPhase<>cpDone) then
+   DoCompile(cRun);
+  if (MainFile='') or (CompilationPhase<>cpDone) then
+   begin
+     ErrorBox('Oooops, nothing to run.',nil);
+     Exit;
+   end;
+  ExeFile:=MakeExeName(MainFile);
+
+  if UserScreen=nil then
+   begin
+     ErrorBox('Sorry, user screen not available.',nil);
+     Exit;
+   end;
+  DoneMouse;
+  DoneVideo;
+
+  UserScreen^.SwitchTo;
+
+  Exec(ExeFile,GetRunParameters);
+
+  UserScreen^.SwitchBack;
+
+  InitVideo;
+  InitMouse;
+  ReDraw;
+  UpdateScreen(true);
+end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:52  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+}

+ 728 - 0
ide/text/fpswitch.pas

@@ -0,0 +1,728 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Compiler switches routines for the IDE
+
+    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.
+
+ **********************************************************************}
+unit FPSwitches;
+
+interface
+
+uses
+  Objects,
+  Systems,
+  FPConst;
+
+const
+     MinStackSize    = 1024;
+     MaxStackSize    = 67107840;
+     MinHeapSize     = 1024;
+     MaxHeapSize     = 67107840;
+
+type
+    TSwitchMode = (om_Normal,om_Debug,om_Release);
+
+    TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_Longint);
+
+    PSwitchItem = ^TSwitchItem;
+    TSwitchItem = object(TObject)
+      Typ       : TSwitchItemTyp;
+      Name      : string[30];
+      Param     : string[10];
+      constructor Init(const n,p:string);
+      function  NeedParam:boolean;virtual;
+      function  ParamValue:string;virtual;
+      procedure Reset;virtual;
+    end;
+
+    PSelectItem = ^TSelectItem;
+    TSelectItem = object(TSwitchItem)
+      constructor Init(const n,p:string);
+    end;
+
+    PBooleanItem = ^TBooleanItem;
+    TBooleanItem = object(TSwitchItem)
+      IsSet : array[TSwitchMode] of boolean;
+      constructor Init(const n,p:string);
+      function  NeedParam:boolean;virtual;
+      procedure Reset;virtual;
+    end;
+
+    PStringItem = ^TStringItem;
+    TStringItem = object(TSwitchItem)
+      Str : array[TSwitchMode] of string;
+      multiple : boolean;
+      constructor Init(const n,p:string;mult:boolean);
+      function  NeedParam:boolean;virtual;
+      function  ParamValue:string;virtual;
+      procedure Reset;virtual;
+    end;
+
+    PLongintItem = ^TLongintItem;
+    TLongintItem = object(TSwitchItem)
+      Val : array[TSwitchMode] of longint;
+      constructor Init(const n,p:string);
+      function  NeedParam:boolean;virtual;
+      function  ParamValue:string;virtual;
+      procedure Reset;virtual;
+    end;
+
+    PSwitches = ^TSwitches;
+    TSwitches = object
+      constructor Init(ch:char);
+      constructor InitSelect(ch:char);
+      destructor  Done;
+      { general items }
+      function  ItemCount:integer;
+      function  ItemName(index:integer):string;
+      function  ItemParam(index:integer):string;
+      { type specific }
+      procedure AddSelectItem(const name,param:string);
+      procedure AddBooleanItem(const name,param:string);
+      procedure AddLongintItem(const name,param:string);
+      procedure AddStringItem(const name,param:string;mult:boolean);
+      function  GetCurrSel:integer;
+      function  GetBooleanItem(index:integer):boolean;
+      function  GetLongintItem(index:integer):longint;
+      function  GetStringItem(index:integer):string;
+      procedure SetCurrSel(index:integer);
+      procedure SetBooleanItem(index:integer;b:boolean);
+      procedure SetLongintItem(index:integer;l:longint);
+      procedure SetStringItem(index:integer;const s:string);
+      { read / write to cfgfile which must be open }
+      procedure WriteItemsCfg;
+      function  ReadItemsCfg(const s:string):boolean;
+    private
+      IsSel  : boolean;
+      Prefix : char;
+      SelNr  : integer;
+      Items  : PCollection;
+    end;
+
+const
+    SwitchesMode : TSwitchMode = om_Normal;
+
+    SwitchesModeName : array[TSwitchMode] of string[10]=
+      ('~N~ormal','~D~ebug','~R~elease');
+    SwitchesModeStr : array[TSwitchMode] of string[8]=
+      ('NORMAL','DEBUG','RELEASE');
+
+var
+    SyntaxSwitches,
+    VerboseSwitches,
+    CodegenSwitches,
+    OptimizationSwitches,
+    ProcessorSwitches,
+    AsmReaderSwitches,
+    TargetSwitches,
+    ConditionalSwitches,
+    MemorySwitches,
+    DirectorySwitches : PSwitches;
+
+{ write/read the Switches to ppc.cfg file }
+procedure WriteSwitches(const fn:string);
+procedure ReadSwitches(const fn:string);
+
+{ initialize }
+procedure InitSwitches;
+procedure DoneSwitches;
+
+
+implementation
+
+uses
+  Dos,
+  GlobType,Tokens,Compiler,
+  FPUtils,FPVars;
+
+var
+  CfgFile : text;
+
+{*****************************************************************************
+                                TSwitchItem
+*****************************************************************************}
+
+constructor TSwitchItem.Init(const n,p:string);
+begin
+  Inherited Init;
+  Name:=n;
+  Param:=p;
+end;
+
+
+function TSwitchItem.NeedParam:boolean;
+begin
+  NeedParam:=false;
+end;
+
+
+function TSwitchItem.ParamValue:string;
+begin
+  ParamValue:='';
+end;
+
+
+procedure TSwitchItem.Reset;
+begin
+end;
+
+
+{*****************************************************************************
+                                TSelectItem
+*****************************************************************************}
+
+constructor TSelectItem.Init(const n,p:string);
+begin
+  Inherited Init(n,p);
+  Typ:=ot_Select;
+end;
+
+
+{*****************************************************************************
+                               TBooleanItem
+*****************************************************************************}
+
+constructor TBooleanItem.Init(const n,p:string);
+begin
+  Inherited Init(n,p);
+  Typ:=ot_Boolean;
+  Reset;
+end;
+
+
+function TBooleanItem.NeedParam:boolean;
+begin
+  NeedParam:=IsSet[SwitchesMode];
+end;
+
+
+procedure TBooleanItem.Reset;
+begin
+  FillChar(IsSet,sizeof(IsSet),0);
+end;
+
+
+{*****************************************************************************
+                                TStringItem
+*****************************************************************************}
+
+constructor TStringItem.Init(const n,p:string;mult:boolean);
+begin
+  Inherited Init(n,p);
+  Typ:=ot_String;
+  Multiple:=mult;
+  Reset;
+end;
+
+
+function TStringItem.NeedParam:boolean;
+begin
+  NeedParam:=(Str[SwitchesMode]<>'');
+end;
+
+
+function TStringItem.ParamValue:string;
+begin
+  ParamValue:=Str[SwitchesMode];
+end;
+
+
+procedure TStringItem.Reset;
+begin
+  FillChar(Str,sizeof(Str),0);
+end;
+
+
+{*****************************************************************************
+                               TLongintItem
+*****************************************************************************}
+
+constructor TLongintItem.Init(const n,p:string);
+begin
+  Inherited Init(n,p);
+  Typ:=ot_Longint;
+  Reset;
+end;
+
+
+function TLongintItem.NeedParam:boolean;
+begin
+  NeedParam:=(Val[SwitchesMode]<>0);
+end;
+
+
+function TLongintItem.ParamValue:string;
+var
+  s : string;
+begin
+  Str(Val[SwitchesMode],s);
+  ParamValue:=s;
+end;
+
+
+procedure TLongintItem.Reset;
+begin
+  FillChar(Val,sizeof(Val),0);
+end;
+
+
+{*****************************************************************************
+                                   TSwitch
+*****************************************************************************}
+
+constructor TSwitches.Init(ch:char);
+begin
+  new(Items,Init(10,5));
+  Prefix:=ch;
+  SelNr:=0;
+  IsSel:=false;
+end;
+
+
+constructor TSwitches.InitSelect(ch:char);
+begin
+  new(Items,Init(10,5));
+  Prefix:=ch;
+  SelNr:=0;
+  IsSel:=true;
+end;
+
+
+destructor  TSwitches.Done;
+begin
+  dispose(Items,Done);
+end;
+
+
+procedure TSwitches.AddSelectItem(const name,param:string);
+begin
+  Items^.Insert(New(PSelectItem,Init(name,Param)));
+end;
+
+
+procedure TSwitches.AddBooleanItem(const name,param:string);
+begin
+  Items^.Insert(New(PBooleanItem,Init(name,Param)));
+end;
+
+
+procedure TSwitches.AddLongintItem(const name,param:string);
+begin
+  Items^.Insert(New(PLongintItem,Init(name,Param)));
+end;
+
+
+procedure TSwitches.AddStringItem(const name,param:string;mult:boolean);
+begin
+  Items^.Insert(New(PStringItem,Init(name,Param,mult)));
+end;
+
+
+function TSwitches.ItemCount:integer;
+begin
+  ItemCount:=Items^.Count;
+end;
+
+
+function TSwitches.ItemName(index:integer):string;
+var
+  P : PSwitchItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) then
+   ItemName:=P^.Name
+  else
+   ItemName:='';
+end;
+
+
+function TSwitches.ItemParam(index:integer):string;
+var
+  P : PSwitchItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) then
+   ItemParam:='-'+Prefix+P^.Param
+  else
+   ItemParam:='';
+end;
+
+
+function TSwitches.GetBooleanItem(index:integer):boolean;
+var
+  P : PBooleanItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_boolean) then
+   GetBooleanItem:=P^.IsSet[SwitchesMode]
+  else
+   GetBooleanItem:=false;
+end;
+
+
+function TSwitches.GetLongintItem(index:integer):longint;
+var
+  P : PLongintItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_longint) then
+   GetLongintItem:=P^.Val[SwitchesMode]
+  else
+   GetLongintItem:=0;
+end;
+
+
+function TSwitches.GetStringItem(index:integer):string;
+var
+  P : PStringItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_string) then
+   GetStringItem:=P^.Str[SwitchesMode]
+  else
+   GetStringItem:='';
+end;
+
+
+procedure TSwitches.SetBooleanItem(index:integer;b:boolean);
+var
+  P : PBooleanItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_boolean) then
+   P^.IsSet[SwitchesMode]:=b;
+end;
+
+
+procedure TSwitches.SetLongintItem(index:integer;l:longint);
+var
+  P : PLongintItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_longint) then
+   P^.Val[SwitchesMode]:=l;
+end;
+
+
+procedure TSwitches.SetStringItem(index:integer;const s:string);
+var
+  P : PStringItem;
+begin
+  P:=Items^.At(Index);
+  if assigned(P) and (P^.Typ=ot_string) then
+   P^.Str[SwitchesMode]:=s;
+end;
+
+
+function TSwitches.GetCurrSel:integer;
+begin
+  if IsSel then
+   GetCurrSel:=SelNr
+  else
+   GetCurrSel:=-1;
+end;
+
+
+procedure TSwitches.SetCurrSel(index:integer);
+begin
+  if IsSel then
+   SelNr:=index;
+end;
+
+
+procedure TSwitches.WriteItemsCfg;
+var
+  Pref : char;
+
+  procedure writeitem(P:PSwitchItem);{$ifndef FPC}far;{$endif}
+  var
+    s,s1 : string;
+    i : integer;
+  begin
+    if P^.NeedParam then
+     begin
+       if (P^.Typ=ot_string) and (PStringItem(P)^.Multiple) then
+        begin
+          s:=PStringItem(P)^.Str[SwitchesMode];
+          repeat
+            i:=pos(';',s);
+            if i=0 then
+             i:=255;
+            s1:=Copy(s,1,i-1);
+            if s1<>'' then
+             writeln(CfgFile,' -'+Pref+P^.Param+s1);
+            Delete(s,1,i);
+          until s='';
+        end
+       else
+        Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
+     end;
+  end;
+
+begin
+  Pref:=Prefix;
+  if IsSel then
+    writeln(CfgFile,' '+ItemParam(SelNr))
+  else
+    Items^.ForEach(@writeitem);
+end;
+
+
+function TSwitches.ReadItemsCfg(const s:string):boolean;
+
+  function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
+  begin
+    CheckItem:=(P^.Param=Copy(s,1,length(P^.Param)));
+  end;
+
+var
+  FoundP : PSwitchItem;
+  code : integer;
+begin
+  FoundP:=Items^.FirstThat(@checkitem);
+  if assigned(FoundP) then
+   begin
+     case FoundP^.Typ of
+      ot_Select  : SelNr:=Items^.IndexOf(FoundP);
+      ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
+      ot_String  : begin
+                     if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
+                      PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
+                        Copy(s,length(FoundP^.Param)+1,255)
+                     else
+                      PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
+                   end;
+      ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
+     end;
+     ReadItemsCfg:=true;
+   end
+  else
+   ReadItemsCfg:=false;
+end;
+
+
+{*****************************************************************************
+                                 Read / Write
+*****************************************************************************}
+
+procedure WriteSwitches(const fn:string);
+var
+  OldSwitchesMode : TSwitchMode;
+begin
+{ create the switches }
+  assign(CfgFile,fn);
+  {$I-}
+   rewrite(CfgFile);
+  {$I+}
+  if ioresult<>0 then
+   exit;
+  writeln(CfgFile,'# Automaticly created file, don''t edit.');
+  OldSwitchesMode:=SwitchesMode;
+  for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
+   begin
+     Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
+     TargetSwitches^.WriteItemsCfg;
+     VerboseSwitches^.WriteItemsCfg;
+     SyntaxSwitches^.WriteItemsCfg;
+     CodegenSwitches^.WriteItemsCfg;
+     OptimizationSwitches^.WriteItemsCfg;
+     ProcessorSwitches^.WriteItemsCfg;
+     AsmReaderSwitches^.WriteItemsCfg;
+     DirectorySwitches^.WriteItemsCfg;
+     MemorySwitches^.WriteItemsCfg;
+     ConditionalSwitches^.WriteItemsCfg;
+     Writeln(CfgFile,'#ENDIF');
+     Writeln(CfgFile,'');
+   end;
+  close(CfgFile);
+  SwitchesMode:=OldSwitchesMode;
+end;
+
+
+procedure ReadSwitches(const fn:string);
+var
+  c : char;
+  s : string;
+  OldSwitchesMode,i : TSwitchMode;
+begin
+  assign(CfgFile,fn);
+  {$I-}
+   reset(CfgFile);
+  {$I+}
+  if ioresult<>0 then
+   exit;
+  OldSwitchesMode:=SwitchesMode;
+  SwitchesMode:=om_Normal;
+  while not eof(CfgFile) do
+   begin
+     readln(CfgFile,s);
+     s:=LTrim(s);
+     if (length(s)>2) and (s[1]='-') then
+      begin
+        c:=s[2];
+        Delete(s,1,2);
+        case c of
+         'd' : ConditionalSwitches^.ReadItemsCfg(s);
+         'S' : SyntaxSwitches^.ReadItemsCfg(s);
+         'F' : DirectorySwitches^.ReadItemsCfg(s);
+         'T' : TargetSwitches^.ReadItemsCfg(s);
+         'R' : AsmReaderSwitches^.ReadItemsCfg(s);
+         'C' : CodegenSwitches^.ReadItemsCfg(s);
+         'v' : VerboseSwitches^.ReadItemsCfg(s);
+         'O' : begin
+                 if not OptimizationSwitches^.ReadItemsCfg(s) then
+                  ProcessorSwitches^.ReadItemsCfg(s);
+               end;
+        end;
+      end
+     else
+      if (Copy(s,1,7)='#IFDEF ') then
+       begin
+         Delete(s,1,7);
+         for i:=low(TSwitchMode) to high(TSwitchMode) do
+          if s=SwitchesModeStr[i] then
+           begin
+             SwitchesMode:=i;
+             break;
+           end;
+       end;
+   end;
+  close(CfgFile);
+  SwitchesMode:=OldSwitchesMode;
+end;
+
+
+
+{*****************************************************************************
+                                 Initialize
+*****************************************************************************}
+
+procedure InitSwitches;
+begin
+  New(SyntaxSwitches,Init('S'));
+  with SyntaxSwitches^ do
+   begin
+     AddBooleanItem('~D~elphi 2 extensions on','2');
+     AddBooleanItem('~C~-like operators','c');
+     AddBooleanItem('S~t~op after first error','e');
+     AddBooleanItem('Allo~w~ LABEL and GOTO','g');
+     AddBooleanItem('C++ styled ~i~nline','i');
+     AddBooleanItem('Global C ~m~acros','m');
+     AddBooleanItem('TP/BP ~7~.0 compatibility','o');
+     AddBooleanItem('Del~p~hi compatibility','d');
+     AddBooleanItem('A~l~low STATIC in objects','s');
+   end;
+  New(VerboseSwitches,Init('v'));
+  with VerboseSwitches^ do
+   begin
+     AddBooleanItem('~W~arnings','w');
+     AddBooleanItem('~N~otes','n');
+     AddBooleanItem('~H~ints','h');
+     AddBooleanItem('General ~I~nfo','i');
+     AddBooleanItem('~U~sed,tried info','ut');
+     AddBooleanItem('~A~ll','a');
+     AddBooleanItem('Show all ~P~rocedures if error','b');
+   end;
+  New(CodegenSwitches,Init('C'));
+  with CodegenSwitches^ do
+   begin
+     AddBooleanItem('~R~ange checking','r');
+     AddBooleanItem('~S~tack checking','t');
+     AddBooleanItem('~I~/O checking','i');
+     AddBooleanItem('Integer ~o~verflow checking','o');
+   end;
+  New(OptimizationSwitches,Init('O'));
+  with OptimizationSwitches^ do
+   begin
+     AddBooleanItem('Generate ~s~maller code','g');
+     AddBooleanItem('Generate ~f~aster code','G');
+     AddBooleanItem('Use register-~v~ariables','r');
+     AddBooleanItem('~U~ncertain optimizations','u');
+     AddBooleanItem('Level ~1~ optimizations','1');
+     AddBooleanItem('Level ~2~ optimizations','2');
+   end;
+  New(ProcessorSwitches,InitSelect('O'));
+  with ProcessorSwitches^ do
+   begin
+     AddSelectItem('i~3~86/i486','p1');
+     AddSelectItem('Pentium/PentiumMM~X~ (tm)','p2');
+     AddSelectItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
+   end;
+  New(TargetSwitches,InitSelect('T'));
+  with TargetSwitches^ do
+   begin
+     AddSelectItem('DOS (GO32V~1~)','go32v1');
+     AddSelectItem('~D~OS (GO32V2)','go32v2');
+     AddSelectItem('~L~inux','linux');
+     AddSelectItem('~O~S/2','os2');
+     AddSelectItem('~W~IN32','win32');
+   end;
+  New(AsmReaderSwitches,InitSelect('R'));
+  with AsmReaderSwitches^ do
+   begin
+     AddSelectItem('No preprocessin~g~','direct');
+     AddSelectItem('~A~T&T style assembler','att');
+     AddSelectItem('Int~e~l style assembler','intel');
+   end;
+  New(ConditionalSwitches,Init('d'));
+  with ConditionalSwitches^ do
+   begin
+     AddStringItem('Conditio~n~al defines','',true);
+   end;
+  New(MemorySwitches,Init('C'));
+  with MemorySwitches^ do
+   begin
+     AddLongintItem('~S~tack size','s');
+     AddLongintItem('~H~eap size','h');
+   end;
+  New(DirectorySwitches,Init('F'));
+  with DirectorySwitches^ do
+   begin
+     AddStringItem('~U~nit directories','u',true);
+     AddStringItem('~I~nclude directories','i',true);
+     AddStringItem('~L~ibrary directories','l',true);
+     AddStringItem('~O~bject directories','o',true);
+   end;
+  SwitchesPath:=LocateFile(SwitchesName);
+  if SwitchesPath='' then
+    SwitchesPath:=SwitchesName;
+  SwitchesPath:=FExpand(SwitchesPath);
+end;
+
+
+procedure DoneSwitches;
+begin
+  dispose(SyntaxSwitches,Done);
+  dispose(VerboseSwitches,Done);
+  dispose(CodegenSwitches,Done);
+  dispose(OptimizationSwitches,Done);
+  dispose(ProcessorSwitches,Done);
+  dispose(TargetSwitches,Done);
+  dispose(AsmReaderSwitches,Done);
+  dispose(ConditionalSwitches,Done);
+  dispose(MemorySwitches,Done);
+  dispose(DirectorySwitches,Done);
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:52  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+}

+ 7 - 2
ide/text/fptemplt.pas

@@ -157,8 +157,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:52  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.2  1998/12/22 10:39:51  peter
     + options are now written/read

+ 475 - 0
ide/text/fpusrscr.pas

@@ -0,0 +1,475 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    User screen support routines
+
+    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.
+
+ **********************************************************************}
+
+unit FPUsrScr;
+
+interface
+
+{$ifdef TP}
+  {$define DOS}
+{$else}
+  {$ifdef GO32V2}
+    {$define DOS}
+  {$endif}
+{$endif}
+
+uses Objects;
+
+type
+
+    PScreen = ^TScreen;
+    TScreen = object(TObject)
+      function    GetWidth: integer; virtual;
+      function    GetHeight: integer; virtual;
+      procedure   GetLine(Line: integer; var Text, Attr: string); virtual;
+      procedure   GetCursorPos(var P: TPoint); virtual;
+      procedure   Capture; virtual;
+      procedure   SwitchTo; virtual;
+      procedure   SwitchBack; virtual;
+    end;
+
+{$ifdef DOS}
+    TDOSVideoInfo = record
+      Mode      : word;
+      ScreenSize: word;
+      Page      : byte;
+      Rows,Cols : integer;
+      CurPos    : TPoint;
+      CurShapeT : integer;
+      CurShapeB : integer;
+      StateSize : word;
+      StateBuf  : pointer;
+    end;
+
+    PDOSScreen = ^TDOSScreen;
+    TDOSScreen = object(TScreen)
+      constructor Init;
+      destructor  Done; virtual;
+    public
+      function    GetWidth: integer; virtual;
+      function    GetHeight: integer; virtual;
+      procedure   GetLine(Line: integer; var Text, Attr: string); virtual;
+      procedure   GetCursorPos(var P: TPoint); virtual;
+      procedure   Capture; virtual;
+      procedure   SwitchTo; virtual;
+      procedure   SwitchBack; virtual;
+    private
+      VideoInfo    : TDOSVideoInfo;
+      VBufferSize  : word;
+      VBuffer      : PByteArray;
+      TM           : TDOSVideoInfo;
+      function    GetLineStartOfs(Line: integer): word;
+      procedure   GetBuffer(Size: word);
+      procedure   FreeBuffer;
+      procedure   GetVideoMode(var MI: TDOSVideoInfo);
+      procedure   SetVideoMode(MI: TDOSVideoInfo);
+    end;
+{$endif}
+
+{$ifdef Linux}
+    PLinuxScreen = ^TLinuxScreen;
+    TLinuxScreen = object(TScreen)
+      constructor Init;
+      destructor  Done; virtual;
+    public
+      function    GetWidth: integer; virtual;
+      function    GetHeight: integer; virtual;
+      procedure   GetLine(Line: integer; var Text, Attr: string); virtual;
+      procedure   GetCursorPos(var P: TPoint); virtual;
+      procedure   Capture; virtual;
+      procedure   SwitchTo; virtual;
+      procedure   SwitchBack; virtual;
+    end;
+{$endif}
+
+procedure InitUserScreen;
+procedure DoneUserScreen;
+
+const UserScreen : PScreen = nil;
+
+implementation
+
+uses
+  Dos,Video
+  {$ifdef TP}
+    {$ifdef DPMI}
+    ,WinAPI
+    {$endif}
+  {$endif}
+  {$ifdef FPC}
+    {$ifdef GO32V2}
+    ,Go32
+    {$endif}
+  {$endif}
+  ;
+
+function TScreen.GetWidth: integer;
+begin
+  Abstract;
+end;
+
+function TScreen.GetHeight: integer;
+begin
+  Abstract;
+end;
+
+procedure TScreen.GetLine(Line: integer; var Text, Attr: string);
+begin
+  Abstract;
+end;
+
+procedure TScreen.GetCursorPos(var P: TPoint);
+begin
+  Abstract;
+end;
+
+procedure TScreen.Capture;
+begin
+  Abstract;
+end;
+
+procedure TScreen.SwitchTo;
+begin
+  Abstract;
+end;
+
+procedure TScreen.SwitchBack;
+begin
+  Abstract;
+end;
+
+
+{****************************************************************************
+                                 TDOSScreen
+****************************************************************************}
+
+{$ifdef DOS}
+
+constructor TDOSScreen.Init;
+begin
+  inherited Init;
+  Capture;
+end;
+
+
+destructor TDOSScreen.Done;
+begin
+  inherited Done;
+  FreeBuffer;
+end;
+
+
+function TDOSScreen.GetWidth: integer;
+begin
+  GetWidth:=VideoInfo.Cols;
+end;
+
+
+function TDOSScreen.GetHeight: integer;
+begin
+  GetHeight:=VideoInfo.Rows;
+end;
+
+
+procedure TDOSScreen.GetLine(Line: integer; var Text, Attr: string);
+var X: integer;
+    W: word;
+begin
+  Text:=''; Attr:='';
+  if Line<GetHeight then
+  begin
+    W:=GetLineStartOfs(Line);
+    for X:=0 to GetWidth-1 do
+     begin
+       Text:=Text+chr(VBuffer^[W+X*2]);
+       Attr:=Attr+chr(VBuffer^[W+X*2+1]);
+     end;
+  end;
+end;
+
+
+procedure TDOSScreen.GetCursorPos(var P: TPoint);
+begin
+  P:=VideoInfo.CurPos;
+end;
+
+
+procedure TDOSScreen.Capture;
+var X,Y: integer;
+    W: word;
+    r: registers;
+    VSeg,SOfs: word;
+begin
+  GetVideoMode(VideoInfo);
+  GetBuffer(VideoInfo.ScreenSize);
+  if VideoInfo.Mode=7 then
+   VSeg:=SegB000
+  else
+   VSeg:=SegB800;
+  SOfs:=MemW[Seg0040:$4e];
+{$ifdef FPC}
+  DosmemGet(VSeg,SOfs,VBuffer^,VideoInfo.ScreenSize);
+{$else}
+  Move(ptr(VSeg,SOfs)^,VBuffer^,VideoInfo.ScreenSize);
+{$endif}
+end;
+
+
+procedure TDOSScreen.SwitchTo;
+var X,Y: integer;
+    W: word;
+    r: registers;
+    VSeg,SOfs: word;
+begin
+  GetVideoMode(TM);
+  SetVideoMode(VideoInfo);
+  if VideoInfo.Mode=7 then
+    VSeg:=SegB000
+  else
+    VSeg:=SegB800;
+  SOfs:=MemW[Seg0040:$4e];
+{$ifdef FPC}
+  DosmemPut(VSeg,SOfs,VBuffer^,VideoInfo.ScreenSize);
+{$else}
+  Move(VBuffer^,ptr(VSeg,SOfs)^,VideoInfo.ScreenSize);
+{$endif}
+end;
+
+
+procedure TDOSScreen.SwitchBack;
+begin
+  Capture;
+  SetVideoMode(TM);
+end;
+
+
+function TDOSScreen.GetLineStartOfs(Line: integer): word;
+begin
+  GetLineStartOfs:=(VideoInfo.Cols*Line)*2;
+end;
+
+
+procedure TDOSScreen.GetBuffer(Size: word);
+begin
+  if (VBuffer<>nil) and (VBufferSize=Size) then Exit;
+  if VBuffer<>nil then FreeBuffer;
+  VBufferSize:=Size;
+  GetMem(VBuffer,VBufferSize);
+end;
+
+
+procedure TDOSScreen.FreeBuffer;
+begin
+  if (VBuffer<>nil) and (VBufferSize>0) then FreeMem(VBuffer,VBufferSize);
+  VBuffer:=nil;
+end;
+
+
+procedure TDOSScreen.GetVideoMode(var MI: TDOSVideoInfo);
+var
+  r: registers;
+{$ifdef TP}
+  P: pointer;
+  Sel: longint;
+  {$I realintr.inc}
+{$endif}
+begin
+  if (MI.StateSize>0) and (MI.StateBuf<>nil) then
+     begin FreeMem(MI.StateBuf,MI.StateSize); MI.StateBuf:=nil; end;
+
+  MI.ScreenSize:=MemW[Seg0040:$4c];
+  r.ah:=$0f;
+  intr($10,r);
+  MI.Mode:=r.al;
+  MI.Page:=r.bh;
+  MI.Cols:=r.ah;
+  MI.Rows:=MI.ScreenSize div (MI.Cols*2);
+  r.ah:=$03;
+  r.bh:=MI.Page;
+  intr($10,r);
+  with MI do
+  begin
+    CurPos.X:=r.dl; CurPos.Y:=r.dh;
+    CurShapeT:=r.ch; CurShapeB:=r.cl;
+  end;
+
+(*
+{$ifdef TP}
+  { check VGA functions }
+  MI.StateSize:=0;
+  r.ah:=$1c; r.al:=0; r.cx:=7; intr($10,r);
+  if (r.al=$1c) and ((r.flags and fCarry)=0) and (r.bx>0) then
+  begin
+    MI.StateSize:=r.bx;
+    GetMem(MI.StateBuf,MI.StateSize); FillChar(MI.StateBuf^,MI.StateSize,0);
+    P:=MI.StateBuf;
+{$ifdef DPMI}
+    Sel:=GlobalDosAlloc(MI.StateSize);
+    P:=Ptr(Sel shr 16,0);
+{$endif}
+    r.ah:=$1c; r.al:=1; r.cx:=7;
+    r.es:=PtrRec(P).Seg; r.bx:=PtrRec(P).Ofs;
+    {$ifdef DPMI}realintr($10,r);{$else}intr($10,r);{$endif}
+{$ifdef DPMI}
+    Move(Ptr(Sel and $ffff,0)^,MI.StateBuf^,MI.StateSize);
+    GlobalDosFree(Sel and $ffff);
+{$endif}
+  end;
+{$endif}
+*)
+end;
+
+
+procedure TDOSScreen.SetVideoMode(MI: TDOSVideoInfo);
+var r: registers;
+{$ifdef TP}
+    P: pointer;
+    Sel: longint;
+{$I realintr.inc}
+{$endif}
+begin
+  r.ah:=$00; r.al:=MI.Mode; intr($10,r);
+  r.ah:=$05; r.al:=MI.Page; intr($10,r);
+  r.ah:=$02; r.bh:=MI.Page; r.dl:=MI.CurPos.X; r.dh:=MI.CurPos.Y; intr($10,r);
+  r.ah:=$01; r.ch:=MI.CurShapeT; r.cl:=MI.CurShapeB; intr($10,r);
+
+  (*
+{$ifdef TP}
+  if (MI.StateSize>0) and (MI.StateBuf<>nil) then
+  begin
+    P:=MI.StateBuf;
+{$ifdef DPMI}
+    Sel:=GlobalDosAlloc(MI.StateSize);
+    Move(MI.StateBuf^,ptr(Sel and $ffff,0)^,MI.StateSize);
+    P:=Ptr(Sel shr 16,0);
+{$endif}
+    r.ah:=$1c; r.al:=2; r.cx:=7;
+    r.es:=PtrRec(P).Seg; r.bx:=PtrRec(P).Ofs;
+    {$ifdef DPMI}realintr($10,r);{$else}intr($10,r);{$endif}
+{$ifdef DPMI}
+    GlobalDosFree(Sel and $ffff);
+{$endif}
+  end;
+{$endif}
+*)
+end;
+
+{$endif}
+
+
+{****************************************************************************
+                                 TLinuxScreen
+****************************************************************************}
+
+{$ifdef Linux}
+
+constructor TLinuxScreen.Init;
+begin
+  inherited Init;
+end;
+
+
+destructor TLinuxScreen.Done;
+begin
+  inherited Done;
+end;
+
+
+function TLinuxScreen.GetWidth: integer;
+begin
+  GetWidth:=ScreenWidth;
+end;
+
+
+function TLinuxScreen.GetHeight: integer;
+begin
+  GetHeight:=ScreenHeight;
+end;
+
+
+procedure TLinuxScreen.GetLine(Line: integer; var Text, Attr: string);
+begin
+  Text:='';
+  Attr:='';
+end;
+
+
+procedure TLinuxScreen.GetCursorPos(var P: TPoint);
+begin
+  P.X:=0;
+  P.Y:=0;
+end;
+
+
+procedure TLinuxScreen.Capture;
+begin
+end;
+
+
+procedure TLinuxScreen.SwitchTo;
+begin
+end;
+
+
+procedure TLinuxScreen.SwitchBack;
+begin
+end;
+
+{$endif}
+
+
+{****************************************************************************
+                                 Initialize
+****************************************************************************}
+
+procedure InitUserScreen;
+begin
+{$ifdef DOS}
+  UserScreen:=New(PDOSScreen, Init);
+{$else}
+  {$ifdef LINUX}
+    UserScreen:=New(PLinuxScreen, Init);
+  {$else}
+    UserScreen:=New(PScreen, Init);
+  {$endif}
+{$endif}
+end;
+
+
+procedure DoneUserScreen;
+begin
+  if UserScreen<>nil then
+   begin
+     UserScreen^.SwitchTo;
+     Dispose(UserScreen, Done);
+   end;
+end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:53  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.0  1998/12/24 09:55:49  gabor
+    Original implementation
+
+}

+ 238 - 3
ide/text/fputils.pas

@@ -20,18 +20,27 @@ interface
 const
 {$ifdef linux}
   dirsep = '/';
+  exeext = '';
 {$else}
   dirsep = '\';
+  exeext = '.exe';
 {$endif}
 
 function IntToStr(L: longint): string;
 function IntToStrZ(L: longint; MinLen: byte): string;
 function IntToStrL(L: longint; MinLen: byte): string;
 function StrToInt(S: string): longint;
+function IntToHex(L: longint): string;
+function IntToHexL(L: longint; MinLen: byte): string;
+function HexToInt(S: string): longint;
 function CharStr(C: char; Count: byte): string;
 function SmartPath(Path: string): string;
+function MakeExeName(const fn:string):string;
 function LExpand(S: string; MinLen: byte): string;
 function RExpand(S: string; MinLen: byte): string;
+function LTrim(S: string): string;
+function RTrim(S: string): string;
+function Trim(S: string): string;
 function KillTilde(S: string): string;
 function UpcaseStr(S: string): string;
 function LowerCaseStr(S: string): string;
@@ -39,12 +48,26 @@ function Max(A,B: longint): longint;
 function Min(A,B: longint): longint;
 function DirOf(S: string): string;
 function NameOf(S: string): string;
+function NameAndExtOf(S: string): string;
 function StrToExtended(S: string): Extended;
 function Power(const A,B: double): double;
+function GetCurDir: string;
+function MatchesMask(What, Mask: string): boolean;
+function MatchesMaskList(What, MaskList: string): boolean;
+function MatchesFileList(What, FileList: string): boolean;
+function EatIO: integer;
+function ExistsFile(FileName: string): boolean;
+function CompleteDir(Path: string): string;
+function LocateFile(FileList: string): string;
+
+const LastStrToIntResult : integer = 0;
+      LastHexToIntResult : integer = 0;
+      ListSeparator      : char = ';';
 
 implementation
 
-uses Dos;
+uses Dos,
+     FPVars;
 
 function IntToStr(L: longint): string;
 var S: string;
@@ -59,6 +82,7 @@ var L: longint;
 begin
   Val(S,L,C);
   if C<>0 then L:=-1;
+  LastStrToIntResult:=C;
   StrToInt:=L;
 end;
 
@@ -95,6 +119,18 @@ begin
   SmartPath:=Path;
 end;
 
+
+function MakeExeName(const fn:string):string;
+var
+  d : DirStr;
+  n : NameStr;
+  e : ExtStr;
+begin
+  FSplit(fn,d,n,e);
+  MakeExeName:=d+n+ExeExt;
+end;
+
+
 function LExpand(S: string; MinLen: byte): string;
 begin
   if length(S)<MinLen then S:=CharStr(' ',MinLen-length(S))+S;
@@ -158,6 +194,13 @@ begin
   NameOf:=N;
 end;
 
+function NameAndExtOf(S: string): string;
+var D: DirStr; E: ExtStr; N: NameStr;
+begin
+  FSplit(S,D,N,E);
+  NameAndExtOf:=N+E;
+end;
+
 function StrToExtended(S: string): Extended;
 var R : Extended;
     C : integer;
@@ -172,13 +215,205 @@ begin
          else Power:=exp(B*ln(A));
 end;
 
+function GetCurDir: string;
+var S: string;
+begin
+  GetDir(0,S);
+  if copy(S,length(S),1)<>DirSep then S:=S+DirSep;
+  GetCurDir:=S;
+end;
+
+function IntToHex(L: longint): string;
+const HexNums : string[16] = '0123456789ABCDEF';
+var S: string;
+    R: real;
+function DivF(Mit,Mivel: real): longint;
+begin
+  DivF:=trunc(Mit/Mivel);
+end;
+function ModF(Mit,Mivel: real): longint;
+begin
+  ModF:=trunc(Mit-DivF(Mit,Mivel)*Mivel);
+end;
+begin
+  S:='';
+  R:=L; if R<0 then begin R:=R+2147483647+2147483647+2; end;
+  repeat
+    S:=HexNums[ModF(R,16)+1]+S;
+    R:=DivF(R,16);
+  until R=0;
+  IntToHex:=S;
+end;
+
+function HexToInt(S: string): longint;
+var L,I: longint;
+    C: char;
+const HexNums: string[16] = '0123456789ABCDEF';
+begin
+  S:=Trim(S); L:=0; I:=1; LastHexToIntResult:=0;
+  while (I<=length(S)) and (LastHexToIntResult=0) do
+  begin
+    C:=Upcase(S[I]);
+    if C in['0'..'9','A'..'F'] then
+    begin
+      L:=L*16+(Pos(C,HexNums)-1);
+    end else LastHexToIntResult:=I;
+    Inc(I);
+  end;
+  HexToInt:=L;
+end;
+
+function IntToHexL(L: longint; MinLen: byte): string;
+var S: string;
+begin
+  S:=IntToHex(L);
+  while length(S)<MinLen do S:='0'+S;
+  IntToHexL:=S;
+end;
+
+function LTrim(S: string): string;
+begin
+  while copy(S,1,1)=' ' do Delete(S,1,1);
+  LTrim:=S;
+end;
+
+function RTrim(S: string): string;
+begin
+  while copy(S,length(S),1)=' ' do Delete(S,length(S),1);
+  RTrim:=S;
+end;
+
+function Trim(S: string): string;
+begin
+  Trim:=RTrim(LTrim(S));
+end;
+
+function MatchesMask(What, Mask: string): boolean;
+var P: integer;
+    Match: boolean;
+begin
+  P:=Pos('*',Mask);
+  if P>0 then
+    begin
+      Mask:=copy(Mask,1,P-1);
+      What:=copy(What,1,P-1);
+    end;
+  Match:=length(Mask)=length(What); P:=1;
+  if Match and (Mask<>'') then
+  repeat
+    Match:=Match and ((Mask[P]='?') or (Upcase(Mask[P])=Upcase(What[P])));
+    Inc(P);
+  until (Match=false) or (P>length(Mask));
+  MatchesMask:=Match;
+end;
+
+function MatchesMaskList(What, MaskList: string): boolean;
+var P: integer;
+    Match: boolean;
+begin
+  Match:=false;
+  if What<>'' then
+  repeat
+    P:=Pos(ListSeparator, MaskList);
+    if P=0 then P:=length(MaskList)+1;
+    Match:=MatchesMask(What,copy(MaskList,1,P-1));
+    Delete(MaskList,1,P);
+  until Match or (MaskList='');
+  MatchesMaskList:=Match;
+end;
+
+function MatchesFileList(What, FileList: string): boolean;
+var P: integer;
+    Match: boolean;
+    WD,FD : record D: DirStr; N: NameStr; E: ExtStr; end;
+    F: string;
+begin
+  Match:=false;
+  FSplit(What,WD.D,WD.N,WD.E);
+  if What<>'' then
+  repeat
+    P:=Pos(ListSeparator, FileList);
+    if P=0 then P:=length(FileList)+1;
+    F:=copy(FileList,1,P-1);
+    FSplit(F,FD.D,FD.N,FD.E);
+    Match:=MatchesMask(WD.D+WD.N,FD.D+FD.N) and
+           MatchesMask(WD.E,FD.E);
+    Delete(FileList,1,P);
+  until Match or (FileList='');
+  MatchesFileList:=Match;
+end;
+
+function EatIO: integer;
+begin
+  EatIO:=IOResult;
+end;
+
+function ExistsFile(FileName: string): boolean;
+var f: file;
+    Exists: boolean;
+begin
+  {$I-}
+  Assign(f,FileName);
+  Reset(f,1);
+  Exists:=EatIO=0;
+  Close(f);
+  EatIO;
+  {$I+}
+  ExistsFile:=Exists;
+end;
+
+function CompleteDir(Path: string): string;
+begin
+  if copy(Path,length(Path),1)<>DirSep then Path:=Path+DirSep;
+  CompleteDir:=Path;
+end;
+
+function LocateFile(FileList: string): string;
+var FilePath: string;
+function CheckFile(Path,Name: string): boolean;
+var OK: boolean;
+begin
+  Path:=CompleteDir(Path);
+  Path:=Path+Name;
+  OK:=ExistsFile(Path);
+  if OK then FilePath:=Path;
+  CheckFile:=OK;
+end;
+function LocateSingleFile(FileName: string): boolean;
+var OK: boolean;
+begin
+  OK:=CheckFile(FExpand('.'),FileName);
+  if OK=false then OK:=CheckFile(StartupDir,FileName);
+  if OK=false then OK:=CheckFile(DirOf(FExpand(ParamStr(0))),FileName);
+  LocateSingleFile:=OK;
+end;
+var P: integer;
+begin
+  FilePath:='';
+  if FileList<>'' then
+  repeat
+    P:=Pos(ListSeparator,FileList); if P=0 then P:=length(FileList)+1;
+    LocateSingleFile(copy(FileList,1,P-1));
+    Delete(FileList,1,P);
+  until (FilePath<>'') or (FileList='');
+  LocateFile:=FilePath;
+end;
+
 
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:53  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
+  Revision 1.31 1998/12/27 11:25:37  gabor
+    + MatchesMask(), MatchesMaskList() and MatchesFileList() added
+    + NameAndExtOf() added
   Revision 1.3  1998/12/22 10:39:52  peter
     + options are now written/read
     + find and replace routines

+ 72 - 0
ide/text/fpvars.pas

@@ -0,0 +1,72 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Global variables for the IDE
+
+    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.
+
+ **********************************************************************}
+unit FPVars;
+
+interface
+
+uses Objects,Views,App,
+     FPConst,FPUtils,FPViews,FPCalc;
+
+type
+    TRecentFileEntry = record
+      FileName  : string;
+      LastPos   : TPoint;
+    end;
+
+    TCompPhase = (cpCompiling,cpLinking,cpDone);
+
+const ClipboardWindow  : PClipboardWindow = nil;
+      CalcWindow       : PCalculator = nil;
+      RecentFileCount  : integer = 0;
+      HighlightExts    : string[80] = '*.pas;*.pp;*.inc';
+      PrimaryFile      : string = '';
+      IsEXECompiled    : boolean = false;
+      MainFile         : string = '';
+      CompilationPhase : TCompPhase = cpDone;
+      ProgramInfoWindow: PProgramInfoWindow = nil;
+      UserScreenWindow : PScreenWindow = nil;
+      HelpFiles        : FPViews.PUnsortedStringCollection = nil;
+      ShowStatusOnError: boolean = true;
+      StartupDir       : string = '.'+DirSep;
+      INIPath          : string = ININame;
+      SwitchesPath     : string = SwitchesName;
+      CtrlMouseAction  : integer = acTopicSearch;
+      AltMouseAction   : integer = acBrowseSymbol;
+
+      ActionCommands   : array[acFirstAction..acLastAction] of word =
+        (cmHelpTopicSearch,cmGotoCursor,cmToggleBreakpoint,
+         cmEvaluate,cmAddWatch,cmBrowseAtCursor);
+
+      AppPalette       : string = CAppColor;
+
+var   RecentFiles      : array[1..MaxRecentFileCount] of TRecentFileEntry;
+
+implementation
+
+END.
+{
+  $Log$
+  Revision 1.1  1998-12-28 15:47:54  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.0  1998/12/23 07:34:40  gabor
+
+}

+ 289 - 10
ide/text/fpviews.pas

@@ -26,7 +26,7 @@ uses
 {$endif}
   WHlpView,
   Comphook,
-  FPConst;
+  FPConst,FPUsrScr;
 
 type
 {$IFNDEF EDITORS}
@@ -121,6 +121,15 @@ type
       procedure HandleEvent(var Event: TEvent); virtual;
     end;
 
+    TLocalMenuListBox = object(TAdvancedListBox)
+      procedure   HandleEvent(var Event: TEvent); virtual;
+      procedure   LocalMenu(P: TPoint); virtual;
+      function    GetLocalMenu: PMenu; virtual;
+      function    GetCommandTarget: PView; virtual;
+    private
+      LastLocalCmd: word;
+    end;
+
     PColorStaticText = ^TColorStaticText;
     TColorStaticText = object(TAdvancedStaticText)
       Color: word;
@@ -132,11 +141,12 @@ type
 
     PUnsortedStringCollection = ^TUnsortedStringCollection;
     TUnsortedStringCollection = object(TCollection)
+      function  At(Index: Integer): PString;
       procedure FreeItem(Item: Pointer); virtual;
     end;
 
     PHSListBox = ^THSListBox;
-    THSListBox = object(TListBox)
+    THSListBox = object(TLocalMenuListBox)
       constructor Init(var Bounds: TRect; ANumCols: Word; AHScrollBar, AVScrollBar: PScrollBar);
     end;
 
@@ -173,9 +183,13 @@ type
       MaxWidth: integer;
       constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
       procedure   AddItem(P: PMessageItem); virtual;
-      procedure   Clear; virtual;
       function    GetText(Item: Integer; MaxLen: Integer): String; virtual;
+      procedure   Clear; virtual;
+      procedure   TrackSource; virtual;
+      procedure   GotoSource; virtual;
       procedure   Draw; virtual;
+      procedure   HandleEvent(var Event: TEvent); virtual;
+      function    GetLocalMenu: PMenu; virtual;
       destructor  Done; virtual;
     end;
 
@@ -230,6 +244,23 @@ type
       InDraw: boolean;
     end;
 
+    PScreenView = ^TScreenView;
+    TScreenView = object(TScroller)
+      Screen: PScreen;
+      constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
+                    AScreen: PScreen);
+      procedure   Draw; virtual;
+      procedure   Update; virtual;
+      procedure   HandleEvent(var Event: TEvent); virtual;
+    end;
+
+    PScreenWindow = ^TScreenWindow;
+    TScreenWindow = object(TWindow)
+      ScreenView : PScreenView;
+      constructor Init(AScreen: PScreen);
+      procedure   Close; virtual;
+    end;
+
 function  SearchFreeWindowNo: integer;
 
 procedure InsertOK(ADialog: PDialog);
@@ -237,6 +268,7 @@ procedure InsertButtons(ADialog: PDialog);
 
 procedure ErrorBox(S: string; Params: pointer);
 procedure InformationBox(S: string; Params: pointer);
+function  ConfirmBox(S: string; Params: pointer; CanCancel: boolean): word;
 
 function IsThereAnyEditor: boolean;
 function IsThereAnyWindow: boolean;
@@ -259,6 +291,8 @@ procedure DisposeTabDef(P: PTabDef);
 function  GetEditorCurWord(Editor: PEditor): string;
 procedure InitReservedWords;
 
+procedure TranslateMouseClick(View: PView; var Event: TEvent);
+
 const
       SourceCmds  : TCommandSet =
         ([cmSave,cmSaveAs,cmCompile]);
@@ -275,9 +309,9 @@ const
 implementation
 
 uses
-  Memory,MsgBox,Validate,
+  Keyboard,Memory,MsgBox,Validate,
   Tokens,
-  FPUtils,FPHelp;
+  FPVars,FPUtils,FPHelp;
 
 const
   NoNameCount    : integer = 0;
@@ -616,7 +650,9 @@ end;
 procedure TSourceEditor.HandleEvent(var Event: TEvent);
 var DontClear: boolean;
     P: TPoint;
+    S: string;
 begin
+  TranslateMouseClick(@Self,Event);
   case Event.What of
     evMouseDown :
       if MouseInView(Event.Where) and (Event.Buttons=mbRightButton) then
@@ -645,9 +681,14 @@ begin
             end;
           cmOpenAtCursor :
             begin
-              OpenFileName:=LowerCaseStr(GetEditorCurWord(@Self))+'.pas';
+              S:=LowerCaseStr(GetEditorCurWord(@Self));
+              OpenFileName:=S+'.pp'+ListSeparator+
+                            S+'.pas'+ListSeparator+
+                            S+'.inc';
               Message(Application,evCommand,cmOpen,nil);
             end;
+          cmEditorOptions :
+            Message(Application,evCommand,cmEditorOptions,@Self);
           cmHelp :
             Message(@Self,evCommand,cmHelpTopicSearch,@Self);
           cmHelpTopicSearch :
@@ -683,6 +724,7 @@ var HSB,VSB: PScrollBar;
     LoadFile: boolean;
 begin
   inherited Init(Bounds,AFileName,SearchFreeWindowNo);
+  Options:=Options or ofTileAble;
   GetExtent(R); R.A.Y:=R.B.Y-1; R.Grow(-1,0); R.A.X:=14;
   New(HSB, Init(R)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
   GetExtent(R); R.A.X:=R.B.X-1; R.Grow(0,-1);
@@ -1621,6 +1663,11 @@ begin
   MessageBox(S,Params,mfInformation+mfInsertInApp+mfOKButton);
 end;
 
+function ConfirmBox(S: string; Params: pointer; CanCancel: boolean): word;
+begin
+  MessageBox(S,Params,mfConfirmation+mfInsertInApp+mfYesButton+mfNoButton+integer(CanCancel)*mfCancelButton);
+end;
+
 function IsSeparator(P: PMenuItem): boolean;
 begin
   IsSeparator:=(P<>nil) and (P^.Name=nil) and (P^.HelpCtx=hcNoContext);
@@ -1858,6 +1905,11 @@ begin
  end;
 end;
 
+function TUnsortedStringCollection.At(Index: Integer): PString;
+begin
+  At:=inherited At(Index);
+end;
+
 procedure TUnsortedStringCollection.FreeItem(Item: Pointer);
 begin
   if Item<>nil then DisposeStr(Item);
@@ -1876,12 +1928,121 @@ begin
   Flags:=Flags or (wfMove + wfGrow + wfClose + wfZoom);
 end;
 
+procedure TLocalMenuListBox.LocalMenu(P: TPoint);
+var M: PMenu;
+    MV: PAdvancedMenuPopUp;
+    R: TRect;
+    Re: word;
+begin
+  M:=GetLocalMenu;
+  if M=nil then Exit;
+  if LastLocalCmd<>0 then
+     M^.Default:=SearchMenuItem(M,LastLocalCmd);
+  Desktop^.GetExtent(R);
+  MakeGlobal(P,R.A); {Desktop^.MakeLocal(R.A,R.A);}
+  New(MV, Init(R, M));
+  Re:=Application^.ExecView(MV);
+  if M^.Default=nil then LastLocalCmd:=0
+     else LastLocalCmd:=M^.Default^.Command;
+  Dispose(MV, Done);
+  if Re<>0 then
+    Message(GetCommandTarget,evCommand,Re,@Self);
+end;
+
+function TLocalMenuListBox.GetLocalMenu: PMenu;
+begin
+  Abstract;
+end;
+
+function TLocalMenuListBox.GetCommandTarget: PView;
+begin
+  GetCommandTarget:=@Self;
+end;
+
+procedure TLocalMenuListBox.HandleEvent(var Event: TEvent);
+var DontClear: boolean;
+    P: TPoint;
+begin
+  case Event.What of
+    evMouseDown :
+      if MouseInView(Event.Where) and (Event.Buttons=mbRightButton) then
+        begin
+          MakeLocal(Event.Where,P); Inc(P.X); Inc(P.Y);
+          LocalMenu(P);
+          ClearEvent(Event);
+        end;
+    evKeyDown :
+      begin
+        DontClear:=false;
+        case Event.KeyCode of
+          kbAltF10 : Message(@Self,evCommand,cmLocalMenu,@Self);
+        else DontClear:=true;
+        end;
+        if DontClear=false then ClearEvent(Event);
+      end;
+    evCommand :
+      begin
+        DontClear:=false;
+        case Event.Command of
+          cmLocalMenu :
+            begin
+              P:=Cursor; Inc(P.X); Inc(P.Y);
+              LocalMenu(P);
+            end;
+        else DontClear:=true;
+        end;
+        if not DontClear then ClearEvent(Event);
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+
 constructor TMessageListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
 begin
   inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
   NoSelection:=true;
 end;
 
+function TMessageListBox.GetLocalMenu: PMenu;
+var M: PMenu;
+begin
+  if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
+  M:=NewMenu(
+    NewItem('~C~lear','',kbNoKey,cmMsgClear,hcMsgClear,
+    NewLine(
+    NewItem('~G~oto source','',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
+    NewItem('~T~rack source','',kbNoKey,cmMsgTrackSource,hcMsgTrackSource,
+    nil)))));
+  GetLocalMenu:=M;
+end;
+
+procedure TMessageListBox.HandleEvent(var Event: TEvent);
+var DontClear: boolean;
+begin
+  case Event.What of
+    evCommand :
+      begin
+        DontClear:=false;
+        case Event.What of
+          cmDefault :
+            Message(@Self,evCommand,cmMsgGotoSource,nil);
+          cmMsgGotoSource :
+            if Range>0 then
+            GotoSource;
+          cmMsgTrackSource :
+            if Range>0 then
+            TrackSource;
+          cmMsgClear :
+            Clear;
+        else DontClear:=true;
+        end;
+        if DontClear=false then ClearEvent(Event);
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
 procedure TMessageListBox.AddItem(P: PMessageItem);
 var W: integer;
 begin
@@ -1915,6 +2076,16 @@ begin
   SetRange(0); DrawView;
 end;
 
+procedure TMessageListBox.TrackSource;
+begin
+end;
+
+procedure TMessageListBox.GotoSource;
+var P: PMessageItem;
+begin
+{  if TryToOpenSource(}
+end;
+
 procedure TMessageListBox.Draw;
 var
   I, J, Item: Integer;
@@ -2035,8 +2206,10 @@ begin
     V_Used        then ClassS:='Used'        else if TClass =
     V_Tried       then ClassS:='Tried'       else if TClass =
     V_Debug       then ClassS:='Debug'
-  else ClassS:='???';
-  if ClassS<>'' then ClassS:=RExpand(ClassS,0)+': ';
+  else
+   ClassS:='???';
+  if ClassS<>'' then
+   ClassS:=RExpand(ClassS,0)+': ';
   S:=ClassS;
   if (Module<>nil) and (ID<>0) then
      S:=S+Module^+' ('+IntToStr(ID)+'): ';
@@ -2485,12 +2658,118 @@ begin
         end;
 end;
 
+constructor TScreenView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
+              AScreen: PScreen);
+begin
+  inherited Init(Bounds,AHScrollBar,AVScrollBar);
+  Screen:=AScreen;
+  if Screen=nil then
+   Fail;
+  SetState(sfCursorVis,true);
+  Update;
+end;
+
+procedure TScreenView.Update;
+begin
+  SetLimit(UserScreen^.GetWidth,UserScreen^.GetHeight);
+  DrawView;
+end;
+
+procedure TScreenView.HandleEvent(var Event: TEvent);
+begin
+  case Event.What of
+    evBroadcast :
+      case Event.Command of
+        cmUpdate  : Update;
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+procedure TScreenView.Draw;
+var B: TDrawBuffer;
+    X,Y: integer;
+    Text,Attr: string;
+    P: TPoint;
+begin
+  Screen^.GetCursorPos(P);
+  for Y:=Delta.Y to Delta.Y+Size.Y-1 do
+  begin
+    if Y<Screen^.GetHeight then
+      Screen^.GetLine(Y,Text,Attr)
+    else
+       begin Text:=''; Attr:=''; end;
+    Text:=copy(Text,Delta.X+1,255); Attr:=copy(Attr,Delta.X+1,255);
+    MoveChar(B,' ',0,Size.X);
+    for X:=1 to length(Text) do
+      MoveChar(B[X-1],Text[X],ord(Attr[X]),1);
+    WriteLine(0,Y-Delta.Y,Size.X,1,B);
+  end;
+  SetCursor(P.X-Delta.X,P.Y-Delta.Y);
+end;
+
+constructor TScreenWindow.Init(AScreen: PScreen);
+var R: TRect;
+    VSB,HSB: PScrollBar;
+begin
+  Desktop^.GetExtent(R);
+  inherited Init(R, 'User screen', wnNoNumber);
+  Options:=Options or ofTileAble;
+  GetExtent(R); R.Grow(-1,-1); R.Move(1,0); R.A.X:=R.B.X-1;
+  New(VSB, Init(R)); VSB^.Options:=VSB^.Options or ofPostProcess;
+  VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
+  GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.A.Y:=R.B.Y-1;
+  New(HSB, Init(R)); HSB^.Options:=HSB^.Options or ofPostProcess;
+  HSB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY; Insert(HSB);
+  GetExtent(R); R.Grow(-1,-1);
+  New(ScreenView, Init(R, HSB, VSB, AScreen));
+  ScreenView^.GrowMode:=gfGrowHiX+gfGrowHiY;
+  Insert(ScreenView);
+end;
+
+procedure TScreenWindow.Close;
+begin
+  Hide;
+end;
+
+const InTranslate : boolean = false;
+
+procedure TranslateMouseClick(View: PView; var Event: TEvent);
+procedure TranslateAction(Action: integer);
+var E: TEvent;
+begin
+  if Action<>acNone then
+  begin
+    E:=Event;
+    E.What:=evMouseDown; E.Buttons:=mbLeftButton;
+    View^.HandleEvent(E);
+    Event.What:=evCommand;
+    Event.Command:=ActionCommands[Action];
+  end;
+end;
+begin
+  if InTranslate then Exit;
+  InTranslate:=true;
+  case Event.What of
+    evMouseDown :
+      if (GetShiftState and kbAlt)<>0 then
+        TranslateAction(AltMouseAction) else
+      if (GetShiftState and kbCtrl)<>0 then
+        TranslateAction(CtrlMouseAction);
+  end;
+  InTranslate:=false;
+end;
 
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:54  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.4  1998/12/22 10:39:53  peter
     + options are now written/read

+ 61 - 0
ide/text/realintr.inc

@@ -0,0 +1,61 @@
+{$IFDEF DPMI}
+const
+    DPMI_INTR      = $31;
+
+type
+    TDPMIRegisters = record     { DPMI call structure }
+      EDI     : LongInt;
+      ESI     : LongInt;
+      EBP     : LongInt;
+      Reserved: LongInt;
+      EBX     : LongInt;
+      EDX     : LongInt;
+      ECX     : LongInt;
+      EAX     : LongInt;
+      Flags   : Word;
+      ES      : Word;
+      DS      : Word;
+      FS      : Word;
+      GS      : Word;
+      IP      : Word;
+      CS      : Word;
+      SP      : Word;
+      SS      : Word;
+    end;
+
+  var
+    DPMIRegs: TDPMIRegisters;
+
+  procedure realintr(IntNo: byte; var r: registers);
+  var Regs: Registers;
+  begin
+    FillChar(DPMIRegs, SizeOf(TDPMIRegisters), 0);
+    DPMIRegs.EAX := r.ax;
+    DPMIRegs.EBX := r.bx;
+    DPMIRegs.ECX := r.cx;
+    DPMIRegs.EDX := r.dx;
+    DPMIRegs.EDI := r.di;
+    DPMIRegs.ESI := r.si;
+    DPMIRegs.EBP := r.bp;
+    DPMIRegs.DS := r.ds;
+    DPMIRegs.ES := r.es;
+    DPMIRegs.Flags := r.flags;
+    Regs.AX := $0300;
+    Regs.BL := IntNo;
+    Regs.BH := 0;
+    Regs.CX := 0;
+    Regs.ES := Seg(DPMIRegs);
+    Regs.DI := Ofs(DPMIRegs);
+    Intr(DPMI_INTR, Regs);
+    r.ax := DPMIRegs.EAX;
+    r.bx := DPMIRegs.EBX;
+    r.cx := DPMIRegs.ECX;
+    r.dx := DPMIRegs.EDX;
+    r.di := DPMIRegs.EDI;
+    r.si := DPMIRegs.ESI;
+    r.bp := DPMIRegs.EBP;
+    r.ds := DPMIRegs.DS;
+    r.es := DPMIRegs.ES;
+    r.Flags := DPMIRegs.Flags;
+  end;
+{$ENDIF}

+ 108 - 49
ide/text/weditor.pas

@@ -28,17 +28,18 @@ const
       MaxLineLength = 255;
       MaxLineCount  = 16380;
 
-      efBlockInsCursor      = $00000001;
-      efAutoIndent          = $00000002;
-      efPersistentBlocks    = $00000004;
-      efVerticalBlocks      = $00000008;
-      efUseTabCharacters    = $00000010;
-      efBackSpaceUnindents  = $00000020;
+      efBackupFiles         = $00000001;
+      efInsertMode          = $00000002;
+      efAutoIndent          = $00000004;
+      efUseTabCharacters    = $00000008;
+      efBackSpaceUnindents  = $00000010;
+      efPersistentBlocks    = $00000020;
       efSyntaxHighlight     = $00000040;
-      efAutoBrackets        = $00000080;
-      efHighlightColumn     = $00000100;
-      efHighlightRow        = $00000200;
-      efBackupFiles         = $00001000;
+      efBlockInsCursor      = $00000080;
+      efVerticalBlocks      = $00000100;
+      efHighlightColumn     = $00000200;
+      efHighlightRow        = $00000400;
+      efAutoBrackets        = $00000800;
 
       attrAsm       = 1;
       attrComment   = 2;
@@ -94,7 +95,7 @@ const
       coFirstColor        = 0;
       coLastColor         = coDirectiveColor;
 
-      CIndicator          = #2#3;
+      CIndicator          = #2#3#1;
       CEditor             = #33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48;
 
       TAB           = #9;
@@ -144,12 +145,12 @@ type
       CanUndo    : Boolean;
       Modified   : Boolean;
       IsReadOnly : Boolean;
-      Overwrite  : Boolean;
       NoSelect   : Boolean;
       Flags      : longint;
       TabSize    : integer;
       constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
                     PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
+      procedure   SetFlags(AFlags: longint); virtual;
       procedure   ConvertEvent(var Event: TEvent); virtual;
       procedure   HandleEvent(var Event: TEvent); virtual;
       procedure   SetState(AState: Word; Enable: Boolean); virtual;
@@ -172,6 +173,7 @@ type
       function    IsClipboard: Boolean;
       destructor  Done; virtual;
     public
+      { Text & info storage abstraction }
       function    GetLineCount: integer; virtual;
       function    GetLineText(I: integer): string; virtual;
       procedure   SetLineText(I: integer; S: string); virtual;
@@ -182,6 +184,7 @@ type
     private
       KeyState: Integer;
       ErrorMessage: PString;
+      function    Overwrite: boolean;
       function    GetLine(I: integer): PLine;
       procedure   CheckSels;
       function    UpdateAttrs(FromLine: integer; Attrs: byte): integer;
@@ -248,8 +251,9 @@ type
     TCodeEditorDialog = function(Dialog: Integer; Info: Pointer): Word;
 
 const
-     DefaulTCodeEditorFlags : longint =
-      efBackupFiles+efAutoIndent+efPersistentBlocks+efBackSpaceUnindents+efSyntaxHighlight;
+     DefaultCodeEditorFlags : longint =
+      efBackupFiles+efInsertMode+efAutoIndent+efPersistentBlocks+
+      efBackSpaceUnindents+efSyntaxHighlight;
      DefaultTabSize     : integer = 8;
 
      ToClipCmds         : TCommandSet = ([cmCut,cmCopy,cmClear]);
@@ -752,21 +756,29 @@ var
   S: String[15];
   B: TDrawBuffer;
 begin
-  Color := GetColor(1);
   if (State and sfDragging = 0) and (State and sfActive <> 0) then
-  begin
-    Frame := #205;
-  end else
-  begin
-    if (State and sfDragging)<>0 then Color := GetColor(2);
-    Frame := #196;
-  end;
+   begin
+     Color := GetColor(1);
+     Frame := #205;
+   end
+  else
+   begin
+     if (State and sfDragging)<>0 then
+      Color := GetColor(2)
+     else
+      Color := GetColor(3);
+     Frame := #196;
+   end;
   MoveChar(B, Frame, Color, Size.X);
-  if Modified then WordRec(B[0]).Lo := 15;
-  L[0] := Location.Y + 1;
-  L[1] := Location.X + 1;
-  FormatStr(S, ' %d:%d ', L);
-  MoveStr(B[8 - Pos(':', S)], S, Color);
+  if State and sfActive<>0 then
+   begin
+     if Modified then
+       WordRec (B[0]).Lo := 77;
+     L[0] := Location.Y + 1;
+     L[1] := Location.X + 1;
+     FormatStr(S, ' %d:%d ', L);
+     MoveStr(B[8 - Pos(':', S)], S, Color);
+   end;
   WriteBuf(0, 0, Size.X, 1, B);
 end;
 
@@ -780,7 +792,8 @@ end;
 procedure TIndicator.SetState(AState: Word; Enable: Boolean);
 begin
   inherited SetState(AState, Enable);
-  if (AState = sfDragging) or (AState=sfActive) then DrawView;
+  if (AState = sfDragging) or (AState=sfActive) then
+   DrawView;
 end;
 
 procedure TIndicator.SetValue(ALocation: TPoint; AModified: Boolean);
@@ -795,17 +808,35 @@ begin
   end;
 end;
 
+
+{*****************************************************************************
+                               TCodeEditor
+*****************************************************************************}
+
 constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
                     PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
 begin
   inherited Init(Bounds,AHScrollBar,AVScrollBar);
+  New(Lines, Init(500,1000));
   SetState(sfCursorVis,true);
-  Flags:=DefaulTCodeEditorFlags; TabSize:=DefaultTabSize;
+  SetFlags(DefaultCodeEditorFlags); TabSize:=DefaultTabSize;
   Indicator:=AIndicator;
-  New(Lines, Init(500,1000));
   UpdateIndicator; LimitsChanged;
 end;
 
+procedure TCodeEditor.SetFlags(AFlags: longint);
+var I: integer;
+begin
+  Flags:=AFlags;
+  SetInsertMode((Flags and efInsertMode)<>0);
+  if (Flags and efSyntaxHighlight)<>0 then
+    UpdateAttrs(0,attrAll) else
+  for I:=0 to GetLineCount-1 do
+    SetLineFormat(I,'');
+  UpdateIndicator;
+  DrawView;
+end;
+
 function TCodeEditor.GetErrorMessage: string;
 var S: string;
 begin
@@ -1019,6 +1050,15 @@ var SelectColor,
     ColorTab: array[coFirstColor..coLastColor] of word;
     ErrorLine: integer;
     ErrorMsg: string[MaxViewWidth];
+function CombineColors(Orig,Modifier: byte): byte;
+var Color: byte;
+begin
+  if (Modifier and $0f)=0 then
+    Color:=(Orig and $0f) or (Modifier and $f0)
+  else
+    Color:=(Orig and $f0) or (Modifier and $0f);
+  CombineColors:=Color;
+end;
 const NulLine : TLine = (Text: nil; Format: nil);
 begin
   ErrorMsg:=copy(GetErrorMessage,1,MaxViewWidth);
@@ -1055,8 +1095,8 @@ begin
     LineText:=GetLineText(AY);
     Format:=GetLineFormat(AY);
 
-    if (Flags and efSyntaxHighlight)<>0 then MaxX:=length(LineText)+1
-       else MaxX:=Size.X+Delta.X;
+{    if (Flags and efSyntaxHighlight)<>0 then MaxX:=length(LineText)+1
+       else }MaxX:=Size.X+Delta.X;
     for X:=1 to Min(MaxX,255) do
     begin
       AX:=Delta.X+X-1;
@@ -1083,15 +1123,15 @@ begin
           if (PointOfs(SelStart)<=PointOfs(PX)) and (PointOfs(PX)<PointOfs(SelEnd)) then
              begin Color:=SelectColor; FreeFormat[X]:=false; end;
       end;
-      if ( ((Flags and efHighlightRow)   <>0) and (AY=CurPos.Y) ) then
-         begin Color:=(Color and $f0)  or (HighlightRowColor and $0f); FreeFormat[X]:=false; end;
-      if ( ((Flags and efHighlightColumn)<>0) and (AX=CurPos.X) ) then
-         begin Color:=HighlightColColor; FreeFormat[X]:=false; end;
-
       if FreeFormat[X] then
          if X<=length(Format) then
             Color:=ColorTab[ord(Format[X])] else Color:=ColorTab[coTextColor];
 
+      if ( ((Flags and efHighlightRow)   <>0) and (PX.Y=CurPos.Y) ) then
+         begin Color:=CombineColors(Color,HighlightRowColor); FreeFormat[X]:=false; end;
+      if ( ((Flags and efHighlightColumn)<>0) and (PX.X=CurPos.X) ) then
+         begin Color:=CombineColors(Color,HighlightColColor); FreeFormat[X]:=false; end;
+
       if (0<=X-1-Delta.X) and (X-1-Delta.X<MaxViewWidth) then
       MoveChar(B[X-1-Delta.X],C,Color,1);
     end;
@@ -1106,6 +1146,11 @@ begin
   SetState(sfCursorIns,Overwrite);
 end;
 
+function TCodeEditor.Overwrite: boolean;
+begin
+  Overwrite:=(Flags and efInsertMode)=0;
+end;
+
 function TCodeEditor.GetLineCount: integer;
 begin
   GetLineCount:=Lines^.Count;
@@ -1877,7 +1922,8 @@ end;
 
 procedure TCodeEditor.SetInsertMode(InsertMode: boolean);
 begin
-  Overwrite:=not InsertMode;
+  if InsertMode then Flags:=Flags or efInsertMode
+                else Flags:=Flags and (not efInsertMode);
   DrawCursor;
 end;
 
@@ -1999,7 +2045,6 @@ end;
 function GetCharClass(C: char): TCharClass;
 var CC: TCharClass;
 begin
-  C:=Upcase(C);
   if C in WhiteSpaceChars then CC:=ccWhiteSpace else
   if C in AlphaChars      then CC:=ccAlpha else
   if C in NumberChars     then CC:=ccNumber else
@@ -2091,7 +2136,7 @@ begin
   end;
 end;
 var CurLine: Sw_integer;
-    Line,NextLine,OldLine: PLine;
+    Line,NextLine,PrevLine,OldLine: PLine;
     C: char;
 begin
   if ((Flags and efSyntaxHighlight)=0) or (FromLine>=GetLineCount) then
@@ -2101,13 +2146,14 @@ begin
     Exit;
   end;
   CurLine:=FromLine;
+  if CurLine>0 then PrevLine:=Lines^.At(CurLine-1) else PrevLine:=nil;
   repeat
     Line:=Lines^.At(CurLine);
-    if CurLine>0 then
+    if PrevLine<>nil then
        begin
-         InAsm:=Lines^.At(CurLine-1)^.EndsWithAsm;
-         InComment:=Lines^.At(CurLine-1)^.EndsWithComment;
-         InDirective:=Lines^.At(CurLine-1)^.EndsWithDirective;
+         InAsm:=PrevLine^.EndsWithAsm;
+         InComment:=PrevLine^.EndsWithComment;
+         InDirective:=PrevLine^.EndsWithDirective;
        end else
        begin
          InAsm:=false; InComment:=false; InDirective:=false;
@@ -2143,6 +2189,7 @@ begin
          (NextLine^.BeginsWithDirective=Line^.EndsWithDirective) and
          (NextLine^.Format<>nil)
          then Break;
+    PrevLine:=Line;
   until false;
   UpdateAttrs:=CurLine;
 end;
@@ -2281,13 +2328,15 @@ begin
 end;
 
 function TFileEditor.LoadFile: boolean;
-
 {$ifdef TPUNIXLF}
+var OnlyLF: boolean;
   procedure readln(var t:text;var s:string);
   var
     c : char;
     i : longint;
   begin
+    if OnlyLF=false then system.readln(t,s) else
+   begin
     c:=#0;
     i:=0;
     while (not eof(t)) and (c<>#10) do
@@ -2300,8 +2349,9 @@ function TFileEditor.LoadFile: boolean;
         end;
      end;
     if (i>0) and (s[i]=#13) then
-     dec(i);
+     begin dec(i); OnlyLF:=false; end;
     s[0]:=chr(i);
+   end;
   end;
 {$endif}
 
@@ -2315,6 +2365,7 @@ begin
   FM:=FileMode; FileMode:=0;
   Assign(f,FileName);
   Reset(f);
+  {$ifdef TPUNIXLF}OnlyLF:=true;{$endif}
   OK:=(IOResult=0);
   while OK and (Eof(f)=false) and (GetLineCount<MaxLineCount) do
   begin
@@ -2647,9 +2698,17 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
-
+  Revision 1.2  1998-12-28 15:47:55  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.4  1998/12/27 12:01:23  gabor
+    * efXXXX constants revised for BP compatibility
+    * fixed column and row highlighting (needs to rewrite default palette in the INI)
   Revision 1.3  1998/12/22 10:39:54  peter
     + options are now written/read
     + find and replace routines

+ 12 - 3
ide/text/whelp.pas

@@ -801,7 +801,11 @@ begin
   HelpFiles^.ForEach(@InsertKeywordsOfFile);
   New(Lines, Init((Keywords^.Count div 2)+100,100));
   T:=NewTopic(0,0,0);
-  if HelpFiles^.Count=0 then AddLine('No help files installed.') else
+  if HelpFiles^.Count=0 then
+    begin
+      AddLine('');
+      AddLine(' No help files installed.')
+    end else
   begin
     AddLine(' Help index');
     KWCount:=0; Line:='';
@@ -850,8 +854,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:56  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.4  1998/12/22 10:39:55  peter
     + options are now written/read

+ 13 - 5
ide/text/whlpview.pas

@@ -176,7 +176,8 @@ type
 
 implementation
 
-uses Crt;
+uses
+  Video;
 
 const CommentColor = Blue;
 
@@ -482,7 +483,7 @@ end;
 constructor THelpViewer.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
 begin
   inherited Init(Bounds, AHScrollBar, AVScrollBar, nil, 0);
-  Flags:=0; IsReadOnly:=true;
+  Flags:=efInsertMode; IsReadOnly:=true;
   New(WordList, Init(50,50));
   Margin:=1; CurLink:=-1;
 end;
@@ -1031,9 +1032,16 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:54  peter
-    * moved
-
+  Revision 1.2  1998-12-28 15:47:57  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
+
+  Revision 1.31 1998/12/27 12:07:30  gabor
+    * changed THelpViewer.Init to reflect changes in WEDITOR
   Revision 1.3  1998/12/22 10:39:56  peter
     + options are now written/read
     + find and replace routines

+ 181 - 6
ide/text/wini.pas

@@ -20,6 +20,7 @@ interface
 uses Objects;
 
 type
+
     PINIEntry = ^TINIEntry;
     TINIEntry = object(TObject)
       constructor Init(ALine: string);
@@ -42,7 +43,9 @@ type
     TINISection = object(TObject)
       constructor Init(AName: string);
       function    GetName: string;
-      procedure   AddEntry(S: string);
+      function    AddEntry(S: string): PINIEntry;
+      function    SearchEntry(Tag: string): PINIEntry; virtual;
+      procedure   ForEachEntry(EnumProc: pointer); virtual;
       destructor  Done; virtual;
     private
       Name     : PString;
@@ -51,10 +54,18 @@ type
 
     PINIFile = ^TINIFile;
     TINIFile = object(TObject)
+      MakeNullEntries: boolean;
       constructor Init(AFileName: string);
       function    Read: boolean; virtual;
       function    Update: boolean; virtual;
       function    IsModified: boolean; virtual;
+      function    SearchSection(Section: string): PINISection; virtual;
+      function    SearchEntry(Section, Tag: string): PINIEntry; virtual;
+      procedure   ForEachEntry(Section: string; EnumProc: pointer); virtual;
+      function    GetEntry(Section, Tag, Default: string): string; virtual;
+      procedure   SetEntry(Section, Tag, Value: string); virtual;
+      function    GetIntEntry(Section, Tag: string; Default: longint): longint; virtual;
+      procedure   SetIntEntry(Section, Tag: string; Value: longint); virtual;
       destructor  Done; virtual;
     private
       ReadOnly: boolean;
@@ -67,6 +78,33 @@ const MainSectionName : string[40] = 'MainSection';
 
 implementation
 
+{$ifdef FPC}uses callspec;{$endif}
+
+const LastStrToIntResult : integer = 0;
+
+function IntToStr(L: longint): string;
+var S: string;
+begin
+  Str(L,S);
+  IntToStr:=S;
+end;
+
+function StrToInt(S: string): longint;
+var L: longint;
+    C: integer;
+begin
+  Val(S,L,C); if C<>0 then L:=-1;
+  LastStrToIntResult:=C;
+  StrToInt:=L;
+end;
+
+function UpcaseStr(S: string): string;
+var I: integer;
+begin
+  for I:=1 to length(S) do
+      S[I]:=Upcase(S[I]);
+  UpcaseStr:=S;
+end;
 
 function LTrim(S: string): string;
 begin
@@ -173,7 +211,7 @@ begin
           ValueS:=ValueS+C;
           Inc(P2);
         end;
-      Value:=NewStr(ValueS);
+      Value:=NewStr(Trim(ValueS));
       Comment:=NewStr(copy(S,P2+1,255));
     end else
     begin
@@ -207,13 +245,43 @@ begin
   GetName:=GetStr(Name);
 end;
 
-procedure TINISection.AddEntry(S: string);
+function TINISection.AddEntry(S: string): PINIEntry;
 var E: PINIEntry;
 begin
   New(E, Init(S));
   Entries^.Insert(E);
+  AddEntry:=E;
 end;
 
+procedure TINISection.ForEachEntry(EnumProc: pointer);
+var I: integer;
+    E: PINIEntry;
+begin
+  for I:=0 to Entries^.Count-1 do
+    begin
+      E:=Entries^.At(I);
+      {$ifdef FPC}
+        CallPointerMethodLocal(EnumProc,CurrentFramePointer,@Self,E);
+      {$else}
+      asm
+        push E.word[2]
+        push E.word[0]
+        push word ptr [bp]
+        call EnumProc
+      end;
+      {$endif}
+    end;
+end;
+
+function TINISection.SearchEntry(Tag: string): PINIEntry;
+function MatchingEntry(E: PINIEntry): boolean; {$ifndef FPC}far;{$endif}
+begin
+  MatchingEntry:=UpcaseStr(E^.GetTag)=Tag;
+end;
+begin
+  Tag:=UpcaseStr(Tag);
+  SearchEntry:=Entries^.FirstThat(@MatchingEntry);
+end;
 
 destructor TINISection.Done;
 begin
@@ -316,9 +384,111 @@ begin
   Close(f);
   EatIO;
 {$I+}
-  Update:=true;
+  if OK then
+    for I:=0 to Sections^.Count-1 do
+      begin
+        P:=Sections^.At(I);
+        for J:=0 to P^.Entries^.Count-1 do
+          begin
+            E:=P^.Entries^.At(J);
+            E^.Modified:=false;
+          end;
+      end;
+  Update:=OK;
+end;
+
+function TINIFile.SearchSection(Section: string): PINISection;
+function MatchingSection(P: PINISection): boolean; {$ifndef FPC}far;{$endif}
+var SN: string;
+    M: boolean;
+begin
+  SN:=UpcaseStr(P^.GetName);
+  M:=SN=Section;
+  MatchingSection:=M;
+end;
+begin
+  Section:=UpcaseStr(Section);
+  SearchSection:=Sections^.FirstThat(@MatchingSection);
+end;
+
+function TINIFile.SearchEntry(Section, Tag: string): PINIEntry;
+var P: PINISection;
+    E: PINIEntry;
+begin
+  P:=SearchSection(Section);
+  if P=nil then E:=nil else
+    E:=P^.SearchEntry(Tag);
+  SearchEntry:=E;
+end;
+
+procedure TINIFile.ForEachEntry(Section: string; EnumProc: pointer);
+var P: PINISection;
+    E: PINIEntry;
+    I: integer;
+begin
+  P:=SearchSection(Section);
+  if P<>nil then
+    for I:=0 to P^.Entries^.Count-1 do
+      begin
+        E:=P^.Entries^.At(I);
+      {$ifdef FPC}
+        CallPointerMethodLocal(EnumProc,CurrentFramePointer,@Self,E);
+      {$else}
+        asm
+          push E.word[2]
+          push E.word[0]
+          push word ptr [bp]
+          call EnumProc
+        end;
+      {$endif}
+      end;
+end;
+
+function TINIFile.GetEntry(Section, Tag, Default: string): string;
+var E: PINIEntry;
+    S: string;
+begin
+  E:=SearchEntry(Section,Tag);
+  if E=nil then S:=Default else
+    S:=E^.GetValue;
+  GetEntry:=S;
 end;
 
+procedure TINIFile.SetEntry(Section, Tag, Value: string);
+var E: PINIEntry;
+    P: PINISection;
+begin
+  E:=SearchEntry(Section,Tag);
+  if E=nil then
+   if (MakeNullEntries=true) or (Value<>'') then
+    begin
+      P:=SearchSection(Section);
+      if P=nil then
+        begin
+          New(P, Init(Section));
+          Sections^.Insert(P);
+        end;
+      E:=P^.AddEntry(Tag+'='+Value);
+      E^.Modified:=true;
+    end;
+  if E<>nil then
+    E^.SetValue(Value);
+end;
+
+function TINIFile.GetIntEntry(Section, Tag: string; Default: longint): longint;
+var L: longint;
+begin
+  L:=StrToInt(GetEntry(Section,Tag,IntToStr(Default)));
+  if LastStrToIntResult<>0 then L:=Default;
+  GetIntEntry:=L;
+end;
+
+procedure TINIFile.SetIntEntry(Section, Tag: string; Value: longint);
+begin
+  SetEntry(Section,Tag,IntToStr(Value));
+end;
+
+
 destructor TINIFile.Done;
 begin
   if IsModified then
@@ -333,8 +503,13 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1998-12-22 14:27:55  peter
-    * moved
+  Revision 1.2  1998-12-28 15:47:58  peter
+    + Added user screen support, display & window
+    + Implemented Editor,Mouse Options dialog
+    + Added location of .INI and .CFG file
+    + Option (INI) file managment implemented (see bottom of Options Menu)
+    + Switches updated
+    + Run program
 
   Revision 1.1  1998/12/22 10:39:57  peter
     + options are now written/read