1
/*===========================================================================
2
Copyright (C) 1986-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
.IDENTIFICATION twindel.c
32
.AUTHOR Francois Ochsenbein [ESO-IPG]
34
.KEYWORDS Window Management
35
.ENVIRONMENT TermWindows
36
.COMMENTS This module includes functions to insert or delete lines/chars.
39
.VERSION 1.0 29-Aug-1986: Creation
41
.VERSION 2.0 03-Dec-1986 New terminal-independant graphic characters
42
with output buffering version.
43
.VERSION 2.1 29-Jun-1987 Version '2'
45
.VERSION 3.0 20-Mar-1988: Version '3'
48
----------------------------------------------------------------------------*/
50
#define DEBUG 0 /* Only for debugging */
52
#define PM_LEVEL LEVEL_TW
54
#define TW_import 0 /* Do not use macro window definitions */
58
extern int tw_st(), tw_goto(), tw_chars(), tw_fill(), tw_r(), tw_copw();
59
extern int tv_buffer();
61
extern int pm_enter(), pm_iexit(), pm_ed_i();
65
MID_EXTERN WINDOW *Screen;
69
#define ENTER_DEBUG(x) ENTER(x)
70
#define EXIT_DEBUG(x) EXIT(x)
71
#define DISPLAY(opt) tw_ed(w,opt)
74
#define ENTER_DEBUG(x)
75
#define EXIT_DEBUG(x) return(x)
78
MID_STATIC int chars[2] = {0, 0};
84
/*======================================================================
86
*======================================================================*/
89
.PURPOSE Delete n chars on a specified window, pushing characters to the
91
.RETURNS OK / NOK (Not all characters deleted)
92
.REMARKS A negative number of times asks to delete chars at the left of
93
the cursor ( the cursor moves in this case).
94
The hardware `delete char' capability is not used.
95
Deleting is limited witin markers.
97
WINDOW *w; /* MOD: The window concerned */
98
int nchar; /* IN: Number of chars to delete */
106
TRACE_ED_STR2("Deleting Chars on Window: ", w->id, 8);
107
TRACE_ED_I("Chars: ", nchar);
115
if (n > chars[0]) n = chars[0], status = NOK;
119
else if (n > chars[1])
120
n = chars[1], status = NOK;
124
/* Copy the chars which are kept */
127
d = tw_copw(w, d, w, d+n, chars[1] - n);
129
/* Fill with blanks the rest of the line(s) */
131
tw_fill(w, d, n, w->attr_init);
138
/*==========================================================================
140
*==========================================================================*/
143
.PURPOSE Delete lines (moving up lines below) on a window,
144
including the current line
145
.RETURNS OK / NOK (not all lines deleted)
146
.REMARKS On return, the cursor is at the beginning of the current line.
147
If lines<0, lines on top of the current line are deleted.
149
WINDOW *w; /* MOD: The window concerned */
150
int lines; /* IN: Upper line of the scrolling region */
156
TRACE_ED_I("Delete Lines: ", lines);
158
n = lines, J = w->Nj, i = w->pos/J;
160
if ( (i + n) < 0) n = -i, status = NOK;
162
if ( (i + n) >= w->Ni) n = w->Ni - i, status = NOK;
168
if (n == 0) FINISH; /* The move to the line beginning is done */
170
n = ABSOLUTE(n); /* Number of deleted lines */
172
/* Update in Memory: First copy moved lines */
174
L = (w->Ni - n) * J - w->pos; /* Chars to copy */
175
L = tw_copw(w, w->pos, w, w->pos + n*J, L);
178
/* ... and clear bottom lines */
179
tw_fill(w, L, n*J, w->attr_init);
186
/*==========================================================================
188
*==========================================================================*/
191
.PURPOSE Insert blank lines (moving down lines below) on a window.
193
.REMARKS On return, the cursor is at the beginning of the current (blank) line.
194
If lines<0, lines are inserted on top of the current line.
196
WINDOW *w; /* MOD: The window concerned */
197
int lines; /* IN: Upper line of the scrolling region */
203
TRACE_ED_I("Insert lines: ", lines);
205
J = w->Nj, i = w->pos/J;
207
if (lines < 0) tw_goto(w, i + lines, 0), n = -lines;
208
else tw_goto(w, i, 0), n = lines;
210
if (n == 0) Return; /* The move to the line beginning is done */
212
if ( (n + i) > w->Ni) n = w->Ni - i;
214
/* Update in Memory: First copy moved lines */
216
L = (w->Ni - n) * J - w->pos; /* Chars to copy */
217
tw_copw(w, w->pos + n*J, w, w->pos, L);
219
/* ... and clear lines */
220
tw_fill(w, w->pos, n*J, w->attr_init);