1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-21 16:14:14 -04:00

Rename pr_left, pr_center and pr_right to leftch, centerch and rightch

This commit is contained in:
John Zaitseff 2011-08-15 19:46:26 +10:00
parent 907a995b98
commit a6c362d2e8
5 changed files with 98 additions and 98 deletions

View File

@ -117,7 +117,7 @@ void init_game (void)
WIN_COLS - 7, &width, 1,
"Loading game %d... ", game_num);
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);
game_loaded = load_game(game_num);
@ -152,7 +152,7 @@ void init_game (void)
0, 0, 1, WIN_COLS - 7, &width, 1,
"Loading game %d... ", game_num);
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);
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;
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);
curs_set(CURS_ON);
@ -323,7 +323,7 @@ int ask_game_number (void)
maxwidth = ((lines == 1) ? widthbuf[0] : MAX(widthbuf[0], widthbuf[1])) + 5;
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);
curs_set(CURS_ON);
@ -393,7 +393,7 @@ void ask_player_names (void)
"Do you need any instructions? [^{Y^}/^{N^}] ");
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
attr_normal_window);
pr_left(curwin, 2, 2, chbuf, lines, &width);
leftch(curwin, 2, 2, chbuf, lines, &width);
free(chbuf);
if (answer_yesno(curwin)) {
show_help();
@ -413,7 +413,7 @@ void ask_player_names (void)
true, attr_normal_window);
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 8,
&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++) {
player[i].name = NULL;
@ -499,7 +499,7 @@ void ask_player_names (void)
"Does any player need instructions? [^{Y^}/^{N^}] ");
newtxwin(5, width + YESNO_COLS + 4, 6, WCENTER, true,
attr_normal_window);
pr_left(curwin, 2, 2, chbuf, lines, &width);
leftch(curwin, 2, 2, chbuf, lines, &width);
if (answer_yesno(curwin)) {
show_help();
}
@ -606,13 +606,13 @@ void show_map (bool closewin)
lines = mkchstr(chbuf, BUFSIZE, attr_mapwin_title, attr_mapwin_highlight,
0, 1, WIN_COLS - 4, &width, 1, " Player: ^{%s^} ",
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,
attr_mapwin_blink, 1, WIN_COLS / 2, &width, 1,
(turn_number != max_turn) ? " Turn: ^{%d^} " :
" ^[*** 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);
@ -681,19 +681,19 @@ void show_status (int num)
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
lines = mkchstr(chbuf, BUFSIZE, attr_title, 0, 0, 1, WIN_COLS - 4,
&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,
WIN_COLS - 4, &width, 1, "Player: ^{%s^}",
player[num].name);
pr_center(curwin, 2, 0, chbuf, lines, &width);
centerch(curwin, 2, 0, chbuf, lines, &width);
val = total_value(num);
if (val == 0.0) {
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight,
attr_blink, 1, WIN_COLS - 4, &width, 1,
"^[* * * B A N K R U P T * * *^]");
pr_center(curwin, 11, 0, chbuf, lines, &width);
centerch(curwin, 11, 0, chbuf, lines, &width);
} else {
char *buf = xmalloc(BUFSIZE);
@ -711,7 +711,7 @@ void show_status (int num)
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0,
1, WIN_COLS - 4, &width, 1,
"No companies on the map");
pr_center(curwin, 8, 0, chbuf, lines, &width);
centerch(curwin, 8, 0, chbuf, lines, &width);
} else {
// Handle the locale's currency symbol
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);

View File

@ -205,12 +205,12 @@ void show_help (void)
werase(curwin);
wbkgd(curwin, attr_normal_window);
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,
WIN_COLS - 4, &width, 1, "Page %d of %d",
curpage + 1, numpages);
pr_center(curwin, 2, 0, chbuf, lines, &width);
centerch(curwin, 2, 0, chbuf, lines, &width);
wmove(curwin, 4, 2);
// Process the help text string
@ -356,11 +356,11 @@ void show_help (void)
}
if (curpage == 0) {
pr_center(curwin, getmaxy(curwin) - 2, 0, ch_contfirst,
ln_contfirst, &w_contfirst);
centerch(curwin, getmaxy(curwin) - 2, 0, ch_contfirst,
ln_contfirst, &w_contfirst);
} else {
pr_center(curwin, getmaxy(curwin) - 2, 0, ch_contnext,
ln_contnext, &w_contnext);
centerch(curwin, getmaxy(curwin) - 2, 0, ch_contnext,
ln_contnext, &w_contnext);
}
wrefresh(curwin);

