+ PANEL *pan = 0;
+ int code;
+ short pair = (short) which;
+ short fg = (short) ((pair == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK);
+ short bg = pair;
+ int x0, y0, x1, y1;
+
+ init_pair(pair, fg, bg);
+
+ /* remove the old panel, if any */
+ my_remove_panel(pans, which);
+
+ /* get the position of one corner */
+ wmove(stdscr, getmaxy(stdscr) / 2, getmaxx(stdscr) / 2);
+ getyx(stdscr, y0, x0);
+ while ((code = get_position("First corner", "", which, &x0, &y0)) == 0) {
+ ;
+ }
+
+ if (code > 0) {
+ char also[80];
+ sprintf(also, " (first %d,%d)", y0, x0);
+ /* get the position of the opposite corner */
+ while ((code = get_position("Opposite corner",
+ also, which, &x1, &y1)) == 0) {
+ ;
+ }
+
+ if (code > 0) {
+ int tly = MIN(y0, y1);
+ int tlx = MIN(x0, x1);
+ pan = mkpanel(pair, ABS(y1 - y0) + 1, ABS(x1 - x0) + 1, tly, tlx);
+ /* finish */
+ myFill(pan);
+ pans[which] = pan;
+ pflush();
+ wmove(stdscr, y1, x1);
+ }
+ }
+}
+
+static void
+my_move_panel(PANEL ** pans, int which, bool continuous)
+{
+ if (pans[which] != 0) {
+ int code;
+ int y0, x0;
+ int y1, x1;
+ WINDOW *win = panel_window(pans[which]);
+ char also[80];
+
+ getbegyx(win, y0, x0);
+ sprintf(also, " (start %d,%d)", y0, x0);
+ wmove(stdscr, y0, x0);
+ while ((code = get_position("Move panel", also, which, &x1, &y1)) == 0) {
+ if (continuous) {
+ move_panel(pans[which], y1, x1);
+ pflush();
+ }
+ }
+ if (code > 0) {
+ move_panel(pans[which], y1, x1);
+ }
+ }
+}
+
+static void
+my_resize_panel(PANEL ** pans, int which, FillPanel myFill)
+{
+ if (pans[which] != 0) {
+ int code;
+ int y0, x0;
+ int y1, x1;
+ WINDOW *win = panel_window(pans[which]);
+ char also[80];
+
+ getbegyx(win, y0, x0);
+ sprintf(also, " (start %d,%d)", y0, x0);
+ wmove(stdscr, y0, x0);
+ while ((code = get_position("Resize panel",
+ also, which, &x1, &y1)) == 0) {
+ ;
+ }
+ if (code > 0) {
+ WINDOW *next = newwin(ABS(y1 - y0) + 1,
+ ABS(x1 - x0) + 1,
+ MIN(y0, y1),
+ MIN(x0, x1));
+ if (next != 0) {
+ keypad(next, TRUE);
+ if (use_colors) {
+ wbkgdset(next, (chtype) (COLOR_PAIR(which) | ' '));
+ } else if (!unboxed) {
+ wbkgdset(next, A_BOLD | ' ');
+ }
+ replace_panel(pans[which], next);
+ myFill(pans[which]);
+ delwin(win);
+ }
+ }
+ }
+}