Explorar o código

* print ASCII characters better

git-svn-id: branches/unicodekvm@40092 -
nickysn %!s(int64=7) %!d(string=hai) anos
pai
achega
eb30bfa9f0
Modificáronse 1 ficheiros con 13 adicións e 1 borrados
  1. 13 1
      packages/rtl-console/tests/kbd1.pp

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

@@ -3,11 +3,23 @@ program kbd1;
 uses
 uses
   keyboard;
   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);
 procedure ShowKeyEvent(K: TKeyEvent);
 begin
 begin
   case GetKeyEventFlags(K) and 3 of
   case GetKeyEventFlags(K) and 3 of
     kbASCII:
     kbASCII:
-      Writeln('ASCII key #', Ord(GetKeyEventChar(K)));
+      ShowASCIIKey(GetKeyEventChar(K));
     kbUniCode:
     kbUniCode:
       Writeln('Unicode key');
       Writeln('Unicode key');
     kbFnKey:
     kbFnKey: