mirror of
https://git.zap.org.au/git/trader.git
synced 2025-02-02 15:08:13 -05:00
Rename pr_left, pr_center and pr_right to leftch, centerch and rightch
This commit is contained in:
parent
907a995b98
commit
a6c362d2e8
26
src/game.c
26
src/game.c
@ -117,7 +117,7 @@ void init_game (void)
|
|||||||
WIN_COLS - 7, &width, 1,
|
WIN_COLS - 7, &width, 1,
|
||||||
"Loading game %d... ", game_num);
|
"Loading game %d... ", game_num);
|
||||||
newtxwin(5, width + 5, 6, WCENTER, true, attr_status_window);
|
newtxwin(5, width + 5, 6, WCENTER, true, attr_status_window);
|
||||||
pr_center(curwin, 2, 0, chbuf, 1, &width);
|
centerch(curwin, 2, 0, chbuf, 1, &width);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
game_loaded = load_game(game_num);
|
game_loaded = load_game(game_num);
|
||||||
@ -152,7 +152,7 @@ void init_game (void)
|
|||||||
0, 0, 1, WIN_COLS - 7, &width, 1,
|
0, 0, 1, WIN_COLS - 7, &width, 1,
|
||||||
"Loading game %d... ", game_num);
|
"Loading game %d... ", game_num);
|
||||||
newtxwin(5, width + 5, 9, WCENTER, true, attr_status_window);
|
newtxwin(5, width + 5, 9, WCENTER, true, attr_status_window);
|
||||||
pr_center(curwin, 2, 0, chbuf, 1, &width);
|
centerch(curwin, 2, 0, chbuf, 1, &width);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
game_loaded = load_game(game_num);
|
game_loaded = load_game(game_num);
|
||||||
@ -258,7 +258,7 @@ static int ask_number_players (void)
|
|||||||
maxwidth = ((lines == 1) ? widthbuf[0] : MAX(widthbuf[0], widthbuf[1])) + 5;
|
maxwidth = ((lines == 1) ? widthbuf[0] : MAX(widthbuf[0], widthbuf[1])) + 5;
|
||||||
|
|
||||||
newtxwin(lines + 4, maxwidth, 3, WCENTER, true, attr_normal_window);
|
newtxwin(lines + 4, maxwidth, 3, WCENTER, true, attr_normal_window);
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, widthbuf);
|
leftch(curwin, 2, 2, chbuf, lines, widthbuf);
|
||||||
free(chbuf);
|
free(chbuf);
|
||||||
|
|
||||||
curs_set(CURS_ON);
|
curs_set(CURS_ON);
|
||||||
@ -323,7 +323,7 @@ int ask_game_number (void)
|
|||||||
maxwidth = ((lines == 1) ? widthbuf[0] : MAX(widthbuf[0], widthbuf[1])) + 5;
|
maxwidth = ((lines == 1) ? widthbuf[0] : MAX(widthbuf[0], widthbuf[1])) + 5;
|
||||||
|
|
||||||
newtxwin(lines + 4, maxwidth, 6, WCENTER, true, attr_normal_window);
|
newtxwin(lines + 4, maxwidth, 6, WCENTER, true, attr_normal_window);
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, widthbuf);
|
leftch(curwin, 2, 2, chbuf, lines, widthbuf);
|
||||||
free(chbuf);
|
free(chbuf);
|
||||||
|
|
||||||
curs_set(CURS_ON);
|
curs_set(CURS_ON);
|
||||||
@ -393,7 +393,7 @@ void ask_player_names (void)
|
|||||||
"Do you need any instructions? [^{Y^}/^{N^}] ");
|
"Do you need any instructions? [^{Y^}/^{N^}] ");
|
||||||
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
|
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
|
||||||
attr_normal_window);
|
attr_normal_window);
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, &width);
|
leftch(curwin, 2, 2, chbuf, lines, &width);
|
||||||
free(chbuf);
|
free(chbuf);
|
||||||
if (answer_yesno(curwin)) {
|
if (answer_yesno(curwin)) {
|
||||||
show_help();
|
show_help();
|
||||||
@ -413,7 +413,7 @@ void ask_player_names (void)
|
|||||||
true, attr_normal_window);
|
true, attr_normal_window);
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 8,
|
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 8,
|
||||||
&width, 1, " Enter Player Names ");
|
&width, 1, " Enter Player Names ");
|
||||||
pr_center(curwin, 1, 0, chbuf, lines, &width);
|
centerch(curwin, 1, 0, chbuf, lines, &width);
|
||||||
|
|
||||||
for (i = 0; i < number_players; i++) {
|
for (i = 0; i < number_players; i++) {
|
||||||
player[i].name = NULL;
|
player[i].name = NULL;
|
||||||
@ -499,7 +499,7 @@ void ask_player_names (void)
|
|||||||
"Does any player need instructions? [^{Y^}/^{N^}] ");
|
"Does any player need instructions? [^{Y^}/^{N^}] ");
|
||||||
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
|
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
|
||||||
attr_normal_window);
|
attr_normal_window);
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, &width);
|
leftch(curwin, 2, 2, chbuf, lines, &width);
|
||||||
if (answer_yesno(curwin)) {
|
if (answer_yesno(curwin)) {
|
||||||
show_help();
|
show_help();
|
||||||
}
|
}
|
||||||
@ -606,13 +606,13 @@ void show_map (bool closewin)
|
|||||||
lines = mkchstr(chbuf, BUFSIZE, attr_mapwin_title, attr_mapwin_highlight,
|
lines = mkchstr(chbuf, BUFSIZE, attr_mapwin_title, attr_mapwin_highlight,
|
||||||
0, 1, WIN_COLS - 4, &width, 1, " Player: ^{%s^} ",
|
0, 1, WIN_COLS - 4, &width, 1, " Player: ^{%s^} ",
|
||||||
player[current_player].name);
|
player[current_player].name);
|
||||||
pr_left(curwin, 1, 2, chbuf, lines, &width);
|
leftch(curwin, 1, 2, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_mapwin_title, attr_mapwin_highlight,
|
lines = mkchstr(chbuf, BUFSIZE, attr_mapwin_title, attr_mapwin_highlight,
|
||||||
attr_mapwin_blink, 1, WIN_COLS / 2, &width, 1,
|
attr_mapwin_blink, 1, WIN_COLS / 2, &width, 1,
|
||||||
(turn_number != max_turn) ? " Turn: ^{%d^} " :
|
(turn_number != max_turn) ? " Turn: ^{%d^} " :
|
||||||
" ^[*** Last Turn ***^] ", turn_number);
|
" ^[*** Last Turn ***^] ", turn_number);
|
||||||
pr_right(curwin, 1, WIN_COLS - 2, chbuf, lines, &width);
|
rightch(curwin, 1, WIN_COLS - 2, chbuf, lines, &width);
|
||||||
|
|
||||||
wattrset(curwin, attr_map_window);
|
wattrset(curwin, attr_map_window);
|
||||||
|
|
||||||
@ -681,19 +681,19 @@ void show_status (int num)
|
|||||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 4,
|
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 4,
|
||||||
&width, 1, " Stock Portfolio ");
|
&width, 1, " Stock Portfolio ");
|
||||||
pr_center(curwin, 1, 0, chbuf, lines, &width);
|
centerch(curwin, 1, 0, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0, 1,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0, 1,
|
||||||
WIN_COLS - 4, &width, 1, "Player: ^{%s^}",
|
WIN_COLS - 4, &width, 1, "Player: ^{%s^}",
|
||||||
player[num].name);
|
player[num].name);
|
||||||
pr_center(curwin, 2, 0, chbuf, lines, &width);
|
centerch(curwin, 2, 0, chbuf, lines, &width);
|
||||||
|
|
||||||
val = total_value(num);
|
val = total_value(num);
|
||||||
if (val == 0.0) {
|
if (val == 0.0) {
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight,
|
||||||
attr_blink, 1, WIN_COLS - 4, &width, 1,
|
attr_blink, 1, WIN_COLS - 4, &width, 1,
|
||||||
"^[* * * B A N K R U P T * * *^]");
|
"^[* * * B A N K R U P T * * *^]");
|
||||||
pr_center(curwin, 11, 0, chbuf, lines, &width);
|
centerch(curwin, 11, 0, chbuf, lines, &width);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char *buf = xmalloc(BUFSIZE);
|
char *buf = xmalloc(BUFSIZE);
|
||||||
@ -711,7 +711,7 @@ void show_status (int num)
|
|||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0,
|
||||||
1, WIN_COLS - 4, &width, 1,
|
1, WIN_COLS - 4, &width, 1,
|
||||||
"No companies on the map");
|
"No companies on the map");
|
||||||
pr_center(curwin, 8, 0, chbuf, lines, &width);
|
centerch(curwin, 8, 0, chbuf, lines, &width);
|
||||||
} else {
|
} else {
|
||||||
// Handle the locale's currency symbol
|
// Handle the locale's currency symbol
|
||||||
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);
|
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);
|
||||||
|
12
src/help.c
12
src/help.c
@ -205,12 +205,12 @@ void show_help (void)
|
|||||||
werase(curwin);
|
werase(curwin);
|
||||||
wbkgd(curwin, attr_normal_window);
|
wbkgd(curwin, attr_normal_window);
|
||||||
box(curwin, 0, 0);
|
box(curwin, 0, 0);
|
||||||
pr_center(curwin, 1, 0, ch_title, ln_title, &w_title);
|
centerch(curwin, 1, 0, ch_title, ln_title, &w_title);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0, 1,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0, 1,
|
||||||
WIN_COLS - 4, &width, 1, "Page %d of %d",
|
WIN_COLS - 4, &width, 1, "Page %d of %d",
|
||||||
curpage + 1, numpages);
|
curpage + 1, numpages);
|
||||||
pr_center(curwin, 2, 0, chbuf, lines, &width);
|
centerch(curwin, 2, 0, chbuf, lines, &width);
|
||||||
wmove(curwin, 4, 2);
|
wmove(curwin, 4, 2);
|
||||||
|
|
||||||
// Process the help text string
|
// Process the help text string
|
||||||
@ -356,11 +356,11 @@ void show_help (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curpage == 0) {
|
if (curpage == 0) {
|
||||||
pr_center(curwin, getmaxy(curwin) - 2, 0, ch_contfirst,
|
centerch(curwin, getmaxy(curwin) - 2, 0, ch_contfirst,
|
||||||
ln_contfirst, &w_contfirst);
|
ln_contfirst, &w_contfirst);
|
||||||
} else {
|
} else {
|
||||||
pr_center(curwin, getmaxy(curwin) - 2, 0, ch_contnext,
|
centerch(curwin, getmaxy(curwin) - 2, 0, ch_contnext,
|
||||||
ln_contnext, &w_contnext);
|
ln_contnext, &w_contnext);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
58
src/intf.c
58
src/intf.c
@ -418,7 +418,7 @@ void init_title (void)
|
|||||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_game_title, 0, 0, 1, COLS,
|
lines = mkchstr(chbuf, BUFSIZE, attr_game_title, 0, 0, 1, COLS,
|
||||||
&width, 1, _("Star Traders"));
|
&width, 1, _("Star Traders"));
|
||||||
pr_center(stdscr, 0, 0, chbuf, lines, &width);
|
centerch(stdscr, 0, 0, chbuf, lines, &width);
|
||||||
attrset(attr_root_window);
|
attrset(attr_root_window);
|
||||||
free(chbuf);
|
free(chbuf);
|
||||||
}
|
}
|
||||||
@ -626,11 +626,11 @@ int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
|
|||||||
|
|
||||||
titlelines = mkchstr(titlebuf, BUFSIZE, title_attr, 0, 0, 1,
|
titlelines = mkchstr(titlebuf, BUFSIZE, title_attr, 0, 0, 1,
|
||||||
ncols - 4, &titlewidth, 1, boxtitle);
|
ncols - 4, &titlewidth, 1, boxtitle);
|
||||||
pr_center(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
|
centerch(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
|
||||||
free(titlebuf);
|
free(titlebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_center(curwin, usetitle ? 3 : 2, 0, chbuf, lines, widthbuf);
|
centerch(curwin, usetitle ? 3 : 2, 0, chbuf, lines, widthbuf);
|
||||||
wait_for_key(curwin, getmaxy(curwin) - 2, keywait_attr);
|
wait_for_key(curwin, getmaxy(curwin) - 2, keywait_attr);
|
||||||
deltxwin();
|
deltxwin();
|
||||||
|
|
||||||
@ -1202,19 +1202,19 @@ error:
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// chstrdup: Duplicate a chtype buffer
|
// chstrdup: Duplicate a chtype buffer
|
||||||
|
|
||||||
chtype *chstrdup (const chtype *restrict chbuf, int chbufsize)
|
chtype *chstrdup (const chtype *restrict chstr, int chstrsize)
|
||||||
{
|
{
|
||||||
const chtype *p;
|
const chtype *p;
|
||||||
int len;
|
int len;
|
||||||
chtype *ret;
|
chtype *ret;
|
||||||
|
|
||||||
|
|
||||||
// Determine chbuf length, including ending NUL
|
// Determine chstr length, including ending NUL
|
||||||
for (len = 1, p = chbuf; *p != '\0' && len <= chbufsize; p++, len++)
|
for (len = 1, p = chstr; *p != '\0' && len <= chstrsize; p++, len++)
|
||||||
;
|
;
|
||||||
|
|
||||||
ret = xmalloc(len * sizeof(chtype));
|
ret = xmalloc(len * sizeof(chtype));
|
||||||
memcpy(ret, chbuf, len * sizeof(chtype));
|
memcpy(ret, chstr, len * sizeof(chtype));
|
||||||
ret[len - 1] = '\0'; // Terminating NUL, just in case not present
|
ret[len - 1] = '\0'; // Terminating NUL, just in case not present
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1222,22 +1222,22 @@ chtype *chstrdup (const chtype *restrict chbuf, int chbufsize)
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// pr_left: Print strings in chbuf left-aligned
|
// leftch: Print strings in chstr left-aligned
|
||||||
|
|
||||||
int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
int leftch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||||
int lines, const int *restrict widthbuf)
|
int lines, const int *restrict widthbuf)
|
||||||
{
|
{
|
||||||
assert(win != NULL);
|
assert(win != NULL);
|
||||||
assert(chbuf != NULL);
|
assert(chstr != NULL);
|
||||||
assert(lines > 0);
|
assert(lines > 0);
|
||||||
assert(widthbuf != NULL);
|
assert(widthbuf != NULL);
|
||||||
|
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
for ( ; *chbuf != '\0'; chbuf++) {
|
for ( ; *chstr != '\0'; chstr++) {
|
||||||
if (*chbuf == '\n') {
|
if (*chstr == '\n') {
|
||||||
wmove(win, getcury(win) + 1, x);
|
wmove(win, getcury(win) + 1, x);
|
||||||
} else {
|
} else {
|
||||||
waddch(win, *chbuf);
|
waddch(win, *chstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1246,22 +1246,22 @@ int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// pr_center: Print strings in chbuf centred in window
|
// centerch: Print strings in chstr centred in window
|
||||||
|
|
||||||
int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
|
int centerch (WINDOW *win, int y, int offset, const chtype *restrict chstr,
|
||||||
int lines, const int *restrict widthbuf)
|
int lines, const int *restrict widthbuf)
|
||||||
{
|
{
|
||||||
int ln = 0;
|
int ln = 0;
|
||||||
|
|
||||||
|
|
||||||
assert(win != NULL);
|
assert(win != NULL);
|
||||||
assert(chbuf != NULL);
|
assert(chstr != NULL);
|
||||||
assert(lines > 0);
|
assert(lines > 0);
|
||||||
assert(widthbuf != NULL);
|
assert(widthbuf != NULL);
|
||||||
|
|
||||||
wmove(win, y, (getmaxx(win) - widthbuf[ln]) / 2 + offset);
|
wmove(win, y, (getmaxx(win) - widthbuf[ln]) / 2 + offset);
|
||||||
for ( ; *chbuf != '\0'; chbuf++) {
|
for ( ; *chstr != '\0'; chstr++) {
|
||||||
if (*chbuf == '\n') {
|
if (*chstr == '\n') {
|
||||||
if (ln++ >= lines) {
|
if (ln++ >= lines) {
|
||||||
return ERR;
|
return ERR;
|
||||||
} else {
|
} else {
|
||||||
@ -1269,7 +1269,7 @@ int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
|
|||||||
(getmaxx(win) - widthbuf[ln]) / 2 + offset);
|
(getmaxx(win) - widthbuf[ln]) / 2 + offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
waddch(win, *chbuf);
|
waddch(win, *chstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1278,29 +1278,29 @@ int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// pr_right: Print strings in chbuf right-aligned
|
// rightch: Print strings in chstr right-aligned
|
||||||
|
|
||||||
int pr_right (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||||
int lines, const int *restrict widthbuf)
|
int lines, const int *restrict widthbuf)
|
||||||
{
|
{
|
||||||
int ln = 0;
|
int ln = 0;
|
||||||
|
|
||||||
|
|
||||||
assert(win != NULL);
|
assert(win != NULL);
|
||||||
assert(chbuf != NULL);
|
assert(chstr != NULL);
|
||||||
assert(lines > 0);
|
assert(lines > 0);
|
||||||
assert(widthbuf != NULL);
|
assert(widthbuf != NULL);
|
||||||
|
|
||||||
wmove(win, y, x - widthbuf[ln]);
|
wmove(win, y, x - widthbuf[ln]);
|
||||||
for ( ; *chbuf != '\0'; chbuf++) {
|
for ( ; *chstr != '\0'; chstr++) {
|
||||||
if (*chbuf == '\n') {
|
if (*chstr == '\n') {
|
||||||
if (ln++ >= lines) {
|
if (ln++ >= lines) {
|
||||||
return ERR;
|
return ERR;
|
||||||
} else {
|
} else {
|
||||||
wmove(win, getcury(win) + 1, x - widthbuf[ln]);
|
wmove(win, getcury(win) + 1, x - widthbuf[ln]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
waddch(win, *chbuf);
|
waddch(win, *chstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2449,7 +2449,7 @@ void wait_for_key (WINDOW *win, int y, chtype attr)
|
|||||||
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr, 0, 0, 1, getmaxx(win) - 4,
|
lines = mkchstr(chbuf, BUFSIZE, attr, 0, 0, 1, getmaxx(win) - 4,
|
||||||
&width, 1, _("[ Press <SPACE> to continue ] "));
|
&width, 1, _("[ Press <SPACE> to continue ] "));
|
||||||
pr_center(win, y, 0, chbuf, lines, &width);
|
centerch(win, y, 0, chbuf, lines, &width);
|
||||||
wrefresh(win);
|
wrefresh(win);
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
|
74
src/intf.h
74
src/intf.h
@ -303,14 +303,14 @@ extern int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
|
|||||||
Returns: int - Number of lines actually used
|
Returns: int - Number of lines actually used
|
||||||
|
|
||||||
This function converts the format string and following arguments into
|
This function converts the format string and following arguments into
|
||||||
chbuf, a chtype buffer that can be used for calls to pr_left(),
|
chbuf, a chtype buffer that can be used for calls to leftch(), centerch()
|
||||||
pr_center() and pr_right(). At most maxlines lines are used, each with
|
and rightch(). At most maxlines lines are used, each with a maximum
|
||||||
a maximum width of maxwidth. The actual widths of each resulting line
|
width of maxwidth. The actual widths of each resulting line are stored
|
||||||
are stored in widthbuf (which must not be NULL). If maxlines is
|
in widthbuf (which must not be NULL). If maxlines is greater than 1,
|
||||||
greater than 1, lines are wrapped as needed.
|
lines are wrapped as needed.
|
||||||
|
|
||||||
The format string is similar to but more limited than printf(). In
|
The format string is similar to but more limited than printf(). In
|
||||||
particular, the following conversion specifiers are understood:
|
particular, only the following conversion specifiers are understood:
|
||||||
|
|
||||||
%% - Print the ASCII percent sign (ASCII code U+0025)
|
%% - Print the ASCII percent sign (ASCII code U+0025)
|
||||||
|
|
||||||
@ -404,60 +404,60 @@ extern chtype *chstrdup (const chtype *restrict chstr, int chstrsize);
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: pr_left - Print strings in chbuf left-aligned
|
Function: leftch - Print strings in chstr left-aligned
|
||||||
Parameters: win - Window to use (should be curwin)
|
Parameters: win - Window to use (should be curwin)
|
||||||
y - Line on which to print first string
|
y - Line on which to print first string
|
||||||
x - Starting column number for each line
|
x - Starting column number for each line
|
||||||
chbuf - chtype buffer as returned from mkchstr()
|
chstr - chtype string as returned from mkchstr()
|
||||||
lines - Number of lines in chbuf (as returned from mkchstr())
|
lines - Number of lines in chstr as returned from mkchstr()
|
||||||
widthbuf - Widths of each line (as returned from mkchstr())
|
widthbuf - Widths of each line as returned from mkchstr()
|
||||||
Returns: int - Error code OK
|
Returns: int - Error code OK
|
||||||
|
|
||||||
This function takes the strings in the chtype array chbuf and prints
|
This function takes the strings in the chtype array chstr and prints
|
||||||
them left-aligned in the window win. Note that wrefresh() is NOT
|
them left-aligned in the window win. Note that wrefresh() is NOT
|
||||||
called.
|
called.
|
||||||
*/
|
*/
|
||||||
extern int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
extern int leftch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||||
int lines, const int *restrict widthbuf);
|
int lines, const int *restrict widthbuf);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: pr_center - Print strings in chbuf centred in window
|
Function: centerch - Print strings in chstr centred in window
|
||||||
Parameters: win - Window to use (should be curwin)
|
Parameters: win - Window to use (should be curwin)
|
||||||
y - Line on which to print first string
|
y - Line on which to print first string
|
||||||
offset - Column offset to add to position for each line
|
offset - Column offset to add to position for each line
|
||||||
chbuf - chtype buffer as returned from mkchstr()
|
chstr - chtype string as returned from mkchstr()
|
||||||
lines - Number of lines in chbuf (as returned from mkchstr())
|
lines - Number of lines in chstr as returned from mkchstr()
|
||||||
widthbuf - Widths of each line (as returned from mkchstr())
|
widthbuf - Widths of each line as returned from mkchstr()
|
||||||
Returns: int - ERR if more lines in chbuf[] than lines, else OK
|
Returns: int - ERR if more lines in chstr[] than lines, else OK
|
||||||
|
|
||||||
This function takes the strings in the chtype array chbuf and prints
|
This function takes the strings in the chtype array chstr and prints
|
||||||
them centred in the window win, offset by the parameter offset. Note
|
them centred in the window win, offset by the parameter offset. Note
|
||||||
that wrefresh() is NOT called. ERR is returned if there are more lines
|
that wrefresh() is NOT called. ERR is returned if there are more lines
|
||||||
in chbuf[] than are passed in the parameter lines.
|
in chstr[] than are passed in the parameter lines.
|
||||||
*/
|
*/
|
||||||
extern int pr_center (WINDOW *win, int y, int offset,
|
extern int centerch (WINDOW *win, int y, int offset,
|
||||||
const chtype *restrict chbuf, int lines,
|
const chtype *restrict chstr, int lines,
|
||||||
const int *restrict widthbuf);
|
const int *restrict widthbuf);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: pr_right - Print strings in chbuf right-aligned
|
Function: rightch - Print strings in chstr right-aligned
|
||||||
Parameters: win - Window to use (should be curwin)
|
Parameters: win - Window to use (should be curwin)
|
||||||
y - Line on which to print first string
|
y - Line on which to print first string
|
||||||
x - Ending column number for each line
|
x - Ending column number for each line
|
||||||
chbuf - chtype buffer as returned from mkchstr()
|
chstr - chtype string as returned from mkchstr()
|
||||||
lines - Number of lines in chbuf (as returned from mkchstr())
|
lines - Number of lines in chstr as returned from mkchstr()
|
||||||
widthbuf - Widths of each line (as returned from mkchstr())
|
widthbuf - Widths of each line as returned from mkchstr()
|
||||||
Returns: int - ERR if more lines in chbuf[] than lines, else OK
|
Returns: int - ERR if more lines in chstr[] than lines, else OK
|
||||||
|
|
||||||
This function takes the strings in the chtype array chbuf and prints
|
This function takes the strings in the chtype array chstr and prints
|
||||||
them right-aligned in the window win, with each line ending at column
|
them right-aligned in the window win, with each line ending just before
|
||||||
x. Note that wrefresh() is NOT called. ERR is returned if there are
|
column x. Note that wrefresh() is NOT called. ERR is returned if
|
||||||
more lines in chbuf[] than are passed in the parameter lines.
|
there are more lines in chstr[] than are passed in the parameter lines.
|
||||||
*/
|
*/
|
||||||
extern int pr_right (WINDOW *win, int y, int x, const chtype *restrict chbuf,
|
extern int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
|
||||||
int lines, const int *restrict widthbuf);
|
int lines, const int *restrict widthbuf);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
26
src/move.c
26
src/move.c
@ -236,28 +236,28 @@ selection_t get_move (void)
|
|||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<1>^} Display stock portfolio");
|
"^{<1>^} Display stock portfolio");
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, &width);
|
leftch(curwin, 2, 2, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<2>^} Declare bankruptcy");
|
"^{<2>^} Declare bankruptcy");
|
||||||
pr_left(curwin, 3, 2, chbuf, lines, &width);
|
leftch(curwin, 3, 2, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<3>^} Save and end the game");
|
"^{<3>^} Save and end the game");
|
||||||
pr_left(curwin, 2, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 2, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<CTRL><C>^} Quit the game");
|
"^{<CTRL><C>^} Quit the game");
|
||||||
pr_left(curwin, 3, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 3, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
|
|
||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, attr_choice,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, attr_choice,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"Select move [^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: ",
|
"Select move [^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: ",
|
||||||
MOVE_TO_KEY(0), MOVE_TO_KEY(NUMBER_MOVES - 1));
|
MOVE_TO_KEY(0), MOVE_TO_KEY(NUMBER_MOVES - 1));
|
||||||
pr_right(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
rightch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
|
|
||||||
curs_set(CURS_ON);
|
curs_set(CURS_ON);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
@ -273,7 +273,7 @@ selection_t get_move (void)
|
|||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_choice, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_choice, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"Move ^{%c^}", key);
|
"Move ^{%c^}", key);
|
||||||
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
} else {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '1':
|
case '1':
|
||||||
@ -290,7 +290,7 @@ selection_t get_move (void)
|
|||||||
attr_normal | A_BOLD, 0, 1,
|
attr_normal | A_BOLD, 0, 1,
|
||||||
getmaxx(curwin) / 2 - 4, &width, 1,
|
getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<2>^} (Declare bankruptcy)");
|
"^{<2>^} (Declare bankruptcy)");
|
||||||
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '3':
|
case '3':
|
||||||
@ -301,7 +301,7 @@ selection_t get_move (void)
|
|||||||
attr_normal | A_BOLD, 0, 1,
|
attr_normal | A_BOLD, 0, 1,
|
||||||
getmaxx(curwin) / 2 - 4, &width, 1,
|
getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<3>^} (Save and end the game)");
|
"^{<3>^} (Save and end the game)");
|
||||||
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_ESC:
|
case KEY_ESC:
|
||||||
@ -317,7 +317,7 @@ selection_t get_move (void)
|
|||||||
attr_normal | A_BOLD, 0, 1,
|
attr_normal | A_BOLD, 0, 1,
|
||||||
getmaxx(curwin) / 2 - 4, &width, 1,
|
getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"^{<CTRL><C>^} (Quit the game)");
|
"^{<CTRL><C>^} (Quit the game)");
|
||||||
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -334,7 +334,7 @@ selection_t get_move (void)
|
|||||||
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
|
||||||
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
1, getmaxx(curwin) / 2 - 4, &width, 1,
|
||||||
"Are you sure? [^{Y^}/^{N^}] ");
|
"Are you sure? [^{Y^}/^{N^}] ");
|
||||||
pr_right(curwin, 2, getmaxx(curwin) / 2, chbuf, lines, &width);
|
rightch(curwin, 2, getmaxx(curwin) / 2, chbuf, lines, &width);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
if (! answer_yesno(curwin)) {
|
if (! answer_yesno(curwin)) {
|
||||||
@ -351,7 +351,7 @@ selection_t get_move (void)
|
|||||||
WIN_COLS - 7, &width, 1,
|
WIN_COLS - 7, &width, 1,
|
||||||
"Saving game %d... ", game_num);
|
"Saving game %d... ", game_num);
|
||||||
newtxwin(5, width + 5, 7, WCENTER, true, attr_status_window);
|
newtxwin(5, width + 5, 7, WCENTER, true, attr_status_window);
|
||||||
pr_center(curwin, 2, 0, chbuf, 1, &width);
|
centerch(curwin, 2, 0, chbuf, 1, &width);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
saved = save_game(game_num);
|
saved = save_game(game_num);
|
||||||
@ -381,7 +381,7 @@ selection_t get_move (void)
|
|||||||
|
|
||||||
newtxwin(lines + 4, maxwidth, 8, WCENTER, true,
|
newtxwin(lines + 4, maxwidth, 8, WCENTER, true,
|
||||||
attr_normal_window);
|
attr_normal_window);
|
||||||
pr_left(curwin, 2, 2, chbuf, lines, widthbuf);
|
leftch(curwin, 2, 2, chbuf, lines, widthbuf);
|
||||||
|
|
||||||
curs_set(CURS_ON);
|
curs_set(CURS_ON);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
@ -421,7 +421,7 @@ selection_t get_move (void)
|
|||||||
0, 0, 1, WIN_COLS - 7, &width, 1,
|
0, 0, 1, WIN_COLS - 7, &width, 1,
|
||||||
"Saving game %d... ", game_num);
|
"Saving game %d... ", game_num);
|
||||||
newtxwin(5, width + 5, 7, WCENTER, true, attr_status_window);
|
newtxwin(5, width + 5, 7, WCENTER, true, attr_status_window);
|
||||||
pr_center(curwin, 2, 0, chbuf, 1, &width);
|
centerch(curwin, 2, 0, chbuf, 1, &width);
|
||||||
wrefresh(curwin);
|
wrefresh(curwin);
|
||||||
|
|
||||||
saved = save_game(game_num);
|
saved = save_game(game_num);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user