+ mvaddstr(win->start_y - 1, win->start_x + title_offset, title); }
+ refresh(); }
+
+void draw_windows_borders (struct Win * win, struct Win * win_active, struct Corners * corners, int ccount) {
+// Craw draw_window_borders() for all windows in chain from win on. Save current window's border corners.
+ char active = 0;
+ if (win == win_active)
+ active = 1;
+ draw_window_borders(win, active);
+ corners[ccount].tl_y = win->start_y - 1;
+ corners[ccount].tl_x = win->start_x - 1;
+ corners[ccount].tr_y = win->start_y - 1;
+ corners[ccount].tr_x = win->start_x + win->width;
+ corners[ccount].bl_y = win->start_y + win->height;
+ corners[ccount].bl_x = win->start_x - 1;
+ corners[ccount].br_y = win->start_y + win->height;
+ corners[ccount].br_x = win->start_x + win->width;
+ if (0 != win->next) {
+ draw_windows_borders (win->next, win_active, corners, ccount + 1); } }
+
+void draw_windows (struct Win * win) {
+// Draw contents of all windows in window chain from win on.
+ draw_window(win);
+ if (0 != win->next) {
+ draw_windows (win->next); } }
+
+void draw_all_windows (struct WinMeta * win_meta) {
+// Draw all windows and their borders.
+ int y, x;
+ for (y = 0; y < win_meta->height; y++)
+ for (x = 0; x < win_meta->width; x++)
+ mvaddch(y, x, ' ');
+ if (win_meta->chain_start) {
+ int n_wins = 1;
+ struct Win * win_p = win_meta->chain_start;
+ while (0 != win_p->next) {
+ win_p = win_p->next;
+ n_wins++; }
+ struct Corners * all_corners = malloc(sizeof(struct Corners) * n_wins);
+ draw_windows_borders (win_meta->chain_start, win_meta->active, all_corners, 0);
+ draw_windows (win_meta->chain_start);
+ for (y = 0; y < n_wins; y++) {
+ mvaddch(all_corners[y].tl_y, all_corners[y].tl_x, 'o');
+ mvaddch(all_corners[y].tr_y, all_corners[y].tr_x, 'o');
+ mvaddch(all_corners[y].bl_y, all_corners[y].bl_x, 'o');
+ mvaddch(all_corners[y].br_y, all_corners[y].br_x, 'o'); }
+ free(all_corners); } }
+
+void draw_window(struct Win * win) {
+// Draw window content if visible.