connwrap - initialize gnutls session in cw_connect
[centerim.git] / kkconsui / src / screenarea.cc
blob3d3c07f441c73da4cc3fccde6882d5a4c0099413
1 /*
3 * a class for saving and restoring screen areas
4 * $Id: screenarea.cc,v 1.1 2001/06/27 13:42:07 konst Exp $
6 * Copyright (C) 1999-2001 by Konstantin Klyagin <k@thekonst.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
25 #include "screenarea.h"
27 screenarea::screenarea() {
30 screenarea::screenarea(int fx1, int fy1, int fx2, int fy2) {
31 save(fx1, fy1, fx2, fy2);
34 screenarea::~screenarea() {
35 freebuffer();
38 void screenarea::save() {
39 save(0, 0, COLS, LINES);
42 void screenarea::save(int fx1, int fy1, int fx2, int fy2) {
43 int i;
44 chtype *line;
45 #ifdef HAVE_NCURSESW
46 wchar_t *line2;
47 #endif
49 freebuffer();
51 for(i = 0; i <= fy2-fy1; i++) {
52 line = new chtype[fx2-fx1+2];
53 #ifdef HAVE_NCURSESW
54 line2 = new wchar_t[fx2-fx1+2];
55 #endif
56 mvinchnstr(fy1+i, fx1, line, fx2-fx1+1);
57 #ifdef HAVE_NCURSESW
58 mvinnwstr(fy1+i, fx1, line2, fx2-fx1+1);
59 #endif
60 buffer.push_back(line);
61 #ifdef HAVE_NCURSESW
62 buffer2.push_back(line2);
63 #endif
66 x1 = fx1;
67 y1 = fy1;
68 x2 = fx2;
69 y2 = fy2;
72 void screenarea::restore() {
73 restore(x1, y1, x2, y2);
76 void screenarea::restore(int fx1, int fy1, int fx2, int fy2) {
77 vector<chtype *>::iterator i;
78 #ifdef HAVE_NCURSESW
79 vector<wchar_t *>::iterator j;
80 #endif
81 int k = fy1;
82 chtype *line;
83 #ifdef HAVE_NCURSESW
84 wchar_t *line2;
85 #endif
86 int l;
87 if(!buffer.empty()) {
88 #ifdef HAVE_NCURSESW
89 for(i = buffer.begin(), j = buffer2.begin(); i != buffer.end(); i++, j++) {
90 #else
91 for(i = buffer.begin(); i != buffer.end(); i++) {
92 #endif
93 line = *i;
94 #ifdef HAVE_NCURSESW
95 line2 = *j;
96 const chtype *line_ptr = line;
97 const wchar_t *line2_ptr = line2;
98 for(l = 0; l < fx2-fx1+1; l++, line_ptr++, line2_ptr++ )
100 attrset( (*line_ptr & A_COLOR) | (*line_ptr & A_ATTRIBUTES) );
101 mvaddnwstr(k, fx1+l, line2_ptr, 1);
103 k++;
104 #else
105 mvaddchnstr(k++, fx1, line, fx2-fx1+1);
106 #endif
110 refresh();
113 freebuffer();
116 void screenarea::freebuffer() {
117 while(!buffer.empty()) {
118 delete[] buffer.front();
119 buffer.erase(buffer.begin());
121 #ifdef HAVE_NCURSESW
122 while(!buffer2.empty()) {
123 delete[] buffer2.front();
124 buffer2.erase(buffer2.begin());
126 #endif
129 bool screenarea::empty() {
130 return buffer.empty();