View File

@ -418,7 +418,7 @@ void init_title (void)
chbuf = xmalloc(BUFSIZE * sizeof(chtype));
lines = mkchstr(chbuf, BUFSIZE, attr_game_title, 0, 0, 1, COLS,
&width, 1, _("Star Traders"));
pr_center(stdscr, 0, 0, chbuf, lines, &width);
centerch(stdscr, 0, 0, chbuf, lines, &width);
attrset(attr_root_window);
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,
ncols - 4, &titlewidth, 1, boxtitle);
pr_center(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
centerch(curwin, 1, 0, titlebuf, titlelines, &titlewidth);
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);
deltxwin();
@ -1202,19 +1202,19 @@ error:
/***********************************************************************/
// chstrdup: Duplicate a chtype buffer
chtype *chstrdup (const chtype *restrict chbuf, int chbufsize)
chtype *chstrdup (const chtype *restrict chstr, int chstrsize)
{
const chtype *p;
int len;
chtype *ret;
// Determine chbuf length, including ending NUL
for (len = 1, p = chbuf; *p != '\0' && len <= chbufsize; p++, len++)
// Determine chstr length, including ending NUL
for (len = 1, p = chstr; *p != '\0' && len <= chstrsize; p++, len++)
;
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
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 lines, const int *restrict widthbuf)
int leftch (WINDOW *win, int y, int x, const chtype *restrict chstr,
int lines, const int *restrict widthbuf)
{
assert(win != NULL);
assert(chbuf != NULL);
assert(chstr != NULL);
assert(lines > 0);
assert(widthbuf != NULL);
wmove(win, y, x);
for ( ; *chbuf != '\0'; chbuf++) {
if (*chbuf == '\n') {
for ( ; *chstr != '\0'; chstr++) {
if (*chstr == '\n') {
wmove(win, getcury(win) + 1, x);
} 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 lines, const int *restrict widthbuf)
int centerch (WINDOW *win, int y, int offset, const chtype *restrict chstr,
int lines, const int *restrict widthbuf)
{
int ln = 0;
assert(win != NULL);
assert(chbuf != NULL);
assert(chstr != NULL);
assert(lines > 0);
assert(widthbuf != NULL);
wmove(win, y, (getmaxx(win) - widthbuf[ln]) / 2 + offset);
for ( ; *chbuf != '\0'; chbuf++) {
if (*chbuf == '\n') {
for ( ; *chstr != '\0'; chstr++) {
if (*chstr == '\n') {
if (ln++ >= lines) {
return ERR;
} else {
@ -1269,7 +1269,7 @@ int pr_center (WINDOW *win, int y, int offset, const chtype *restrict chbuf,
(getmaxx(win) - widthbuf[ln]) / 2 + offset);
}
} 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 lines, const int *restrict widthbuf)
int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
int lines, const int *restrict widthbuf)
{
int ln = 0;
assert(win != NULL);
assert(chbuf != NULL);
assert(chstr != NULL);
assert(lines > 0);
assert(widthbuf != NULL);
wmove(win, y, x - widthbuf[ln]);
for ( ; *chbuf != '\0'; chbuf++) {
if (*chbuf == '\n') {
for ( ; *chstr != '\0'; chstr++) {
if (*chstr == '\n') {
if (ln++ >= lines) {
return ERR;
} else {
wmove(win, getcury(win) + 1, x - widthbuf[ln]);
}
} 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));
lines = mkchstr(chbuf, BUFSIZE, attr, 0, 0, 1, getmaxx(win) - 4,
&width, 1, _("[ Press <SPACE> to continue ] "));
pr_center(win, y, 0, chbuf, lines, &width);
centerch(win, y, 0, chbuf, lines, &width);
wrefresh(win);
done = false;

View File

@ -303,14 +303,14 @@ extern int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
Returns: int - Number of lines actually used
This function converts the format string and following arguments into
chbuf, a chtype buffer that can be used for calls to pr_left(),
pr_center() and pr_right(). At most maxlines lines are used, each with
a maximum width of maxwidth. The actual widths of each resulting line
are stored in widthbuf (which must not be NULL). If maxlines is
greater than 1, lines are wrapped as needed.
chbuf, a chtype buffer that can be used for calls to leftch(), centerch()
and rightch(). At most maxlines lines are used, each with a maximum
width of maxwidth. The actual widths of each resulting line are stored
in widthbuf (which must not be NULL). If maxlines is greater than 1,
lines are wrapped as needed.
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)
@ -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)
y - Line on which to print first string
x - Starting column number for each line
chbuf - chtype buffer as returned from mkchstr()
lines - Number of lines in chbuf (as returned from mkchstr())
widthbuf - Widths of each line (as returned from mkchstr())
chstr - chtype string as returned from mkchstr()
lines - Number of lines in chstr as returned from mkchstr()
widthbuf - Widths of each line as returned from mkchstr()
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
called.
*/
extern int pr_left (WINDOW *win, int y, int x, const chtype *restrict chbuf,
int lines, const int *restrict widthbuf);
extern int leftch (WINDOW *win, int y, int x, const chtype *restrict chstr,
int lines, const int *restrict widthbuf);
/*
Function: pr_center - Print strings in chbuf centred in window
Parameters: win - Window to use (should be curwin)
y - Line on which to print first string
offset - Column offset to add to position for each line
chbuf - chtype buffer as returned from mkchstr()
lines - Number of lines in chbuf (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
Function: centerch - Print strings in chstr centred in window
Parameters: win - Window to use (should be curwin)
y - Line on which to print first string
offset - Column offset to add to position for each line
chstr - chtype string as returned from mkchstr()
lines - Number of lines in chstr as returned from mkchstr()
widthbuf - Widths of each line as returned from mkchstr()
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
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,
const chtype *restrict chbuf, int lines,
const int *restrict widthbuf);
extern int centerch (WINDOW *win, int y, int offset,
const chtype *restrict chstr, int lines,
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)
y - Line on which to print first string
x - Ending column number for each line
chbuf - chtype buffer as returned from mkchstr()
lines - Number of lines in chbuf (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
chstr - chtype string as returned from mkchstr()
lines - Number of lines in chstr as returned from mkchstr()
widthbuf - Widths of each line as returned from mkchstr()
Returns: int - ERR if more lines in chstr[] than lines, else OK
This function takes the strings in the chtype array chbuf and prints
them right-aligned in the window win, with each line ending at column
x. Note that wrefresh() is NOT called. ERR is returned if there are
more lines in chbuf[] than are passed in the parameter lines.
This function takes the strings in the chtype array chstr and prints
them right-aligned in the window win, with each line ending just before
column x. Note that wrefresh() is NOT called. ERR is returned if
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,
int lines, const int *restrict widthbuf);
extern int rightch (WINDOW *win, int y, int x, const chtype *restrict chstr,
int lines, const int *restrict widthbuf);
/*

View File

@ -236,28 +236,28 @@ selection_t get_move (void)
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"Select move [^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: ",
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);
wrefresh(curwin);
@ -273,7 +273,7 @@ selection_t get_move (void)
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_choice, 0,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"Move ^{%c^}", key);
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
} else {
switch (key) {
case '1':
@ -290,7 +290,7 @@ selection_t get_move (void)
attr_normal | A_BOLD, 0, 1,
getmaxx(curwin) / 2 - 4, &width, 1,
"^{<2>^} (Declare bankruptcy)");
pr_left(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
leftch(curwin, 1, getmaxx(curwin) / 2, chbuf, lines, &width);
break;
case '3':
@ -301,7 +301,7 @@ selection_t get_move (void)
attr_normal | A_BOLD, 0, 1,
getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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;
case KEY_ESC:
@ -317,7 +317,7 @@ selection_t get_move (void)
attr_normal | A_BOLD, 0, 1,
getmaxx(curwin) / 2 - 4, &width, 1,
"^{<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;
default:
@ -334,7 +334,7 @@ selection_t get_move (void)
lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_keycode, 0,
1, getmaxx(curwin) / 2 - 4, &width, 1,
"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);
if (! answer_yesno(curwin)) {
@ -351,7 +351,7 @@ selection_t get_move (void)
WIN_COLS - 7, &width, 1,
"Saving game %d... ", game_num);
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);
saved = save_game(game_num);
@ -381,7 +381,7 @@ selection_t get_move (void)
newtxwin(lines + 4, maxwidth, 8, WCENTER, true,
attr_normal_window);
pr_left(curwin, 2, 2, chbuf, lines, widthbuf);
leftch(curwin, 2, 2, chbuf, lines, widthbuf);
curs_set(CURS_ON);
wrefresh(curwin);
@ -421,7 +421,7 @@ selection_t get_move (void)
0, 0, 1, WIN_COLS - 7, &width, 1,
"Saving game %d... ", game_num);
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);
saved = save_game(game_num);