From: Christian Heller Date: Tue, 30 Jul 2013 01:10:53 +0000 (+0200) Subject: Made unnecessarily extern functions in draw_wins module static. X-Git-Tag: tce~1116 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/error?a=commitdiff_plain;h=dd29efee173dfad19a4ea5fa16f35aabb17c4642;p=plomrogue Made unnecessarily extern functions in draw_wins module static. --- diff --git a/src/draw_wins.c b/src/draw_wins.c index 6287b20..eca0f75 100644 --- a/src/draw_wins.c +++ b/src/draw_wins.c @@ -14,121 +14,19 @@ +/* Write "text" into window "win" as far as possible. Start on row "start_y". */ +static void draw_with_linebreaks(struct Win * win, char * text, + uint16_t start_y); + +/* Write "text" not starting from the top but from the bottom of "win". */ +static void draw_text_from_bottom(struct Win * win, char * text); + /* Draw onto "map" in "win" the objects in the chain at "start". */ static void draw_map_objects(struct World * world, struct MapObj * start, struct Map * map, struct Win * win); -extern void draw_with_linebreaks(struct Win * win, char * text, - uint16_t start_y) -{ - uint16_t x, y; - char toggle; - char fin = 0; - int16_t z = -1; - for (y = start_y; y < win->frame.size.y; y++) - { - if (0 == fin) - { - toggle = 0; - } - for (x = 0; x < win->frame.size.x; x++) - { - if (0 == toggle) - { - z++; - if ('\n' == text[z]) - { - toggle = 1; - continue; - } - else - { - mvwaddch(win->frame.curses_win, y, x, text[z]); - } - if ('\n' == text[z+1]) - { - z++; - toggle = 1; - } - else if (0 == text[z+1]) - { - toggle = 1; - fin = 1; - } - } - } - } -} - - - -extern void draw_text_from_bottom (struct Win * win, char * text) -{ - /* Determine number of lines text would have in a window of win's width, - * but infinite height. Treat \n and \0 as control chars for incrementing - * y and stopping the loop. Make sure +they* don't count as cell space. - */ - char toggle = 0; - uint16_t x, y, offset; - int16_t z = -1; - for (y = 0; 0 == toggle; y++) - { - for (x = 0; x < win->frame.size.x; x++) - { - z++; - if ('\n' == text[z]) - { - break; - } - if ('\n' == text[z+1]) - { - z++; - break; - } - else if (0 == text[z+1]) - { - toggle = 1; - break; - } - } - } - z = -1; - - /* Depending on what's bigger, determine start point in window or text. */ - uint16_t start_y = 0; - if (y < win->frame.size.y) - { - start_y = win->frame.size.y - y; - } - else if (y > win->frame.size.y) - { - offset = y - win->frame.size.y; - for (y = 0; y < offset; y++) - { - for (x = 0; x < win->frame.size.x; x++) - { - z++; - if ('\n' == text[z]) - { - break; - } - if ('\n' == text[z+1]) - { - z++; - break; - } - } - } - text = text + (sizeof(char) * (z + 1)); - } - - draw_with_linebreaks(win, text, start_y); -} - - - extern void draw_log_win(struct Win * win) { struct World * world = (struct World *) win->data; @@ -246,6 +144,115 @@ extern void draw_keys_win(struct Win * win) +static void draw_with_linebreaks(struct Win * win, char * text, + uint16_t start_y) +{ + uint16_t x, y; + char toggle; + char fin = 0; + int16_t z = -1; + for (y = start_y; y < win->frame.size.y; y++) + { + if (0 == fin) + { + toggle = 0; + } + for (x = 0; x < win->frame.size.x; x++) + { + if (0 == toggle) + { + z++; + if ('\n' == text[z]) + { + toggle = 1; + continue; + } + else + { + mvwaddch(win->frame.curses_win, y, x, text[z]); + } + if ('\n' == text[z+1]) + { + z++; + toggle = 1; + } + else if (0 == text[z+1]) + { + toggle = 1; + fin = 1; + } + } + } + } +} + + + +static void draw_text_from_bottom (struct Win * win, char * text) +{ + /* Determine number of lines text would have in a window of win's width, + * but infinite height. Treat \n and \0 as control chars for incrementing + * y and stopping the loop. Make sure +they* don't count as cell space. + */ + char toggle = 0; + uint16_t x, y, offset; + int16_t z = -1; + for (y = 0; 0 == toggle; y++) + { + for (x = 0; x < win->frame.size.x; x++) + { + z++; + if ('\n' == text[z]) + { + break; + } + if ('\n' == text[z+1]) + { + z++; + break; + } + else if (0 == text[z+1]) + { + toggle = 1; + break; + } + } + } + z = -1; + + /* Depending on what's bigger, determine start point in window or text. */ + uint16_t start_y = 0; + if (y < win->frame.size.y) + { + start_y = win->frame.size.y - y; + } + else if (y > win->frame.size.y) + { + offset = y - win->frame.size.y; + for (y = 0; y < offset; y++) + { + for (x = 0; x < win->frame.size.x; x++) + { + z++; + if ('\n' == text[z]) + { + break; + } + if ('\n' == text[z+1]) + { + z++; + break; + } + } + } + text = text + (sizeof(char) * (z + 1)); + } + + draw_with_linebreaks(win, text, start_y); +} + + + static void draw_map_objects(struct World * world, struct MapObj * start, struct Map * map, struct Win * win) { diff --git a/src/draw_wins.h b/src/draw_wins.h index 8801f13..4b8574b 100644 --- a/src/draw_wins.h +++ b/src/draw_wins.h @@ -12,38 +12,16 @@ struct Win; -/* Write "text" into window "win" as far as possible. Start on row "start_y". - * - * TODO: Why is this external? - */ -extern void draw_with_linebreaks(struct Win * win, char * text, - uint16_t start_y); - - - -/* Write "text" not starting from the top but from the bottom of "win". - * - * TODO: Why is this external? - */ -extern void draw_text_from_bottom(struct Win * win, char * text); - - /* Write game log text into "win" from bottom to top. */ extern void draw_log_win(struct Win * win); - - /* Draw game map and actors/objects on it into "win". Respect scroll offset. */ extern void draw_map_win(struct Win * win); - - /* Draw into "win" the game / player status infos. */ extern void draw_info_win(struct Win * win); - - /* Draw keybindings selection/manipulation menu. */ extern void draw_keys_win(struct Win * win);