Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/resize Import Xterm's resize(1) for querying (x)term...



details:   https://anonhg.NetBSD.org/src/rev/b73cde8139c9
branches:  trunk
changeset: 958174:b73cde8139c9
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Sun Dec 27 21:13:17 2020 +0000

description:
Import Xterm's resize(1) for querying (x)terminal sizes in base for headless
clients

diffstat:

 distrib/sets/lists/base/mi           |    3 +-
 distrib/sets/lists/man/mi            |    5 +-
 distrib/sets/lists/xbase/mi          |   10 +-
 doc/CHANGES                          |    4 +-
 external/mit/xorg/bin/xterm/Makefile |    4 +-
 usr.bin/resize/Makefile              |    7 +
 usr.bin/resize/resize.1              |  219 +++++++++++++
 usr.bin/resize/resize.c              |  388 +++++++++++++++++++++++
 usr.bin/resize/xstrings.c            |  580 +++++++++++++++++++++++++++++++++++
 usr.bin/resize/xstrings.h            |   87 +++++
 10 files changed, 1297 insertions(+), 10 deletions(-)

diffs (truncated from 1430 to 300 lines):

diff -r aef9f10a105f -r b73cde8139c9 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Sun Dec 27 20:56:14 2020 +0000
+++ b/distrib/sets/lists/base/mi        Sun Dec 27 21:13:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1272 2020/11/23 12:41:47 martin Exp $
+# $NetBSD: mi,v 1.1273 2020/12/27 21:13:18 reinoud Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -951,6 +951,7 @@
 ./usr/bin/renice                               base-util-bin
 ./usr/bin/reset                                        base-util-bin
 ./usr/bin/rev                                  base-util-bin
+./usr/bin/resize                               base-util-bin
 ./usr/bin/revoke                               base-util-bin
 ./usr/bin/rfcomm_sppd                          base-util-bin
 ./usr/bin/rlog                                 base-rcs-bin
diff -r aef9f10a105f -r b73cde8139c9 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sun Dec 27 20:56:14 2020 +0000
+++ b/distrib/sets/lists/man/mi Sun Dec 27 21:13:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1711 2020/11/10 21:47:41 kamil Exp $
+# $NetBSD: mi,v 1.1712 2020/12/27 21:13:18 reinoud Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -490,6 +490,7 @@
 ./usr/share/man/cat1/rehash.0                  man-util-catman         .cat
 ./usr/share/man/cat1/repeat.0                  man-util-catman         .cat
 ./usr/share/man/cat1/reset.0                   man-util-catman         .cat
+./usr/share/man/cat1/resize.0                  man-util-catman         .cat
 ./usr/share/man/cat1/rev.0                     man-util-catman         .cat
 ./usr/share/man/cat1/rfcomm_sppd.0             man-util-catman         .cat
 ./usr/share/man/cat1/rlog.0                    man-rcs-catman          .cat
@@ -3774,6 +3775,7 @@
 ./usr/share/man/html1/rehash.html              man-util-htmlman        html
 ./usr/share/man/html1/repeat.html              man-util-htmlman        html
 ./usr/share/man/html1/reset.html               man-util-htmlman        html
+./usr/share/man/html1/resize.html              man-util-htmlman        html
 ./usr/share/man/html1/rev.html                 man-util-htmlman        html
 ./usr/share/man/html1/rfcomm_sppd.html         man-util-htmlman        html
 ./usr/share/man/html1/rlog.html                        man-rcs-htmlman         html
@@ -6708,6 +6710,7 @@
 ./usr/share/man/man1/rehash.1                  man-util-man            .man
 ./usr/share/man/man1/repeat.1                  man-util-man            .man
 ./usr/share/man/man1/reset.1                   man-util-man            .man
+./usr/share/man/man1/resize.1                  man-util-man            .man
 ./usr/share/man/man1/rev.1                     man-util-man            .man
 ./usr/share/man/man1/rfcomm_sppd.1             man-util-man            .man
 ./usr/share/man/man1/rlog.1                    man-rcs-man             .man
diff -r aef9f10a105f -r b73cde8139c9 distrib/sets/lists/xbase/mi
--- a/distrib/sets/lists/xbase/mi       Sun Dec 27 20:56:14 2020 +0000
+++ b/distrib/sets/lists/xbase/mi       Sun Dec 27 21:13:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.163 2020/11/10 21:47:41 kamil Exp $
+# $NetBSD: mi,v 1.164 2020/12/27 21:13:18 reinoud Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -53,7 +53,7 @@
 ./usr/X11R7/bin/perfboth                               xbase-x11perf-bin       xorg
 ./usr/X11R7/bin/perfratio                              xbase-x11perf-bin       xorg
 ./usr/X11R7/bin/proxymngr                              xbase-proxymngr-bin     xorg
-./usr/X11R7/bin/resize                                 xbase-xterm-bin xorg
+./usr/X11R7/bin/resize                                 xbase-obsolete          obsolete
 ./usr/X11R7/bin/revpath                                        xbase-revpath-bin       xorg
 ./usr/X11R7/bin/sessreg                                        xbase-sessreg-bin       xorg
 ./usr/X11R7/bin/setxkbmap                              xbase-setxkbmap-bin     xorg
