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