1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
|
Description: Patch qith all changes done to upstream in version 1.6.6-7 and older versions.
Author: Julien Danjou (version 1.6.6-7) Joey Hess (older versions)
Last-Update: 2011-02-13
--- a/misc.c
+++ b/misc.c
@@ -1,12 +1,19 @@
/* Miscellaneous system dependent routines for splitsh */
+#define _GNU_SOURCE /* for getpt and other gnu extensions to libc */
+
#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <utime.h>
+#include <string.h>
#ifdef HAVE_TERMIO_H
@@ -26,6 +33,8 @@
/*#define STTY_HACK*/
#endif
+int tty_reset(int fd);
+
/*
* Initialize a pty, fork a command running under it, and then
* return the master file descriptor
@@ -46,7 +55,10 @@
int get_master_pty(), get_slave_pty();
char *get_ttyname(), *myputenv();
- char LINES[12], COLUMNS[12], SPLITVT[24];
+#ifndef TIOCGWINSZ
+ char LINES[12], COLUMNS[12];
+#endif
+ char SPLITVT[24];
int returnfd, slave_fd;
/* Get the master pty file descriptor */
@@ -108,8 +120,16 @@
/* "touch" the tty so 'w' reports proper idle times */
(void) utime(get_ttyname(), NULL);
+ /* Set our gid to our real gid if necessary */
+ if (setgid(getgid()) != 0) {
+ perror("setgid");
+ exit(1);
+ }
/* Set our uid to our real uid if necessary */
- (void) setuid(getuid());
+ if (setuid(getuid()) != 0) {
+ perror("setuid");
+ exit(1);
+ }
/* Run the requested program, with possible leading dash. */
execvp(((*argv[0] == '-') ? argv[0]+1 : argv[0]), argv);
@@ -184,14 +204,15 @@
#else /* ! IRIX */
-#if defined(SOLARIS) || defined(linux) /* System V.4 pty routines from W. Richard Stevens */
+#if defined(SOLARIS) || defined(__GLIBC__) /* System V.4 pty routines from W. Richard Stevens */
#ifdef SOLARIS
#include <stropts.h>
-#endif
#define DEV_CLONE "/dev/ptmx"
+#endif
+
extern char *ptsname();
int get_master_pty()
@@ -199,9 +220,14 @@
char *ttyptr;
+#ifdef SOLARIS
if ( (master_fd=open(DEV_CLONE, O_RDWR)) < 0 )
return(-1);
-
+#else /* GLIBC */
+ if ( (master_fd=getpt()) == -1 )
+ return (-1);
+#endif
+
if ( grantpt(master_fd) < 0 ) /* grant access to slave */
{
close(master_fd);
@@ -399,8 +425,10 @@
void dropctty()
{
+#ifndef CIBAUD
int fd;
-
+#endif
+
#if defined(_POSIX_SOURCE) || defined(SOLARIS) || \
defined(__386BSD__) || defined(__FreeBSD__)
setsid(); /* The POSIX solution is simple. :) */
@@ -714,7 +742,6 @@
extern char **environ; /* The process environment strings */
char *newptr, **envptr;
- char *tmptr, temp[BUFSIZ];
int distance, n=0;
for ( distance=0; ((*(string+distance)) &&
@@ -765,7 +792,7 @@
char *line;
char *tokens;
{
- char *head, *ptr;
+ char *head;
int i=0;
for ( head=line; *line && i < size-2; ) {
@@ -853,7 +880,7 @@
{
char *argv[4];
int pipe_fds[2];
- int rw, child;
+ int rw;
if ( strcmp(type, "r") == 0 )
rw=0; /* READ access for parent */
@@ -877,7 +904,14 @@
close(pipe_fds[0]); close(pipe_fds[1]);
/* Set our uid to our real uid if necessary */
- (void) setuid(getuid());
+ if (setgid(getgid()) != 0) {
+ perror("setgid");
+ exit(1);
+ }
+ if (setuid(getuid()) != 0) {
+ perror("setuid");
+ exit(1);
+ }
/* Run the requested program */
argv[0]="/bin/sh";
--- a/parserc.c
+++ b/parserc.c
@@ -1,6 +1,8 @@
/* Routines to parse the ~/.splitvtrc file and set default options */
+#include <unistd.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -223,7 +225,7 @@
char line[BUFSIZ], newline[BUFSIZ*2], *parsed[256];
char *head, *tail, *ptr, *subptr;
char *envptr, envbuf[128];
- int i, n, quoted=0;
+ int i, n;
int ignoring=0, ifs=0;
/* Get our home directory */
--- a/vttest.c
+++ b/vttest.c
@@ -12,6 +12,7 @@
-Sam Lantinga (slouken@toadflax.cs.ucdavis.edu)
*/
+#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
@@ -48,9 +49,12 @@
int vttest()
{
char buff[512];
- int x=0, w, rc=0, fd;
+ int x=0, rc=0, fd;
struct termio ttold, ttraw;
+ /* Disabled since at least on sparc it causes a hang. */
+ return 1;
+
/* Set the terminal in a raw mode */
if ( (fd=open("/dev/tty", O_RDWR, 0666)) < 0 )
return(0);
--- a/vtmouse.c
+++ b/vtmouse.c
@@ -7,10 +7,13 @@
#define SPLITVT_SOURCE
+#include <string.h>
+#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vtmouse.h"
+#include "splitvt.h"
extern FILE *safe_popen(); /* From misc.c */
--- a/lock.c
+++ b/lock.c
@@ -1,9 +1,13 @@
/* The screen locking module for splitvt */
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
#include <stdio.h>
#include <pwd.h>
#include "vt100.h"
+#include "splitvt.h"
#define UNLOCKED 0
#define ENTERED1 1
--- a/splitvt.c
+++ b/splitvt.c
@@ -14,6 +14,9 @@
static char *version=
"@(#)Splitvt 1.6.6 3/11/2006 -Sam Lantinga (slouken@devolution.com)\n";
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -84,6 +87,8 @@
char *upper_args[MAX_ARGS+1]={NULL}, *lower_args[MAX_ARGS+1]={NULL};
int upper_empty=1, lower_empty=1;
+int force_height=0;
+
void print_usage(argv)
char *argv;
{
@@ -101,13 +106,14 @@
fprintf(stderr, "\t-nologin\t\tOverrides \"set login on\" in startup file\n");
fprintf(stderr, "\t-rcfile file\t\tLoads 'file' at startup instead of ~/.splitvtrc\n");
fprintf(stderr, "\t-norc\t\t\tSuppresses loading your startup file\n");
+ fprintf(stderr, "\t-f\t\t\tAllow setting screen size of less than 3 lines\n");
fprintf(stderr, "\t-v\t\t\tPrint out the version number\n");
fprintf(stderr, "\n");
exit(1);
}
-main(argc, argv)
+int main(argc, argv)
int argc;
char *argv[];
{
@@ -117,7 +123,10 @@
int i, len, maxfds, numready;
char buffer[BUFSIZ], *ptr;
char *xterm_title=NULL;
- struct timeval tv, *tvptr;
+#ifdef NEED_INET_H
+ struct timeval tv;
+#endif
+ struct timeval *tvptr;
fd_set read_mask;
static struct passwd pwdata; /* Our passwd entry */
@@ -157,7 +166,7 @@
splitvtrc();
/* Parse command line options */
- while ( (i=getopt(argc, argv, "n:u:l:r:b:s:t:vh")) != EOF )
+ while ( (i=getopt(argc, argv, "fn:u:l:r:b:s:t:vh")) != EOF )
{
switch (i)
{
@@ -169,11 +178,19 @@
break;
case 'u': if ( strcmp(optarg, "pper") != 0 )
print_usage(argv[0]);
+ if (optind >= argc) {
+ fprintf(stderr, "-upper requires an argument\n");
+ print_usage(argv[0]);
+ }
tokenize(upper_args, MAX_ARGS+1,
argv[optind++], " ");
upper_empty=0;
break;
case 'l': if ( strcmp(optarg, "ower") == 0 ) {
+ if (optind >= argc) {
+ fprintf(stderr, "-lower requires an argument\n");
+ print_usage(argv[0]);
+ }
tokenize(lower_args, MAX_ARGS+1,
argv[optind++], " ");
lower_empty=0;
@@ -200,7 +217,9 @@
case 'v': printf("%s", version+4);
exit(0);
break;
- case 'h':
+ case 'f': force_height=1;
+ break;
+ case 'h':
default: print_usage(argv[0]);
break;
}
@@ -224,7 +243,7 @@
}
(void) tty_raw(0); /* Set the tty raw here to prevent lost input */
- if ( (ptr=init_vt100()) != NULL )
+ if ( (ptr=init_vt100(1)) != NULL )
{
if ( tty_reset(0) < 0 )
(void) tty_sane(0);
@@ -487,6 +506,7 @@
}
}
finish(0);
+ exit(0);
}
void reset_bar(sleeptime)
@@ -510,6 +530,7 @@
" 'x' Lock the screen",
" 'h' Show this help screen",
" 'q' Quickly quit splitvt",
+" '0-9' Line count for + or -",
NULL
};
vt_showscreen("Splitvt HELP screen:", help);
@@ -714,7 +735,7 @@
tmp_uulines=UU_lines;
UU_lines=WU_lines;
UU_lines += howfar; /* Positive to go down, negative to go up */
- init_vt100(); /* Reset the windows to the new size */
+ init_vt100(0); /* Reset the windows to the new size */
/* Tell the running processes about the size change */
if ( topok )
@@ -736,7 +757,7 @@
signal(sig, winch);
- if ( (ptr=init_vt100()) != NULL ) {
+ if ( (ptr=init_vt100(1)) != NULL ) {
fprintf(stderr, "Can't resize window: %s. (exiting)\n", ptr);
finish(0);
} else
--- a/utmp.c
+++ b/utmp.c
@@ -1,22 +1,27 @@
/* utmp.c Shareware Copyright by Sam Lantinga 10/6/93 */
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <utmp.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
+#include "splitvt.h"
#ifdef DEBUG_UTMP
#undef UTMP_FILE
#define UTMP_FILE "/tmp/utmp"
#else
#ifndef UTMP_FILE
-#define UTMP_FILE "/etc/utmp"
+#define UTMP_FILE "/var/run/utmp"
#endif /* UTMP_FILE */
#endif /* DEBUG_UTMP */
+int get_utmp(char *tty, struct utmp *save);
+int set_utmp(char *tty, struct utmp *save);
/* Remove us from the utmp file, saving our entry to replace later */
@@ -95,7 +100,7 @@
if (strncmp(ttyptr, ut.ut_line, sizeof(ut.ut_line)) == 0) {
/* Break out; we've found our entry! */
if ( save )
- d_copy((char *)&ut, save, sizeof(ut));
+ d_copy((char *)&ut, (char *)&save, sizeof(ut));
close(fd);
return(0);
}
@@ -159,7 +164,9 @@
int uid; /* The uid corresponding to user */
char *tty; /* /dev/ttyxx */
{
+#if !defined(SOLARIS) && !defined(IRIX) && !defined(__GLIBC__)
struct stat sb;
+#endif
struct utmp ut;
char *ttyptr;
@@ -196,12 +203,13 @@
#endif
(void) time(&ut.ut_time);
-#if !defined(SOLARIS) && !defined(IRIX)
- /* Solaris and Irix machines do this automatically */
+#if !defined(SOLARIS) && !defined(IRIX) && !defined(__GLIBC__)
+ /* Solaris and Irix and GLIBC machines do this automatically */
/* Change the ownership and mode of the tty */
if ( stat(tty, &sb) == 0 ) {
(void) chmod(tty, 0620); /* crw--w---- */
(void) chown(tty, uid, sb.st_gid);
+
}
#endif
return(set_utmp(tty, &ut));
--- a/splitvt.1
+++ b/splitvt.1
@@ -51,6 +51,11 @@
Suppresses loading your ~/.splitvtrc
.TP
.TB
+.I -f
+Allow setting the height of either the top or the bottom window to less than
+3 lines.
+.TP
+.TB
.I -v
Print out the version number of splitvt
.LP
@@ -177,7 +182,7 @@
splitvt will attempt to erase the current utmp entry, and replace it
with entries for the two windows. This allows you to use programs
such as 'talk' within the splitvt windows. If you do not have write
-permission to the /etc/utmp file, you will not be able to modify the
+permission to the /var/run/utmp file, you will not be able to modify the
utmp entries.
splitvt can be made set-uid root. splitvt will reset its user id to
--- a/videomem.c
+++ b/videomem.c
@@ -1,6 +1,7 @@
/* This file holds the functions for manipulating video memory */
+#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "video.h"
@@ -114,7 +115,7 @@
int x1, x2;
int y1, y2;
{
- int l=0, i, j, eol, eos;
+ int l=0, i, j, eol, eos=0;
--maxlen; /* Account for trailing null */
for ( i=(x1-1); (i<x2 && l<maxlen); ++i ) {
@@ -320,7 +321,7 @@
void paint_video(win)
window *win;
{
- unsigned char change, on=NORMAL;
+ unsigned char on=NORMAL;
int i, j, oldattr=0;
vt_setscroll(0,0);
--- a/cut-paste.c
+++ b/cut-paste.c
@@ -3,8 +3,11 @@
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include "vt100.h"
#include "video.h"
+#include "splitvt.h"
+#include "terminal.h"
#define RIGHT 0x01
#define LEFT 0x02
@@ -87,7 +90,6 @@
int len;
position *mark1, *mark2;
{
- int selection=0;
position startsel, endsel;
if ( mark1->x == mark2->x )
@@ -201,9 +203,9 @@
void vt_initsel()
{
extern char *pathsearch(); /* From misc.c */
- char *display;
#ifdef USE_XCB
+ char *display;
/* Use xcb if we have both an X display and the command. */
/* xcb needs to support my hacked '-R' option. */
if ( (display=(char *)getenv("DISPLAY")) && pathsearch("xcb", 1) )
@@ -255,7 +257,7 @@
char *buf;
int len;
{
- int c, state=NORMAL;
+ int c;
position here, cursor, mark1, mark2;
window *thiswin;
@@ -312,7 +314,7 @@
default: break;
}
}
- return; /* Hopefully, we never reach here */
+ return NULL; /* Hopefully, we never reach here */
}
--- a/splitvt.man
+++ b/splitvt.man
@@ -176,7 +176,7 @@
replace it with entries for the two windows. This allows
you to use programs such as 'talk' within the splitvt win-
dows. If you do not have write permission to the
- /etc/utmp file, you will not be able to modify the utmp
+ /etc/utmp file, you will not be able to modify the utmp
entries.
splitvt can be made set-uid root. splitvt will reset its
--- a/config.c
+++ b/config.c
@@ -161,6 +161,7 @@
VERBOSE_PRINT("\tI will use wait4() instead of waitpid().\n");
}
+#if 0
if ( exists("/usr/lib", "libnet.a") ) /* Socket routines */
strcat(ldflags, " -lnet");
if ( exists("/usr/lib", "libnsl.a") ) /* AT&T socket library */
@@ -169,9 +170,10 @@
strcat(ldflags, " -lnsl_s");
if ( exists("/usr/lib", "libsun.a") ) /* IRIX yp routines */
strcat(ldflags, " -lsun");
+#endif
/* Tell the user what kind of configuration to do */
- if ( (access("/etc/utmp", (R_OK|W_OK)) == 0) && getuid() )
+ if ( (access("/var/run/utmp", (R_OK|W_OK)) == 0) && getuid() )
write_utmp=1;
else
write_utmp=0;
@@ -182,14 +184,14 @@
VERBOSE_PRINT(
"This program doesn't need to be installed set-uid root.\n");
VERBOSE_PRINT(
- "\nThis program will put entries for its windows in /etc/utmp.\n");
+ "\nThis program will put entries for its windows in /var/run/utmp.\n");
} else {
VERBOSE_PRINT(
- "If installed set-uid root, this program will put entries for its windows\nin /etc/utmp.\n");
+ "If installed set-uid root, this program will put entries for its windows\nin /var/run/utmp.\n");
}
} else if ( write_utmp ) {
VERBOSE_PRINT(
- "This program will put entries for its windows in /etc/utmp.\n");
+ "This program will put entries for its windows in /var/run/utmp.\n");
VERBOSE_PRINT(
"\nIf installed set-uid root, this program will change ownership of the\n");
VERBOSE_PRINT(
@@ -198,7 +200,7 @@
VERBOSE_PRINT(
"If installed set-uid root, this program will put entries for its windows\n");
VERBOSE_PRINT(
- "in /etc/utmp, and will also change ownership of the ttys it acquires to the\n");
+ "in /var/run/utmp, and will also change ownership of the ttys it acquires to the\n");
VERBOSE_PRINT(
"user running this program.\n");
}
@@ -227,13 +229,13 @@
}
fprintf(makefile,
"PTYOPTS = -DPTYCHAR=$(PTYCHAR) -DHEXDIGIT=$(HEXDIGIT)\n");
- sprintf(line, "\nCFLAGS = %s $(PTYOPTS)\nLIBS = %s\n", cflags, ldflags);
+ sprintf(line, "\nCFLAGS = -Wall %s $(PTYOPTS)\nLIBS = %s\n", cflags, ldflags);
fprintf(makefile, "%s", line);
fprintf(makefile, "OBJS = splitvt.o misc.o utmp.o vt100.o videomem.o terminal.o vttest.o vtmouse.o \\\n");
fprintf(makefile, " parserc.o lock.o cut-paste.o\n\n");
fprintf(makefile, "splitvt: $(OBJS)\n");
#if defined(linux) && !defined(DEBUG)
- fprintf(makefile, "\t$(CC) -s -o $@ $(OBJS) $(LIBS)\n");
+ fprintf(makefile, "\t$(CC) -o $@ $(OBJS) $(LIBS)\n");
#else
fprintf(makefile, "\t$(CC) -o $@ $(OBJS) $(LIBS)\n");
#endif
--- a/terminal.c
+++ b/terminal.c
@@ -4,9 +4,11 @@
actually write to the terminal.
*/
-
+#include <curses.h>
+#include <term.h>
#include <stdio.h>
#include <string.h>
+#include "splitvt.h"
#include "video.h"
#include "terminal.h"
@@ -126,7 +128,7 @@
}
return(NULL);
}
-void outc(c) int c; { putchar(c); }
+int outc(c) int c; { return putchar(c); }
void vt_rows_cols(termtype, rows, cols)
char *termtype;
--- a/vt100.c
+++ b/vt100.c
@@ -8,6 +8,9 @@
Many thanks to Matt Ostanik who wrote the ANSI Handbook.
*/
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_TERMIO_H
#include <termio.h> /* Used only for TIOCGWINSZ */
@@ -22,6 +25,7 @@
#include "vt100.h"
#include "video.h"
#include "terminal.h"
+#include "splitvt.h"
#define SEP_CHAR ' ' /* Separator bar character */
@@ -685,10 +689,9 @@
break;
case 3: /* 132 char/row */
if ( physical.cols != 132 ) {
- upper.cols=132;
- lower.cols=132;
physical.cols=132;
vt_widemode(1);
+ init_vt100(0);
}
break;
case 4: /* Set jump scroll */
@@ -728,11 +731,9 @@
break;
case 3: /* 80 char/row */
if ( physical.cols == 132 ) {
- vt_rows_cols(terminal_type,
- NULL, &physical.cols);
- upper.cols=physical.cols;
- lower.cols=physical.cols;
+ physical.cols = 80;
vt_widemode(0);
+ init_vt100(0);
}
break;
case 4: /* Set smooth scroll */
@@ -845,7 +846,8 @@
static int setup_vt100 = 0; /* Have we initialized the vt100 system? */
-char *init_vt100()
+char *init_vt100(reread_tsize)
+int reread_tsize;
{
#ifdef TIOCGWINSZ
struct /* winsize */ {
@@ -855,7 +857,7 @@
unsigned short ws_ypixel; /* vertical size - not used */
} mywinz;
#endif
- int i, **videomem, oldrows, newrows, newcols;
+ int i, **videomem, oldrows = 0, newrows, newcols;
position newpos;
char *ptr, *errmesg;
@@ -871,18 +873,22 @@
vt_initsel();
}
+ if (reread_tsize)
+ {
#ifdef TIOCGWINSZ
- if ( ioctl(0, TIOCGWINSZ, &mywinz) == 0 ) {
- if ( mywinz.ws_row )
- physical.rows=mywinz.ws_row;
- if ( mywinz.ws_col )
- physical.cols=mywinz.ws_col;
- }
+ if ( ioctl(0, TIOCGWINSZ, &mywinz) == 0 ) {
+ if ( mywinz.ws_row )
+ physical.rows=mywinz.ws_row;
+ if ( mywinz.ws_col )
+ physical.cols=mywinz.ws_col;
+ }
#endif
- if ( (ptr=(char *)getenv("LINES")) != NULL )
- physical.rows=atoi(ptr);
- if ( (ptr=(char *)getenv("COLUMNS")) != NULL )
- physical.cols=atoi(ptr);
+
+ if ( (ptr=(char *)getenv("LINES")) != NULL )
+ physical.rows=atoi(ptr);
+ if ( (ptr=(char *)getenv("COLUMNS")) != NULL )
+ physical.cols=atoi(ptr);
+ }
/* Now set defaults if we can't find the window size */
if ( ! physical.rows ) physical.rows=24;
@@ -894,19 +900,21 @@
if ( physical.rows < 7 )
return("Screen is not tall enough to split.");
- /* If physical.cols has been set to 132, assume we are on a
- vt100 wide terminal, and set 132 column mode. Note that
- setting COLUMNS in the environment will override termcap */
- if ( physical.cols == 132 )
- vt_widemode(1);
+ if ( ! setup_vt100 ) {
+ /* If physical.cols has been set to 132, assume we are on a
+ vt100 wide terminal, and set 132 column mode. Note that
+ setting COLUMNS in the environment will override termcap */
+ if ( physical.cols == 132 )
+ vt_widemode(1);
+ }
/* Set the exportable variables */
if ( UU_lines ) {
/* Check the user set # of lines */
- if ( UU_lines > (physical.rows-1-3) )
- LU_lines=(physical.rows-1-3);
- else if ( UU_lines < 3 )
- LU_lines=3;
+ if ( UU_lines > (physical.rows-1-3+(2*force_height)) )
+ LU_lines=(physical.rows-1-3+(2*force_height));
+ else if ( UU_lines < 3 - (2*force_height))
+ LU_lines=3 - (2*force_height);
else
LU_lines=UU_lines;
--- a/splitvt.h
+++ b/splitvt.h
@@ -37,3 +37,24 @@
/* Functions exported from splitvt.c */
extern void reset_bar();
+
+/* If set, allow resizing to less than 3 lines */
+extern int force_height;
+
+void tokenize(char *array[], int size, char *line, char *tokens);
+void d_copy(register char *src, register char *dst, register int len);
+int tty_getmode(int fd);
+int tty_raw(int fd);
+int tty_reset(int fd);
+int tty_sane(int fd);
+int remove_me(void);
+int pty_open(char *argv[], int *childpid, int win);
+int addutmp(char *user, int uid, char *tty);
+char *vt_setsel(char *buf, int len, int startx, int endx, int starty, int endy);
+int delutmp(char *user, char *tty);
+int replace_me(void);
+void pty_setwin(int fd, int win);
+void d_zero(register char *dst, register int len);
+void vt_initsel(void);
+int vttest(void);
+int safe_pclose(FILE *pipefp);
--- a/examples/menu
+++ b/examples/menu
@@ -3,17 +3,6 @@
# An example menu utilizing the SPLITVT environment variable.
#
-# Portably echo a line with no trailing newline:
-echo_n() {
- if [ "`echo -n \"\"`" = "" ]; then
- echo -n "$*"
- elif [ "`echo -e \"\\c\"`" == "" ]; then
- echo -e "$*\c"
- else
- echo "$*\c"
- fi
-}
-
if [ "$SPLITVT" = "upper" ]; then
echo "This is the upper window MENU:"
echo ""
@@ -21,7 +10,7 @@
echo "2) oranges"
echo "3) bananas"
echo ""
- echo_n "Enter your fruit of choice: "
+ printf "Enter your fruit of choice: "
read fruit
case $fruit in
1) echo "You like apples!";;
@@ -36,7 +25,7 @@
echo "2) carrots"
echo "3) cabbage"
echo ""
- echo_n "Enter your vegetable of choice: "
+ printf "Enter your vegetable of choice: "
read fruit
case $fruit in
1) echo "You like pickles!";;
|