ec5962d52e
git-svn-id: svn://kolibrios.org@643 a494cfbc-eb01-0410-851d-a64ba20cac60
102 lines
2.6 KiB
ObjectPascal
102 lines
2.6 KiB
ObjectPascal
|
||
{ ‚ FreePascal 2.2.0 ª®¤¨à®¢ª cp866 ¥ ॠ«¨§®¢ . }
|
||
{-$codepage cp866}
|
||
|
||
{$mode objfpc}
|
||
{$smartlink on}
|
||
{$apptype console}
|
||
|
||
{ <20> ¤ ë© ¬®¬¥â à áᬠâਢ ¥âáï ¢ë¯®«¥¨¥ ¯à¨«®¤¥¨ï ⮫쪮 ª ª ª®á®«ì®¥,
|
||
â.¥. ¤¨à¥ªâ¨¢ console ®¡ï§ ⥫ì , ¯®¢¥¤¥¨¥ ¯à®£à ¬¬ë ¯à¨ ®âáãâá⢨¨ í⮩
|
||
¤¨à¥ªâ¨¢ë ¯à¥¤®¯à¥¤¥«¨âì ¥«ì§ï. ƒ à â¨à®¢ ® ¥«ì§ï ¨á¯®«ì§®¢ âì äãªæ¨¨
|
||
Write, WriteLn, Read, ReadLn ®â®á¨â¥«ì® áâ ¤ à⮩ ª®á®«¨ ¢¢®¤ /¢ë¢®¤ .
|
||
}
|
||
|
||
program Example;
|
||
|
||
{ ‚ᥠäãªæ¨¨ ¨¬¥î騥 ¢ ᢮¥¬ ¨¬¥¨ ¯à¥ä¨ªá 'kos_' ïîâáï ¯« âä®à¬®§ ¢¨á¨¬ë¬¨
|
||
¨ ॠ«¨§®¢ ë ⮫쪮 ¯®¤ KolibriOS. ˆå ¨á¯®«ì§®¢ ¨¥ ¢ «î¡ëå ¯à®£à ¬¬ëå
|
||
¯à¨«®¦¥¨ïå ª ⥣®à¨ç¥áª¨ ¥ ४®¬¥¤®¢ ®, ¢ë®á¨â¥ ¢á¥ ¬¥â®¤ë, ¨á¯®«ì§ãî騥
|
||
í⨠äãªæ¨¨, ¢ ®â¤¥«ìë¥ ¬®¤ã«¨ (¨ ¨á¯®«ì§ã©â¥ ¥®¡å®¤¨¬ë¥ ¡áâà ªæ¨¨).
|
||
}
|
||
|
||
procedure DoPaint;
|
||
{ ‚뢮¤ ᮤ¥à¦¨¬®£® ®ª ¯à¨«®¦¥¨ï }
|
||
begin
|
||
kos_begindraw();
|
||
{®¯à¥¤¥«¥¨¥ ¯ à ¬¥â஢ ®ª }
|
||
kos_definewindow(200, 200, 200, 50, $23AABBCC);
|
||
{kos_definewindow ¥ ¨¬¥¥â ¯ à ¬¥âà ¤«ï ¢ë¢®¤ § £®«®¢ª ,
|
||
¤¥« ¥¬ íâ® ®â¤¥«ì®© äãªæ¨¥© kos_setcaption}
|
||
{®â®¡à ¦¥¨¥ § £®«®¢ª ®ª }
|
||
kos_setcaption('<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ›');
|
||
{¢ë¢®¤ á®®¡é¥¨ï}
|
||
kos_drawtext(3, 8, '<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...');
|
||
kos_enddraw();
|
||
end;
|
||
|
||
procedure DoKey;
|
||
{ Ž¡à ¡®âª ᮡëâ¨ï ¦ â¨ï ª« ¢¨è¨ }
|
||
var
|
||
Key: DWord;
|
||
Notes: array[0..3] of Byte;
|
||
begin
|
||
Key := kos_getkey();
|
||
{ áâà ¨¢ ¥¬ ¡ãä¥à ¤«ï ®â}
|
||
Notes[0] := $90;
|
||
Notes[1] := Key shr 8;
|
||
Notes[2] := $00;
|
||
{¢®á¯à®¨§¢®¤¨¬}
|
||
kos_speaker(@Notes);
|
||
end;
|
||
|
||
|
||
function DoButton: Boolean;
|
||
{ Ž¡à ¡®âª ᮡëâ¨ï ¦ â¨ï ª®¯ª¨ GUI }
|
||
var
|
||
Button: DWord;
|
||
begin
|
||
{¯®«ãç¨âì ª®¤ ¦ ⮩ ª«¨¢¨è¨}
|
||
Button := kos_getbutton();
|
||
{¥á«¨ [x], â® ¢¥àãâì «®¦ì, § ç¨â á¯à®¢®æ¨à®¢ âì § ªàë⨥ ¯à¨«®¦¥¨ï}
|
||
Result := Button <> 1;
|
||
end;
|
||
|
||
|
||
function ProcessMessage: Boolean;
|
||
{ Ž¦¨¤ ¨¥ ¨ ®¡à ¡®âª ᮡë⨩.
|
||
|
||
@return: ‚®§¢à é ¥â False, ¥á«¨ ¡ë«® ᮡë⨥ ª § ¢¥àè¥¨î ¯à¨«®¦¥¨ï.
|
||
@rtype: True ¨«¨ False }
|
||
var
|
||
Event: DWord;
|
||
begin
|
||
Result := True;
|
||
{®¦¨¤ ¥¬ ᮡëâ¨ï ®â á¨á⥬ë}
|
||
Event := kos_getevent();
|
||
case Event of
|
||
SE_PAINT : DoPaint; {¯¥à¥à¨á®¢ª ®ª }
|
||
SE_KEYBOARD: DoKey; {ᮡë⨥ ®â ª« ¢¨ âãàë}
|
||
SE_BUTTON : Result := DoButton; {ᮡ먥 ®â ª®¯ª¨, ¬®¦¥â ®¯à¥¤¥«¨âì
|
||
§ ¢¥à襨¥ ¯à¨«®¦¥¨ï, ¥á«¨ ¢¥à¥â False}
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure MainLoop;
|
||
{ ƒ« ¢ë© 横« ¯à¨«®¦¥¨ï }
|
||
var
|
||
ThreadSlot: TThreadSlot;
|
||
begin
|
||
{ áâà ¨¢ ¥¬ ᮡëâ¨ï, ª®â®àë¥ ¬ë £®â®¢ë ®¡à ¡ âë¢ âì}
|
||
kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_BUTTON);
|
||
{®¡à ¡®âª ᮡë⨩}
|
||
while ProcessMessage do;
|
||
end;
|
||
|
||
|
||
begin
|
||
WriteLn('Look for a new window, I''m just a konsole ;-)');
|
||
MainLoop;
|
||
end.
|