Menu

[40d7ca]: / joe / w.h  Maximize  Restore  History

Download this file

272 lines (221 with data), 7.2 kB

  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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
* Window management
* Copyright
* (C) 1992 Joseph H. Allen
*
* This file is part of JOE (Joe's Own Editor)
*/
struct watom {
const char *context; /* Context name */
void (*disp)(W *w, int flg); /* Display window */
void (*follow)(W *w);/* Called to have window follow cursor */
int (*abort)(W *w); /* Common user functions */
int (*rtn)(W *w);
int (*type)(W *w, int k);
void (*resize)(W *w,ptrdiff_t width, ptrdiff_t height); /* Called when window changed size */
void (*move)(W *w, ptrdiff_t x, ptrdiff_t y); /* Called when window moved */
void (*ins)(W *w, B *b,off_t l,off_t n,int flg); /* Called on line insertions */
void (*del)(W *w, B *b,off_t l,off_t n,int flg); /* Called on line deletions */
int what; /* Type of this thing */
};
/* A screen with windows */
struct screen {
SCRN *t; /* Screen data on this screen is output to */
ptrdiff_t wind; /* Number of help lines on this screen */
W *topwin; /* Top-most window showing on screen */
W *curwin; /* Window cursor is in */
ptrdiff_t w, h; /* Width and height of this screen */
};
/* Buffer stack entry */
struct bstack {
struct bstack *next;
B *b;
P *top;
P *cursor;
};
/* A window (base class) */
struct window {
LINK(W) link; /* Linked list of windows in order they
appear on the screen */
Screen *t; /* Screen this thing is on */
ptrdiff_t x, y, w, h; /* Position and size of window */
/* Currently, x = 0, w = width of screen. */
/* y == -1 if window is not on screen */
ptrdiff_t ny, nh; /* Temporary values for wfit */
ptrdiff_t reqh; /* Requested new height or 0 for same */
/* This is an argument for wfit */
ptrdiff_t fixed; /* If this is zero, use 'hh'. If not, this
is a fixed size window and this variable
gives its height */
ptrdiff_t hh; /* Height window would be on a screen with
1000 lines. When the screen size changes
this is used to calculate the window's
real height */
W *win; /* Window this one operates on */
W *main; /* Main window of this family */
W *orgwin; /* Window where space from this window came */
ptrdiff_t curx, cury; /* Cursor position within window */
KBD *kbd; /* Keyboard handler for this window */
WATOM *watom; /* The type of this window */
void *object; /* Object which inherits this */
#if 0
union { /* FIXME: instead of void *object we should */
BW *bw; /* use this union to get strict type checking */
PW *pw; /* from C compiler (need to check and change */
QW *qw; /* all of the occurrencies of ->object) */
TW *tw;
MENU *menu;
BASE *base;
} object;
#endif
const char *msgt; /* Message at top of window */
const char *msgb; /* Message at bottom of window */
const char *huh; /* Name of window for context sensitive hlp */
int *notify; /* Address of kill notification flag */
struct bstack *bstack; /* Pushed buffer stack */
};
/* Anything which goes in window.object must start like this: */
struct base {
W *parent;
};
/***************/
/* Subroutines */
/***************/
/* int getgrouph(W *);
* Get height of a family of windows
*/
ptrdiff_t getgrouph(W *w);
/* W *findtopw(W *);
* Find first (top-most) window of a family
*/
W *findtopw(W *w);
/* W *findbotw(W *);
* Find last (bottom-most) window a family
*/
W *findbotw(W *w);
int demotegroup(W *w);
/* W *lastw(Screen *t);
* Find last window on screen
*/
W *lastw(Screen *t);
/* Determine number of main windows
*/
int countmain(Screen *t);
/* void wfit(Screen *t);
*
* Fit all of the windows onto the screen
*/
void wfit(Screen *t);
/* W *watpos(Screen *t, int x, int y);
* Return the window at the given location, or NULL if there is none
*/
W *watpos(Screen *t, ptrdiff_t x, ptrdiff_t y);
/*****************/
/* Main routines */
/*****************/
/* Screen *screate(SCRN *);
*
* Create a screen
*/
Screen *screate(SCRN *scrn);
/* void sresize(Screen *t);
* Screen size changed
*/
void sresize(Screen *t);
/* void chsize(Screen *t,int mul,int div)
* Resize windows: each window is multiplied by the fraction mul/div
*/
/* void chsize(); */
/* W *wcreate(Screen *t,WATOM *watom,W *where,W *target,W *original,int height);
*
* Try to create a window
*
* 't' Is the screen the window is placed on
* 'watom' Type of new window
* 'where' The window is placed after this window, or if 'where'==0, the
* window is placed on the end of the screen
* 'target' The window operates on this window. The window becomes a
* member of 'target's family or starts a new family if
* 'target'==0.
* 'original' Attempt to get 'height' from this window. When the window is
* aborted, the space gets returned to 'original' if it still
* exists. If 'original'==0, the window will force other
* windows to go off of the screen.
* 'height' The height of the window
*
* Returns the new window or returns 0 if there was not enough space to
* create the window and maintain family integrity.
*/
W *wcreate(Screen *t, WATOM *watom, W *where, W *target, W *original, ptrdiff_t height, const char *huh, int *notify);
/* int wabort(W *w);
*
* Kill a window and it's children
*/
int wabort(W *w);
/* int wnext(Screen *);
*
* Switch to next window
*/
int wnext(Screen *t);
/* int wprev(Screen *);
*
* Switch to previous window
*/
int wprev(Screen *t);
/* int wgrow(W *);
*
* increase size of window. Return 0 for success, -1 for fail.
*/
int wgrow(W *w);
/* int wshrink(W *);
*
* Decrease size of window. Returns 0 for success, -1 for fail.
*/
int wshrink(W *w);
int wgrowup(W *w);
int wgrowdown(W *w);
/* void wshowone(W *);
*
* Show only one window on the screen
*/
void wshowone(W *w);
/* void wshowall(Screen *);
*
* Show all windows on the screen, including the given one
*/
void wshowall(Screen *t);
/* void wredraw(W *);
*
* Force complete redraw of window
*/
void wredraw(W *w);
/* void updall()
*
* Redraw all windows
*/
void updall(void);
/* void msgnw[t](W *w, char *s);
* Display a message which will be eliminated on the next keypress.
* msgnw displays message on bottom line of window
* msgnwt displays message on top line of window
*/
void msgnw(W *w, const char *s);
void msgnwt(W *w, const char *s);
#define JOE_MSGBUFSIZE 300
extern char msgbuf[JOE_MSGBUFSIZE]; /* Message composition buffer for msgnw/msgnwt */
void msgout(W *w); /* Output msgnw/msgnwt messages */
void msgclr(W *w); /* Clear them */
/* Common user functions */
int urtn(W *w, int k); /* User hit return */
int utype(W *w, int k); /* User types a character */
int uretyp(W *w, int k); /* Refresh the screen */
int ugroww(W *w, int k); /* Grow current window */
int uexpld(W *w, int k); /* Explode current window or show all windows */
int ushrnk(W *w, int k); /* Shrink current window */
int unextw(W *w, int k); /* Goto next window */
int uprevw(W *w, int k); /* Goto previous window */
int umwind(W *w, int k); /* Go to message window */
int umfit(W *w, int k); /* Fit two windows on screen */
void scrdel(B *b, off_t l, off_t n, int flg);
void scrins(B *b, off_t l, off_t n, int flg);
extern int bg_msg; /* Background color for messages */
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.