mkkeytab.pp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. program mkkeytab;
  2. {
  3. This program takes the keyboard scan code definitions, (the const section
  4. of the rtl/unix/keyboard.pp file) and outputs a
  5. latex table. The final output is done with some reformatting with the
  6. following sed commands:
  7. mkkeytab | sed 's/[aA]lt/ALT-/g' | sed 's/[Ss]hift/SHIFT-/g' | sed 's/[Cc]trl/CTRL-/g' > keys.tex
  8. }
  9. uses sysutils,classes;
  10. Function ScanLine (S: String) : String;
  11. Var
  12. I : Integer;
  13. KN,KC : String;
  14. begin
  15. I:=Pos('=',S);
  16. Result:='';
  17. If I<>0 then
  18. begin
  19. KN:=Trim(Copy(S,1,I-1));
  20. Delete(KN,1,2);
  21. Delete(S,1,I);
  22. I:=Pos(';',S);
  23. If I<>0 then
  24. begin
  25. KC:=Trim(Copy(S,1,I-1));
  26. Delete(KC,1,1);
  27. Result:= KC+' & '+KN;
  28. end;
  29. end;
  30. end;
  31. Var
  32. F : text;
  33. List : TstringList;
  34. I,RowCount : Integer;
  35. S: String;
  36. begin
  37. List:=TstringList.Create;
  38. Assign(f,'keys.txt');
  39. Reset(f);
  40. While not eof(f) do
  41. begin
  42. Readln (f,s);
  43. S:=ScanLine(s);
  44. If S<>'' then
  45. List.Add(S);
  46. end;
  47. RowCount:=List.Count div 3;
  48. if (List.Count mod 3)<>0 then
  49. begin
  50. Inc(RowCount);
  51. List.Add('');
  52. List.Add('');
  53. end;
  54. For I:=0 to rowcount-1 do
  55. Writeln(Format('%-20s & %-20s & %-20s \\',[List[i],List[I+RowCount],List[I+2*RowCount]]));
  56. end.