home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / hp / 9788 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.7 KB  |  73 lines

  1. Path: sparky!uunet!cs.utexas.edu!ut-emx!tivoli!TIVOLI.COM!stuart
  2. From: stuart@TIVOLI.COM (Stuart Jarriel)
  3. Newsgroups: comp.sys.hp
  4. Subject: Re: HPView Icon Labels: Meaningful text?
  5. Message-ID: <3405@tivoli.UUCP>
  6. Date: 27 Aug 92 23:25:53 GMT
  7. References: <1992Aug26.083349.993@cfa160.harvard.edu>
  8. Sender: news@tivoli.UUCP
  9. Organization: Tivoli Systems, Inc
  10. Lines: 61
  11.  
  12. This program can set the title bar and icon label on any running 
  13. hpterm or xterm.
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18.  
  19. #define ESC '\033'
  20. #define BEL '\007'
  21. #define STRING_MAX_LEN 200
  22.  
  23. main(argc,argv)
  24. int argc;
  25. char **argv;
  26. {
  27.   int len, i;
  28.   char *buffer;
  29.   char *term;
  30.  
  31. /* you must have one word as a title */
  32.   if (argc < 2) exit(1);
  33.  
  34. /* if X is running, WINDOWID will be set */
  35.   if (strlen(getenv("WINDOWID")) == 0) exit(0);
  36.  
  37. /* lets make room for a BIG name */
  38.   if ((buffer = malloc(STRING_MAX_LEN)) == NULL) exit(0);
  39.  
  40.   for (i=1; i<= argc; i++)  {
  41.     if ((strlen(buffer) + strlen(argv[i])) > STRING_MAX_LEN) {
  42.       perror("window title too long");
  43.       exit(1);
  44.     }
  45.     buffer = strcat(buffer,argv[i]);
  46.     buffer = strcat(buffer," ");
  47.   }
  48.  
  49.   len = strlen(buffer);
  50.  
  51. /* If there is no term environment set ... */
  52.  
  53.   if ((term = getenv("TERM")) == NULL) exit(0);
  54.  
  55. /*  This sequence if term has 'hp' in it */
  56.  
  57.   if (strstr(term,"hp") != NULL) {
  58.     printf("%c&f0k%dD%s",ESC,len,buffer);
  59.     printf("%c&f-1k%dD%s",ESC,len,buffer);
  60.   }
  61.  
  62. /*  This sequence if term is an xterm or vt100 */
  63.   
  64.   if (strstr(term,"xterm") != NULL) {
  65. /* sets window then icon */
  66. /*  printf("%c]2;%s%c",ESC,buffer,BEL);
  67.     printf("%c]2;%s%c",ESC,buffer,BEL);  */
  68.  
  69. /* sets BOTH at the same time */
  70.     printf("%c]0;%s%c",ESC,buffer,BEL);
  71.   }
  72. }
  73.