Browse Source

+ Implemented still missing 'switch' entries in Options menu
+ Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
ASCII chars and inserted directly in the text.
+ Added symbol browser
* splitted fp.pas to fpide.pas

peter 26 years ago
parent
commit
3caaa020b0

+ 17 - 515
ide/text/fp.pas

@@ -13,508 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-program FreePascal;
+program FP;
 
 uses
-  Video,Mouse,Keyboard,
-  Dos,Objects,Memory,Drivers,Views,Menus,Dialogs,App,StdDlg,
-  ColorSel,
-  Systems,Commands,HelpCtx,
-  WHelp,WHlpView,WINI,{$ifdef EDITORS}Editors,{$else}WEditor,{$endif}
-  FPConst,FPVars,FPUtils,FPSwitches,FPIni,FPIntf,FPCompile,FPHelp,FPViews,
-  FPTemplt,FPCalc,FPUsrScr;
+  Dos,
+  FPIni,FPViews,FPConst,FPVars,FPUtils,FPIde,FPHelp,FPSwitches,FPUsrScr;
 
-type
-    TIDEApp = object(TApplication)
-      constructor Init;
-      procedure   InitMenuBar; virtual;
-      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;
-      procedure NewEditor;
-      procedure NewFromTemplate;
-      procedure Open(FileName: string);
-      procedure OpenRecentFile(RecentIndex: integer);
-      procedure SaveAll;
-      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;
-      procedure HelpTopicSearch;
-      procedure HelpPrevTopic;
-      procedure HelpUsingHelp;
-      procedure HelpFiles;
-      procedure About;
-    private
-      procedure AddRecentFile(AFileName: string; CurX, CurY: integer);
-      function  SearchRecentFile(AFileName: string): integer;
-      procedure RemoveRecentFile(Index: integer);
-    private
-      procedure Update;
-      procedure CurDirChanged;
-      procedure UpdatePrimaryFile;
-      procedure UpdateINIFile;
-      procedure UpdateRecentFileList;
-    end;
 
-function IDEUseSyntaxHighlight(Editor: PFileEditor): boolean; {$ifndef FPC}far;{$endif}
-begin
-  IDEUseSyntaxHighlight:=MatchesFileList(NameAndExtOf(Editor^.FileName),HighlightExts);
-end;
-
-constructor TIDEApp.Init;
-begin
-  {$ifndef EDITORS}UseSyntaxHighlight:=IDEUseSyntaxHighlight;{$endif}
-  inherited Init;
-  New(ClipboardWindow, Init);
-  Desktop^.Insert(ClipboardWindow);
-  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;
-end;
-
-procedure TIDEApp.InitMenuBar;
-var R: TRect;
-begin
-  GetExtent(R); R.B.Y:=R.A.Y+1;
-  MenuBar:=New(PAdvancedMenuBar, Init(R, NewMenu(
-    NewSubMenu('~F~ile',hcFileMenu, NewMenu(
-      NewItem('~N~ew','',kbNoKey,cmNew,hcNew,
-      NewItem('New from ~t~emplate...','',kbNoKey,cmNewFromTemplate,hcNewFromTemplate,
-      NewItem('~O~pen...','F3',kbF3,cmOpen,hcOpen,
-      NewItem('~S~ave','F2',kbF2,cmSave,hcSave,
-      NewItem('Save ~a~s...','',kbNoKey,cmSaveAs,hcSaveAs,
-      NewItem('Save a~l~l','',kbNoKey,cmSaveAll,hcSaveAll,
-      NewLine(
-      NewItem('~C~hange dir...','',kbNoKey,cmChangeDir,hcChangeDir,
-      NewItem('~D~OS shell','',kbNoKey,cmDOSShell,hcDOSShell,
-      NewItem('E~x~it','Alt+X',kbNoKey,cmQuit,hcQuit,
-      nil))))))))))),
-    NewSubMenu('~E~dit',hcEditMenu, NewMenu(
-      NewItem('~U~ndo','Alt+BkSp', kbAltBack, cmUndo, hcUndo,
-      NewItem('~R~edo','', kbNoKey, cmRedo, hcRedo,
-      NewLine(
-      NewItem('Cu~t~','Shift+Del', kbShiftDel, cmCut, hcCut,
-      NewItem('~C~opy','Ctrl+Ins', kbCtrlIns, cmCopy, hcCut,
-      NewItem('~P~aste','Shift+Ins', kbShiftIns, cmPaste, hcPaste,
-      NewItem('C~l~ear','Ctrl+Del', kbCtrlDel, cmClear, hcClear,
-      NewLine(
-      NewItem('~S~how clipboard','', kbNoKey, cmShowClipboard, hcShowClipboard,
-      nil)))))))))),
-    NewSubMenu('~S~earch',hcSearchMenu, NewMenu(
-      NewItem('~F~ind...','', kbNoKey, cmFind, hcFind,
-      NewItem('~R~eplace...','', kbNoKey, cmReplace, hcReplace,
-      NewItem('~S~earch again','', kbNoKey, cmSearchAgain, hcSearchAgain,
-      NewLine(
-      NewItem('~G~o to line number...','', kbNoKey, cmJumpLine, hcGotoLine,
-      NewItem('Find ~p~rocedure...','', kbNoKey, cmFindProcedure, hcFindProcedure,
-      NewLine(
-      NewItem('~O~bjects','', kbNoKey, cmObjects, hcObjects,
-      NewItem('Mod~u~les','', kbNoKey, cmModules, hcModules,
-      NewItem('~G~lobals','', kbNoKey, cmGlobals, hcGlobals,
-      nil))))))))))),
-    NewSubMenu('~R~un',hcRunMenu, NewMenu(
-      NewItem('~R~un','Ctrl+F9', kbCtrlF9, cmRun, hcRun,
-      NewItem('P~a~rameters...','', kbNoKey, cmParameters, hcParameters,
-      NewLine(
-      NewItem('~U~ser screen','Alt+F5', kbAltF5, cmUserScreen, hcUserScreen,
-      nil))))),
-    NewSubMenu('~C~ompile',hcCompileMenu, NewMenu(
-      NewItem('~C~ompile','Alt+F9', kbAltF9, cmCompile, hcCompile,
-      NewItem('~M~ake','F9', kbF9, cmMake, hcMake,
-      NewItem('~B~uild','', kbNoKey, cmBuild, hcBuild,
-      NewLine(
-      NewItem('~T~arget...','', kbNoKey, cmTarget, hcTarget,
-      NewItem('~P~rimary file...','', kbNoKey, cmPrimaryFile, hcPrimaryFile,
-      NewItem('C~l~ear primary file','', kbNoKey, cmClearPrimary, hcClearPrimary,
-      NewLine(
-      NewItem('~I~nformation...','', kbNoKey, cmInformation, hcInformation,
-      nil)))))))))),
-    NewSubMenu('~D~ebug', hcDebugMenu, NewMenu(
-      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,
-      NewItem('De~b~ugger...','', kbNoKey, cmDebugger, hcDebugger,
-      NewItem('~D~irectories...','', kbNoKey, cmDirectories, hcDirectories,
-      NewItem('~T~ools...','', kbNoKey, cmTools, hcTools,
-      NewLine(
-      NewSubMenu('~E~nvironment', hcEnvironmentMenu, NewMenu(
-        NewItem('~P~references...','', kbNoKey, cmPreferences, hcPreferences,
-        NewItem('~E~ditor...','', kbNoKey, cmEditor, hcEditor,
-        NewItem('~M~ouse...','', kbNoKey, cmMouse, hcMouse,
-        NewItem('~S~tartup...','', kbNoKey, cmStartup, hcStartup,
-        NewItem('~C~olors...','', kbNoKey, cmColors, hcColors,
-        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,
-      NewItem('Cl~o~se all','', kbNoKey, cmCloseAll, hcCloseAll,
-      NewLine(
-      NewItem('~S~ize/Move','Ctrl+F5', kbCtrlF5, cmResize, hcResize,
-      NewItem('~Z~oom','F5', kbF5, cmZoom, hcZoom,
-      NewItem('~N~ext','F6', kbF6, cmNext, hcNext,
-      NewItem('~P~revious','Shift+F6', kbShiftF6, cmPrev, hcPrev,
-      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)))))))))))))),
-    NewSubMenu('~H~elp', hcHelpMenu, NewMenu(
-      NewItem('~C~ontents','', kbNoKey, cmHelpContents, hcHelpContents,
-      NewItem('~I~ndex','Shift+F1', kbShiftF1, cmHelpIndex, hcHelpIndex,
-      NewItem('~T~opic search','Ctrl+F1', kbCtrlF1, cmHelpTopicSearch, hcHelpTopicSearch,
-      NewItem('~P~revious topic','Alt+F1', kbAltF1, cmHelpPrevTopic, hcHelpPrevTopic,
-      NewItem('~U~sing help','',kbNoKey, cmHelpUsingHelp, hcHelpUsingHelp,
-      NewItem('~F~iles...','',kbNoKey, cmHelpFiles, hcHelpFiles,
-      NewLine(
-      NewItem('~A~bout...','',kbNoKey, cmAbout, hcAbout,
-      nil))))))))),
-    nil)))))))))))));
-  DisableCommands(EditorCmds+SourceCmds+CompileCmds);
-  Update;
-end;
-
-procedure TIDEApp.InitStatusLine;
-var
-  R: TRect;
-begin
-  GetExtent(R);
-  R.A.Y := R.B.Y - 1;
-  StatusLine:=New(PIDEStatusLine, Init(R,
-    NewStatusDef(hcFirstCommand, hcLastCommand,
-      NewStatusKey('~F1~ Help', kbF1, cmHelp,
-      StdStatusKeys(
-      nil)),
-    NewStatusDef(hcHelpWindow, hcHelpWindow,
-      NewStatusKey('~F1~ Help on help', kbF1, cmHelpUsingHelp,
-      NewStatusKey('~Alt+F1~ Previous topic', kbAltF1, cmHelpPrevTopic,
-      NewStatusKey('~Shift+F1~ Help index', kbShiftF1, cmHelpIndex,
-      NewStatusKey('~Esc~ Close help', kbEsc, cmClose,
-      nil)))),
-    NewStatusDef(hcSourceWindow, hcSourceWindow,
-      NewStatusKey('~F1~ Help', kbF1, cmHelp,
-      NewStatusKey('~F2~ Save', kbF2, cmSave,
-      NewStatusKey('~F3~ Open', kbF3, cmOpen,
-      NewStatusKey('~Alt+F9~ Compile', kbAltF9, cmCompile,
-      NewStatusKey('~F9~ Make', kbF9, cmMake,
-      NewStatusKey('~Alt+F10~ Local menu', kbAltF10, cmLocalMenu,
-      StdStatusKeys(
-      nil))))))),
-    NewStatusDef(hcCalcWindow, hcCalcWindow,
-      NewStatusKey('~F1~ Help', kbF1, cmHelp,
-      NewStatusKey('~Esc~ Close', kbEsc, cmClose,
-      NewStatusKey('~Ctrl+Enter~ Transfer result', kbCtrlEnter, cmCalculatorPaste,
-      StdStatusKeys(
-      nil)))),
-    NewStatusDef(0, $FFFF,
-      NewStatusKey('~F1~ Help', kbF1, cmHelp,
-      NewStatusKey('~F3~ Open', kbF3, cmOpen,
-      NewStatusKey('~Alt+F9~ Compile', kbAltF9, cmCompile,
-      NewStatusKey('~F9~ Make', kbF9, cmMake,
-      NewStatusKey('~Alt+F10~ Local menu', kbAltF10, cmLocalMenu,
-      StdStatusKeys(
-      nil)))))),
-    nil)))))));
-end;
-
-procedure TIDEApp.HandleEvent(var Event: TEvent);
-var DontClear: boolean;
-begin
-  case Event.What of
-       evCommand :
-         begin
-           DontClear:=false;
-           case Event.Command of
-             cmUpdate        : Message(Application,evBroadcast,cmUpdate,nil);
-           { -- File menu -- }
-             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);
-           { -- Edit menu -- }
-             cmShowClipboard : ShowClipboard;
-           { -- Run menu -- }
-             cmParameters    : Parameters;
-             cmRun           : DoRun;
-           { -- Compile menu -- }
-             cmCompile       : DoCompile(cCompile);
-             cmBuild         : DoCompile(cBuild);
-             cmMake          : DoCompile(cMake);
-             cmTarget        : Target;
-             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;
-{             cmHelpTopicSearch: HelpTopicSearch;}
-             cmHelpPrevTopic : HelpPrevTopic;
-             cmHelpUsingHelp : HelpUsingHelp;
-             cmHelpFiles     : HelpFiles;
-             cmAbout         : About;
-           else DontClear:=true;
-           end;
-           if DontClear=false then ClearEvent(Event);
-         end;
-       evBroadcast :
-         case Event.Command of
-           cmUpdate              :
-             Update;
-           cmSourceWindowClosing :
-             with PSourceWindow(Event.InfoPtr)^ do
-               if Editor^.FileName<>'' then
-                  AddRecentFile(Editor^.FileName,Editor^.CurPos.X,Editor^.CurPos.Y);
-         end;
-  end;
-  inherited HandleEvent(Event);
-end;
-
-procedure TIDEApp.Update;
-begin
-  SetCmdState([cmSaveAll],IsThereAnyEditor);
-  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);
-end;
-
-procedure TIDEApp.CurDirChanged;
-begin
-  Message(Application,evBroadcast,cmUpdateTitle,nil);
-  UpdatePrimaryFile;
-  UpdateINIFile;
-  UpdateMenu(MenuBar^.Menu);
-end;
-
-procedure TIDEApp.UpdatePrimaryFile;
-begin
-  SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmPrimaryFile),SmartPath(PrimaryFile));
-  SetCmdState([cmClearPrimary],PrimaryFile<>'');
-  if PrimaryFile<>'' then
-     SetCmdState(CompileCmds,true);
-  UpdateMenu(MenuBar^.Menu);
-  Message(ProgramInfoWindow,evBroadcast,cmUpdate,nil);
-end;
-
-procedure TIDEApp.UpdateINIFile;
-begin
-  SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(INIPath));
-end;
-
-procedure TIDEApp.UpdateRecentFileList;
-var P: PMenuItem;
-    ID,I: word;
-    FileMenu: PMenuItem;
-begin
-  ID:=cmRecentFileBase;
-  FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
-  repeat
-{    Inc(ID);
-    P:=SearchMenuItem(FileMenu^.SubMenu,ID);
-    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
-     RemoveMenuItem(FileMenu^.SubMenu,P);
-
-  if RecentFileCount>0 then
-     AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
-  for I:=1 to RecentFileCount do
-  begin
-    P:=NewItem('~'+IntToStr(I)+'~. '+SmartPath(RecentFiles[I].FileName),' ',
-        kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
-    AppendMenuItem(FileMenu^.SubMenu,P);
-  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}
-
-{$I FPMWND.INC}
-
-{$I FPMHELP.INC}
+procedure ProcessParams(BeforeINI: boolean);
 
-procedure TIDEApp.AddRecentFile(AFileName: string; CurX, CurY: integer);
-begin
-  if SearchRecentFile(AFileName)<>-1 then Exit;
-  if RecentFileCount>0 then
-   Move(RecentFiles[1],RecentFiles[2],SizeOf(RecentFiles[1])*Min(RecentFileCount,High(RecentFiles)-1));
-  if RecentFileCount<High(RecentFiles) then Inc(RecentFileCount);
-  with RecentFiles[1] do
+  function IsSwitch(const Param: string): boolean;
   begin
-    FileName:=AFileName;
-    LastPos.X:=CurX; LastPos.Y:=CurY;
+    IsSwitch:=(Param<>'') and (Param[1]<>DirSep) { <- allow UNIX root-relative paths            }
+          and (Param[1] in ['-','/']);           { <- but still accept dos switch char, eg. '/' }
   end;
-  UpdateRecentFileList;
-end;
-
-function TIDEApp.SearchRecentFile(AFileName: string): integer;
-var Idx,I: integer;
-begin
-  Idx:=-1;
-  for I:=1 to RecentFileCount do
-    if UpcaseStr(AFileName)=UpcaseStr(RecentFiles[I].FileName) then
-      begin Idx:=I; Break; end;
-  SearchRecentFile:=Idx;
-end;
 
-procedure TIDEApp.RemoveRecentFile(Index: integer);
-begin
-  if Index<RecentFileCount then
-     Move(RecentFiles[Index+1],RecentFiles[Index],SizeOf(RecentFiles[1])*(RecentFileCount-Index));
-  Dec(RecentFileCount);
-end;
-
-function TIDEApp.GetPalette: PPalette;
-var P: string;
-begin
-  P:=AppPalette;
-  GetPalette:=@P;
-end;
-
-destructor TIDEApp.Done;
-begin
-  inherited Done;
-  DoneHelpSystem;
-  DoneTemplates;
-end;
-
-function IsSwitch(Param: string): boolean;
-begin
-  IsSwitch:=(Param<>'') and (Param[1]<>DirSep) { <- allow UNIX root-relative paths            }
-        and (Param[1] in ['-','/']);           { <- but still accept dos switch char, eg. '/' }
-end;
-
-var MyApp: TIDEApp;
-
-procedure ProcessParams(BeforeINI: boolean);
 var I: integer;
     Param: string;
 begin
@@ -541,12 +54,14 @@ begin
         end;
       end
     else
-      if BeforeINI=false then
+      if not BeforeINI then
         MyApp.Open(Param);
   end;
 end;
 
+
 BEGIN
+  {$ifdef TP}HeapLimit:=256;{$endif}
   writeln('þ Free Pascal IDE  Version '+VersionStr);
   StartupDir:=CompleteDir(FExpand('.'));
 
@@ -578,25 +93,12 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.4  1999-01-04 11:49:41  peter
-   * 'Use tab characters' now works correctly
-   + Syntax highlight now acts on File|Save As...
-   + Added a new class to syntax highlight: 'hex numbers'.
-   * There was something very wrong with the palette managment. Now fixed.
-   + Added output directory (-FE<xxx>) support to 'Directories' dialog...
-   * Fixed some possible bugs in Running/Compiling, and the compilation/run
-     process revised
-
-  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
+  Revision 1.5  1999-01-12 14:29:31  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
 
 }

