/****************************************************************************
- * Copyright (c) 2006-2010,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 2006-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: movewindow.c,v 1.33 2012/01/15 00:30:35 tom Exp $
+ * $Id: movewindow.c,v 1.39 2013/05/04 19:41:02 tom Exp $
*
* Demonstrate move functions for windows and derived windows from the curses
* library.
static unsigned num_windows;
static FRAME *all_windows;
+static void
+failed(const char *s)
+{
+ perror(s);
+ endwin();
+ ExitProgram(EXIT_FAILURE);
+}
+
static void
message(int lineno, CONST_FMT char *fmt, va_list argp)
{
i = event.y - uli;
j = event.x - ulj;
}
- moved = TRUE;
} else {
beep();
break;
res.x = ulj + j;
return (&res);
}
- i %= si;
- j %= sj;
+
+ if (si <= 0)
+ i = 0;
+ else
+ i %= si;
+
+ if (sj <= 0)
+ j = 0;
+ else
+ j %= sj;
/*
* If the caller can handle continuous movement, return the result.
keypad(child, TRUE);
if (need > have) {
all_windows = typeRealloc(FRAME, need, all_windows);
+ if (!all_windows)
+ failed("add_window");
}
all_windows[num_windows].parent = parent;
all_windows[num_windows].child = child;
if (parent != 0) {
bool top = (parent == stdscr);
- if (!top) {
- int min_col = top ? COL_MIN : 0;
- int max_col = top ? COL_MAX : getmaxx(parent);
- int min_line = top ? LINE_MIN : 0;
- int max_line = top ? LINE_MAX : getmaxy(parent);
- PAIR *tmp;
- bool more;
-
- show_derwin(win);
- while ((tmp = selectcell(parent,
- win,
- min_line, min_col,
- max_line, max_col,
- TRUE,
- &more)) != 0) {
- int y0, x0;
-
- getbegyx(parent, y0, x0);
- if (mvderwin(win, tmp->y, tmp->x) != ERR) {
- refresh_all(win);
- doupdate();
- repaint_one(win);
- doupdate();
- result = TRUE;
- show_derwin(win);
- } else {
- flash();
- }
- if (!more)
- break;
+ int min_col = top ? COL_MIN : 0;
+ int max_col = top ? COL_MAX : getmaxx(parent);
+ int min_line = top ? LINE_MIN : 0;
+ int max_line = top ? LINE_MAX : getmaxy(parent);
+ PAIR *tmp;
+ bool more;
+
+ show_derwin(win);
+ while ((tmp = selectcell(parent,
+ win,
+ min_line, min_col,
+ max_line, max_col,
+ TRUE,
+ &more)) != 0) {
+ if (mvderwin(win, tmp->y, tmp->x) != ERR) {
+ refresh_all(win);
+ doupdate();
+ repaint_one(win);
+ doupdate();
+ result = TRUE;
+ show_derwin(win);
+ } else {
+ flash();
}
+ if (!more)
+ break;
}
}
head_line("done");
getmaxyx(win, y1, x1);
for (y = 0; y < y1; ++y) {
for (x = 0; x < x1; ++x) {
- MvWAddCh(win, y, x, ch);
+ MvWAddCh(win, y, x, (chtype) ch);
if (++ch > 'z')
ch = 'a';
}