Text menus

Search this archive.

From: Jay Link (jlink@interlink-bbs.com)
Date: Fri 19 May 2000 - 15:09:55 IDT


Hi-

Someone was asking me a while ago about text menus, as are often found in
installation programs. I hope this person is on the list!  :-)

Here's a simple program I wrote that illustrates how to change colors on
the console display. It doesn't use SVGAlib, but this sort of thing could
be used as an SVGAlib program installer.

It should be fairly clear how to mix & match the foreground and background
colors. The background value comes first.


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   printf("\n");

   printf("\033[47;37m%s\033[0m","GREY on GREY");
   printf("\033[40;37m%s\033[0m","\n");         /* return to normal */
   printf("\033[46;37m%s\033[0m","GREY on LT BLUE");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[45;37m%s\033[0m","GREY on PURPLE");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;37m%s\033[0m","GREY on BLUE");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[43;37m%s\033[0m","GREY on BROWN");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[42;37m%s\033[0m","GREY on LIME");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[41;37m%s\033[0m","GREY on RED");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;37m%s\033[0m","GREY on BLACK");
   printf("\033[40;37m%s\033[0m","\n");

   printf("\n");

   printf("\033[40;38m%s\033[0m","WHITE on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;37m%s\033[0m","GREY on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;36m%s\033[0m","LT BLUE on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;35m%s\033[0m","PURPLE on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;34m%s\033[0m","BLUE on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;33m%s\033[0m","BROWN on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;32m%s\033[0m","LIME on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;31m%s\033[0m","RED on BLACK");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[40;30m%s\033[0m","BLACK on BLACK");
   printf("\033[40;37m%s\033[0m","\n");

   printf("\n");

   getchar();

   printf("\033[44;38m%s\033[0m",
   "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "º                                                           º");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "º                                                           º");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "º                                                           º");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "º                                                           º");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "º                                                           º");
   printf("\033[40;37m%s\033[0m","\n");
   printf("\033[44;38m%s\033[0m",
   "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
   printf("\033[40;37m%s\033[0m","\n");

   printf("\n");

   return 0;
}


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST