Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,481 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,731 people online right now. Registration is fast and FREE... Join Now!




VT-100 Console stuff

 
Reply to this topicStart new topic

VT-100 Console stuff

ellisgl
1 Mar, 2008 - 02:19 PM
Post #1

D.I.C Head
**

Joined: 10 Nov, 2007
Posts: 68



Thanked: 1 times
My Contributions
I'm trying to take it old school with VT-100 terminal stuff and just wanted to post this little test
CODE

<?php
// 80x24 Terminal - actuall 24x24
// Function
// Compair 2 assoc arrays - give back the changes.
function array_diff_assoc_recursive($array1, $array2)
{
  foreach($array1 as $key => $value)
   {
    if(is_array($value))
     {
      if(!isset($array2[$key]))
       {
        $difference[$key] = $value;
       }
      elseif(!is_array($array2[$key]))
       {
        $difference[$key] = $value;
       }
      else
       {
        $new_diff = array_diff_assoc_recursive($value, $array2[$key]);

        if($new_diff != FALSE)
         {
          $difference[$key] = $new_diff;
         }
       }
     }
    elseif(!isset($array2[$key]) || $array2[$key] != $value)
     {
      $difference[$key] = $value;
     }
   }
  return !isset($difference) ? 0 : $difference;
}

// array mover
function array_mover($arr)
{
  $x = array_shift($arr);
  array_push($arr, $x);
  return($arr);
}

// Set up the first array ($a[x][y] X = Across, Y = Down)
// Since 0,0 is not valid we start the arrays as 1,1
$a = array();

// Clear the screen
echo chr(27),'[2J';

// Set up the first screen.
$xarr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','O','P','Q','R','S','T','U','V','W','X');

for($j=1; $j<=24; ++$j)
{
  for($i=1; $i<=80; ++$i)
   {
    $a[$j][$i] = $xarr[$j-1];
   }
}

// Loop thru it since it's the first time displaying
foreach($a as $b1=>$c1)
{
  foreach($c1 as $d1=>$e1)
   {
    echo chr(27),'[',$b1,';',$d1,'f',$e1;
   }
}

// Move the array around and draw it..
for($i=1; $i>0;)
{
  $a = array_mover($a);

  foreach($a as $b1=>$c1)
   {
    foreach($c1 as $d1=>$e1)
     {
      echo chr(27),'[',$b1,';',$d1,'f',$e1;
     }
   }
}
?>


If you know how to do a lot more with VT-100 / ANSI stuff - go ahead and comment.
User is offlineProfile CardPM
+Quote Post

bhandari
RE: VT-100 Console Stuff
5 Mar, 2008 - 02:25 AM
Post #2

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
QUOTE
If you know how to do a lot more with VT-100 / ANSI stuff


what exactly do you want??
User is offlineProfile CardPM
+Quote Post

ellisgl
RE: VT-100 Console Stuff
25 Mar, 2008 - 08:46 AM
Post #3

D.I.C Head
**

Joined: 10 Nov, 2007
Posts: 68



Thanked: 1 times
My Contributions
QUOTE(bhandari @ 5 Mar, 2008 - 03:25 AM) *

what exactly do you want??


I'm actually wanting to do a console terminal program (Telnet/SSH/Serial). One where I can tab to "fields" and input data, change screens, update the data on the screen (I.E. Clock or and event happened - pop something up in a box), save to the DB etc.
Basically would be a system that would work in conjunction with Asterisk for a small answering service. But it's the VT-100 stuff that would be hurdle. How do save the saves of the tabs and stuff - how to not over do screen rewrites - replace only what needs to be replaced. How to figure out the tabs, fields - which one the cursor is in and the the data that would be in that field, scrolling that data...etc...
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:58PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month