Category : C Source Code
Archive   : WINDOW_C.ZIP
Filename : W_CLOSE.C

 
Output of file : W_CLOSE.C contained in archive : WINDOW_C.ZIP
/* w_close.c -- part of Windows package; contains w_close, w_unlink,
w_refresh, w_dispose
*/

#include
#include
#include "windows.h"

/*
** w_close() -- close an open window, removing from screen & linked list
** passed: pointer to window structure
** calls: w_unlink(), w_refresh()
** uses: layers_w
** notes: makes sure that the window is actually open, and that
** it's not main_w (i.e., that layers_w > 0); removes the
** window's record from the linked list of open windows,
** then re-draws the screen's open windows from the bottom
** layer up
*/

void w_close(w)
Window *w;
{
if (w->open && layers_w) {
w_unlink(w);
w_refresh();
}
}

/*
** w_unlink() -- removes a window pointer from the linked list
** passed: pointer to window structure
** sets: layers_w, top_w
** notes: this routine is called as part of the process of
** closing an open window; does not destroy storage for
** window's information; if the window was on top the
** window which was underneath becomes the top window;
** otherwise the window's previous neighbors on each side
** are spliced together to seal up the gap
*/

void w_unlink(w)
Window *w;
{
if (w == top_w) {
top_w = w->prev;
top_w->next = NULL;
}
else {
w->prev->next = w->next;
w->next->prev = w->prev;
}
layers_w--;
w->open = 0;
}

/*
** w_refresh() -- redraws the screen, working from the bottom window up
** calls: w_draw()
** uses: main_w
** notes: this routine is called to rebuild a screen when a
** window has been closed and removed from the display
*/

void w_refresh()
{
Window *w;

for (w = main_w; w != NULL; w = w->next)
w_draw(w);
}

/*
** w_dispose() -- frees up space used by window's information
** passed: pointer to window structure
** calls: w_close(), free()
** uses: main_w
** notes: makes sure the window is closed first; takes no
** action if called with main_w
*/

void w_dispose(w)
Window *w;
{
if (w == main_w)
return;
if (w->open)
w_close(w);
free((char *) w->data);
free((char *) w);
}



  3 Responses to “Category : C Source Code
Archive   : WINDOW_C.ZIP
Filename : W_CLOSE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/