PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of David Tamas   CLI Magic   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: CLI Magic
Get input and display console output using tput
Author: By
Last change:
Date: 9 years ago
Size: 2,939 bytes
 

Contents

Class file image Download
<?php

require_once 'cli.php';

//standard cli samples
gCli()->showCursor(false);
gCli()->setbgColor('black');
gCli()->setColor('white');
gCli()->clearScrean();

gCli()->gotoXY(5,1);
echo
'Hello';
gCli()->gotoXY(5,2);
echo
gCli()->textParser('%red%Red text%rst%');

gCli()->thickBorder(20, 2, 20, 10, 'Hello window');

gCli()->gotoXY(5,3);
echo
'Press any key';
gCli()->gotoXY(5,4);
echo
'to continue';



while (
true) {
   
gCli()->gotoXY(5,5);
    echo
gCli()->textParser('%spinner% [%knightrider%]');
   
$c = gCli()->isKeypressed();
   
    if (
$c) {
        break;
    }
}


//Windowing system
gCli()->clearScrean();
gCli()->gotoXY(1, 1);

$infoWindow = new gWindow(1, 1, 80, 14, 'G-Lex\'s CLI magics');
$infoWindow->draw();
$statusWindow = new gWindow(81, 1, 50, 14, 'System status');
$statusWindow->draw();


$infoWindow->addLine('Version: %green;bold% 1.0' );
$infoWindow->addLine(' ');
$infoWindow->addLine('You can hold a lot of texts within this area');
$infoWindow->addLine('%green%Press%rst% %red%x%rst% to exit');

$statusSystem = $statusWindow->addStatusSignal('%white;bold%System%rst%');
$statusDriver = $statusWindow->addStatusSignal('Camera driver');
$statusCamera = $statusWindow->addStatusSignal('Camera status', '%red;faint%offline%rst%');
$statusConnection = $statusWindow->addStatusSignal('Camera connection');
$statusCameraWarming = $statusWindow->addStatusSignal('Camera warming');
$statusAlarm = $statusWindow->addStatusSignal('Alarm');
$statusMotion = $statusWindow->addStatusSignal('Motion');
$statusKeyframes = $statusWindow->addStatusSignal('Keyframes');
$statusAutopan = $statusWindow->addStatusSignal('AutoPan');
$statusPanPos = $statusWindow->addStatusSignal('PanPosition');
$statusSystem->setSignal('%yellow;bold%init%rst%', true);

 
$statusDriver->setSignal(true, true);

$statusConnection->setSignal(true, true);
$statusCamera->setSignal('%yellow;bold%online%rst%', true);


$statusPanPos->setSignal('0x0', true);
$statusCamera->setSignal('%yellow;bold%ready%rst%', true);


$statusCamera->setSignal('%yellow;bold%centering%rst%', true);
$statusCameraWarming->setSignal('%knightrider%');

$warmupEnd = time() + 5;
while (
$warmupEnd > time()) {
   
$statusCameraWarming->setSignal('%knightrider%');
   
usleep(10000);
}
$statusCameraWarming->setSignal('%green;bold%ready%rst%');
$statusCamera->setSignal('%green;bold%online%rst%', true);
$statusSystem->setSignal('%green;bold%ARMED%rst%', true);
$statusAlarm->setSignal('%green;bold%no%rst%', true);
$statusMotion->setSignal('%green;bold%no%rst%', true);

 while (
true) {
   
$c = gCli()->isKeypressed();
    if (
$c) {
       
$infoWindow->addLine(dateStamp().'KeyCode: '.ord($c).' | '. dechex(ord($c)));
    }
   
    if (
$c == 'x') {
        break;
    }
   
   
}
 
gCli()->clearScrean();
gCli()->gotoXY(1, 1);
gCli()->showCursor(true);