Browse Source

* print ASCII characters better

git-svn-id: branches/unicodekvm@40092 -
nickysn 6 years ago
parent
commit
eb30bfa9f0
1 changed files with 13 additions and 1 deletions
  1. 13 1
      packages/rtl-console/tests/kbd1.pp

+ 13 - 1
packages/rtl-console/tests/kbd1.pp

@@ -3,11 +3,23 @@ program kbd1;
 uses
   keyboard;
 
+procedure ShowASCIIKey(C: Char);
+begin
+  Write('ASCII key #', Ord(C), ' - #$', HexStr(Ord(C), 2));
+  if C = '''' then
+    Write(' - ''''''''')
+  else if (C >= #32) and (C <= #126) then
+    Write(' - ''', C, '''')
+  else if C < #32 then
+    Write(' - ^', Chr(Ord(C) + Ord('@')));
+  Writeln;
+end;
+
 procedure ShowKeyEvent(K: TKeyEvent);
 begin
   case GetKeyEventFlags(K) and 3 of
     kbASCII:
-      Writeln('ASCII key #', Ord(GetKeyEventChar(K)));
+      ShowASCIIKey(GetKeyEventChar(K));
     kbUniCode:
       Writeln('Unicode key');
     kbFnKey: