Browse Source

* patches from Gabor

peter 26 years ago
parent
commit
ba891366d5
5 changed files with 73 additions and 17 deletions
  1. 42 9
      ide/text/fp.pas
  2. 7 1
      ide/text/fpconst.pas
  3. 8 4
      ide/text/fpini.pas
  4. 11 2
      ide/text/fpmopts.inc
  5. 5 1
      ide/text/fpvars.pas

+ 42 - 9
ide/text/fp.pas

@@ -164,7 +164,7 @@ begin
       NewItem('~C~alculator', '', kbNoKey, cmCalculator, hcCalculator,
       nil)))),
     NewSubMenu('~O~ptions', hcOptionsMenu, NewMenu(
-      NewItem('Mode...','', kbNoKey, cmSetSwitchesMode, hcSetSwitchesMode,
+      NewItem('Mode~.~..','', kbNoKey, cmSetSwitchesMode, hcSetSwitchesMode,
       NewItem('~C~ompiler...','', kbNoKey, cmCompiler, hcCompiler,
       NewItem('~M~emory sizes...','', kbNoKey, cmMemorySizes, hcMemorySizes,
       NewItem('~L~inker...','', kbNoKey, cmLinker, hcLinker,
@@ -498,17 +498,43 @@ begin
   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 InitApp;
-var S: string;
-    I: integer;
+procedure ProcessParams(BeforeINI: boolean);
+var I: integer;
+    Param: string;
 begin
   for I:=1 to ParamCount do
   begin
-    S:=ParamStr(I);
-    if not(S[1] in['-','/']) then
-      MyApp.Open(S);
+    Param:=ParamStr(I);
+    if IsSwitch(Param) then
+      begin
+        Param:=copy(Param,2,255);
+        if Param<>'' then
+        case Upcase(Param[1]) of
+          'C' : { custom config file (BP compatiblity) }
+           if BeforeINI then
+            INIPath:=copy(Param,2,255);
+          'R' : { enter the directory last exited from (BP comp.) }
+            begin
+              Param:=copy(Param,2,255);
+              if (Param='') or (Param='+') then
+                StartupOptions:=StartupOptions or soReturnToLastDir
+              else
+              if (Param='-') then
+                StartupOptions:=StartupOptions and (not soReturnToLastDir);
+            end;
+        end;
+      end
+    else
+      if BeforeINI=false then
+        MyApp.Open(Param);
   end;
 end;
 
@@ -516,6 +542,8 @@ BEGIN
   writeln('þ Free Pascal IDE  Version '+VersionStr);
   StartupDir:=CompleteDir(FExpand('.'));
 
+  ProcessParams(true);
+
   InitReservedWords;
   InitHelpFiles;
   InitSwitches;
@@ -527,7 +555,9 @@ BEGIN
   ReadSwitches(SwitchesPath);
 
   MyApp.Init;
-  InitApp;
+
+  ProcessParams(false);
+
   MyApp.Run;
   MyApp.Done;
 
@@ -540,7 +570,10 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.2  1998-12-28 15:47:40  peter
+  Revision 1.3  1998-12-30 13:38:38  peter
+    * patches from Gabor
+
+  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

+ 7 - 1
ide/text/fpconst.pas

@@ -46,6 +46,9 @@ const
      acFirstAction        = acTopicSearch;
      acLastAction         = acBrowseSymbol;
 
+     { Startup Option constants }
+     soReturnToLastDir    = $00000001;
+
      { Command constants }
      cmShowClipboard     = 201;
      cmFindProcedure     = 206;
@@ -241,7 +244,10 @@ implementation
 END.
 {
   $Log$
-  Revision 1.2  1998-12-28 15:47:43  peter
+  Revision 1.3  1998-12-30 13:38:39  peter
+    * patches from Gabor
+
+  Revision 1.2  1998/12/28 15:47:43  peter
     + Added user screen support, display & window
     + Implemented Editor,Mouse Options dialog
     + Added location of .INI and .CFG file

+ 8 - 4
ide/text/fpini.pas

@@ -64,10 +64,11 @@ const
   ieCtrlClickAction  = 'CtrlClickAction';
 
 procedure InitINIFile;
+var S: string;
 begin
-  INIPath:=LocateFile(ININame);
-  if INIPath='' then
-    INIPath:=ININame;
+  S:=LocateFile(ININame);
+  if S<>'' then
+    INIPath:=S;
   INIPath:=FExpand(INIPath);
 end;
 
@@ -223,7 +224,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  1998-12-30 10:25:01  peter
+  Revision 1.3  1998-12-30 13:38:40  peter
+    * patches from Gabor
+
+  Revision 1.2  1998/12/30 10:25:01  peter
     * fixed readinifile
 
   Revision 1.1  1998/12/28 15:47:45  peter

+ 11 - 2
ide/text/fpmopts.inc

@@ -38,7 +38,13 @@ begin
     for I:=high(TSwitchMode) downto low(TSwitchMode) do
       LastItem:=NewSItem(SwitchesModeName[I], LastItem);
     New(RB, Init(R2, LastItem));
-    RB^.SetData(SwitchesMode);
+    L:=ord(SwitchesMode);
+    { ^^^ this is necessary, since TRadioButtons.GetData() reads a full
+      longint and by just specifying the SwitchesMode var (only 1 bytes),
+      the three bytes located next to it in the memory will determine the
+      three most significant bytes of the longint. And if they aren't all
+      zero, then we will select some items outside the actual ones... }
+    RB^.SetData(L);
     Insert(RB);
     R2.Copy(R);
     R2.B.Y:=R2.A.Y+1;
@@ -645,7 +651,10 @@ end;
 
 {
   $Log$
-  Revision 1.2  1998-12-28 15:47:49  peter
+  Revision 1.3  1998-12-30 13:38:41  peter
+    * patches from Gabor
+
+  Revision 1.2  1998/12/28 15:47:49  peter
     + Added user screen support, display & window
     + Implemented Editor,Mouse Options dialog
     + Added location of .INI and .CFG file

+ 5 - 1
ide/text/fpvars.pas

@@ -45,6 +45,7 @@ const ClipboardWindow  : PClipboardWindow = nil;
       SwitchesPath     : string = SwitchesName;
       CtrlMouseAction  : integer = acTopicSearch;
       AltMouseAction   : integer = acBrowseSymbol;
+      StartupOptions   : longint = 0;
 
       ActionCommands   : array[acFirstAction..acLastAction] of word =
         (cmHelpTopicSearch,cmGotoCursor,cmToggleBreakpoint,
@@ -59,7 +60,10 @@ implementation
 END.
 {
   $Log$
-  Revision 1.1  1998-12-28 15:47:54  peter
+  Revision 1.2  1998-12-30 13:38:42  peter
+    * patches from Gabor
+
+  Revision 1.1  1998/12/28 15:47:54  peter
     + Added user screen support, display & window
     + Implemented Editor,Mouse Options dialog
     + Added location of .INI and .CFG file