From: Hourier Date: Sun, 13 Sep 2020 05:48:01 +0000 (+0900) Subject: [Refactor] #40585 Moved term_nuke() from main.c to z-term.c/h X-Git-Tag: vmacos3.0.0-alpha52~517^2~214^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=86820a8c727ee1eda2d26579e0e9f9859b9984ea;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40585 Moved term_nuke() from main.c to z-term.c/h --- diff --git a/src/main.c b/src/main.c index e84b545e2..c5363b0ca 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,4 @@ -/* File: main.c */ - -/* +/* * Copyright (c) 1997 Ben Harrison, and others * * This software may be copied and distributed for educational, research, @@ -42,68 +40,7 @@ */ -#if !defined(WINDOWS) - -/* - * Nuke a term - */ -static errr term_nuke(term_type *t) -{ - TERM_LEN w = t->wid; - TERM_LEN h = t->hgt; - - /* Call the special "nuke" hook */ - if (t->active_flag) { - /* Call the "nuke" hook */ - if (t->nuke_hook) - (*t->nuke_hook)(t); - - /* Remember */ - t->active_flag = FALSE; - - /* Assume not mapped */ - t->mapped_flag = FALSE; - } - - /* Nuke "displayed" */ - term_win_nuke(t->old, w, h); - - /* Kill "displayed" */ - KILL(t->old, term_win); - - /* Nuke "requested" */ - term_win_nuke(t->scr, w, h); - - /* Kill "requested" */ - KILL(t->scr, term_win); - - /* If needed */ - if (t->mem) { - /* Nuke "memorized" */ - term_win_nuke(t->mem, w, h); - - /* Kill "memorized" */ - KILL(t->mem, term_win); - } - - /* If needed */ - if (t->tmp) { - /* Nuke "temporary" */ - term_win_nuke(t->tmp, w, h); - - /* Kill "temporary" */ - KILL(t->tmp, term_win); - } - - /* Free some arrays */ - C_KILL(t->x1, h, TERM_LEN); - C_KILL(t->x2, h, TERM_LEN); - - /* Free the input queue */ - C_KILL(t->key_queue, t->key_size, char); - return 0; -} - +#ifndef WINDOWS /* * A hook for "quit()". * diff --git a/src/term/z-term.c b/src/term/z-term.c index f056992e2..f574ab16c 100644 --- a/src/term/z-term.c +++ b/src/term/z-term.c @@ -2299,3 +2299,37 @@ errr term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s) return 0; } #endif + +#ifndef WINDOWS +errr term_nuke(term_type *t) +{ + TERM_LEN w = t->wid; + TERM_LEN h = t->hgt; + if (t->active_flag) { + if (t->nuke_hook) + (*t->nuke_hook)(t); + + t->active_flag = FALSE; + t->mapped_flag = FALSE; + } + + term_win_nuke(t->old, w, h); + KILL(t->old, term_win); + term_win_nuke(t->scr, w, h); + KILL(t->scr, term_win); + if (t->mem) { + term_win_nuke(t->mem, w, h); + KILL(t->mem, term_win); + } + + if (t->tmp) { + term_win_nuke(t->tmp, w, h); + KILL(t->tmp, term_win); + } + + C_KILL(t->x1, h, TERM_LEN); + C_KILL(t->x2, h, TERM_LEN); + C_KILL(t->key_queue, t->key_size, char); + return 0; +} +#endif diff --git a/src/term/z-term.h b/src/term/z-term.h index 1ccf15864..d7a22da78 100644 --- a/src/term/z-term.h +++ b/src/term/z-term.h @@ -137,49 +137,52 @@ typedef struct term_type { extern term_type *Term; errr term_win_nuke(term_win *s, TERM_LEN w, TERM_LEN h); -extern errr term_user(int n); -extern errr term_xtra(int n, int v); +errr term_user(int n); +errr term_xtra(int n, int v); -extern void term_queue_char(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc); -extern void term_queue_bigchar(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc); +void term_queue_char(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc); +void term_queue_bigchar(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc); -extern void term_queue_line(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR *a, char *c, TERM_COLOR *ta, char *tc); +void term_queue_line(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR *a, char *c, TERM_COLOR *ta, char *tc); -extern errr term_fresh(void); -extern errr term_set_cursor(int v); -extern errr term_gotoxy(TERM_LEN x, TERM_LEN y); -extern errr term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c); -extern errr term_addch(TERM_COLOR a, char c); -extern errr term_add_bigch(TERM_COLOR a, char c); -extern errr term_addstr(int n, TERM_COLOR a, concptr s); -extern errr term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c); -extern errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s); -extern errr term_erase(TERM_LEN x, TERM_LEN y, int n); -extern errr term_clear(void); -extern errr term_redraw(void); -extern errr term_redraw_section(TERM_LEN x1, TERM_LEN y1, TERM_LEN x2, TERM_LEN y2); +errr term_fresh(void); +errr term_set_cursor(int v); +errr term_gotoxy(TERM_LEN x, TERM_LEN y); +errr term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c); +errr term_addch(TERM_COLOR a, char c); +errr term_add_bigch(TERM_COLOR a, char c); +errr term_addstr(int n, TERM_COLOR a, concptr s); +errr term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c); +errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s); +errr term_erase(TERM_LEN x, TERM_LEN y, int n); +errr term_clear(void); +errr term_redraw(void); +errr term_redraw_section(TERM_LEN x1, TERM_LEN y1, TERM_LEN x2, TERM_LEN y2); -extern errr term_get_cursor(int *v); -extern errr term_get_size(TERM_LEN *w, TERM_LEN *h); -extern errr term_locate(TERM_LEN *x, TERM_LEN *y); -extern errr term_what(TERM_LEN x, TERM_LEN y, TERM_COLOR *a, char *c); +errr term_get_cursor(int *v); +errr term_get_size(TERM_LEN *w, TERM_LEN *h); +errr term_locate(TERM_LEN *x, TERM_LEN *y); +errr term_what(TERM_LEN x, TERM_LEN y, TERM_COLOR *a, char *c); -extern errr term_flush(void); -extern errr term_key_push(int k); -extern errr term_inkey(char *ch, bool wait, bool take); +errr term_flush(void); +errr term_key_push(int k); +errr term_inkey(char *ch, bool wait, bool take); -extern errr term_save(void); -extern errr term_load(void); +errr term_save(void); +errr term_load(void); -extern errr term_resize(TERM_LEN w, TERM_LEN h); +errr term_resize(TERM_LEN w, TERM_LEN h); -extern errr term_activate(term_type *t); +errr term_activate(term_type *t); -extern errr term_init(term_type *t, TERM_LEN w, TERM_LEN h, int k); +errr term_init(term_type *t, TERM_LEN w, TERM_LEN h, int k); #ifdef JP -extern errr term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s); +errr term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s); #endif +#ifndef WINDOWS +errr term_nuke(term_type *t); #endif +#endif