+
+NCursesWindow NCursesWindow::Clone() {
+ WINDOW *d = ::dupwin(w);
+ NCursesWindow W(d);
+ W.subwins = subwins;
+ W.sib = sib;
+ W.par = par;
+ W.alloced = alloced;
+ return W;
+}
+
+typedef int (*RIPOFFINIT)(NCursesWindow&);
+static RIPOFFINIT R_INIT[5]; // There can't be more
+static int r_init_idx = 0;
+static RIPOFFINIT* prip = R_INIT;
+
+extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int));
+
+NCursesWindow::NCursesWindow(WINDOW *win, int cols) {
+ w = win;
+ assert((w->_maxx+1)==cols);
+ alloced = FALSE;
+ subwins = par = sib = 0;
+}
+
+int NCursesWindow::ripoff_init(WINDOW *w, int cols)
+{
+ int res = ERR;
+
+ RIPOFFINIT init = *prip++;
+ if (init) {
+ NCursesWindow* W = new NCursesWindow(w,cols);
+ res = init(*W);
+ }
+ return res;
+}
+
+int NCursesWindow::ripoffline(int ripoff_lines,
+ int (*init)(NCursesWindow& win)) {
+ int code = ::_nc_ripoffline(ripoff_lines,ripoff_init);
+ if (code==OK && init && ripoff_lines) {
+ R_INIT[r_init_idx++] = init;
+ }
+ return code;
+}