Browse Source

* Video and keyboard initialization spaghetti organized and hopefully fixed.
- Remove useless function from validate.pas

git-svn-id: trunk@3443 -

daniel 19 years ago
parent
commit
dc6e856dda
5 changed files with 79 additions and 33 deletions
  1. 16 10
      fv/app.pas
  2. 41 2
      fv/drivers.pas
  3. 4 13
      fv/validate.pas
  4. 16 6
      ide/fp.pas
  5. 2 2
      ide/fpide.pas

+ 16 - 10
fv/app.pas

@@ -230,7 +230,7 @@ TYPE
       PROCEDURE Run; Virtual;
       PROCEDURE Run; Virtual;
       PROCEDURE Idle; Virtual;
       PROCEDURE Idle; Virtual;
       PROCEDURE InitScreen; Virtual;
       PROCEDURE InitScreen; Virtual;
-      procedure DoneScreen; virtual;
+{      procedure DoneScreen; virtual;}
       PROCEDURE InitDeskTop; Virtual;
       PROCEDURE InitDeskTop; Virtual;
       PROCEDURE OutOfMemory; Virtual;
       PROCEDURE OutOfMemory; Virtual;
       PROCEDURE InitMenuBar; Virtual;
       PROCEDURE InitMenuBar; Virtual;
@@ -789,11 +789,15 @@ END;
 {  InitScreen -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB        }
 {  InitScreen -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB        }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 PROCEDURE TProgram.InitScreen;
 PROCEDURE TProgram.InitScreen;
+
+{Initscreen is passive only, i.e. it detects the video size and capabilities
+ after initalization. Active video initalization is the task of Tapplication.}
+
 BEGIN
 BEGIN
   { the orginal code can't be used here because of the limited
   { the orginal code can't be used here because of the limited
     video unit capabilities, the mono modus can't be handled
     video unit capabilities, the mono modus can't be handled
   }
   }
-  Drivers.InitVideo;
+{  Drivers.InitVideo;}
   if (ScreenMode.Col div ScreenMode.Row<2) then
   if (ScreenMode.Col div ScreenMode.Row<2) then
     ShadowSize.X := 1
     ShadowSize.X := 1
   else
   else
@@ -809,11 +813,11 @@ BEGIN
 END;
 END;
 
 
 
 
-procedure TProgram.DoneScreen;
+{procedure TProgram.DoneScreen;
 begin
 begin
   Drivers.DoneVideo;
   Drivers.DoneVideo;
   Buffer:=nil;
   Buffer:=nil;
-end;
+end;}
 
 
 
 
 {--TProgram-----------------------------------------------------------------}
 {--TProgram-----------------------------------------------------------------}
@@ -965,14 +969,15 @@ END;
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 CONSTRUCTOR TApplication.Init;
 CONSTRUCTOR TApplication.Init;
 BEGIN
 BEGIN
-{   InitMemory;}                                        { Start memory up }
+{   InitMemory;}                                              { Start memory up }
+   initkeyboard;
    Drivers.InitVideo;                                         { Start video up }
    Drivers.InitVideo;                                         { Start video up }
    Drivers.InitEvents;                                        { Start event drive }
    Drivers.InitEvents;                                        { Start event drive }
    Drivers.InitSysError;                                      { Start system error }
    Drivers.InitSysError;                                      { Start system error }
-   InitHistory;                                       { Start history up }
+   InitHistory;                                               { Start history up }
    InitResource;
    InitResource;
    InitMsgBox;
    InitMsgBox;
-   Inherited Init;                                    { Call ancestor }
+   Inherited Init;                                            { Call ancestor }
    { init mouse and cursor }
    { init mouse and cursor }
    Video.SetCursorType(crHidden);
    Video.SetCursorType(crHidden);
    Mouse.SetMouseXY(1,1);
    Mouse.SetMouseXY(1,1);
@@ -988,8 +993,9 @@ BEGIN
    DoneResource;
    DoneResource;
    Drivers.DoneSysError;                                      { Close system error }
    Drivers.DoneSysError;                                      { Close system error }
    Drivers.DoneEvents;                                        { Close event drive }
    Drivers.DoneEvents;                                        { Close event drive }
