Browse Source

+ keyboarddriver example also with listings package

michael 24 years ago
parent
commit
6e9bfb8c1f
1 changed files with 2 additions and 126 deletions
  1. 2 126
      docs/keyboard.tex

+ 2 - 126
docs/keyboard.tex

@@ -609,130 +609,6 @@ function to register and log the key events in a file. This driver
 can work on top of any other driver, as long as it is inserted in the 
 \var{uses} clause {\em after} the real driver unit, and the real driver unit
 should set the driver record in its initialization section.
-\begin{verbatim}
-unit logkeys;
-
-interface
-
-Procedure StartKeyLogging;
-Procedure StopKeyLogging;
-Function  IsKeyLogging : Boolean;
-Procedure  SetKeyLogFileName(FileName : String);
-
-
-implementation
-
-uses sysutils,keyboard;
-
-var
-  NewKeyBoardDriver,
-  OldKeyBoardDriver : TKeyboardDriver;
-  Active,Logging : Boolean;
-  LogFileName : String;
-  KeyLog : Text;
-
-Function TimeStamp : String;
-
-begin
-  TimeStamp:=FormatDateTime('hh:nn:ss',Time());
-end;
-  
-Procedure StartKeyLogging;
-
-begin
-  Logging:=True;
-  Writeln(KeyLog,'Start logging keystrokes at: ',TimeStamp);
-end;
-
-Procedure StopKeyLogging;
-
-begin
-  Writeln(KeyLog,'Stop logging keystrokes at: ',TimeStamp);
-  Logging:=False;
-end;
-
-Function IsKeyLogging : Boolean;
-
-begin
-  IsKeyLogging:=Logging;
-end;
-
-Function LogGetKeyEvent : TKeyEvent;
-
-Var
-  K : TKeyEvent;
-
-begin
-  K:=OldkeyboardDriver.GetKeyEvent();
-  If Logging then
-    begin
-    Write(KeyLog,TimeStamp);
-    Writeln(KeyLog,': Key event: ',KeyEventToString(TranslateKeyEvent(K)));
-    end;
-  LogGetKeyEvent:=K;  
-end;
-
-Procedure LogInitKeyBoard;
-
-begin
-  OldKeyBoardDriver.InitDriver();
-  Assign(KeyLog,logFileName);
-  Rewrite(KeyLog);
-  Active:=True;
-  StartKeyLogging;
-end;
-
-Procedure LogDoneKeyBoard;
-
-begin
-  StopKeyLogging;
-  Close(KeyLog);
-  Active:=False;
-  OldKeyBoardDriver.DoneDriver();
-end;
-
-Procedure SetKeyLogFileName(FileName : String);
-
-begin
-  If Not Active then
-    LogFileName:=FileName;
-end;
-
-Initialization
-  GetKeyBoardDriver(OldKeyBoardDriver);
-  NewKeyBoardDriver:=OldKeyBoardDriver;
-  NewKeyBoardDriver.GetKeyEvent:=@LogGetKeyEvent;
-  NewKeyBoardDriver.InitDriver:=@LogInitKeyboard;
-  NewKeyBoardDriver.DoneDriver:=@LogDoneKeyboard;
-  LogFileName:='keyboard.log';
-  Logging:=False;
-  SetKeyboardDriver(NewKeyBoardDriver);
-end.  
-\end{verbatim}
+\FPCexample{logkeys}
 The following program demonstrates the use of the unit:
-\begin{verbatim}
-program example9;
-
-{ This program demonstrates the logkeys unit. }
-
-uses keyboard,logkeys;
-
-Var
-  K : TKeyEvent;
-
-begin
-  InitKeyBoard;
-  Writeln('Press keys, press "q" to end, "s" toggles logging.');
-  Repeat
-    K:=GetKeyEvent;
-    K:=TranslateKeyEvent(K);
-    Writeln('Got key : ',KeyEventToString(K));
-    if GetKeyEventChar(K)='s' then
-      if IsKeyLogging then
-        StopKeyLogging
-      else
-        StartKeyLogging;  
-  Until (GetKeyEventChar(K)='q');
-  DoneKeyBoard;
-end.
-\end{verbatim}
+\FPCexample{ex9}