View of xos/tests/video.c


XOS | Parent Directory | View | Download

/* Copyright (C) 2008  Emmanuel Varoquaux
 
   This file is part of XOS.
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
#include <stdio.h>
 
#define title(s) (printf("**** %s ****\n", (s)))
 
int main()
{
  /* Sortie standard non temporisee. */
  setbuf(stdout, NULL);
 
  /* Test naif */
  printf("Yeah, let's test the video driver.\n\n");
 
  /* Cloche */
  title("Bell");
  printf("\a\n");
 
  /* Backspace */
  title("Backspace");
  printf("\babX\bcXe\b\bd\n");
 
  /* Tab */
  title("Tab");
  printf("\ta\tbc\tdefghij\tklmnopqr\tstu\b\b\tv\n");
 
  /* Sequences d'echappement invalides */
  title("Invalid escape sequences");
  printf("ab\e[1;2%%cd\e[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;mef\n");
 
  /* Save / restore cursor & attr */
  title("Save / restore cursor");
  printf("a\e7\e[1mX\e8b\n");
 
  /* Cursor control */
  title("Cursor control");
  printf("0\n1\e[A2\e[B3\e[C4\e[2D5\n");
 
  /* Wrapping off */
  title("Wrapping Off");
  printf("\e[?7l000000000000000000000000000000000000000000000000000000000000000000000000000012345678\n");
 
  /* Wrapping on */
  title("Wrapping On");
  printf("\e[?7h000000000000000000000000000000000000000000000000000000000000000000000000000012345678\n");
 
  /* Attribute mode */
  title("Attribute mode");
  printf("a\e[42;35mb\e[1mc\e[7md\e[8me\e[0;33mf\e[44mg\e[42;35mh\e[39mi\e[35;49mj\e[mk\n");
 
  /* Modes reverse video et concealed */
  title("Reverse and concealed");
  printf("\e[42;35mNORMAL \e[7mREVERSE \e[8mREV AND CONC \e[27mCONCEALED \e[28mNORMAL \e[m\n");
 
  /* Save / unsave cursor */
  title("Save / restore cursor");
  printf("a\e[s\e[1mX\e[ub\e[mc\n");
 
  /* Effacement et couleur du curseur */
  title("Effacement");
  printf("\e[1;35;41mAX\b\e[K");
 
  /* Ne peuvent etre testes qu'individuellement - decommenter */
#if 0
  printf("a\ec"); /* Reset terminal */
#elif 0
  printf("\e[HHELLO !\n"); /* Cursor home */
#elif 0
  printf("abcd\e[2D\e[K\n"); /* Erase end of line */
#elif 0
  printf("abcd\e[2D\e[1K\n"); /* Erase start of line */
#elif 0
  printf("abcd\e[2D\e[2K\n"); /* Erase line */
#elif 0
  printf("\n\na\e[Abcd\e[Ae\e[B\e[3D\e[J\n\n\n"); /* Erase down */
#elif 0
  printf("\n\na\e[Abcd\e[Ae\e[B\e[3D\e[1J\n\n\n"); /* Erase up */
#elif 0
  printf("\n\na\e[Abcd\e[Ae\e[B\e[3D\e[2J\n\n\n"); /* Erase screen */
#endif
 
  /* Test libre de l'echo */
  while (1);
}