File: mgr.trm

package info (click to toggle)
gnuplot 3.7.2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,212 kB
  • ctags: 4,635
  • sloc: ansic: 43,538; cpp: 970; makefile: 883; lisp: 661; sh: 578; asm: 539; objc: 379; csh: 297; pascal: 192; perl: 138
file content (241 lines) | stat: -rw-r--r-- 5,979 bytes parent folder | download | duplicates (2)
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
/*
 * Id: $
 */

/* GNUPLOT - mgr.trm */

/*[
 * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Mgr window system, color display
 *
 * AUTHOR
 *  Vincent Broman, broman@nosc.mil
 */
/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
register_term(mgr)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void MGR_init __PROTO((void));
TERM_PUBLIC void MGR_graphics __PROTO((void));
TERM_PUBLIC void MGR_text __PROTO((void));
TERM_PUBLIC void MGR_linetype __PROTO((int linetype));
TERM_PUBLIC void MGR_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void MGR_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void MGR_put_text __PROTO((unsigned int x, unsigned int y, char *str));
TERM_PUBLIC void MGR_reset __PROTO((void));
#define MGR_XMAX 640
#define MGR_YMAX 400
#define MGR_VCHAR 16
#define MGR_HCHAR 8
#define MGR_VTIC 4
#define MGR_HTIC 4
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
#undef ESC
#include <term.h>		/* from Mgr, not gnuplot */



static int MGR_border = 5;
static int MGR_winnbr = 0;

static int MGR_rowcount = 24;
static int MGR_winwidth = MGR_XMAX;
static int MGR_winheight = MGR_YMAX;
static int MGR_vchar = MGR_VCHAR;
static int MGR_hchar = MGR_HCHAR;


TERM_PUBLIC void MGR_init()
{
    char res[300];
    int winnbr;
    int w, h, bor;

    m_setup(0);
    m_ttyset();

    m_getinfo(G_SYSTEM);
    if (m_gets(res) && sscanf(res, "%*s%d%d%d", &w, &h, &bor) == 3)
	MGR_border = bor;

    m_newwin(0, 0, MGR_winwidth + 2 * MGR_border,
	     MGR_winheight + 2 * MGR_border);

    if (m_gets(res) && sscanf(res, "%d", &winnbr) == 1)
	MGR_winnbr = winnbr;

    /* if no alt window is created, then the main window is used
     * and if size is different, term_tbl updated later */
    m_selectwin(MGR_winnbr);
    m_setmode(M_ABS);

    m_getinfo(G_FONT);
    if (m_gets(res) && sscanf(res, "%d %d", &w, &h) == 2) {
	MGR_vchar = h;
	MGR_hchar = w;
    }
    m_ttyreset();

    term->v_char = MGR_vchar;
    term->h_char = MGR_hchar;
    term->v_tic = MGR_vchar / 4;
    term->h_tic = MGR_hchar / 2;

    m_selectwin(0);
    m_flush();
}


TERM_PUBLIC void MGR_graphics()
{
    char res[32];
    int c, r, w, h;

    m_selectwin(MGR_winnbr);
    m_setmode(M_ACTIVATE);
    m_clear();

    /* we permit the user to reshape the window arbitrarily.
       do_plot calls boundary to recheck the term_tbl for each plot */
    m_ttyset();
    m_getinfo(G_WINSIZE);
    if (m_gets(res) && sscanf(res, "%d %d", &c, &r) == 2)
	MGR_rowcount = r;
    m_getinfo(G_COORDS);
    if (m_gets(res) && sscanf(res, "%d %d %d %d", &c, &r, &w, &h) == 4) {
	term->xmax = MGR_winwidth = w;
	term->ymax = MGR_winheight = h;
    }
    m_ttyreset();
    m_flush();
}


TERM_PUBLIC void MGR_text()
{
    m_go(0, 0);
    m_aligntext();
    if (MGR_winnbr == 0)
	m_move(0, MGR_rowcount - 1);
    m_selectwin(0);
    m_flush();
}


TERM_PUBLIC void MGR_linetype(linetype)
int linetype;
{
/*
 * this mapping of colors is intended for a color sun on which
 * colors 0-23 are defined, 0 is white, 1 is black.
 */
    m_linecolor(B_SRC, (linetype < 0) ? 1 : (2 + (linetype % 22)));
}


TERM_PUBLIC void MGR_move(x, y)
unsigned int x, y;
{
    m_go(x, MGR_winheight - 1 - y);
}


TERM_PUBLIC void MGR_vector(x, y)
unsigned int x, y;
{
    m_draw(x, MGR_winheight - 1 - y);
}


TERM_PUBLIC void MGR_put_text(x, y, str)
unsigned int x, y;
char *str;
{
    MGR_move(x, y - MGR_vchar / 2);
    m_aligntext();
    m_printstr(str);
}


TERM_PUBLIC void MGR_reset()
{
    m_destroywin(MGR_winnbr);
    MGR_winnbr = 0;
    m_setmode(M_ACTIVATE);
    m_flush();
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(mgr_driver)
    "mgr", "Mgr window system",
    /* dimensions nominal, replaced during MGR_graphics call */
    MGR_XMAX, MGR_YMAX, MGR_VCHAR, MGR_HCHAR,
    MGR_VTIC, MGR_HTIC, options_null, MGR_init, MGR_reset,
    MGR_text, null_scale, MGR_graphics, MGR_move, MGR_vector,
    MGR_linetype, MGR_put_text, null_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(mgr_driver)

#undef LAST_TERM
#define LAST_TERM mgr_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(mgr)
"1 mgr",
"?commands set terminal mgr",
"?set terminal mgr",
"?set term mgr",
"?terminal mgr",
"?term mgr",
"?mgr",
" The `mgr` terminal driver supports the Mgr Window system.  It has no options."
END_HELP(mgr)
#endif