-   DoneScreen;
+   drivers.donevideo;
 {   DoneMemory;}                                       { Close memory }
 {   DoneMemory;}                                       { Close memory }
+   donekeyboard;
 END;
 END;
 
 
 {--TApplication-------------------------------------------------------------}
 {--TApplication-------------------------------------------------------------}
@@ -1019,14 +1025,14 @@ PROCEDURE TApplication.DosShell;
 BEGIN                                                 { Compatability only }
 BEGIN                                                 { Compatability only }
   DoneSysError;
   DoneSysError;
   DoneEvents;
   DoneEvents;
-  DoneScreen;
+  drivers.donevideo;
 {  DoneDosMem;}
 {  DoneDosMem;}
   WriteShellMsg;
   WriteShellMsg;
   SwapVectors;
   SwapVectors;
   Exec(GetEnv('COMSPEC'), '');
   Exec(GetEnv('COMSPEC'), '');
   SwapVectors;
   SwapVectors;
 {  InitDosMem;}
 {  InitDosMem;}
-  InitScreen;
+  drivers.initvideo;
   InitEvents;
   InitEvents;
   InitSysError;
   InitSysError;
   Redraw;
   Redraw;

+ 41 - 2
fv/drivers.pas

@@ -57,6 +57,10 @@ UNIT Drivers;
   {$DEFINE ENDIAN_BIG}
   {$DEFINE ENDIAN_BIG}
 {$endif CPU68K}
 {$endif CPU68K}
 
 
+{$ifdef FPC}
+  {$INLINE ON}
+{$endif}
+
 USES
 USES
    {$IFDEF OS_WINDOWS}                                { WIN/NT CODE }
    {$IFDEF OS_WINDOWS}                                { WIN/NT CODE }
          Windows,                                     { Standard unit }
          Windows,                                     { Standard unit }
@@ -464,6 +468,21 @@ PROCEDURE DoneEvents;
 {                           VIDEO CONTROL ROUTINES                          }
 {                           VIDEO CONTROL ROUTINES                          }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 
 