+ 18 - 3
ide/text/fpcompil.pas

@@ -84,7 +84,12 @@ begin
     cpDone      :
       begin
         StatusS:='Done.';
-        if Status.ErrorCount=0 then KeyS:=SuccessS else KeyS:=FailS;
+        KeyS:=SuccessS;
+      end;
+    cpFailed    :
+      begin
+        StatusS:='Failed to compile...';
+        KeyS:=FailS;
       end;
   end;
   ST^.SetText(
@@ -119,7 +124,9 @@ end;
 function CompilerComment(Level:Longint; const s:string):boolean; {$ifndef FPC}far;{$endif}
 begin
   CompilerComment:=false;
+{$ifndef DEV}
   if (status.verbosity and Level)=Level then
+{$endif}
    begin
      ProgramInfoWindow^.AddMessage(Level,S,SmartPath(status.currentmodule),status.currentline);
      SD^.MsgLB^.AddItem(New(PCompilerMessage, Init(Level, S, SmartPath(status.currentmodule),status.currentline)));
@@ -215,7 +222,7 @@ begin
 
   Application^.Delete(SD);
   SD^.SetState(sfModal,false);
-  Dispose(SD, Done);
+  Dispose(SD, Done); SD:=nil;
 
 {  if (WasVisible=false) and (status.errorcount=0) then
    ProgramInfoWindow^.Hide;}
@@ -224,7 +231,15 @@ end;
 end.
 {
   $Log$
-  Revision 1.3  1999-01-04 11:49:42  peter
+  Revision 1.4  1999-01-12 14:29:32  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.3  1999/01/04 11:49:42  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 22 - 2
ide/text/fpconst.pas

@@ -127,6 +127,7 @@ const
      hcClipboardWindow   = 8002;
      hcCalcWindow        = 8003;
      hcInfoWindow        = 8004;
+     hcBrowserWindow     = 8005;
 
      hcShift             = 10000;
 
@@ -229,6 +230,15 @@ 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 ;
 
+     CBrowserWindow =
+        #215#216#217#218#219#220#221#222#223#224#225#226;
+
+     CBrowserListBox =
+        #9#9#10#11#12;
+
+     CBrowserTab =
+        #6#12;
+
      CIDEAppColor = CAppColor +
          { CIDEHelpDialog }
 {128-143}#$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 + { 1-16}
@@ -238,14 +248,24 @@ const
          { CSourceWindow }
 {167-182}#$17#$1F#$1A#$31#$31#$1E#$71#$1F#$00#$00#$00#$00#$00#$00#$00#$00 + { 1-16}
 {183-198}#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00 + {17-32}
-{199-214}#$1E#$1F#$17#$1F#$1E#$1B#$13#$1A#$1E#$71#$3F#$1F#$1C#$13#$00#$4E ; {33-48}
+{199-214}#$1E#$1F#$17#$1F#$1E#$1B#$13#$1A#$1E#$71#$3F#$1F#$1C#$13#$1F#$4E + {33-48}
+         { CBrowserWindow }
+{215-   }#$31#$3F#$3A#$31#$31#$31#$71#$1F#$31#$2F#$3E#$3F ;
 
 implementation
 
 END.
 {
   $Log$
-  Revision 1.4  1999-01-04 11:49:43  peter
+  Revision 1.5  1999-01-12 14:29:33  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.4  1999/01/04 11:49:43  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 562 - 0
ide/text/fpide.pas

@@ -0,0 +1,562 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Main IDEApp object
+
+    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 fpide;
+interface
+
+uses
+  Drivers,Views,App,
+  {$ifdef EDITORS}Editors,{$else}WEditor,{$endif}
+  FPViews;
+
+type
+    TIDEApp = object(TApplication)
+      constructor Init;
+      procedure   InitMenuBar; virtual;
+      procedure   InitStatusLine; virtual;
+      procedure   Open(FileName: string);
+      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;
+      procedure NewEditor;
+      procedure NewFromTemplate;
+      procedure OpenRecentFile(RecentIndex: integer);
+      procedure SaveAll;
+      procedure ChangeDir;
+      procedure ShowClipboard;
+      procedure Objects;
+      procedure Modules;
+      procedure Globals;
+      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;
+      procedure HelpTopicSearch;
+      procedure HelpPrevTopic;
+      procedure HelpUsingHelp;
+      procedure HelpFiles;
+      procedure About;
+    private
+      procedure AddRecentFile(AFileName: string; CurX, CurY: integer);
+      function  SearchRecentFile(AFileName: string): integer;
+      procedure RemoveRecentFile(Index: integer);
+    private
+      procedure Update;
+      procedure CurDirChanged;
+      procedure UpdatePrimaryFile;
+      procedure UpdateINIFile;
+      procedure UpdateRecentFileList;
+    end;
+
+
+var
+  MyApp: TIDEApp;
+
+implementation
+
+uses
+  Video,Mouse,Keyboard,
+  Dos,Objects,Memory,Menus,Dialogs,StdDlg,ColorSel,Commands,HelpCtx,
+  Systems,BrowCol,
+  WHelp,WHlpView,WINI,
+  FPConst,FPVars,FPUtils,FPSwitches,FPIni,FPIntf,FPCompile,FPHelp,
+  FPTemplt,FPCalc,FPUsrScr,FPSymbol;
+
+
+function IDEUseSyntaxHighlight(Editor: PFileEditor): boolean; {$ifndef FPC}far;{$endif}
+begin
+  IDEUseSyntaxHighlight:=MatchesFileList(NameAndExtOf(Editor^.FileName),HighlightExts);
+end;
+
+constructor TIDEApp.Init;
+begin
+  {$ifndef EDITORS}UseSyntaxHighlight:=IDEUseSyntaxHighlight;{$endif}
+  inherited Init;
+  New(ClipboardWindow, Init);
+  Desktop^.Insert(ClipboardWindow);
+  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;
+end;
+
+procedure TIDEApp.InitMenuBar;
+var R: TRect;
+begin
+  GetExtent(R); R.B.Y:=R.A.Y+1;
+  MenuBar:=New(PAdvancedMenuBar, Init(R, NewMenu(
+    NewSubMenu('~F~ile',hcFileMenu, NewMenu(
+      NewItem('~N~ew','',kbNoKey,cmNew,hcNew,
+      NewItem('New from ~t~emplate...','',kbNoKey,cmNewFromTemplate,hcNewFromTemplate,
+      NewItem('~O~pen...','F3',kbF3,cmOpen,hcOpen,
+      NewItem('~S~ave','F2',kbF2,cmSave,hcSave,
+      NewItem('Save ~a~s...','',kbNoKey,cmSaveAs,hcSaveAs,
+      NewItem('Save a~l~l','',kbNoKey,cmSaveAll,hcSaveAll,
+      NewLine(
+      NewItem('~C~hange dir...','',kbNoKey,cmChangeDir,hcChangeDir,
+      NewItem('~D~OS shell','',kbNoKey,cmDOSShell,hcDOSShell,
+      NewItem('E~x~it','Alt+X',kbNoKey,cmQuit,hcQuit,
+      nil))))))))))),
+    NewSubMenu('~E~dit',hcEditMenu, NewMenu(
+      NewItem('~U~ndo','Alt+BkSp', kbAltBack, cmUndo, hcUndo,
+      NewItem('~R~edo','', kbNoKey, cmRedo, hcRedo,
+      NewLine(
+      NewItem('Cu~t~','Shift+Del', kbShiftDel, cmCut, hcCut,
+      NewItem('~C~opy','Ctrl+Ins', kbCtrlIns, cmCopy, hcCut,
+      NewItem('~P~aste','Shift+Ins', kbShiftIns, cmPaste, hcPaste,
+      NewItem('C~l~ear','Ctrl+Del', kbCtrlDel, cmClear, hcClear,
+      NewLine(
+      NewItem('~S~how clipboard','', kbNoKey, cmShowClipboard, hcShowClipboard,
+      nil)))))))))),
+    NewSubMenu('~S~earch',hcSearchMenu, NewMenu(
+      NewItem('~F~ind...','', kbNoKey, cmFind, hcFind,
+      NewItem('~R~eplace...','', kbNoKey, cmReplace, hcReplace,
+      NewItem('~S~earch again','', kbNoKey, cmSearchAgain, hcSearchAgain,
+      NewLine(
+      NewItem('~G~o to line number...','', kbNoKey, cmJumpLine, hcGotoLine,
+      NewItem('Find ~p~rocedure...','', kbNoKey, cmFindProcedure, hcFindProcedure,
+      NewLine(
+      NewItem('~O~bjects','', kbNoKey, cmObjects, hcObjects,
+      NewItem('Mod~u~les','', kbNoKey, cmModules, hcModules,
+      NewItem('G~l~obals','', kbNoKey, cmGlobals, hcGlobals,
+      nil))))))))))),
+    NewSubMenu('~R~un',hcRunMenu, NewMenu(
+      NewItem('~R~un','Ctrl+F9', kbCtrlF9, cmRun, hcRun,
+      NewItem('P~a~rameters...','', kbNoKey, cmParameters, hcParameters,
+      NewLine(
+      NewItem('~U~ser screen','Alt+F5', kbAltF5, cmUserScreen, hcUserScreen,
+      nil))))),
+    NewSubMenu('~C~ompile',hcCompileMenu, NewMenu(
+      NewItem('~C~ompile','Alt+F9', kbAltF9, cmCompile, hcCompile,
+      NewItem('~M~ake','F9', kbF9, cmMake, hcMake,
+      NewItem('~B~uild','', kbNoKey, cmBuild, hcBuild,
+      NewLine(
+      NewItem('~T~arget...','', kbNoKey, cmTarget, hcTarget,
+      NewItem('~P~rimary file...','', kbNoKey, cmPrimaryFile, hcPrimaryFile,
+      NewItem('C~l~ear primary file','', kbNoKey, cmClearPrimary, hcClearPrimary,
+      NewLine(
+      NewItem('~I~nformation...','', kbNoKey, cmInformation, hcInformation,
+      nil)))))))))),
+    NewSubMenu('~D~ebug', hcDebugMenu, NewMenu(
+      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,
+      NewItem('De~b~ugger...','', kbNoKey, cmDebugger, hcDebugger,
+      NewItem('~D~irectories...','', kbNoKey, cmDirectories, hcDirectories,
+      NewItem('~T~ools...','', kbNoKey, cmTools, hcTools,
+      NewLine(
+      NewSubMenu('~E~nvironment', hcEnvironmentMenu, NewMenu(
+        NewItem('~P~references...','', kbNoKey, cmPreferences, hcPreferences,
+        NewItem('~E~ditor...','', kbNoKey, cmEditor, hcEditor,
+        NewItem('~M~ouse...','', kbNoKey, cmMouse, hcMouse,
+        NewItem('~S~tartup...','', kbNoKey, cmStartup, hcStartup,
+        NewItem('~C~olors...','', kbNoKey, cmColors, hcColors,
+        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,
+      NewItem('Cl~o~se all','', kbNoKey, cmCloseAll, hcCloseAll,
+      NewLine(
+      NewItem('~S~ize/Move','Ctrl+F5', kbCtrlF5, cmResize, hcResize,
+      NewItem('~Z~oom','F5', kbF5, cmZoom, hcZoom,
+      NewItem('~N~ext','F6', kbF6, cmNext, hcNext,
+      NewItem('~P~revious','Shift+F6', kbShiftF6, cmPrev, hcPrev,
+      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)))))))))))))),
+    NewSubMenu('~H~elp', hcHelpMenu, NewMenu(
+      NewItem('~C~ontents','', kbNoKey, cmHelpContents, hcHelpContents,
+      NewItem('~I~ndex','Shift+F1', kbShiftF1, cmHelpIndex, hcHelpIndex,
+      NewItem('~T~opic search','Ctrl+F1', kbCtrlF1, cmHelpTopicSearch, hcHelpTopicSearch,
+      NewItem('~P~revious topic','Alt+F1', kbAltF1, cmHelpPrevTopic, hcHelpPrevTopic,
+      NewItem('~U~sing help','',kbNoKey, cmHelpUsingHelp, hcHelpUsingHelp,
+      NewItem('~F~iles...','',kbNoKey, cmHelpFiles, hcHelpFiles,
+      NewLine(
+      NewItem('~A~bout...','',kbNoKey, cmAbout, hcAbout,
+      nil))))))))),
+    nil)))))))))))));
+  DisableCommands(EditorCmds+SourceCmds+CompileCmds);
+  Update;
+end;
+
+procedure TIDEApp.InitStatusLine;
+var
+  R: TRect;
+begin
+  GetExtent(R);
+  R.A.Y := R.B.Y - 1;
+  StatusLine:=New(PIDEStatusLine, Init(R,
+    NewStatusDef(hcFirstCommand, hcLastCommand,
+      NewStatusKey('~F1~ Help', kbF1, cmHelp,
+      StdStatusKeys(
+      nil)),
+    NewStatusDef(hcHelpWindow, hcHelpWindow,
+      NewStatusKey('~F1~ Help on help', kbF1, cmHelpUsingHelp,
+      NewStatusKey('~Alt+F1~ Previous topic', kbAltF1, cmHelpPrevTopic,
+      NewStatusKey('~Shift+F1~ Help index', kbShiftF1, cmHelpIndex,
+      NewStatusKey('~Esc~ Close help', kbEsc, cmClose,
+      nil)))),
+    NewStatusDef(hcSourceWindow, hcSourceWindow,
+      NewStatusKey('~F1~ Help', kbF1, cmHelp,
+      NewStatusKey('~F2~ Save', kbF2, cmSave,
+      NewStatusKey('~F3~ Open', kbF3, cmOpen,
+      NewStatusKey('~Alt+F9~ Compile', kbAltF9, cmCompile,
+      NewStatusKey('~F9~ Make', kbF9, cmMake,
+      NewStatusKey('~Alt+F10~ Local menu', kbAltF10, cmLocalMenu,
+      StdStatusKeys(
+      nil))))))),
+    NewStatusDef(hcCalcWindow, hcCalcWindow,
+      NewStatusKey('~F1~ Help', kbF1, cmHelp,
+      NewStatusKey('~Esc~ Close', kbEsc, cmClose,
+      NewStatusKey('~Ctrl+Enter~ Transfer result', kbCtrlEnter, cmCalculatorPaste,
+      StdStatusKeys(
+      nil)))),
+    NewStatusDef(0, $FFFF,
+      NewStatusKey('~F1~ Help', kbF1, cmHelp,
+      NewStatusKey('~F3~ Open', kbF3, cmOpen,
+      NewStatusKey('~Alt+F9~ Compile', kbAltF9, cmCompile,
+      NewStatusKey('~F9~ Make', kbF9, cmMake,
+      NewStatusKey('~Alt+F10~ Local menu', kbAltF10, cmLocalMenu,
+      StdStatusKeys(
+      nil)))))),
+    nil)))))));
+end;
+
+procedure TIDEApp.HandleEvent(var Event: TEvent);
+var DontClear: boolean;
+begin
+  case Event.What of
+       evCommand :
+         begin
+           DontClear:=false;
+           case Event.Command of
+             cmUpdate        : Message(Application,evBroadcast,cmUpdate,nil);
+           { -- File menu -- }
+             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);
+           { -- Edit menu -- }
+             cmShowClipboard : ShowClipboard;
+           { -- Search menu -- }
+             cmObjects       : Objects;
+             cmModules       : Modules;
+             cmGlobals       : Globals;
+           { -- Run menu -- }
+             cmParameters    : Parameters;
+             cmRun           : DoRun;
+           { -- Compile menu -- }
+             cmCompile       : DoCompile(cCompile);
+             cmBuild         : DoCompile(cBuild);
+             cmMake          : DoCompile(cMake);
+             cmTarget        : Target;
+             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;
+{             cmHelpTopicSearch: HelpTopicSearch;}
+             cmHelpPrevTopic : HelpPrevTopic;
+             cmHelpUsingHelp : HelpUsingHelp;
+             cmHelpFiles     : HelpFiles;
+             cmAbout         : About;
+           else DontClear:=true;
+           end;
+           if DontClear=false then ClearEvent(Event);
+         end;
+       evBroadcast :
+         case Event.Command of
+           cmUpdate              :
+             Update;
+           cmSourceWindowClosing :
+             with PSourceWindow(Event.InfoPtr)^ do
+               if Editor^.FileName<>'' then
+                  AddRecentFile(Editor^.FileName,Editor^.CurPos.X,Editor^.CurPos.Y);
+         end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+procedure TIDEApp.Update;
+begin
+  SetCmdState([cmSaveAll],IsThereAnyEditor);
+  SetCmdState([cmCloseAll,cmTile,cmCascade,cmWindowList],IsThereAnyWindow);
+  SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals{,cmInformation}],{SymbolInfoLoaded}true);
+  UpdatePrimaryFile;
+  UpdateINIFile;
+  Message(MenuBar,evBroadcast,cmUpdate,nil);
+  UpdateRecentFileList;
+  Message(Application,evBroadcast,cmCommandSetChanged,nil);
+end;
+
+procedure TIDEApp.CurDirChanged;
+begin
+  Message(Application,evBroadcast,cmUpdateTitle,nil);
+  UpdatePrimaryFile;
+  UpdateINIFile;
+  UpdateMenu(MenuBar^.Menu);
+end;
+
+procedure TIDEApp.UpdatePrimaryFile;
+begin
+  SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmPrimaryFile),SmartPath(PrimaryFile));
+  SetCmdState([cmClearPrimary],PrimaryFile<>'');
+  if PrimaryFile<>'' then
+     SetCmdState(CompileCmds,true);
+  UpdateMenu(MenuBar^.Menu);
+  Message(ProgramInfoWindow,evBroadcast,cmUpdate,nil);
+end;
+
+procedure TIDEApp.UpdateINIFile;
+begin
+  SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(INIPath));
+end;
+
+procedure TIDEApp.UpdateRecentFileList;
+var P: PMenuItem;
+    ID,I: word;
+    FileMenu: PMenuItem;
+begin
+  ID:=cmRecentFileBase;
+  FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
+  repeat
+{    Inc(ID);
+    P:=SearchMenuItem(FileMenu^.SubMenu,ID);
+    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
+     RemoveMenuItem(FileMenu^.SubMenu,P);
+
+  if RecentFileCount>0 then
+     AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
+  for I:=1 to RecentFileCount do
+  begin
+    P:=NewItem('~'+IntToStr(I)+'~. '+SmartPath(RecentFiles[I].FileName),' ',
+        kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
+    AppendMenuItem(FileMenu^.SubMenu,P);
+  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 FPMSRCH.INC}
+
+{$I FPMRUN.INC}
+
+{$I FPMCOMP.INC}
+
+{$I FPMDEBUG.INC}
+
+{$I FPMTOOLS.INC}
+
+{$I FPMOPTS.INC}
+
+{$I FPMWND.INC}
+
+{$I FPMHELP.INC}
+
+procedure TIDEApp.AddRecentFile(AFileName: string; CurX, CurY: integer);
+begin
+  if SearchRecentFile(AFileName)<>-1 then Exit;
+  if RecentFileCount>0 then
+   Move(RecentFiles[1],RecentFiles[2],SizeOf(RecentFiles[1])*Min(RecentFileCount,High(RecentFiles)-1));
+  if RecentFileCount<High(RecentFiles) then Inc(RecentFileCount);
+  with RecentFiles[1] do
+  begin
+    FileName:=AFileName;
+    LastPos.X:=CurX; LastPos.Y:=CurY;
+  end;
+  UpdateRecentFileList;
+end;
+
+function TIDEApp.SearchRecentFile(AFileName: string): integer;
+var Idx,I: integer;
+begin
+  Idx:=-1;
+  for I:=1 to RecentFileCount do
+    if UpcaseStr(AFileName)=UpcaseStr(RecentFiles[I].FileName) then
+      begin Idx:=I; Break; end;
+  SearchRecentFile:=Idx;
+end;
+
+procedure TIDEApp.RemoveRecentFile(Index: integer);
+begin
+  if Index<RecentFileCount then
+     Move(RecentFiles[Index+1],RecentFiles[Index],SizeOf(RecentFiles[1])*(RecentFileCount-Index));
+  Dec(RecentFileCount);
+end;
+
+function TIDEApp.GetPalette: PPalette;
+var P: string;
+begin
+  P:=AppPalette;
+  GetPalette:=@P;
+end;
+
+destructor TIDEApp.Done;
+begin
+  inherited Done;
+  DoneHelpSystem;
+  DoneTemplates;
+end;
+
+END.
+{
+  $Log$
+  Revision 1.1  1999-01-12 14:29:34  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.4  1999/01/04 11:49:41  peter
+   * 'Use tab characters' now works correctly
+   + Syntax highlight now acts on File|Save As...
+   + Added a new class to syntax highlight: 'hex numbers'.
+   * There was something very wrong with the palette managment. Now fixed.
+   + Added output directory (-FE<xxx>) support to 'Directories' dialog...
+   * Fixed some possible bugs in Running/Compiling, and the compilation/run
+     process revised
+
+  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
+
+}

+ 15 - 3
ide/text/fpmhelp.inc

@@ -161,7 +161,7 @@ procedure TIDEApp.About;
 var R,R2: TRect;
     D: PCenterDialog;
 begin
-  R.Assign(0,0,38,10);
+  R.Assign(0,0,38,12);
   New(D, Init(R, 'About'));
   with D^ do
   begin
@@ -171,9 +171,13 @@ begin
     R2.Move(0,2);
     Insert(New(PStaticText, Init(R2, ^C'Version '+VersionStr)));
     R2.Move(0,2);
-    Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998 by')));
+    Insert(New(PStaticText, Init(R2, ^C'Copyright (C) 1998-99 by')));
     R2.Move(0,2);
     Insert(New(PStaticText, Init(R2, ^C'B‚rczi G bor')));
+    R2.Move(0,1);
+    Insert(New(PStaticText, Init(R2, ^C'and')));
+    R2.Move(0,1);
+    Insert(New(PStaticText, Init(R2, ^C'Peter Vreman')));
   end;
   InsertOK(D);
   Desktop^.ExecView(D);
@@ -182,7 +186,15 @@ end;
 
 {
   $Log$
-  Revision 1.2  1998-12-28 15:47:48  peter
+  Revision 1.3  1999-01-12 14:29:34  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  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

+ 78 - 53
ide/text/fpmopts.inc

@@ -230,56 +230,61 @@ end;
 procedure TIDEApp.MemorySizes;
 var R,R2,R3: TRect;
     D: PCenterDialog;
-    IL1,IL2: PIntegerLine;
+    ILs: array[0..10] of PIntegerLine;
+    I: integer;
 begin
-{$ifdef NOTYET}
-  R.Assign(0,0,40,7);
+  R.Assign(0,0,40,2+MemorySizeSwitches^.ItemCount*2);
   New(D, Init(R, 'Memory sizes'));
   with D^ do
   begin
     GetExtent(R); R.Grow(-3,-1);
     R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+1;
-    R3.Copy(R2); R3.A.X:=21; R3.B.X:=R3.A.X+10;
-    New(IL1, Init(R3, MinStackSize, MaxStackSize));
-    IL1^.Data^:=IntToStr(GetStackSize);
-    Insert(IL1);
-    R3.Copy(R2); R3.B.X:=21;
-    Insert(New(PLabel, Init(R3, '~S~tack size', IL1)));
+    for I:=0 to MemorySizeSwitches^.ItemCount-1 do
+     begin
+       R3.Copy(R2); R3.A.X:=21; R3.B.X:=R3.A.X+10;
+       New(ILs[I], Init(R3, MinMemSize, MaxMemSize));
+       ILs[I]^.Data^:=IntToStr(MemorySizeSwitches^.GetLongintItem(I));
+       Insert(ILs[I]);
+       R3.Copy(R2); R3.B.X:=21;
+       Insert(New(PLabel, Init(R3, MemorySizeSwitches^.ItemName(I), ILs[I])));
+       R2.Move(0,2);
+     end;
 
-    R2.Move(0,2);
-    R3.Copy(R2); R3.A.X:=21; R3.B.X:=R3.A.X+10;
+{    R3.Copy(R2); R3.A.X:=21; R3.B.X:=R3.A.X+10;
     New(IL2, Init(R3, MinHeapSize, MaxHeapSize));
     IL2^.Data^:=IntToStr(GetHeapSize);
     Insert(IL2);
     R3.Copy(R2); R3.B.X:=21;
-    Insert(New(PLabel, Init(R3, 'Local ~h~eap size', IL2)));
+    Insert(New(PLabel, Init(R3, 'Local ~h~eap size', IL2)));}
   end;
   InsertButtons(D);
-  IL1^.Select;
+  ILs[0]^.Select;
   if Desktop^.ExecView(D)=cmOK then
   begin
-    SetStackSize(StrToInt(IL1^.Data^));
-    SetHeapSize(StrToInt(IL2^.Data^));
+    for I:=0 to MemorySizeSwitches^.ItemCount-1 do
+     begin
+       MemorySizeSwitches^.SetLongintItem(I,StrToInt(ILs[I]^.Data^));
+     end;
+{    SetStackSize(StrToInt(IL1^.Data^));
+    SetHeapSize(StrToInt(IL2^.Data^));}
   end;
   Dispose(D, Done);
-{$endif}
 end;
 
 procedure TIDEApp.Linker;
 var R,R2: TRect;
     D: PCenterDialog;
-    RB1,RB2: PRadioButtons;
-    Mask,V,I: longint;
+    RB2: PRadioButtons;
+    I: longint;
     Items: PSItem;
     L: longint;
 begin
-{$ifdef NOTYET}
   R.Assign(0,0,56,8);
   New(D, Init(R, 'Linker'));
   with D^ do
   begin
     GetExtent(R); R.Grow(-3,-1);
-    R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+GetEXEFormatCount; R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2;
+{    R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+GetEXEFormatCount; R2.B.X:=R2.A.X+(R2.B.X-R2.A.X) div 2;
     Items:=nil;
     for I:=GetEXEFormatCount downto 1 do
       Items:=NewSItem(GetEXEFormatName(TEXEFormat(I)),Items);
@@ -297,14 +302,14 @@ begin
     RB1^.SetData(L);
     Insert(RB1);
     R2.Copy(R); R2.B.Y:=R2.A.Y+1;
-    Insert(New(PLabel, Init(R2, 'Output format', RB1)));
+    Insert(New(PLabel, Init(R2, 'Output format', RB1)));}
 
-    R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+2; R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2+1;
-    New(RB2, Init(R2,
-      NewSItem('D~y~namic libraries',
-      NewSItem('S~t~atic libraries',
-      nil))));
-    L:=ord(GetLinkLibraryType)-1;
+    R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+LibLinkerSwitches^.ItemCount; R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2+1;
+    Items:=nil;
+    for I:=LibLinkerSwitches^.ItemCount-1 downto 0 do
+      Items:=NewSItem(LibLinkerSwitches^.ItemName(I), Items);
+    New(RB2, Init(R2, Items));
+    L:=LibLinkerSwitches^.GetCurrSel;
     RB2^.SetData(L);
     Insert(RB2);
     R2.Copy(R); R2.B.Y:=R2.A.Y+1; R2.A.X:=R2.B.X-(R2.B.X-R2.A.X) div 2+1;
@@ -313,43 +318,41 @@ begin
   InsertButtons(D);
   if Desktop^.ExecView(D)=cmOK then
   begin
-    SetEXEFormat(TEXEFormat(RB1^.Value+1));
-    SetLinkLibraryType(TLibraryType(RB2^.Value+1));
+{    SetEXEFormat(TEXEFormat(RB1^.Value+1));}
+    LibLinkerSwitches^.SetCurrSel(RB2^.Value);
   end;
   Dispose(D, Done);
-{$endif}
 end;
 
 procedure TIDEApp.Debugger;
 var R,R2: TRect;
     D: PCenterDialog;
     RB1,RB2: PRadioButtons;
-    L: longint;
+    L,I: longint;
+    Items: PSItem;
 begin
-{$ifdef NOTYET}
-  R.Assign(0,0,46,11);
+  R.Assign(0,0,46,2+DebugInfoSwitches^.ItemCount+2+ProfileInfoSwitches^.ItemCount+2);
   New(D, Init(R, 'Debugging/Profiling'));
   with D^ do
   begin
     GetExtent(R); R.Grow(-3,-1);
-    R2.Copy(R); Inc(R2.A.Y,2); R2.B.Y:=R2.A.Y+3;
-    New(RB1, Init(R2,
-      NewSItem('~S~trip all symbols from executable',
-      NewSItem('Generate g~s~ym symbol information',
-      NewSItem('Generate ~d~bx symbol information',
-      nil)))));
-    L:=ord(GetSymbolFormat);
+    R2.Copy(R); Inc(R2.A.Y,2); R2.B.Y:=R2.A.Y+DebugInfoSwitches^.ItemCount;
+    Items:=nil;
+    for I:=DebugInfoSwitches^.ItemCount-1 downto 0 do
+      Items:=NewSItem(DebugInfoSwitches^.ItemName(I), Items);
+    New(RB1, Init(R2, Items));
+    L:=DebugInfoSwitches^.GetCurrSel;
     RB1^.SetData(L);
     Insert(RB1);
     R2.Copy(R); Inc(R2.A.Y); R2.B.Y:=R2.A.Y+1;
     Insert(New(PLabel, Init(R2, 'Symbol information', RB1)));
 
-    R2.Copy(R); Inc(R2.A.Y,7); R2.B.Y:=R2.A.Y+2;
-    New(RB2, Init(R2,
-      NewSItem('N~o~ profile information',
-      NewSItem('Generate ~p~rofile code for gprof',
-      nil))));
-    L:=ord(GetProfileFormat);
+    R2.Copy(R); Inc(R2.A.Y,2+DebugInfoSwitches^.ItemCount+2); R2.B.Y:=R2.A.Y+ProfileInfoSwitches^.ItemCount;
+    Items:=nil;
+    for I:=ProfileInfoSwitches^.ItemCount-1 downto 0 do
+      Items:=NewSItem(ProfileInfoSwitches^.ItemName(I), Items);
+    New(RB2, Init(R2, Items));
+    L:=ProfileInfoSwitches^.GetCurrSel;
     RB2^.SetData(L);
     Insert(RB2);
     R2.Copy(R); Inc(R2.A.Y,6); R2.B.Y:=R2.A.Y+1;
@@ -359,11 +362,10 @@ begin
   RB1^.Select;
   if Desktop^.ExecView(D)=cmOK then
   begin
-    SetSymbolFormat(TSymbolFormat(RB1^.Value));
-    SetProfileFormat(TProfileFormat(RB2^.Value));
+    DebugInfoSwitches^.SetCurrSel(RB1^.Value);
+    ProfileInfoSwitches^.SetCurrSel(RB2^.Value);
   end;
   Dispose(D, Done);
-{$endif}
 end;
 
 
@@ -483,7 +485,7 @@ begin
 end;
 
 procedure TIDEApp.Mouse;
-var R,R2,R3: TRect;
+var R,R2: TRect;
     D: PCenterDialog;
     SB: PScrollBar;
     CB: PCheckBoxes;
@@ -555,6 +557,20 @@ procedure TIDEApp.Colors;
 var D: PColorDialog;
 begin
   New(D, Init(AppPalette,
+    ColorGroup('Browser',
+      ColorItem('Frame passive'   , 215,
+      ColorItem('Frame active'    , 216,
+      ColorItem('Frame icon'      , 217,
+      ColorItem('Scroll bar page' , 218,
+      ColorItem('Scroll bar icons', 219,
+      ColorItem('Normal text'     , 220,
+      ColorItem('Selected text'   , 221,
+      ColorItem('Active item'     , 222,
+      ColorItem('Inactive item'   , 223,
+      ColorItem('Focused item'    , 224,
+      ColorItem('Selected item'   , 225,
+      ColorItem('Divider'         , 226,
+      nil)))))))))))),
     ColorGroup('Desktop', DesktopColorItems(nil),
     ColorGroup('Dialogs', DialogColorItems(dpGrayDialog,nil),
     ColorGroup('Editor',
@@ -592,8 +608,9 @@ begin
       ColorItem('Assembler'       , 206,
       ColorItem('Symbols'         , 207,
       ColorItem('Directives'      , 211,
-      nil)))))))))),
-    nil))))))));
+      ColorItem('Tabs'            , 213,
+      nil))))))))))),
+    nil)))))))));
   if ExecuteDialog(D, @AppPalette)=cmOK then
     begin
       DoneMemory;
@@ -652,7 +669,15 @@ end;
 
 {
   $Log$
-  Revision 1.4  1999-01-04 11:49:47  peter
+  Revision 1.5  1999-01-12 14:29:35  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.4  1999/01/04 11:49:47  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 13 - 5
ide/text/fpmrun.inc

@@ -40,14 +40,14 @@ begin
   DoneMouse;
   DoneVideo;
 
-  if Assigned(UserScreen) then
-    UserScreen^.SwitchTo;
+{  if Assigned(UserScreen) then
+    UserScreen^.SwitchTo; }
 
   Exec(ExeFile,GetRunParameters);
   LastExitCode:=DosExitCode;
 
-  if Assigned(UserScreen) then
-    UserScreen^.SwitchBack;
+{  if Assigned(UserScreen) then
+    UserScreen^.SwitchBack; }
 
   InitVideo;
   InitMouse;
@@ -83,7 +83,15 @@ end;
 
 {
   $Log$
-  Revision 1.2  1999-01-04 11:49:48  peter
+  Revision 1.3  1999-01-12 14:29:36  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.2  1999/01/04 11:49:48  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 84 - 0
ide/text/fpmsrch.inc

@@ -0,0 +1,84 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Search 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.Objects;
+begin
+end;
+
+procedure TIDEApp.Globals;
+var R: TRect;
+    S: PSortedSymbolCollection;
+    Overflow: boolean;
+
+  procedure InsertInS(P: PSymbol); {$ifndef FPC}far;{$endif}
+
+    procedure InsertItemsInS(P: PSymbolCollection);
+    var I: Sw_integer;
+    begin
+      for I:=0 to P^.Count-1 do
+        InsertInS(P^.At(I));
+    end;
+
+  begin
+    if S^.Count=MaxCollectionSize then
+       begin Overflow:=true; Exit; end;
+    S^.Insert(P);
+    if P^.Items<>nil then
+      InsertItemsInS(P^.Items);
+  end;
+
+begin
+  if BrowCol.Modules=nil then
+     begin ErrorBox('No debug info available.',nil); Exit; end;
+  Overflow:=false;
+  New(S, Init(500,500));
+  BrowCol.Modules^.ForEach(@InsertInS);
+  if Overflow then
+    WarningBox('Too many symbols. Can''t display all of them.',nil);
+  Desktop^.GetExtent(R); R.A.X:=R.B.X-35;
+  Desktop^.Insert(New(PBrowserWindow, Init(R,
+    'Browse: Globals',0,'Global scope',S,nil)));
+end;
+
+procedure TIDEApp.Modules;
+var
+    S: PSortedSymbolCollection;
+procedure InsertInS(P: PSymbol); {$ifndef FPC}far;{$endif}
+begin
+  S^.Insert(P);
+end;
+begin
+  if BrowCol.Modules=nil then
+     begin ErrorBox('No debug info available.',nil); Exit; end;
+  New(S, Init(500,500));
+  BrowCol.Modules^.ForEach(@InsertInS);
+  OpenSymbolBrowser(0,0,'Units','Global scope',S,nil);
+end;
+
+{
+  $Log$
+  Revision 1.1  1999-01-12 14:29:37  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.9  1999/01/09 18:00:47  peter
+     Original implementation
+
+}

+ 10 - 1
ide/text/fpmwnd.inc

@@ -59,6 +59,7 @@ begin
     hcInfoWindow   : S:=PProgramInfoWindow(P)^.GetTitle(MaxLen);
     hcHelpWindow   : S:=PHelpWindow(P)^.GetTitle(MaxLen);
     hcCalcWindow   : S:=PCalculator(P)^.GetTitle(MaxLen);
+    hcBrowserWindow: S:=PBrowserWindow(P)^.GetTitle(MaxLen);
   else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
   end;
   GetText:=copy(S,1,MaxLen);
@@ -162,7 +163,15 @@ end;
 
 {
   $Log$
-  Revision 1.4  1999-01-04 11:49:49  peter
+  Revision 1.5  1999-01-12 14:29:37  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.4  1999/01/04 11:49:49  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 10 - 2
ide/text/fprun.pas

@@ -49,7 +49,7 @@ begin
 
   UserScreen^.SwitchTo;
 
-  Exec(ExeFile,GetRunParameters);
+//  Exec(ExeFile,GetRunParameters);
 
   UserScreen^.SwitchBack;
 
@@ -62,7 +62,15 @@ end;
 end.
 {
   $Log$
-  Revision 1.1  1998-12-28 15:47:52  peter
+  Revision 1.2  1999-01-12 14:29:38  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  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

+ 52 - 7
ide/text/fpswitch.pas

@@ -23,10 +23,8 @@ uses
   FPConst;
 
 const
-     MinStackSize    = 1024;
-     MaxStackSize    = 67107840;
-     MinHeapSize     = 1024;
-     MaxHeapSize     = 67107840;
+     MinMemSize      = 1024;     { min. local heap and stack size }
+     MaxMemSize      = 67107840; { max. local heap and stack size }
 
 type
     TSwitchMode = (om_Normal,om_Debug,om_Release);
@@ -36,7 +34,7 @@ type
     PSwitchItem = ^TSwitchItem;
     TSwitchItem = object(TObject)
       Typ       : TSwitchItemTyp;
-      Name      : string[30];
+      Name      : string[50];
       Param     : string[10];
       constructor Init(const n,p:string);
       function  NeedParam:boolean;virtual;
@@ -117,6 +115,10 @@ const
       ('NORMAL','DEBUG','RELEASE');
 
 var
+    LibLinkerSwitches,
+    DebugInfoSwitches,
+    ProfileInfoSwitches,
+    MemorySizeSwitches,
     SyntaxSwitches,
     VerboseSwitches,
     CodegenSwitches,
@@ -540,6 +542,10 @@ begin
      DirectorySwitches^.WriteItemsCfg;
      MemorySwitches^.WriteItemsCfg;
      ConditionalSwitches^.WriteItemsCfg;
+     LibLinkerSwitches^.WriteItemsCfg;
+     DebugInfoSwitches^.WriteItemsCfg;
+     ProfileInfoSwitches^.WriteItemsCfg;
+     MemorySizeSwitches^.WriteItemsCfg;
      Writeln(CfgFile,'#ENDIF');
      Writeln(CfgFile,'');
    end;
@@ -572,11 +578,17 @@ begin
         Delete(s,1,2);
         case c of
          'd' : ConditionalSwitches^.ReadItemsCfg(s);
+         'X' : LibLinkerSwitches^.ReadItemsCfg(s);
+         'g' : DebugInfoSwitches^.ReadItemsCfg(s);
+         'p' : ProfileInfoSwitches^.ReadItemsCfg(s);
          'S' : SyntaxSwitches^.ReadItemsCfg(s);
          'F' : DirectorySwitches^.ReadItemsCfg(s);
          'T' : TargetSwitches^.ReadItemsCfg(s);
          'R' : AsmReaderSwitches^.ReadItemsCfg(s);
-         'C' : CodegenSwitches^.ReadItemsCfg(s);
+         'C' : begin
+                 CodegenSwitches^.ReadItemsCfg(s);
+                 MemorySizeSwitches^.ReadItemsCfg(s);
+               end;
          'v' : VerboseSwitches^.ReadItemsCfg(s);
          'O' : begin
                  if not OptimizationSwitches^.ReadItemsCfg(s) then
@@ -693,6 +705,31 @@ begin
      AddStringItem('~O~bject directories','o',true);
      AddStringItem('~E~XE & PPU directories','E',true);
    end;
+  New(LibLinkerSwitches,InitSelect('X'));
+  with LibLinkerSwitches^ do
+   begin
+     AddSelectItem('~D~ynamic libraries','D');
+     AddSelectItem('~S~tatic libraries','S');
+   end;
+  New(DebugInfoSwitches,InitSelect('g'));
+  with DebugInfoSwitches^ do
+   begin
+     AddSelectItem('~S~trip all symbols from executable','-');
+     AddSelectItem('Generate ~g~sym symbol information','g');
+     AddSelectItem('Generate ~d~bx symbol information','d');
+   end;
+  New(ProfileInfoSwitches,InitSelect('p'));
+  with ProfileInfoSwitches^ do
+   begin
+     AddSelectItem('~N~o profile information','-');
+     AddSelectItem('Generate profile code for g~p~rof','g');
+   end;
+  New(MemorySizeSwitches,Init('C'));
+  with MemorySizeSwitches^ do
+   begin
+     AddLongIntItem('~S~tack size','s');
+     AddLongIntItem('Local ~h~eap size','h');
+   end;
   SwitchesPath:=LocateFile(SwitchesName);
   if SwitchesPath='' then
     SwitchesPath:=SwitchesName;
@@ -718,7 +755,15 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  1999-01-04 11:49:50  peter
+  Revision 1.3  1999-01-12 14:29:39  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.2  1999/01/04 11:49:50  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 496 - 0
ide/text/fpsymbol.pas

@@ -0,0 +1,496 @@
+{
+    $Id$
+    This file is part of the Free Pascal Integrated Development Environment
+    Copyright (c) 1998 by Berczi Gabor
+
+    Symbol browse support 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 FPSymbol;
+
+interface
+
+uses Objects,Drivers,Views,Dialogs,
+     BrowCol,
+     FPViews;
+
+const
+      { Browser tab constants }
+      btScope       = 1;
+      btReferences  = 2;
+      btInheritance = 4;
+
+type
+    PSymbolView = ^TSymbolView;
+    TSymbolView = object(TListBox)
+      constructor  Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
+      procedure    HandleEvent(var Event: TEvent); virtual;
+      function     GetPalette: PPalette; virtual;
+    end;
+
+    PSymbolScopeView = ^TSymbolScopeView;
+    TSymbolScopeView = object(TSymbolView)
+      constructor Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
+      function    GetText(Item,MaxLen: Sw_Integer): String; virtual;
+    private
+      Symbols: PSymbolCollection;
+    end;
+
+    PSymbolReferenceView = ^TSymbolReferenceView;
+    TSymbolReferenceView = object(TSymbolView)
+      constructor Init(var Bounds: TRect; AReferences: PReferenceCollection; AHScrollBar, AVScrollBar: PScrollBar);
+      function    GetText(Item,MaxLen: Sw_Integer): String; virtual;
+      procedure   SelectItem(Item: Sw_Integer); virtual;
+    private
+      References: PReferenceCollection;
+    end;
+
+    PBrowserTab = ^TBrowserTab;
+    TBrowserTab = object(TView)
+      constructor Init(var Bounds: TRect);
+      procedure   SetParams(AFlags: word; ACurrent: Sw_integer); virtual;
+      procedure   Draw; virtual;
+      function    GetPalette: PPalette; virtual;
+    private
+      Flags   : word;
+      Current : Sw_integer;
+    end;
+
+    PBrowserWindow = ^TBrowserWindow;
+    TBrowserWindow = object(TWindow)
+      constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;
+                    const AName: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection);
+      procedure   HandleEvent(var Event: TEvent); virtual;
+      procedure   SelectTab(BrowserTab: Sw_integer); virtual;
+      function    GetPalette: PPalette; virtual;
+    private
+      PageTab       : PBrowserTab;
+      ScopeView     : PSymbolScopeView;
+      ReferenceView : PSymbolReferenceView;
+    end;
+
+procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;
+            Symbols: PSymbolCollection; References: PReferenceCollection);
+
+implementation
+
+uses Commands,App,
+     FPConst,FPUtils,FPVars;
+
+(*procedure ReadBrowseLog(FileName: string);
+var f: text;
+    IOOK,EndOfFile: boolean;
+    Line: string;
+procedure NextLine;
+begin
+  readln(f,Line);
+  EndOfFile:=Eof(f);
+end;
+var Level: integer;
+procedure ProcessSymTable(Indent: integer; Owner: PSymbolCollection);
+var IndentS,S,Source: string;
+    Sym: PSymbol;
+    Ref: PSymbolReference;
+    P: byte;
+    PX: TPoint;
+    PS: PString;
+    PCount: integer;
+    Params: array[0..30] of PString;
+    Typ: tsymtyp;
+    ExitBack: boolean;
+begin
+  Inc(Level);
+  IndentS:=CharStr(' ',Indent); ExitBack:=false;
+  Sym:=nil;
+  repeat
+    if copy(Line,1,length(IndentS))<>IndentS then ExitBack:=true else
+    if copy(Line,Indent+1,3)='***' then
+      { new symbol }
+      begin
+        S:=copy(Line,Indent+1+3,255);
+        P:=Pos('***',S); if P=0 then P:=length(S)+1;
+        S:=Trim(copy(S,1,P-1));
+        if (copy(S,1,1)='_') and (Pos('$$',S)>0) then
+          begin
+            repeat
+              P:=Pos('$$',S);
+              if P>0 then Delete(S,1,P+1);
+            until P=0;
+            P:=Pos('$',S);
+            Delete(S,1,P);
+            PCount:=0;
+            repeat
+              P:=Pos('$',S); if P=0 then P:=length(S)+1;
+              Params[PCount]:=TypeNames^.Add(copy(S,1,P-1));
+              Inc(PCount);
+              Delete(S,1,P);
+            until S='';
+            Sym^.Typ:=procsym;
+            Sym^.SetParams(PCount,@Params);
+          end
+        else
+          New(Sym, Init(S, varsym, 0, nil));
+        Owner^.Insert(Sym);
+        NextLine;
+      end else
+    if copy(Line,Indent+1,3)='---' then
+      { child symtable }
+      begin
+        S:=Trim(copy(Line,Indent+1+12,255));
+        if Level=1 then Typ:=unitsym else
+          Typ:=typesym;
+        if (Sym<>nil) and (Sym^.GetName=S) then
+        else
+          begin
+            New(Sym, Init(S, Typ, 0, nil));
+            Owner^.Insert(Sym);
+          end;
+        Sym^.Typ:=Typ;
+        NextLine;
+        New(Sym^.Items, Init(0,50));
+        ProcessSymTable(Indent+2,Sym^.Items);
+      end else
+{    if Sym<>nil then}
+    if copy(Line,Indent+1,1)=' ' then
+      { reference }
+      begin
+        S:=copy(Line,Indent+1+2,255);
+        P:=Pos('(',S); if P=0 then P:=length(S)+1;
+        Source:=Trim(copy(S,1,P-1)); Delete(S,1,P);
+        P:=Pos(',',S); if P=0 then P:=length(S)+1;
+        PX.Y:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
+        P:=Pos(')',S); if P=0 then P:=length(S)+1;
+        PX.X:=StrToInt(copy(S,1,P-1)); Delete(S,1,P);
+        PS:=ModuleNames^.Add(Source);
+        New(Ref, Init(PS, PX));
+        if Sym^.References=nil then
+          New(Sym^.References, Init(10,50));
+        Sym^.References^.Insert(Ref);
+      end;
+    if ExitBack=false then
+      NextLine;
+  until EndOfFile or ExitBack;
+  Dec(Level);
+end;
+begin
+  DoneSymbolBrowser;
+  InitSymbolBrowser;
+
+{$I-}
+  Assign(f,FileName);
+  Reset(f);
+  Level:=0;
+  NextLine;
+  while (IOResult=0) and (EndOfFile=false) do
+    ProcessSymTable(0,Modules);
+  Close(f);
+  EatIO;
+{$I+}
+end;*)
+
+
+{****************************************************************************
+                               TSymbolView
+****************************************************************************}
+
+constructor TSymbolView.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
+begin
+  inherited Init(Bounds,1,AVScrollBar);
+  HScrollBar:=AHScrollBar;
+  if assigned(HScrollBar) then
+    HScrollBar^.SetRange(1,80);
+  Options:=Options or (ofSelectable+ofTopSelect);
+end;
+
+procedure TSymbolView.HandleEvent(var Event: TEvent);
+var DontClear: boolean;
+begin
+  case Event.What of
+    evKeyDown :
+      begin
+        DontClear:=false;
+        case Event.KeyCode of
+          kbEnter :
+            SelectItem(Focused);
+          kbRight,kbLeft :
+            if HScrollBar<>nil then
+              HScrollBar^.HandleEvent(Event);
+        else DontClear:=true;
+        end;
+        if DontClear=false then ClearEvent(Event);
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+function TSymbolView.GetPalette: PPalette;
+const
+  P: string[length(CBrowserListBox)] = CBrowserListBox;
+begin
+  GetPalette:=@P;
+end;
+
+
+{****************************************************************************
+                               TSymbolScopeView
+****************************************************************************}
+
+constructor TSymbolScopeView.Init(var Bounds: TRect; ASymbols: PSymbolCollection; AHScrollBar, AVScrollBar: PScrollBar);
+begin
+  inherited Init(Bounds,AHScrollBar, AVScrollBar);
+  Symbols:=ASymbols;
+  NewList(ASymbols);
+  SetRange(Symbols^.Count);
+end;
+
+function TSymbolScopeView.GetText(Item,MaxLen: Sw_Integer): String;
+var S: string;
+begin
+  S:=Symbols^.At(Item)^.GetText;
+  GetText:=copy(S,1,MaxLen);
+end;
+
+
+{****************************************************************************
+                             TSymbolReferenceView
+****************************************************************************}
+
+constructor TSymbolReferenceView.Init(var Bounds: TRect; AReferences: PReferenceCollection;
+              AHScrollBar, AVScrollBar: PScrollBar);
+begin
+  inherited Init(Bounds,AHScrollBar, AVScrollBar);
+  References:=AReferences;
+  NewList(AReferences);
+  SetRange(References^.Count);
+end;
+
+function TSymbolReferenceView.GetText(Item,MaxLen: Sw_Integer): String;
+var S: string;
+    P: PReference;
+begin
+  P:=References^.At(Item);
+  S:=P^.GetFileName+'('+IntToStr(P^.Position.Y)+')';
+  GetText:=copy(S,1,MaxLen);
+end;
+
+procedure TSymbolReferenceView.SelectItem(Item: Sw_Integer);
+begin
+end;
+
+
+{****************************************************************************
+                               TBrowserTab
+****************************************************************************}
+
+constructor TBrowserTab.Init(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  SetParams(0,0);
+end;
+
+procedure TBrowserTab.SetParams(AFlags: word; ACurrent: Sw_integer);
+begin
+  Flags:=AFlags; Current:=ACurrent;
+  DrawView;
+end;
+
+procedure TBrowserTab.Draw;
+var B: TDrawBuffer;
+    SelColor, NormColor, C: word;
+    I,CurX,Count: Sw_integer;
+const
+    Names: string[3] = 'SRI';
+begin
+  NormColor:=GetColor(1); SelColor:=GetColor(2);
+  MoveChar(B,'Ä',SelColor,Size.X);
+  CurX:=0; Count:=0;
+  for I:=0 to 2 do
+    if (Flags and (1 shl I))<>0 then
+    begin
+      Inc(Count);
+      if Current=(1 shl I) then C:=SelColor
+                           else C:=NormColor;
+      if Count=1 then MoveChar(B[CurX],'´',SelColor,1)
+                 else MoveChar(B[CurX],'³',SelColor,1);
+      MoveCStr(B[CurX+1],' '+Names[I+1]+' ',C);
+      Inc(CurX,4);
+    end;
+  if Count>0 then
+    MoveChar(B[CurX],'Ã',SelColor,1);
+  WriteLine(0,0,Size.X,Size.Y,B);
+end;
+
+function TBrowserTab.GetPalette: PPalette;
+const P: string[length(CBrowserTab)] = CBrowserTab;
+begin
+  GetPalette:=@P;
+end;
+
+constructor TBrowserWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;
+             const AName: string; ASymbols: PSymbolCollection; AReferences: PReferenceCollection);
+var R: TRect;
+    ST: PStaticText;
+    HSB,VSB: PScrollBar;
+function CreateVSB(R: TRect): PScrollBar;
+var R2: TRect;
+    SB: PScrollBar;
+begin
+  R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
+  New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
+  CreateVSB:=SB;
+end;
+function CreateHSB(R: TRect): PScrollBar;
+var R2: TRect;
+    SB: PScrollBar;
+begin
+  R2.Copy(R); R2.Move(0,1); R2.A.Y:=R2.B.Y-1;
+  New(SB, Init(R2)); SB^.GrowMode:=gfGrowLoY+gfGrowHiX+gfGrowHiY;
+  CreateHSB:=SB;
+end;
+begin
+  inherited Init(Bounds, ATitle, ANumber);
+  HelpCtx:=hcBrowserWindow;
+
+  GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+1;
+  New(ST, Init(R, ' '+AName)); ST^.GrowMode:=gfGrowHiX;
+  Insert(ST);
+
+  GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
+  New(PageTab, Init(R));
+  PageTab^.GrowMode:=gfGrowHiX;
+  Insert(PageTab);
+
+  GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);
+  if assigned(ASymbols) and (ASymbols^.Count>0) then
+    begin
+      HSB:=CreateHSB(R); Insert(HSB);
+      VSB:=CreateVSB(R); Insert(VSB);
+      New(ScopeView, Init(R, ASymbols, HSB, VSB));
+      ScopeView^.GrowMode:=gfGrowHiX+gfGrowHiY;
+      Insert(ScopeView);
+    end;
+  if assigned(AReferences) and (AReferences^.Count>0) then
+    begin
+      HSB:=CreateHSB(R); Insert(HSB);
+      VSB:=CreateVSB(R); Insert(VSB);
+      New(ReferenceView, Init(R, AReferences, HSB, VSB));
+      ReferenceView^.GrowMode:=gfGrowHiX+gfGrowHiY;
+      Insert(ReferenceView);
+    end;
+  if assigned(ScopeView) then
+   SelectTab(btScope)
+  else
+   if assigned(ReferenceView) then
+    SelectTab(btReferences);
+end;
+
+procedure TBrowserWindow.HandleEvent(var Event: TEvent);
+var DontClear: boolean;
+    S: PSymbol;
+    P: TPoint;
+begin
+  case Event.What of
+    evBroadcast :
+      case Event.Command of
+        cmSearchWindow :
+          ClearEvent(Event);
+        cmSearchWindow+1..cmSearchWindow+100 :
+          if (Event.Command-cmSearchWindow=Number) then
+              ClearEvent(Event);
+        cmListItemSelected :
+          if Event.InfoPtr=ScopeView then
+            begin
+              S:=ScopeView^.Symbols^.At(ScopeView^.Focused);
+              MakeGlobal(ScopeView^.Origin,P);
+              Desktop^.MakeLocal(P,P); Inc(P.Y,ScopeView^.Focused-ScopeView^.TopItem);
+              Inc(P.Y);
+              OpenSymbolBrowser(Origin.X-1,P.Y,
+                S^.GetName,
+                ScopeView^.GetText(ScopeView^.Focused,255),
+                S^.Items,S^.References);
+            end else
+          if Event.InfoPtr=ReferenceView then
+            begin
+            end;
+      end;
+    evKeyDown :
+      begin
+        DontClear:=false;
+        case Event.KeyCode of
+          kbEsc :
+            Close;
+          kbCtrlS :
+            SelectTab(btScope);
+          kbCtrlR :
+            SelectTab(btReferences);
+        else DontClear:=true;
+        end;
+        if DontClear=false then ClearEvent(Event);
+      end;
+  end;
+  inherited HandleEvent(Event);
+end;
+
+procedure TBrowserWindow.SelectTab(BrowserTab: Sw_integer);
+var Tabs: Sw_integer;
+begin
+  case BrowserTab of
+    btScope :
+      if assigned(ScopeView) then
+        ScopeView^.Select;
+    btReferences :
+      if assigned(ReferenceView) then
+        ReferenceView^.Select;
+  end;
+  Tabs:=0;
+  if assigned(ScopeView) then
+    Tabs:=Tabs or btScope;
+  if assigned(ReferenceView) then
+    Tabs:=Tabs or btReferences;
+  if (Tabs and BrowserTab)=0 then
+    if (Tabs and btScope)<>0 then BrowserTab:=btScope else
+    if (Tabs and btReferences)<>0 then BrowserTab:=btReferences else
+      BrowserTab:=btInheritance;
+  if PageTab<>nil then PageTab^.SetParams(Tabs,BrowserTab);
+end;
+
+function TBrowserWindow.GetPalette: PPalette;
+const S: string[length(CBrowserWindow)] = CBrowserWindow;
+begin
+  GetPalette:=@S;
+end;
+
+procedure OpenSymbolBrowser(X,Y: Sw_integer;const Name,Line: string;
+            Symbols: PSymbolCollection; References: PReferenceCollection);
+var R: TRect;
+begin
+  if X=0 then X:=Desktop^.Size.X-35;
+  R.A.X:=X; R.A.Y:=Y;
+  R.B.X:=R.A.X+35; R.B.Y:=R.A.Y+15;
+  while (R.B.Y>Desktop^.Size.Y) do R.Move(0,-1);
+  Desktop^.Insert(New(PBrowserWindow, Init(R,
+    'Browse: '+Name,SearchFreeWindowNo,Line,Symbols,References)));
+end;
+
+
+END.
+{
+  $Log$
+  Revision 1.1  1999-01-12 14:29:40  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.0  1999/01/09 11:49:41  gabor
+     Original implementation
+}

+ 18 - 1
ide/text/fputils.pas

@@ -17,6 +17,8 @@ unit FPUtils;
 
 interface
 
+uses Objects;
+
 const
 {$ifdef linux}
   dirsep = '/';
@@ -59,6 +61,7 @@ function EatIO: integer;
 function ExistsFile(FileName: string): boolean;
 function CompleteDir(Path: string): string;
 function LocateFile(FileList: string): string;
+function GetStr(P: PString): string;
 
 const LastStrToIntResult : integer = 0;
       LastHexToIntResult : integer = 0;
@@ -399,11 +402,25 @@ begin
   LocateFile:=FilePath;
 end;
 
+function GetStr(P: PString): string;
+begin
+  if P=nil then GetStr:='' else GetStr:=P^;
+end;
+
+
 
 END.
 {
   $Log$
-  Revision 1.2  1998-12-28 15:47:53  peter
+  Revision 1.3  1999-01-12 14:29:40  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  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

+ 10 - 1
ide/text/fpvars.pas

@@ -48,6 +48,7 @@ const ClipboardWindow  : PClipboardWindow = nil;
       AltMouseAction   : integer = acBrowseSymbol;
       StartupOptions   : longint = 0;
       LastExitCode     : integer = 0;
+      SymbolInfoLoaded : boolean = false;
 
       ActionCommands   : array[acFirstAction..acLastAction] of word =
         (cmHelpTopicSearch,cmGotoCursor,cmToggleBreakpoint,
@@ -62,7 +63,15 @@ implementation
 END.
 {
   $Log$
-  Revision 1.3  1999-01-04 11:49:52  peter
+  Revision 1.4  1999-01-12 14:29:41  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.3  1999/01/04 11:49:52  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 58 - 18
ide/text/fpviews.pas

@@ -52,7 +52,7 @@ type
     PSourceEditor = ^TSourceEditor;
     TSourceEditor = object(TFileEditor)
 {$ifndef EDITORS}
-      function  IsReservedWord(S: string): boolean; virtual;
+      function  IsReservedWord(const S: string): boolean; virtual;
       function  GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
       function  GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
 {$endif}
@@ -270,6 +270,7 @@ procedure InsertOK(ADialog: PDialog);
 procedure InsertButtons(ADialog: PDialog);
 
 procedure ErrorBox(S: string; Params: pointer);
+procedure WarningBox(S: string; Params: pointer);
 procedure InformationBox(S: string; Params: pointer);
 function  ConfirmBox(S: string; Params: pointer; CanCancel: boolean): word;
 
@@ -324,11 +325,15 @@ uses
 
 const
   NoNameCount    : integer = 0;
-  ReservedWords  : PStringCollection = nil;
+  ReservedWords  : PUnsortedStringCollection = nil;
 
 function IsThereAnyEditor: boolean;
+function EditorWindow(P: PView): boolean; {$ifndef FPC}far;{$endif}
 begin
-  IsThereAnyEditor:=Message(Desktop,evBroadcast,cmSearchWindow,nil)<>nil;
+  EditorWindow:=(P^.HelpCtx=hcSourceWindow);
+end;
+begin
+  IsThereAnyEditor:=Desktop^.FirstThat(@EditorWindow)<>nil;
 end;
 
 function IsThereAnyHelpWindow: boolean;
@@ -337,8 +342,11 @@ begin
 end;
 
 function IsThereAnyWindow: boolean;
+var _Is: boolean;
 begin
-  IsThereAnyWindow:=IsThereAnyEditor or IsThereAnyHelpWindow;
+  _Is:=Message(Desktop,evBroadcast,cmSearchWindow,nil)<>nil;
+  _Is:=_Is or ( (ClipboardWindow<>nil) and ClipboardWindow^.GetState(sfVisible));
+  IsThereAnyWindow:=_Is;
 end;
 
 procedure InsertButtons(ADialog: PDialog);
@@ -497,13 +505,34 @@ begin
 end;
 
 procedure InitReservedWords;
-var
-  I,Count: integer;
+var S,WordS: string;
+    Idx,I: integer;
 begin
-  Count:=GetReservedWordCount;
-  New(ReservedWords, Init(Count,100));
-  for I:=1 to Count do
-    ReservedWords^.Insert(NewStr(UpcaseStr(GetReservedWord(I-1))));
+  New(ReservedWords, Init(50,10));
+  for I:=1 to GetReservedWordCount do
+    begin
+      WordS:=GetReservedWord(I-1); Idx:=length(WordS);
+      while ReservedWords^.Count<Idx do
+        ReservedWords^.Insert(NewStr(#0));
+      S:=ReservedWords^.At(Idx-1)^;
+      ReservedWords^.AtFree(Idx-1);
+      ReservedWords^.AtInsert(Idx-1,NewStr(S+WordS+#0));
+    end;
+end;
+
+function IsFPReservedWord(S: string): boolean;
+var _Is: boolean;
+    Idx: integer;
+    P: PString;
+begin
+  Idx:=length(S); _Is:=false;
+  if (Idx>0) and (ReservedWords<>nil) and (ReservedWords^.Count>=Idx) then
+    begin
+      S:=UpcaseStr(S);
+      P:=ReservedWords^.At(Idx-1);
+      _Is:=Pos(#0+S+#0,P^)>0;
+    end;
+  IsFPReservedWord:=_Is;
 end;
 
 
@@ -604,11 +633,9 @@ begin
   GetSpecSymbol:=S;
 end;
 
-function TSourceEditor.IsReservedWord(S: string): boolean;
-var I: Sw_integer;
+function TSourceEditor.IsReservedWord(const S: string): boolean;
 begin
-  S:=UpcaseStr(S);
-  IsReservedWord:=ReservedWords^.Search(@S,I);
+  IsReservedWord:=IsFPReservedWord(S);
 end;
 {$endif EDITORS}
 
@@ -780,13 +807,13 @@ begin
         cmUpdateTitle :
           UpdateTitle;
         cmSearchWindow :
-          if Editor^.IsClipboard=false then
-          ClearEvent(Event);
+          if @Self<>ClipboardWindow then
+            ClearEvent(Event);
         else
           begin
             if (Event.Command>cmSearchWindow) and (Event.Command<=cmSearchWindow+100) and
                (Event.Command-cmSearchWindow=Number) then
-            if Editor^.IsClipboard=false then
+{            if Editor^.IsClipboard=false then}
               ClearEvent(Event);
           end;
       end;
@@ -1667,6 +1694,11 @@ begin
   MessageBox(S,Params,mfError+mfInsertInApp+mfOKButton);
 end;
 
+procedure WarningBox(S: string; Params: pointer);
+begin
+  MessageBox(S,Params,mfWarning+mfInsertInApp+mfOKButton);
+end;
+
 procedure InformationBox(S: string; Params: pointer);
 begin
   MessageBox(S,Params,mfInformation+mfInsertInApp+mfOKButton);
@@ -2811,7 +2843,15 @@ end;
 END.
 {
   $Log$
-  Revision 1.3  1999-01-04 11:49:53  peter
+  Revision 1.4  1999-01-12 14:29:42  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.3  1999/01/04 11:49:53  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 13 - 0
ide/text/test.pas

@@ -1,11 +1,24 @@
 program TestProgram;
 
+uses Test2;
+
 const A =  1234;
       B =  $1234;
 
 var Hello : word;
+    X: PRecord;
+    T : TRecord;
+
+function Func1: shortint;
+var X: word;
+begin
+  if Hello=0 then X:=0 else X:=1;
+  Func1:=X;
+end;
 
 BEGIN
+  X:=nil;
   writeln('Hello world!');
+  writeln(IsOdd(3));
   Halt;
 END.

+ 21 - 0
ide/text/test2.pas

@@ -0,0 +1,21 @@
+unit Test2;
+
+interface
+
+type
+     PRecord = ^TRecord;
+     TRecord = record
+       Field1: longint;
+       Next  : PRecord;
+     end;
+
+function IsOdd(X: integer): boolean;
+
+implementation
+
+function IsOdd(X: integer): boolean;
+begin
+  IsOdd:=(X mod 2)=1;
+end;
+
+END.

+ 50 - 45
ide/text/weditor.pas

@@ -27,6 +27,7 @@ uses
 
 const
       cmFileNameChanged      = 51234;
+      cmASCIIChar            = 51235;
 
 {$ifdef FPC}
       EditorTextBufSize = 32768;
@@ -215,9 +216,10 @@ type
      { Syntax highlight support }
       function    GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
       function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
-      function    IsReservedWord(S: string): boolean; virtual;
+      function    IsReservedWord(const S: string): boolean; virtual;
     public
       SearchRunCount: integer;
+      InASCIIMode: boolean;
       procedure Indent; virtual;
       procedure CharLeft; virtual;
       procedure CharRight; virtual;
@@ -330,9 +332,9 @@ const
      kbShift = kbLeftShift+kbRightShift;
 
 const
-  FirstKeyCount = 37;
+  FirstKeyCount = 38;
   FirstKeys: array[0..FirstKeyCount * 2] of Word = (FirstKeyCount,
-    Ord(^A), cmWordLeft, Ord(^C), cmPageDown,
+    Ord(^A), cmWordLeft, Ord(^B), cmASCIIChar, Ord(^C), cmPageDown,
     Ord(^D), cmCharRight, Ord(^E), cmLineUp,
     Ord(^F), cmWordRight, Ord(^G), cmDelChar,
     Ord(^H), cmBackSpace, Ord(^J), cmJumpLine,
@@ -1152,7 +1154,8 @@ var DontClear : boolean;
 var
   StartP,P: TPoint;
 begin
-  ConvertEvent(Event);
+  if (InASCIIMode=false) or (Event.What<>evKeyDown) then
+    ConvertEvent(Event);
   case Event.What of
     evMouseDown :
       if MouseInView(Event.Where) then
@@ -1173,24 +1176,30 @@ begin
       end;
     evKeyDown :
       begin
-        DontClear:=false;
-        case Event.CharCode of
-         #9,#32..#255 :
-           begin
-             NoSelect:=true;
-             AddChar(Event.CharCode);
-             NoSelect:=false;
-           end;
-        else
-          DontClear:=true;
+        if InASCIIMode and (Event.ScanCode=0) then
+          AddChar(Event.CharCode) else
+        begin
+          DontClear:=false;
+          case Event.CharCode of
+           #9,#32..#255 :
+             begin
+               NoSelect:=true;
+               AddChar(Event.CharCode);
+               NoSelect:=false;
+             end;
+          else
+            DontClear:=true;
+          end;
+          if not DontClear then
+           ClearEvent(Event);
         end;
-        if not DontClear then
-         ClearEvent(Event);
+        InASCIIMode:=false;
       end;
     evCommand :
       begin
         DontClear:=false;
         case Event.Command of
+          cmASCIIChar   : InASCIIMode:=not InASCIIMode;
           cmCharLeft    : CharLeft;
           cmCharRight   : CharRight;
           cmWordLeft    : WordLeft;
@@ -1383,16 +1392,9 @@ end;
 function TCodeEditor.GetLineTextPos(Line,X: integer): integer;
 var
   S: string;
-  L: PLine;
   rx,i : Sw_integer;
 begin
-  S:='';
-  if Line<Lines^.Count then
-   begin
-     L:=Lines^.At(Line);
-     if assigned(L^.Text) then
-      S:=L^.Text^;
-   end;
+  S:=GetLineText(Line);
   i:=0;
   rx:=0;
   while (RX<X) and (i<Length(s)) do
@@ -1402,6 +1404,7 @@ begin
      if s[i]=#9 then
       inc(rx,TabSize-(rx mod tabsize));
    end;
+  if RX<X then Inc(I,X-RX);
   GetLineTextPos:=i;
 end;
 
@@ -1553,7 +1556,7 @@ begin
   Abstract;
 end;
 
-function TCodeEditor.IsReservedWord(S: string): boolean;
+function TCodeEditor.IsReservedWord(const S: string): boolean;
 begin
   IsReservedWord:=false;
 end;
@@ -1584,8 +1587,6 @@ begin
 end;
 
 procedure TCodeEditor.CharLeft;
-var
-  X : Sw_integer;
 begin
   if CurPos.X>0 then
    begin
@@ -2039,15 +2040,16 @@ const OpenBrackets  : string[10] = '[({';
       CloseBrackets : string[10] = '])}';
 var S: string;
     BI: byte;
+  RX : Sw_integer;
 begin
   if IsReadOnly then Exit;
   S:=GetLineText(CurPos.Y);
-  RX:=GetLineTextPos(CurPos.X);
-  if
+  RX:=GetLineTextPos(CurPos.Y,CurPos.X);
   if Overwrite and (RX<length(S)) then
-    SetLineText(CurPos.Y,copy(S,1,CurPos.X)+C+copy(S,CurPos.X+2,255))
+    SetLineText(CurPos.Y,copy(S,1,RX)+C+copy(S,RX+2,255))
   else
-    SetLineText(CurPos.Y,RExpand(copy(S,1,CurPos.X),CurPos.X)+C+copy(S,CurPos.X+1,255));
+    SetLineText(CurPos.Y,RExpand(copy(S,1,RX),RX)+C+copy(S,RX+1,255));
+  Curpos.X:=GetDisplayTextPos(CurPos.Y,RX);
   if PointOfs(SelStart)<>PointOfs(SelEnd) then
     if (CurPos.Y=SelEnd.Y) and (CurPos.X<SelEnd.X) then
       Inc(SelEnd.X);
@@ -2478,7 +2480,7 @@ var
   end;
 
   procedure FormatWord(SClass: TCharClass; StartX:Sw_integer;EndX: Sw_integer);
-  var FX,i: Sw_integer;
+  var
       C: byte;
       WordS: string;
   begin
@@ -2492,13 +2494,7 @@ var
     if InAsm then C:=coAssemblerColor else
     case SClass of
       ccWhiteSpace : C:=coWhiteSpaceColor;
-      ccTab        : begin
-{                       i:=StartX;
-                       for FX:=StartX to EndX do
-                        inc(i,Tabsize-((i-1) mod Tabsize));
-                       EndX:=i;   }
-                       C:=coTabColor;
-                     end;
+      ccTab        : C:=coTabColor;
       ccNumber     : if copy(WordS,1,1)='$' then
                        C:=coHexNumberColor
                      else
@@ -2506,13 +2502,14 @@ var
       ccSymbol     : C:=coSymbolColor;
       ccAlpha      :
         begin
-  {        WordS:=copy(LineText,StartX,EndX-StartX+1);}
-          if IsReservedWord(WordS) then C:=coReservedWordColor
-                                   else C:=coIdentifierColor;
+          if IsReservedWord(WordS) then
+            C:=coReservedWordColor
+          else
+            C:=coIdentifierColor;
         end;
     end;
     if EndX>=StartX then
-     FillChar(Format[StartX],EndX+1-StartX,C);
+      FillChar(Format[StartX],EndX+1-StartX,C);
     if IsAsmPrefix(WordS) and
        (InAsm=false) and (InComment=false) and (InDirective=false) then
       InAsm:=true;
@@ -2577,7 +2574,6 @@ var
 
 var CurLine: Sw_integer;
     Line,NextLine,PrevLine,OldLine: PLine;
-    C: char;
 begin
   if ((Flags and efSyntaxHighlight)=0) or (FromLine>=GetLineCount) then
   begin
@@ -2615,6 +2611,7 @@ begin
      begin
        for X:=1 to length(LineText) do
         ProcessChar(LineText[X]);
+       inc(X);
        ProcessChar(' ');
      end;
     SetLineFormat(CurLine,Format);
@@ -3203,7 +3200,15 @@ end;
 END.
 {
   $Log$
-  Revision 1.5  1999-01-07 15:02:40  peter
+  Revision 1.6  1999-01-12 14:29:44  peter
+    + Implemented still missing 'switch' entries in Options menu
+    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
+      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
+      ASCII chars and inserted directly in the text.
+    + Added symbol browser
+    * splitted fp.pas to fpide.pas
+
+  Revision 1.5  1999/01/07 15:02:40  peter
     * better tab support
 
   Revision 1.4  1999/01/04 11:49:55  peter