From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1117c9,8773941667f7e737,start X-Google-Attributes: gid1117c9,public X-Google-Thread: 10d4db,8773941667f7e737,start X-Google-Attributes: gid10d4db,public X-Google-ArrivalTime: 1994-05-13 15:48:37 PST Newsgroups: comp.os.linux.announce,alt.sources Path: bga.com!news.sprintlink.net!hookup!swrinde!cs.utexas.edu!howland.reston.ans.net!noc.near.net!usenet.elf.com!rpi!batcomputer!cornell!bounce-bounce From: slouken@cs.ucdavis.edu (Whistler) Subject: Announce: Splitvt 1.5.2 Message-ID: Followup-To: comp.os.linux.misc Keywords: splitvt, UNIX utility, terminal Sender: mdw@cs.cornell.edu (Matt Welsh) Reply-To: slouken@cs.ucdavis.edu (Whistler) Organization: University of California, Davis Date: Fri, 13 May 1994 22:10:24 GMT Xref: bga.com comp.os.linux.announce:698 alt.sources:1019 Announcing Splitvt version 1.5.2 ! What it is: Splitvt is a UNIX utility designed to split your screen in half, running a shell (or the program of your choice) in each half. This can be very handy if you want to see the results of two programs at the same time, but don't have X, or, if you want to work in two windows at the same time over a modem. Some people even like to run splitvt in X, just to have two programs running in the same window. Splitvt is a complementary utility to that great program 'screen', and can be used in combination with it to have a variety of split virtual screens. What's New: Splitvt has a few new features since version 1.5. There is now a -norc option to suppress startup from your custom .splitvtrc startup file. The top and bottom bars have been removed to give your screen more real estate. Splitvt now supports some obscure features of xterm that allow you to click your mouse in the window of your choice, eliminating the need for you to hit those pesky control keys to switch windows. (Note: this feature is only available to true xterms) Where you can get it: You can get this program via anonymous ftp from sunsite.unc.edu. I just uploaded the newest version to the /pub/Linux/Incoming directory, and it should be moved soon to its final resting place in /pub/Linux/utils/shell. The file is in a gzipped-shar archive, and can be uncompressed with the following command line: gzip -cd file.shz | sh If for some reason, you cannot ftp it, then feel free to send me email at slouken@cs.ucdavis.edu and I will be happy to send it to you. Troubleshooting: You shouldn't have any problems compiling splitvt if you are on a UNIX system that supports pseudo-terminals. If you are on a UNIX box, chances are good that you can compile it. Look in the README file in the archive for a list of systems splitvt is known to work on. By far the most common problem people have had is splitvt not being able to open enough pseudo-terminals (ttys). This can be caused by many things. If your system isn't one in the README, it might be that your system handles pseudo- terminals differently than any I know. Often, not being able to open enough ptys is caused by too many users on the system or too many pty-intensive applications running (these include xterm, screen, telnetd, expect, etc). If this happens, try waiting a while and try again. Another problem that can occur on some systems is pty hanging. This can happen when applications quit and go into a zombie state, or if the kernel gets confused about the state of the pty. Generally, if you can, try to reboot. This clears all of the hung ptys. A good telltale to whether or not lack of ptys is splitvt's problem is to rlogin a few times to your local system. If you are able to log in properly (without a message like "rlogind: out of ptys"), then the problem is probably with splitvt. That said, most people have very few problems with splitvt, and I hope you are among them that enjoy my fine utility. Oh, the idea for this utility came from the brain of Daveola Ljung. Thanks Dave! If you have any questions, comments, complaints, cash, ;-) send me email at slouken@cs.ucdavis.edu Enjoy! -Sam P.S. Included in this post is a patch to upgrade from splitvt 1.5 to the current version. To apply, save the patch to a file, cd to the source directory for splitvt 1.5, and run the command: patch -p1 #include --- 7,13 ---- -Sam Lantinga 10/5/93 */ ! static char *version="@(#)Splitvt 1.5.2 5/11/94 -Sam Lantinga\n"; #include #include *************** *** 18,24 **** --- 18,27 ---- #include #include #include + #include "vtmouse.h" + #define XTITLE /* Uncomment this for an xterm title bar */ + #ifdef NEED_SELECT_H #include #endif *************** *** 52,57 **** --- 55,61 ---- extern void vt_debug(); /* A vt100 debugging routine */ extern char vt_prompt(); /* A user prompt routine for getting a char */ extern int UU_lines; /* The user requested lines for the top win */ + extern int WU_lines; /* The actual lines for the top win */ /* The command prompt shown by vt_prompt() */ #define PROMPT "\033[1;1msplitvt command: \033[m" *************** *** 107,112 **** --- 111,118 ---- fprintf(stderr, "\t\t\t\tenough to handle the full size.\n\n"); fprintf(stderr, "\t-upper command\t\tRuns 'command' in the upper window\n"); fprintf(stderr, "\t-lower command\t\tRuns 'command' in the lower window\n"); + fprintf(stderr, "\t-norc\t\t\tSuppresses loading your ~/.splitvtrc\n"); + fprintf(stderr, "\n"); exit(1); } *************** *** 125,130 **** --- 131,137 ---- static struct passwd pwdata; /* Our passwd entry */ static int debugflag=0; /* Do we allow debug key? */ + struct event X_event; #ifdef NEED_INET_H /* There is a bug in the Wallabong Group's implementation *************** *** 138,150 **** #endif /* First, get default options from ~/.splitvtrc */ ! splitvtrc(); /* Parse command line options */ ! while ( (i=getopt(argc, argv, "u:l:s:vh")) != EOF ) { switch (i) { case 'u': if ( strcmp(optarg, "pper") != 0 ) print_usage(argv[0]); upper_args[0]=argv[optind++]; --- 145,168 ---- #endif /* First, get default options from ~/.splitvtrc */ ! for ( i=1; argv[i]; ++i ) { ! if ( strcmp(argv[i], "-norc") == 0 ) { ! i=0; ! break; ! } ! } ! if ( i ) ! splitvtrc(); /* Parse command line options */ ! while ( (i=getopt(argc, argv, "n:u:l:s:vh")) != EOF ) { switch (i) { + case 'n': if ( strcmp(optarg, "orc") != 0 ) + print_usage(argv[0]); + /* Already handled above */ + break; case 'u': if ( strcmp(optarg, "pper") != 0 ) print_usage(argv[0]); upper_args[0]=argv[optind++]; *************** *** 159,165 **** break; case 's': UU_lines=atoi(optarg); break; ! case 'v': printf("%s", version); exit(0); break; case 'h': --- 177,183 ---- break; case 's': UU_lines=atoi(optarg); break; ! case 'v': printf("%s", version+4); exit(0); break; case 'h': *************** *** 181,187 **** if ( tty_getmode(ttyfd) < 0 ) { - end_vt100(); fprintf(stderr, "Can't get terminal settings.\n"); exit(2); } --- 199,204 ---- *************** *** 195,200 **** --- 212,224 ---- fprintf(stderr, "\rCan't initialize screen: %s\n", ptr); exit(3); } + #ifdef XTITLE + strcpy(buffer, version+4); + buffer[strlen(buffer)-1]='\0'; + (void) event_init(stdin, stdout, buffer); + #else + (void) event_init(stdin, stdout, NULL); + #endif if ( argv[1] ) { if ( upper_empty ) { *************** *** 323,359 **** if ( FD_ISSET(ttyfd, &read_mask) ) { ! read(ttyfd, buffer, 1); ! if ( buffer[0] == quote_c ) ! { ! read(ttyfd, buffer, 1); ! goto writit; ! } ! else if ( buffer[0] == switch_c ) ! { ! if ( (thisfd == topfd) && bottomok ) ! thisfd=bottomfd; ! else if ( topok ) ! thisfd=topfd; ! SET_WIN(); ! } ! else if ( buffer[0] == command_c ) ! { ! switch (vt_prompt(PROMPT)) { ! /* Print debug info */ ! case 'p': if ( debugflag ) ! vt_debug(stderr); ! break; ! /* Quick exit */ ! case 'q': finish(0); ! break; ! default: break; } ! } ! else { ! writit: ! write(thisfd, buffer, 1); } } --- 347,394 ---- if ( FD_ISSET(ttyfd, &read_mask) ) { ! if ( (buffer[0]=event_getc(&X_event)) == EOF ) ! finish(0); ! if ( X_event.happening ) { ! /* Work only on button release */ ! if ( BUTTON_ISSET(X_event, RELEASE) ) { ! /* Mouse click in which window? */ ! if ( X_event.y > WU_lines ) { ! if ( bottomok ) ! thisfd=bottomfd; ! SET_WIN(); ! } else if ( X_event.y < WU_lines ) { ! if ( topok ) ! thisfd=topfd; ! SET_WIN(); ! } } ! } else { ! if ( buffer[0] == quote_c ) { ! read(ttyfd, buffer, 1); ! goto writeit; ! } else if ( buffer[0] == switch_c ) { ! if ( (thisfd == topfd) && bottomok ) ! thisfd=bottomfd; ! else if ( topok ) ! thisfd=topfd; ! SET_WIN(); ! } else if ( buffer[0] == command_c ) { ! switch (vt_prompt(PROMPT)) { ! /* Print debug info */ ! case 'p': if ( debugflag ) ! vt_debug(stderr); ! break; ! /* Quick exit */ ! case 'q': finish(0); ! break; ! default: break; ! } ! } ! else { writeit: ! write(thisfd, buffer, 1); ! } } } *************** *** 471,476 **** --- 506,512 ---- /* Reset the vt100 window */ end_vt100(); + event_quit(); /* Reset our utmp entries */ if ( pw && topok && upper_tty[0] ) diff --recursive --context --new-file splitvt-1.5.0/splitvt.lsm splitvt/splitvt.lsm *** splitvt-1.5.0/splitvt.lsm Wed May 11 00:29:14 1994 --- splitvt/splitvt.lsm Wed May 11 00:19:28 1994 *************** *** 1,6 **** Begin2 Title = Splitvt - a split windows utility ! Version = 1.5.0 Desc1 = A utility to split a vt100 compatible screen into two halfs, Desc2 = upper and lower, and run a different program simultaneously Desc3 = in each half. --- 1,6 ---- Begin2 Title = Splitvt - a split windows utility ! Version = 1.5.2 Desc1 = A utility to split a vt100 compatible screen into two halfs, Desc2 = upper and lower, and run a different program simultaneously Desc3 = in each half. *************** *** 24,30 **** Comment1 = This is a pretty useful utility, especially when communicating Comment2 = to a UNIX system via modem, or when you want to see the output Comment3 = of two programs simultaneously. ! Comment4 = Entered = 28APR94 EnteredBy = Sam Lantinga End --- 24,30 ---- Comment1 = This is a pretty useful utility, especially when communicating Comment2 = to a UNIX system via modem, or when you want to see the output Comment3 = of two programs simultaneously. ! Comment4 = New: No top or bottom bars, -norc option, xterm mouse support. Entered = 28APR94 EnteredBy = Sam Lantinga End diff --recursive --context --new-file splitvt-1.5.0/vt100.c splitvt/vt100.c *** splitvt-1.5.0/vt100.c Wed May 11 00:29:15 1994 --- splitvt/vt100.c Wed May 11 00:05:08 1994 *************** *** 18,25 **** #include #include ! extern int errno; /* only used in vt_write() */ /* Function declarations */ extern char *getenv(); --- 18,27 ---- #include #include ! #define SEP_CHAR ' ' /* Separator bar character */ + extern int errno; /* only used in vt_write() */ + /* Function declarations */ extern char *getenv(); *************** *** 79,84 **** --- 81,88 ---- static int LU_lines; /* A local copy of UU_lines that is modified */ + static char *termtype; + /* A debugging routine */ void vt_debug(debug) *************** *** 116,122 **** if ( ! isatty(0) || ! isatty(1) ) return("Standard input and output must be a tty"); ! if ( ((ptr=getenv("TERM")) == NULL || strncmp(ptr, "vt100", 5)) && /* A vt100 emulation detector --> */ ! vttest() ) return("Terminal type must be set to vt100"); --- 120,127 ---- if ( ! isatty(0) || ! isatty(1) ) return("Standard input and output must be a tty"); ! if ( ((termtype=getenv("TERM")) == NULL || ! (strncmp(termtype, "vt100", 5)) != 0) && /* A vt100 emulation detector --> */ ! vttest() ) return("Terminal type must be set to vt100"); *************** *** 146,153 **** /* Set the exportable variables */ if ( UU_lines ) { /* Check the user set # of lines */ ! if ( UU_lines > (lines-3-3) ) ! LU_lines=(lines-3-3); else if ( UU_lines < 3 ) LU_lines=3; else --- 151,158 ---- /* Set the exportable variables */ if ( UU_lines ) { /* Check the user set # of lines */ ! if ( UU_lines > (lines-1-3) ) ! LU_lines=(lines-1-3); else if ( UU_lines < 3 ) LU_lines=3; else *************** *** 154,182 **** LU_lines=UU_lines; WU_lines=LU_lines; ! WL_lines=(lines-3-LU_lines); } else ! WL_lines=WU_lines=((lines-3)/2); W_columns=columns; - /* Set up the separator */ strcpy(sep, "\033[7m"); ! for ( i=0; (i + #include "vtmouse.h" + + #undef MAIN + #ifdef MAIN + void event_loop() + { + int c, event_flag; + struct event X_event; + + while ( (c=event_getc(&X_event)) != EOF ) { + if ( X_event.happening ) { + printf("\r\n************\r\n"); + printf("Mouse Event: 0x%x\r\n", X_event.button_state); + printf("\tX coordinate: %d\r\n", X_event.x); + printf("\tY coordinate: %d\r\n", X_event.y); + /* One example of getting the mouse state */ + printf("\tX Event: "); + switch(X_event.button_state&BUTTON_MASK) { + case RELEASE: printf("Button was released!\r\n"); + break; + default: printf("Button %d was pressed!\r\n", + (X_event.button_state&BUTTON_MASK)+1); + break; + } + /* Another example of getting the mouse state */ + printf("\tMouse %s buttons <%c|%c|%c>\r\n", + (BUTTON_ISSET(X_event, RELEASE) ? "released" : "pressed"), + (BUTTON_ISSET(X_event, BUTTON_1) ? 'X' : ' '), + (BUTTON_ISSET(X_event, BUTTON_2) ? 'X' : ' '), + (BUTTON_ISSET(X_event, BUTTON_3) ? 'X' : ' ')); + printf("************\r\n"); + } else { + if ( c == 'Q' ) + return; + else { + putc(c, stdout); + if ( c == '\r' ) + putc('\n', stdout); + } + } + } + } + + int main(int argc, char *argv[]) + { + if ( event_init(stdin, stdout) < 0 ) { + printf("Not running under an xterm.\n"); + exit(2); + } + system("stty -echo raw"); + + event_loop(); + + system("stty -raw echo"); + event_quit(); + + exit(0); + } + #endif + + static FILE *xt_input, *xt_output; + static int have_xterm=0; + static int set_title=0; + + int event_init(input, output, titlebar) + FILE *input, *output; + char *titlebar; + { + char *termtype; + + /* A program can assume that input is unbuffered after this routine */ + setbuf(input, NULL); + xt_input=input; + xt_output=output; + + /* Check for xterm terminal type */ + if ( (termtype=(char *)getenv("TERM")) && strcmp(termtype, "xterm") == 0 ) { + fprintf(xt_output, "\033[?1000h"); + fflush(xt_output); + have_xterm=1; + if ( titlebar ) { + fprintf(xt_output, "\033]0;%s\07", titlebar); + set_title=1; + fflush(xt_output); + } + } else { + return(-1); + } + return(0); + } + + int event_getc(X_event) + struct event *X_event; + { + int c, done=0; + char sequence[]="\033[M\0\0\0", *next=sequence; + + X_event->happening=0; + + if ( have_xterm ) { + while ( *next ) { + if ( (c=getc(xt_input)) == EOF ) + return(EOF); + if ( c == *next ) + ++next; + else { + *next=(char)c; + for ( *(next+1)='\0'; (next > sequence); --next ) + ungetc(*next, xt_input); + return(*sequence); + } + } + /* An event is being sent! */ + X_event->happening=1; + for ( c=0; c<3; ++c ) { + if ( (*(next++)=getc(xt_input)) == EOF ) + return(EOF); + } + X_event->button_state=(sequence[3]-' '); + X_event->x=(sequence[4]-' '); + X_event->y=(sequence[5]-' '); + } else + return(getc(xt_input)); + return(0); + } + + void event_quit() + { + if ( have_xterm ) { + fprintf(xt_output, "\033[?1000l"); + fflush(xt_output); + if ( set_title ) { + fprintf(xt_output, "\033]0;%s\07", "xterm"); + fflush(xt_output); + } + } + } diff --recursive --context --new-file splitvt-1.5.0/vtmouse.h splitvt/vtmouse.h *** splitvt-1.5.0/vtmouse.h --- splitvt/vtmouse.h Tue May 10 23:46:28 1994 *************** *** 0 **** --- 1,23 ---- + + /* Definitions for button_state bitmasks */ + #define BUTTON_MASK 0x03 + #define BUTTON_1 0x00 + #define BUTTON_2 0x01 + #define BUTTON_3 0x02 + #define RELEASE 0x03 + #define SHIFT 0x04 + #define META 0x08 + #define CONTROL 0x0F + + struct event { + int happening; + char button_state; + unsigned int x; + unsigned int y; + }; + #define BUTTON_ISSET(X, B) ((X.button_state&BUTTON_MASK) == B) + + extern int event_init(); + extern int event_getc(); + extern void event_quit(); + -- Mail submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu Be sure to include Keywords: and a short description of your software.