home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!ut-emx!tivoli!TIVOLI.COM!stuart
- From: stuart@TIVOLI.COM (Stuart Jarriel)
- Newsgroups: comp.sys.hp
- Subject: Re: HPView Icon Labels: Meaningful text?
- Message-ID: <3405@tivoli.UUCP>
- Date: 27 Aug 92 23:25:53 GMT
- References: <1992Aug26.083349.993@cfa160.harvard.edu>
- Sender: news@tivoli.UUCP
- Organization: Tivoli Systems, Inc
- Lines: 61
-
- This program can set the title bar and icon label on any running
- hpterm or xterm.
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #define ESC '\033'
- #define BEL '\007'
- #define STRING_MAX_LEN 200
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- int len, i;
- char *buffer;
- char *term;
-
- /* you must have one word as a title */
- if (argc < 2) exit(1);
-
- /* if X is running, WINDOWID will be set */
- if (strlen(getenv("WINDOWID")) == 0) exit(0);
-
- /* lets make room for a BIG name */
- if ((buffer = malloc(STRING_MAX_LEN)) == NULL) exit(0);
-
- for (i=1; i<= argc; i++) {
- if ((strlen(buffer) + strlen(argv[i])) > STRING_MAX_LEN) {
- perror("window title too long");
- exit(1);
- }
- buffer = strcat(buffer,argv[i]);
- buffer = strcat(buffer," ");
- }
-
- len = strlen(buffer);
-
- /* If there is no term environment set ... */
-
- if ((term = getenv("TERM")) == NULL) exit(0);
-
- /* This sequence if term has 'hp' in it */
-
- if (strstr(term,"hp") != NULL) {
- printf("%c&f0k%dD%s",ESC,len,buffer);
- printf("%c&f-1k%dD%s",ESC,len,buffer);
- }
-
- /* This sequence if term is an xterm or vt100 */
-
- if (strstr(term,"xterm") != NULL) {
- /* sets window then icon */
- /* printf("%c]2;%s%c",ESC,buffer,BEL);
- printf("%c]2;%s%c",ESC,buffer,BEL); */
-
- /* sets BOTH at the same time */
- printf("%c]0;%s%c",ESC,buffer,BEL);
- }
- }
-