1/* $NetBSD: ex_screen.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */ 2/*- 3 * Copyright (c) 1993, 1994 4 * The Regents of the University of California. All rights reserved. 5 * Copyright (c) 1993, 1994, 1995, 1996 6 * Keith Bostic. All rights reserved. 7 * 8 * See the LICENSE file for redistribution information. 9 */ 10 11#include "config.h" 12 13#include <sys/cdefs.h> 14#if 0 15#ifndef lint 16static const char sccsid[] = "Id: ex_screen.c,v 10.12 2001/06/25 15:19:19 skimo Exp (Berkeley) Date: 2001/06/25 15:19:19 "; 17#endif /* not lint */ 18#else 19__RCSID("$NetBSD: ex_screen.c,v 1.4 2014/01/26 21:43:45 christos Exp $"); 20#endif 21 22#include <sys/types.h> 23#include <sys/queue.h> 24#include <sys/time.h> 25 26#include <bitstring.h> 27#include <limits.h> 28#include <stdio.h> 29#include <stdlib.h> 30#include <string.h> 31 32#include "../common/common.h" 33#include "../vi/vi.h" 34 35/* 36 * ex_bg -- :bg 37 * Hide the screen. 38 * 39 * PUBLIC: int ex_bg __P((SCR *, EXCMD *)); 40 */ 41int 42ex_bg(SCR *sp, EXCMD *cmdp) 43{ 44 return (vs_bg(sp)); 45} 46 47/* 48 * ex_fg -- :fg [file] 49 * Show the screen. 50 * 51 * PUBLIC: int ex_fg __P((SCR *, EXCMD *)); 52 */ 53int 54ex_fg(SCR *sp, EXCMD *cmdp) 55{ 56 SCR *nsp; 57 int newscreen; 58 59 newscreen = F_ISSET(cmdp, E_NEWSCREEN); 60 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen)) 61 return (1); 62 63 /* Set up the switch. */ 64 if (newscreen) { 65 sp->nextdisp = nsp; 66 F_SET(sp, SC_SSWITCH); 67 } 68 return (0); 69} 70 71/* 72 * ex_resize -- :resize [+-]rows 73 * Change the screen size. 74 * 75 * PUBLIC: int ex_resize __P((SCR *, EXCMD *)); 76 */ 77int 78ex_resize(SCR *sp, EXCMD *cmdp) 79{ 80 adj_t adj; 81 82 switch (FL_ISSET(cmdp->iflags, 83 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) { 84 case E_C_COUNT: 85 adj = A_SET; 86 break; 87 case E_C_COUNT | E_C_COUNT_NEG: 88 adj = A_DECREASE; 89 break; 90 case E_C_COUNT | E_C_COUNT_POS: 91 adj = A_INCREASE; 92 break; 93 default: 94 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); 95 return (1); 96 } 97 return (vs_resize(sp, cmdp->count, adj)); 98} 99 100/* 101 * ex_sdisplay -- 102 * Display the list of screens. 103 * 104 * PUBLIC: int ex_sdisplay __P((SCR *)); 105 */ 106int 107ex_sdisplay(SCR *sp) 108{ 109 GS *gp; 110 SCR *tsp; 111 int cnt, sep; 112 size_t col, len; 113 114 gp = sp->gp; 115 if ((tsp = TAILQ_FIRST(&gp->hq)) == NULL) { 116 msgq(sp, M_INFO, "149|No background screens to display"); 117 return (0); 118 } 119 120 col = len = sep = 0; 121 for (cnt = 1; tsp != NULL && !INTERRUPTED(sp); 122 tsp = TAILQ_NEXT(tsp, q)) { 123 col += len = strlen(tsp->frp->name) + sep; 124 if (col >= sp->cols - 1) { 125 col = len; 126 sep = 0; 127 (void)ex_puts(sp, "\n"); 128 } else if (cnt != 1) { 129 sep = 1; 130 (void)ex_puts(sp, " "); 131 } 132 (void)ex_puts(sp, tsp->frp->name); 133 ++cnt; 134 } 135 if (!INTERRUPTED(sp)) 136 (void)ex_puts(sp, "\n"); 137 return (0); 138} 139