~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to prim/edit/libsrc/edtformat.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)edtformat.c      19.1 (ES0-DMD) 02/25/03 14:00:48 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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, 
 
18
  MA 02139, USA.
 
19
 
 
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 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/* @(#)edtformat.c      4.1.1.1 (ESO-IPG) 7/30/92 17:31:00 */
 
30
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
31
.TYPE        Module
 
32
.NAME        edtformat.c
 
33
.LANGUAGE    C
 
34
.AUTHOR      J.D.Ponz  IPG-ESO Garching
 
35
.CATEGORY    table editor
 
36
.PURPOSE
 
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).
 
40
 
 
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.
 
45
 
 
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
------------------------------------------------------------*/
 
50
 
 
51
#include <tbldef.h>
 
52
#include <tbledt.h>
 
53
#include <tfmdef.h>
 
54
#include <tblfmt.h>
 
55
#include <macrogen.h>           /* For MAX / MIN */
 
56
#include <proto_tbl.h>
 
57
 
 
58
static int offset = 9;          /* Space used for the Sequence Number */
 
59
 
 
60
   int edt_format(mode)
 
61
 
 
62
   int  mode                       /* IN : page mode */;
 
63
 
 
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_);
 
69
   char         last_sep;
 
70
 
 
71
   status = 0;
 
72
   
 
73
 
 
74
   switch (mode) {
 
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;
 
80
          case FIRSTPAGE:
 
81
          case LEFTPAGE:   icol = 1;                             break;
 
82
          }
 
83
   imax = 0; ind = 0;
 
84
 
 
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;
 
97
        icol++;
 
98
        ind++;
 
99
       }
 
100
   if (imax >= data_columns) ind = ind - 1;
 
101
   edt_nc = ind;
 
102
   edt_width = FMT[edt_nc-1].LAST;
 
103
   
 
104
 
 
105
   ClearWindow(header_window);
 
106
   CursorTo(header_window, 0, 0);
 
107
   Put(header_window,"Sequence");
 
108
                                        /* include labels */
 
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);
 
118
       }
 
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_);
 
124
 
 
125
 
 
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);
 
131
   
 
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);
 
138
       }
 
139
   i = ind - 1;
 
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_); 
 
143
 
 
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, '.');
 
151
 
 
152
 
 
153
   ActiveWindow(header_window);
 
154
 
 
155
   return (status);
 
156
}