+{-Initkeyboard-------------------------------------------------------
+Initializes the keyboard. Before it is called read(ln)/write(ln)
+are functional, after it is called FV's keyboard routines are
+functional.
+---------------------------------------------------------------------}
+
+procedure initkeyboard;
+
+{-Donekeyboard-------------------------------------------------------
+Restores keyboard to original state. FV's keyboard routines may not
+be used after a call to this. Read(ln)/write(ln) can be used again.
+---------------------------------------------------------------------}
+
+procedure donekeyboard;
+
 {-InitVideo---------------------------------------------------------
 {-InitVideo---------------------------------------------------------
 Initializes the video manager, Saves the current screen mode in
 Initializes the video manager, Saves the current screen mode in
 StartupMode, and switches to the mode indicated by ScreenMode.
 StartupMode, and switches to the mode indicated by ScreenMode.
@@ -830,7 +849,7 @@ PROCEDURE ExitDrivers; {$IFNDEF PPC_FPC}{$IFNDEF OS_UNIX} FAR; {$ENDIF}{$ENDIF}
 BEGIN
 BEGIN
    DoneSysError;                                      { Relase error trap }
    DoneSysError;                                      { Relase error trap }
    DoneEvents;                                        { Close event driver }
    DoneEvents;                                        { Close event driver }
-   DoneKeyboard;
+{   DoneKeyboard;}
    DoneVideo;
    DoneVideo;
    ExitProc := SaveExit;                              { Restore old exit }
    ExitProc := SaveExit;                              { Restore old exit }
 END;
 END;
@@ -1260,6 +1279,26 @@ END;
 const
 const
   VideoInitialized : boolean = false;
   VideoInitialized : boolean = false;
 
 
+{---------------------------------------------------------------------------}
+{  InitKeyboard -> Platforms ALL - 07Nov06 DM                               }
+{---------------------------------------------------------------------------}
+
+procedure initkeyboard;inline;
+
+begin
+  keyboard.initkeyboard;
+end;
+
+{---------------------------------------------------------------------------}
+{  DoneKeyboard -> Platforms ALL - 07Nov06 DM                               }
+{---------------------------------------------------------------------------}
+
+procedure donekeyboard;inline;
+
+begin
+  keyboard.donekeyboard;
+end;
+
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 {  InitVideo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Nov99 LdB         }
 {  InitVideo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Nov99 LdB         }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
@@ -1521,7 +1560,7 @@ END;
 BEGIN
 BEGIN
    ButtonCount := DetectMouse;                        { Detect mouse }
    ButtonCount := DetectMouse;                        { Detect mouse }
    DetectVideo;                                       { Detect video }
    DetectVideo;                                       { Detect video }
-   InitKeyboard;
+{   InitKeyboard;}
    InitSystemMsg;
    InitSystemMsg;
 {$ifdef win32}
 {$ifdef win32}
    SetFileApisToOEM;
    SetFileApisToOEM;

+ 4 - 13
fv/validate.pas

@@ -302,15 +302,6 @@ USES MsgBox;                                          { GFV standard unit }
 {                              PRIVATE ROUTINES                             }
 {                              PRIVATE ROUTINES                             }
 {***************************************************************************}
 {***************************************************************************}
 
 
-{---------------------------------------------------------------------------}
-{  IsNumber -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
-{---------------------------------------------------------------------------}
-FUNCTION IsNumber (Chr: Char): Boolean;
-BEGIN
-   If (Chr >= '0') AND (Chr <= '9') Then              { Check if '0..9' }
-     IsNumber := True Else IsNumber := False;         { Return result }
-END;
-
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 {  IsLetter -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
 {  IsLetter -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
@@ -520,7 +511,7 @@ VAR I, J: Byte; Rslt: TPicResult; Reprocess: Boolean;
              ';': Inc(I);                             { Next character }
              ';': Inc(I);                             { Next character }
              '*': Begin
              '*': Begin
                  Inc(I);                              { Next character }
                  Inc(I);                              { Next character }
-                 While IsNumber(Pic^[I]) Do Inc(I);   { Search for text }
+                 While Pic^[I] in ['0'..'9'] Do Inc(I);   { Search for text }
                  ToGroupEnd(I);                       { Move to group end }
                  ToGroupEnd(I);                       { Move to group end }
                  Continue;                            { Now continue }
                  Continue;                            { Now continue }
                End;
                End;
@@ -554,7 +545,7 @@ VAR I, J: Byte; Rslt: TPicResult; Reprocess: Boolean;
        Itr := 0;                                      { Zero iteration }
        Itr := 0;                                      { Zero iteration }
        Iteration := prError;                          { Preset error result }
        Iteration := prError;                          { Preset error result }
        Inc(I);                                        { Skip '*' character }
        Inc(I);                                        { Skip '*' character }
-       While (IsNumber(Pic^[I])) Do Begin             { Entry is a number }
+       While Pic^[I] in ['0'..'9'] Do Begin           { Entry is a number }
          Itr := Itr * 10 + Byte(Pic^[I]) - Byte('0'); { Convert to number }
          Itr := Itr * 10 + Byte(Pic^[I]) - Byte('0'); { Convert to number }
          Inc(I);                                      { Next character }
          Inc(I);                                      { Next character }
        End;
        End;
@@ -606,7 +597,7 @@ VAR I, J: Byte; Rslt: TPicResult; Reprocess: Boolean;
          While True Do
          While True Do
            Case Pic^[J] Of
            Case Pic^[J] Of
              '[': ToGroupEnd(J);                      { Find name end }
              '[': ToGroupEnd(J);                      { Find name end }
-             '*': If (IsNumber(Pic^[J + 1]) = False)
+             '*': If not(Pic^[J + 1] in ['0'..'9'])
                Then Begin
                Then Begin
                  Inc(J);                              { Next name }
                  Inc(J);                              { Next name }
                  ToGroupEnd(J);                       { Find name end }
                  ToGroupEnd(J);                       { Find name end }
@@ -631,7 +622,7 @@ VAR I, J: Byte; Rslt: TPicResult; Reprocess: Boolean;
          End;
          End;
          Ch := Input[J];                              { Fetch character }
          Ch := Input[J];                              { Fetch character }
          Case Pic^[I] of
          Case Pic^[I] of
-           '#': If (NOT IsNumber(Ch)) Then Exit       { Check is a number }
+           '#': If NOT (Ch in ['0'..'9']) Then Exit   { Check is a number }
                Else Consume(Ch);                      { Transfer number }
                Else Consume(Ch);                      { Transfer number }
            '?': If (NOT IsLetter(Ch)) Then Exit       { Check is a letter }
            '?': If (NOT IsLetter(Ch)) Then Exit       { Check is a letter }
                Else Consume(Ch);                      { Transfer character }
                Else Consume(Ch);                      { Transfer character }

+ 16 - 6
ide/fp.pas

@@ -284,6 +284,16 @@ begin
 {$ENDIF}
 {$ENDIF}
 end;
 end;
 
 
+{The square bullet needs an MS-DOS code page. On Unix it is for sure the code
+ page is not available before video is initialized. (And only in certain
+ circumstances after that, so, use a plain ascii character as bullet on Unix.)}
+
+{$ifdef unix}
+const bullet='*';
+{$else}
+const bullet='þ';
+{$endif}
+
 BEGIN
 BEGIN
 {$IFDEF HasSignal}
 {$IFDEF HasSignal}
   EnableCatchSignals;
   EnableCatchSignals;
@@ -294,12 +304,12 @@ BEGIN
   HistorySize:=16384;
   HistorySize:=16384;
 
 
   { Startup info }
   { Startup info }
-  writeln('þ Free Pascal IDE Version '+VersionStr+' ['+{$i %date%}+']');
-  writeln('þ Compiler Version '+Version_String);
+  writeln(bullet+' Free Pascal IDE Version '+VersionStr+' ['+{$i %date%}+']');
+  writeln(bullet+' Compiler Version '+Version_String);
 {$ifndef NODEBUG}
 {$ifndef NODEBUG}
-  writeln('þ GBD Version '+GDBVersion);
+  writeln(bullet+' GBD Version '+GDBVersion);
  {$ifdef Windows}
  {$ifdef Windows}
-   writeln('þ Cygwin "',GetCygwinFullName,'" version ',GetCygwinVersionString);
+   writeln(bullet+' Cygwin "',GetCygwinFullName,'" version ',GetCygwinVersionString);
    CheckCygwinVersion;
    CheckCygwinVersion;
  {$endif Windows}
  {$endif Windows}
 {$endif NODEBUG}
 {$endif NODEBUG}
@@ -480,8 +490,8 @@ BEGIN
 {$ifdef unix}
 {$ifdef unix}
   Video.ClearScreen;
   Video.ClearScreen;
 {$endif unix}
 {$endif unix}
-  Video.DoneVideo;
-  Keyboard.DoneKeyboard;
+{  Video.DoneVideo;
+  Keyboard.DoneKeyboard;}
 {$endif fpc}
 {$endif fpc}
 {$ifdef VESA}
 {$ifdef VESA}
   DoneVESAScreenModes;
   DoneVESAScreenModes;

+ 2 - 2
ide/fpide.pas

@@ -879,7 +879,7 @@ begin
   { DoneKeyboard should be called last to
   { DoneKeyboard should be called last to
     restore the keyboard correctly PM }
     restore the keyboard correctly PM }
 {$ifndef go32v2}
 {$ifndef go32v2}
-  DoneScreen;
+  donevideo;
 {$endif ndef go32v2}
 {$endif ndef go32v2}
   DoneKeyboard;
   DoneKeyboard;
   If UseMouse then
   If UseMouse then
@@ -904,7 +904,7 @@ begin
   else
   else
     ButtonCount:=0;
     ButtonCount:=0;
 {$ifndef go32v2}
 {$ifndef go32v2}
-  InitScreen;
+  initvideo;
 {$endif ndef go32v2}
 {$endif ndef go32v2}
 {$ifdef Windows}
 {$ifdef Windows}
   { write the empty screen to dummy console handle }
   { write the empty screen to dummy console handle }