@@ -1309,7 +1309,7 @@
 ./usr/X11R7/man/cat1/mkhtmlindex.0                     xbase-mkhtmlindex-catman        .cat,xorg
 ./usr/X11R7/man/cat1/oclock.0                          xbase-oclock-catman     .cat,xorg
 ./usr/X11R7/man/cat1/proxymngr.0                       xbase-proxymngr-catman  .cat,xorg
-./usr/X11R7/man/cat1/resize.0                          xbase-xterm-catman      .cat,xorg
+./usr/X11R7/man/cat1/resize.0                          xbase-obsolete          obsolete
 ./usr/X11R7/man/cat1/revpath.0                         xbase-revpath-catman    .cat,xorg
 ./usr/X11R7/man/cat1/sessreg.0                         xbase-sessreg-catman    .cat,xorg
 ./usr/X11R7/man/cat1/setxkbmap.0                       xbase-setxkbmap-catman  .cat,xorg
@@ -1457,7 +1457,7 @@
 ./usr/X11R7/man/html1/mkhtmlindex.html                 xbase-mkhtmlindex-htmlman       html,xorg
 ./usr/X11R7/man/html1/oclock.html                      xbase-oclock-htmlman    html,xorg
 ./usr/X11R7/man/html1/proxymngr.html                   xbase-proxymngr-htmlman html,xorg
-./usr/X11R7/man/html1/resize.html                      xbase-resize-htmlman    html,xorg
+./usr/X11R7/man/html1/resize.html                      xbase-obsolete          obsolete
 ./usr/X11R7/man/html1/revpath.html                     xbase-revpath-htmlman   html,xorg
 ./usr/X11R7/man/html1/sessreg.html                     xbase-sessreg-htmlman   html,xorg
 ./usr/X11R7/man/html1/setxkbmap.html                   xbase-setxkbmap-htmlman html,xorg
@@ -1606,7 +1606,7 @@
 ./usr/X11R7/man/man1/mkhtmlindex.1                     xbase-mkhtmlindex-man   .man,xorg
 ./usr/X11R7/man/man1/oclock.1                          xbase-oclock-man        .man,xorg
 ./usr/X11R7/man/man1/proxymngr.1                       xbase-proxymngr-man     .man,xorg
-./usr/X11R7/man/man1/resize.1                          xbase-xterm-man .man,xorg
+./usr/X11R7/man/man1/resize.1                          xbase-obsolete          obsolete
 ./usr/X11R7/man/man1/revpath.1                         xbase-revpath-man       .man,xorg
 ./usr/X11R7/man/man1/sessreg.1                         xbase-sessreg-man       .man,xorg
 ./usr/X11R7/man/man1/setxkbmap.1                       xbase-setxkbmap-man     .man,xorg
diff -r aef9f10a105f -r b73cde8139c9 doc/CHANGES
--- a/doc/CHANGES       Sun Dec 27 20:56:14 2020 +0000
+++ b/doc/CHANGES       Sun Dec 27 21:13:17 2020 +0000
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2770 $>
+# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2771 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -322,4 +322,6 @@
                framebuffer for HP9000/425t. [tsutsui 20201223]
        openresolv: Update to version 3.12.0 [roy 20201227]
        nvmm: implement support for trapping REP CMPS [reinoud 20201227]
+       resize: Import Xterm's resize(1) for querying (x)terminal sizes in
+               base for headless clients [reinoud 20201227]
 
diff -r aef9f10a105f -r b73cde8139c9 external/mit/xorg/bin/xterm/Makefile
--- a/external/mit/xorg/bin/xterm/Makefile      Sun Dec 27 20:56:14 2020 +0000
+++ b/external/mit/xorg/bin/xterm/Makefile      Sun Dec 27 21:13:17 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.18 2020/10/02 13:08:07 nia Exp $
+#      $NetBSD: Makefile,v 1.19 2020/12/27 21:13:18 reinoud Exp $
 
 .include <bsd.own.mk>
 
@@ -38,7 +38,7 @@
 LDADD+=        -lXpm -lXext -lX11 -lcurses -lterminfo -lutil
 DPADD+=        ${LIBXPM} ${LIBXEXT} ${LIBX11} ${LIBCURSES} ${LIBTERMINFO} ${LIBUTIL}
 
-SUBDIR=        resize uxterm
+SUBDIR=        uxterm
 
 .PATH: ${X11SRCDIR.${PROG}}
 
