Article View: comp.sources.d
Article #1627Screen 2.0 change
From: Howard Chu
Date: Thu, 14 Mar 1991 20:34
Date: Thu, 14 Mar 1991 20:34
121 lines
3653 bytes
3653 bytes
Here's a couple small additions to Oliver Lauermann's program screen 2.0,
the ANSI terminal multiplexer... I just noticed that this is now a GNU
copylefted program, but don't know who's currently maintaining it. These
diffs should apply to the 2.1 source without any trouble.
Two simple changes - make the program get and set the kernel's notion of
the screen size, if the ioctl's are present. Also respond to the "report
cursor position" query.
It's not as flexible to use now that SunOS has gone to terminfo for their
curses implementation. Mebbe someone can add code to compile terminfo
definitions on the fly, the way this constructs termcap entries?
-- Howard
RCS file: RCS/screen.c,v
retrieving revision 1.1
diff -c -r1.1 screen.c
*** /tmp/,RCSt1018792 Thu Mar 14 14:33:32 1991
--- screen.c Thu Nov 1 22:51:07 1990
***************
*** 8,14 ****
* not modified.
*/
! static char ScreenVersion[] = "screen 2.0a 19-Oct-88";
#include <stdio.h>
#include <sgtty.h>
--- 8,14 ----
* not modified.
*/
! static char ScreenVersion[] = "screen 2.0hyc 1-Nov-90";
#include <stdio.h>
#include <sgtty.h>
***************
*** 809,814 ****
--- 809,822 ----
ioctl (0, TIOCSPGRP, &mypid);
(void) setpgrp (0, mypid);
SetTTY (0, &OldMode);
+ #ifdef TIOCSWINSZ
+ {
+ struct winsize wbuf;
+ wbuf.ws_row = rows;
+ wbuf.ws_col = cols;
+ ioctl (0, TIOCSWINSZ, &wbuf);
+ }
+ #endif
NewEnv[2] = MakeTermcap (aflag);
sprintf (ebuf, "WINDOW=%d", n);
NewEnv[3] = ebuf;
===================================================================
RCS file: RCS/ansi.c,v
retrieving revision 1.1
diff -c -r1.1 ansi.c
*** /tmp/,RCSt1018792 Thu Mar 14 14:37:04 1991
--- ansi.c Thu Nov 1 22:45:56 1990
***************
*** 8,16 ****
* not modified.
*/
! char AnsiVersion[] = "ansi 2.0a 19-Oct-88";
#include <stdio.h>
#include <sys/types.h>
#include "screen.h"
--- 8,17 ----
* not modified.
*/
! char AnsiVersion[] = "ansi 2.0hyc 1-Nov-90";
#include <stdio.h>
+ #include <sgtty.h> /* See if TIOCGWINSZ is supported */
#include <sys/types.h>
#include "screen.h"
***************
*** 94,101 ****
--- 95,112 ----
Msg (0, "No TERM in environment.");
if (tgetent (tbuf, s) != 1)
Msg (0, "Cannot find termcap entry for %s.", s);
+ #ifdef TIOCGWINSZ
+ {
+ struct winsize wbuf;
+
+ ioctl(0, TIOCGWINSZ, &wbuf);
+ rows=wbuf.ws_row;
+ cols=wbuf.ws_col;
+ }
+ #else
cols = tgetnum ("co");
rows = tgetnum ("li");
+ #endif /* TIOCGWINSZ */
if (cols <= 0)
cols = 80;
if (rows <= 0)
***************
*** 778,783 ****
--- 789,801 ----
if (PO && curr->GotArg[0] && a1 == 5) {
curr->stringp = curr->string;
curr->state = PRIN;
+ }
+ break;
+ case 'n': /* Report cursor position? */
+ if (curr->GotArg[0] && a1 == 6) {
+ char sbuf[16];
+ sprintf(sbuf,"[%d;%dR\n",curr->y+1,curr->x+1);
+ write(curr->ptyfd,sbuf,strlen(sbuf));
}
break;
}
--
-- Howard Chu @ Jet Propulsion Laboratory, Pasadena, CA
Disclaimer: How would I know, I just got here!
Technical Details
Message-ID:
<1991Mar14.203404.21113@jato.jpl.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!hanauma!hycShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!hanauma!hyc From: hyc@hanauma.jpl.nasa.gov (Howard Chu) Newsgroups: comp.sources.d Subject: Screen 2.0 change Message-ID: <1991Mar14.203404.21113@jato.jpl.nasa.gov> Date: 14 Mar 91 20:34:04 GMT Sender: news@jato.jpl.nasa.gov Organization: SAR Systems Development and Processing, JPL Lines: 121 Nntp-Posting-Host: hanauma.jpl.nasa.gov