Mercurial > illumos > onarm
annotate usr/src/cmd/fmli/qued/initfield.c @ 4:1a15d5aaf794
synchronized with onnv_86 (6202) in onnv-gate
author | Koji Uno <koji.uno@sun.com> |
---|---|
date | Mon, 31 Aug 2009 14:38:03 +0900 |
parents | c9caec207d52 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
5 * Common Development and Distribution License, Version 1.0 only | |
6 * (the "License"). You may not use this file except in compliance | |
7 * with the License. | |
8 * | |
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
10 * or http://www.opensolaris.org/os/licensing. | |
11 * See the License for the specific language governing permissions | |
12 * and limitations under the License. | |
13 * | |
14 * When distributing Covered Code, include this CDDL HEADER in each | |
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
16 * If applicable, add the following below this CDDL HEADER, with the | |
17 * fields enclosed by brackets "[]" replaced with your own identifying | |
18 * information: Portions Copyright [yyyy] [name of copyright owner] | |
19 * | |
20 * CDDL HEADER END | |
21 */ | |
22 | |
23 /* | |
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. | |
25 * Use is subject to license terms. | |
26 */ | |
27 | |
28 /* Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ | |
29 /* All Rights Reserved */ | |
30 | |
31 | |
4
1a15d5aaf794
synchronized with onnv_86 (6202) in onnv-gate
Koji Uno <koji.uno@sun.com>
parents:
0
diff
changeset
|
32 #pragma ident "%Z%%M% %I% %E% SMI" |
0 | 33 |
34 #include <stdio.h> | |
35 #include <curses.h> | |
36 #include "wish.h" | |
37 #include "terror.h" | |
38 #include "token.h" | |
39 #include "vtdefs.h" | |
40 #include "winp.h" | |
41 #include "fmacs.h" | |
42 #include "ctl.h" | |
43 #include "attrs.h" | |
44 | |
45 #define FSIZE(x) (x->rows * (x->cols + 1)) | |
46 | |
47 ifield *Cfld = NULL; | |
48 | |
49 ifield * | |
50 deffield() | |
51 { | |
52 int rows, cols, currow, curcol; | |
53 ifield *newfield(); | |
54 | |
55 /* | |
56 * Compute default values | |
57 */ | |
58 vt_ctl(VT_UNDEFINED, CTGETSIZ, &rows, &cols); | |
59 vt_ctl(VT_UNDEFINED, CTGETPOS, &currow, &curcol); | |
60 return(newfield(currow, curcol, rows, cols - curcol - 1, 0)); | |
61 } | |
62 | |
63 ifield * | |
64 newfield(firstrow, firstcol, rows, cols, flags) | |
65 int firstrow; | |
66 int firstcol; | |
67 int rows; | |
68 int cols; | |
69 int flags; | |
70 { | |
71 ifield *newfld; | |
72 | |
73 newfld = (ifield *)new(ifield); | |
74 newfld->frow = firstrow; | |
75 newfld->fcol = firstcol; | |
76 newfld->rows = rows; | |
77 newfld->cols = cols; | |
78 newfld->flags = flags; | |
79 newfld->currow = 0; | |
80 newfld->curcol = 0; | |
81 newfld->scrollbuf = NULL; | |
82 newfld->buffsize = 0; | |
83 newfld->buffoffset = 0; | |
84 newfld->bufflast = 0; | |
85 if (newfld->rows == 1) { | |
86 newfld->currtype = SINGLE; | |
87 if (newfld->flags & I_SCROLL) { | |
88 newfld->flags &= ~(I_WRAP); | |
89 newfld->cols -= 1; | |
90 } | |
91 } | |
92 else { | |
93 newfld->currtype = MULTI; | |
94 newfld->flags &= ~(I_BLANK); | |
95 } | |
96 if (newfld->flags & I_INVISIBLE) { | |
97 /* | |
98 * bit of a kludge to handle no-echo ... rather | |
99 * than putting characters into the window map, | |
100 * these characters are put DIRECTLY into the | |
101 * field value string and are NOT echoed to the | |
102 * screen. | |
103 */ | |
104 if ((newfld->value = (char *) malloc(FSIZE(newfld))) == NULL) | |
105 fatal(NOMEM, ""); | |
106 newfld->valptr = newfld->value; | |
107 } | |
108 else { | |
109 newfld->value = NULL; | |
110 newfld->valptr = NULL; | |
111 } | |
112 newfld->fieldattr = newfld->lastattr = | |
113 (newfld->flags & I_FILL ? Attr_underline: Attr_normal); | |
114 return(newfld); | |
115 } | |
116 | |
117 int | |
118 gotofield(fld, row, col) | |
119 ifield *fld; | |
120 int row; | |
121 int col; | |
122 { | |
123 if (fld != NULL) | |
124 Cfld = fld; | |
125 else if (!Cfld) | |
126 return (0); | |
127 if (row < 0 || col < 0) | |
128 fgo(Cfld->currow, Cfld->curcol); | |
129 else | |
130 fgo(row, col); | |
131 setarrows(); | |
132 return (0); | |
133 } | |
134 | |
135 int | |
136 endfield(fld) | |
137 ifield *fld; | |
138 { | |
139 if (fld == NULL) | |
140 fld = Cfld; | |
141 if (fld) { | |
142 if (fld->value != NULL) { | |
143 free(fld->value); | |
144 fld->value = fld->valptr = NULL; | |
145 } | |
146 if (fld->scrollbuf != NULL) { | |
147 free(fld->scrollbuf); | |
148 fld->scrollbuf = NULL; | |
149 } | |
150 free(fld); | |
151 } | |
152 if (fld == Cfld) | |
153 Cfld = NULL; /* terminating current field */ | |
154 return (0); | |
155 } |