Subject: Line graphics on terminal window
To: None <tech-userlevel@netbsd.org>
From: None <sigsegv@rambler.ru>
List: tech-userlevel
Date: 08/30/2004 21:30:28
Does anyone know how to do line drawings on a terminal window without 
using curses library? I'm trying to use termcap routines to 
enable/disable terminal capabilities. As I understand this correnctly, 
the following are related to line graphics:

as        str       (P)       Start alternative character set
ae        str       (P)       End alternative character set.

Below is a fragment from my program, which prints a string in reverse 
video mode, and then it enables alternative character set and prints out 
every character from -256 to +256. None of the characters printed are 
displaied as line graphics, so I'm doing something wrong here. I 
searched on Google for hours trying to find some info on this topic, but 
couldn't find anything useful. Any hints would be greatly appreciated.


int main(void) {
  int i;
  char bp[1024];
  char strcap[1024];
  char *strcap_ptr = strcap;
 
  if(tgetent(bp, "xterm") != 1)
    printf("tgetent() error\n");
  printf("tgetnum(\"co\") %d\n", tgetnum("co"));
  printf("tgetflag(\"am\") %d\n", tgetflag("am"));
 
  printf("%s", tgetstr("is", &strcap_ptr));
  printf("%s", tgetstr("mr", &strcap_ptr));
  printf("Reverse video set\n");
  printf("%s", tgetstr("me", &strcap_ptr));
 
  /* Enable alternative char set/*
  printf("%s", tgetstr("eA", &strcap_ptr));
  /* Start alternative char set */
  printf("%s", tgetstr("as", &strcap_ptr));
 
  /* Try to guess which characters represent line graphics */
  for(i=-256; i<256; i++)
    printf("%c", i);

  /* End alternative char set */
  printf("%s", tgetstr("ae", &strcap_ptr));
}


This is what the program outputs when I run it:

roman$ ./a.out
tgetnum("co") 80
tgetflag("am") 1
Reverse video set



123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~_



123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~_
roman$