1
/* @(#)edtformat.c 19.1 (ES0-DMD) 02/25/03 14:00:48 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/* @(#)edtformat.c 4.1.1.1 (ESO-IPG) 7/30/92 17:31:00 */
30
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34
.AUTHOR J.D.Ponz IPG-ESO Garching
35
.CATEGORY table editor
37
Find the column layout to the used for edition.
38
The variables updated are edt_nc (number of displayed
39
columns) and edt_column (indexes).
41
The routine is used when a new page is required.
42
There are three modes in the argument:
43
FIRSTPAGE, RIGHTPAGE and LEFTPAGE.
44
Put label information in the header and display header.
46
.RETURNS error status.
47
.VERSION 1.0 25-Mar-1988 Implementation JDP
48
.VERSION 1.1 24-Nov-1989 Modification labels edition, F.O.
49
------------------------------------------------------------*/
55
#include <macrogen.h> /* For MAX / MIN */
56
#include <proto_tbl.h>
58
static int offset = 9; /* Space used for the Sequence Number */
62
int mode /* IN : page mode */;
64
{ int status, len, dtype;
65
char form[10], ws[18];
66
int i, j, k, icol, imax, ind;
67
static char vertical = RuleChar(_VERTICAL_);
68
static char cross = CornerChar(_CROSS_);
75
case RESETPAGE: icol = edt_column[0]; break;
76
case PREVCOL: icol = edt_column[0]-1; break;
77
case NEXTCOL: icol = edt_column[1]; break;
78
/*? case RIGHTPAGE: icol = edt_column[edt_nc] + 1; break;*/
79
case RIGHTPAGE: icol = edt_column[edt_nc] ; break;
81
case LEFTPAGE: icol = 1; break;
85
if (icol == 0) icol =1;
86
while (imax < data_columns && icol <= edt_ncol)
87
{status = TCFGET(edt_tid, icol, ws, &len, &dtype);
88
FMT[ind].colno = icol;
89
FMT[ind].FIRST = imax;
90
FMT[ind].LAST = imax + len ;
91
imax = FMT[ind].LAST + 1;
92
strcpy(FMT[ind].FORMAT,ws);
93
status = TCLGET(edt_tid, icol, ws);
94
i = 0; while(ws[i] != ' ' &&ws[i] != '\0') i++; ws[i] = '\0';
95
strcpy(FMT[ind].LABEL,ws);
96
edt_column[ind] = icol;
100
if (imax >= data_columns) ind = ind - 1;
102
edt_width = FMT[edt_nc-1].LAST;
105
ClearWindow(header_window);
106
CursorTo(header_window, 0, 0);
107
Put(header_window,"Sequence");
109
for (i=0; i<ind; i++)
110
{k = FMT[i].FIRST + offset-1;
111
CursorTo(header_window,0,k);
112
SetAttr(header_window, _GRAPHICS_);
113
Write(header_window, &vertical, 1);
114
SetAttr(header_window, _NORMAL_);
115
len = strlen(FMT[i].LABEL);
116
len = MIN(len, FMT[i].LAST - FMT[i].FIRST);
117
Write(header_window, FMT[i].LABEL, len);
119
k = FMT[ind-1].LAST + offset;
120
CursorTo(header_window,0,k);
121
SetAttr(header_window, _GRAPHICS_);
122
Write(header_window, &vertical, 1);
123
SetAttr(header_window, _NORMAL_);
126
SetAttr(header_window, _GRAPHICS_);
127
CursorTo(header_window, 1, 0);
128
FillWindow(header_window, RuleChar(_HORIZONTAL_));
129
CursorTo(header_window, 1, offset);
130
Write(header_window, &cross, 1);
132
for (i=0; i<ind; i++)
133
{k = FMT[i].FIRST + offset-1;
134
len = FMT[i].LAST - FMT[i].FIRST;
135
CursorTo(header_window,1,k);
136
Write(header_window, &cross, 1);
137
Fill(header_window, RuleChar(_HORIZONTAL_),len);
140
if (edt_column[i] == edt_ncol) /* When at rightmost pos, Use Tee Char */
141
last_sep = TeeChar(_RIGHT_);
142
else last_sep = CornerChar(_CROSS_);
144
k = FMT[i].LAST + offset;
145
CursorTo(header_window,1,k);
146
Write(header_window, &last_sep, 1);
147
SetAttr(header_window, _NORMAL_);
148
if ( last_sep == TeeChar(_RIGHT_))
149
ClearRight(header_window);
150
else FillWindow(header_window, '.');
153
ActiveWindow(header_window);