diff -r aef9f10a105f -r b73cde8139c9 usr.bin/resize/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/resize/Makefile   Sun Dec 27 21:13:17 2020 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: Makefile,v 1.1 2020/12/27 21:13:18 reinoud Exp $
+
+WARNS= 3
+PROG=  resize
+SRCS=  resize.c xstrings.c
+
+.include <bsd.prog.mk>
diff -r aef9f10a105f -r b73cde8139c9 usr.bin/resize/resize.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/resize/resize.1   Sun Dec 27 21:13:17 2020 +0000
@@ -0,0 +1,219 @@
+.\" $XTermId: resize.man,v 1.32 2016/09/24 11:14:15 tom Exp $
+.\"
+.\" Copyright 1998-2013,2016 by Thomas E. Dickey
+.\"
+.\"                         All Rights Reserved
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name(s) of the above copyright
+.\" holders shall not be used in advertising or otherwise to promote the
+.\" sale, use or other dealings in this Software without prior written
+.\" authorization.
+.\"
+.\" updated by Thomas E. Dickey for XFree86, 1998-2006.
+.\"
+.ds N Resize
+.ds n resize
+.\"
+.\" Bulleted paragraph
+.de bP
+.IP \(bu 4
+..
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds AQ \(aq
+.el       .ds AQ '
+.ie \n(.g .ds `` \(lq
+.el       .ds `` ``
+.ie \n(.g .ds '' \(rq
+.el       .ds '' ''
+.TH RESIZE 1 "__app_date__" "__app_version__" "X Window System"
+.SH NAME
+resize \- set environment and terminal settings to current xterm window size
+.SH SYNOPSIS
+.B \*n
+[ \fB\-v\fP | \fB\-u\fP | \fB\-c\fP ] [ \fB\-s\fP [ \fIrow col\fP ] ]
+.SH DESCRIPTION
+.I \*N
+prints a shell command for setting the appropriate environment variables
+to indicate the current size of \fIxterm\fP window from which the command
+is run.
+.PP
+.I \*N
+determines the command through several steps:
+.bP
+first, it finds the name of the user's shell program.
+It uses the \fBSHELL\fP variable if set,
+otherwise it uses the user's data from /etc/passwd.
+.bP
+then it decides whether to use Bourne shell syntax or C-Shell syntax.
+It uses a built-in table of known shells,
+which can be overridden by the \fB\-u\fP and \fB\-c\fP options.
+.bP
+then \fI\*n\fP asks the operating system for the terminal settings.
+This is the same information which can be manipulated using \fIstty\fP.
+.bP
+then \fI\*n\fP asks the terminal for its size in characters.
+Depending on whether the "\fB\-s\fP option is given,
+\fI\*n\fP uses a different escape sequence to ask for this information.
+.bP
+at this point, \fI\*n\fP attempts to update the terminal settings
+to reflect the terminal window's size in pixels:
+.RS
+.bP
+if the \fB\-s\fP option is used,
+\fI\*n\fP then asks the terminal for its size in pixels.
+.bP
+otherwise,
+\fI\*n\fP asks the operating system for the information
+and updates that after ensuring that the window's dimensions are
+a multiple of the character height and width.
+.bP
+in either case, the updated terminal settings are done
+using a different system call than used for \fIstty\fP.
+.RE
+.bP
+then \fI\*n\fP updates the terminal settings to reflect any altered
+values such as its size in rows or columns.
+This affects the values shown by \fIstty\fP.
+.bP
+finally, \fI\*n\fP writes the shell command for setting the
+environment variables to the standard output.
+.SH EXAMPLES
+For \*n's output to take effect,
+\fI\*n\fP must either be evaluated
+as part of the command line (usually done with a shell alias or function) or
+else redirected to a file which can then be read in.
+From the C shell (usually
+known as \fI/bin/csh\fP), the following alias could be defined in the
+user's \fI.cshrc\fP:
+.sp
+.nf
+        %  alias rs \*(AQset noglob; eval \fC\`\fP\*n\fC\`\fP\*(AQ
+.fi
+.sp
+After resizing the window, the user would type:
+.sp
+.nf
+        %  rs
+.fi
+.sp
+Users of versions of the Bourne shell (usually known as \fI/bin/sh\fP) that
+don't have command
+functions will need to send the output to a temporary file and then read it back
+in with the \*(``.\*('' command:
+.sp
+.nf
+        $  \*n > /tmp/out
+        $  .\0/tmp/out
+.fi
+.SH OPTIONS
+The following options may be used with \fI\*n\fP:
+.TP 8
+.B \-c
+This option indicates that C shell commands should be generated even if the
+user's current shell is not \fI/bin/csh\fP.
+.TP 8
+.B \-s \fR[\fIrows columns\fP]
+This option indicates that Sun console escape sequences will be used
+instead of the VT100-style \fIxterm\fP escape codes.
+If \fIrows\fP and
+\fIcolumns\fP are given,
+\fI\*n\fP will ask the \fIxterm\fP to resize itself using those values.
+.IP
+Both of the escape sequences used for this option
+(first to obtain the window size and
+second to modify it)
+are subject to \fIxterm\fP's \fBallowWindowOps\fP resource setting.
+The window manager may also choose to disallow the change.
+.IP
+The VT100-style escape sequence used to determine the
+screen size always works for VT100-compatible terminals.
+VT100s have no corresponding way to modify the screensize.
+.TP 8
+.B \-u
+This option indicates that Bourne shell commands should be generated even if
+the user's current shell is not \fI/bin/sh\fP.
+.TP 8
+.B \-v
+This causes \fI\*n\fP to print a version number to the standard output,



Home | Main Index | Thread Index | Old Index