video4.pp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. { test for the enhanced video attributes support }
  2. program video4;
  3. {$mode objfpc}{$H+}
  4. uses
  5. video, keyboard;
  6. procedure TextOut(X, Y: Integer; const S: AnsiString; Attr: TEnhancedVideoAttributes);
  7. var
  8. W, P, I, M: Integer;
  9. begin
  10. P := ((X-1)+(Y-1)*ScreenWidth);
  11. M := Length(S);
  12. if (P+M) > ScreenWidth*ScreenHeight then
  13. M := ScreenWidth*ScreenHeight-P;
  14. for I := 1 to M do
  15. with EnhancedVideoBuf[P+I-1] do
  16. begin
  17. ExtendedGraphemeCluster := S[I];
  18. EnhancedVideoAttributes := Attr;
  19. end;
  20. end;
  21. var
  22. k: TKeyEvent;
  23. X, Y: Integer;
  24. begin
  25. InitKeyboard;
  26. InitEnhancedVideo;
  27. repeat
  28. TextOut( 1, 4, 'vanilla', []);
  29. TextOut( 6, 6, 'underline', [evaUnderlined]);
  30. TextOut( 1, 8, 'blink', [evaBlinkSlow]);
  31. TextOut( 6, 10, 'underline blink', [evaUnderlined, evaBlinkSlow]);
  32. TextOut( 1, 12, 'negative', [evaInverse]);
  33. TextOut( 6, 14, 'underline negative', [evaUnderlined, evaInverse]);
  34. TextOut( 1, 16, 'blink negative', [evaBlinkSlow, evaInverse]);
  35. TextOut( 6, 18, 'underline blink negative', [evaUnderlined, evaBlinkSlow, evaInverse]);
  36. TextOut(40, 4, 'bold', [evaBold]);
  37. TextOut(46, 6, 'bold underline', [evaBold, evaUnderlined]);
  38. TextOut(40, 8, 'bold blink', [evaBold, evaBlinkSlow]);
  39. TextOut(46, 10, 'bold underline blink', [evaBold, evaUnderlined, evaBlinkSlow]);
  40. TextOut(40, 12, 'bold negative', [evaBold, evaInverse]);
  41. TextOut(46, 14, 'bold underline negative', [evaBold, evaUnderlined, evaInverse]);
  42. TextOut(40, 16, 'bold blink negative', [evaBold, evaBlinkSlow, evaInverse]);
  43. TextOut(46, 18, 'bold underline blink negative', [evaBold, evaUnderlined, evaBlinkSlow, evaInverse]);
  44. TextOut(10, 24, 'Press space to continue', []);
  45. UpdateScreen(False);
  46. k := GetKeyEvent;
  47. k := TranslateKeyEvent(k);
  48. until GetKeyEventChar(k) = ' ';
  49. ClearScreen;
  50. repeat
  51. TextOut( 1, 4, 'vanilla', []);
  52. TextOut( 6, 6, 'bold', [evaBold]);
  53. TextOut( 1, 8, 'faint', [evaFaint]);
  54. TextOut( 6, 10, 'italicized', [evaItalicized]);
  55. TextOut( 1, 12, 'underlined', [evaUnderlined]);
  56. TextOut( 6, 14, 'slowly blinking', [evaBlinkSlow]);
  57. TextOut( 1, 16, 'rapidly blinking', [evaBlinkFast]);
  58. TextOut( 6, 18, 'inverse', [evaInverse]);
  59. TextOut(40, 4, 'invisible', [evaInvisible]);
  60. TextOut(46, 6, 'crossed out', [evaCrossedOut]);
  61. TextOut(40, 8, 'doubly underlined', [evaDoublyUnderlined]);
  62. TextOut(10, 24, 'Press space to continue', []);
  63. UpdateScreen(False);
  64. k := GetKeyEvent;
  65. k := TranslateKeyEvent(k);
  66. until GetKeyEventChar(k) = ' ';
  67. DoneEnhancedVideo;
  68. DoneKeyboard;
  69. end.