/** * Query ncurses for new screen size and try to resize the GCU terms. */ static void do_gcu_resize(void) { int i, rows, cols, y, x; term *old_t = Term; for (i = 0; i < term_count; i++) { /* Activate the current Term */ Term_activate(&data[i].t); /* If we can resize the curses window, then resize the Term */ get_gcu_term_size(i, &rows, &cols, &y, &x); if (wresize(data[i].win, rows, cols) == OK) Term_resize(cols, rows); /* Activate the old term */ Term_activate(old_t); } do_cmd_redraw(); }
/* * Query ncurses for new screen size and try to resize the GCU terms. */ static void do_gcu_resize(void) { int i, rows, cols, y, x; term *old_t = Term; for (i = 0; i < MAX_TERM_DATA; i++) { /* If we're using a big screen, we only care about Term-0 */ if (use_big_screen && i > 0) break; /* Activate the current Term */ Term_activate(&data[i].t); /* If we can resize the curses window, then resize the Term */ get_gcu_term_size(i, &rows, &cols, &y, &x); if (wresize(data[i].win, rows, cols) == OK) Term_resize(cols, rows); /* Activate the old term */ Term_activate(old_t); } do_cmd_redraw(); }
/** * Prepare "curses" for use by the file "ui-term.c" * * Installs the "hook" functions defined above, and then activates * the main screen "term", which clears the screen and such things. * * Someone should really check the semantics of "initscr()" */ errr init_gcu(int argc, char **argv) { int i; int rows, cols, y, x; int next_win = 0; /* Initialize info about terminal capabilities */ termtype = getenv("TERM"); loaded_terminfo = termtype && tgetent(0, termtype) == 1; /* Parse args */ for (i = 1; i < argc; i++) { if (prefix(argv[i], "-b")) { term_count = 1; } else if (prefix(argv[i], "-B")) { bold_extended = TRUE; } else if (prefix(argv[i], "-a")) { ascii_walls = TRUE; } else if (prefix(argv[i], "-n")) { term_count = atoi(&argv[i][2]); if (term_count > MAX_TERM_DATA) term_count = MAX_TERM_DATA; else if (term_count < 1) term_count = 1; } else { plog_fmt("Ignoring option: %s", argv[i]); } } /* Extract the normal keymap */ keymap_norm_prepare(); /* We do it like this to prevent a link error with curseses that * lack ESCDELAY. */ if (!getenv("ESCDELAY")) putenv("ESCDELAY=20"); /* Initialize */ if (initscr() == NULL) return (-1); /* Activate hooks */ quit_aux = hook_quit; /* Require standard size screen */ if (LINES < MIN_TERM0_LINES || COLS < MIN_TERM0_COLS) quit("Angband needs at least an 80x24 'curses' screen"); #ifdef A_COLOR /* Do we have color, and enough color, available? */ can_use_color = ((start_color() != ERR) && has_colors() && (COLORS >= 8) && (COLOR_PAIRS >= 8)); #ifdef HAVE_USE_DEFAULT_COLORS /* Should we use curses' "default color" */ if (use_default_colors() == OK) bg_color = -1; #endif /* Attempt to use colors */ if (can_use_color) { /* Prepare the color pairs */ /* PAIR_WHITE (pair 0) is *always* WHITE on BLACK */ init_pair(PAIR_RED, COLOR_RED, bg_color); init_pair(PAIR_GREEN, COLOR_GREEN, bg_color); init_pair(PAIR_YELLOW, COLOR_YELLOW, bg_color); init_pair(PAIR_BLUE, COLOR_BLUE, bg_color); init_pair(PAIR_MAGENTA, COLOR_MAGENTA, bg_color); init_pair(PAIR_CYAN, COLOR_CYAN, bg_color); init_pair(PAIR_BLACK, COLOR_BLACK, bg_color); /* Prepare the colors */ colortable[COLOUR_DARK] = (COLOR_PAIR(PAIR_BLACK)); colortable[COLOUR_WHITE] = (COLOR_PAIR(PAIR_WHITE) | A_BRIGHT); colortable[COLOUR_SLATE] = (COLOR_PAIR(PAIR_WHITE)); colortable[COLOUR_ORANGE] = (COLOR_PAIR(PAIR_YELLOW) | A_BRIGHT); colortable[COLOUR_RED] = (COLOR_PAIR(PAIR_RED)); colortable[COLOUR_GREEN] = (COLOR_PAIR(PAIR_GREEN)); colortable[COLOUR_BLUE] = (COLOR_PAIR(PAIR_BLUE)); colortable[COLOUR_UMBER] = (COLOR_PAIR(PAIR_YELLOW)); colortable[COLOUR_L_DARK] = (COLOR_PAIR(PAIR_BLACK) | A_BRIGHT); colortable[COLOUR_L_WHITE] = (COLOR_PAIR(PAIR_WHITE)); colortable[COLOUR_L_PURPLE] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[COLOUR_YELLOW] = (COLOR_PAIR(PAIR_YELLOW) | A_BRIGHT); colortable[COLOUR_L_RED] = (COLOR_PAIR(PAIR_MAGENTA) | A_BRIGHT); colortable[COLOUR_L_GREEN] = (COLOR_PAIR(PAIR_GREEN) | A_BRIGHT); colortable[COLOUR_L_BLUE] = (COLOR_PAIR(PAIR_BLUE) | A_BRIGHT); colortable[COLOUR_L_UMBER] = (COLOR_PAIR(PAIR_YELLOW)); colortable[COLOUR_PURPLE] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[COLOUR_VIOLET] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[COLOUR_TEAL] = (COLOR_PAIR(PAIR_CYAN)); colortable[COLOUR_MUD] = (COLOR_PAIR(PAIR_YELLOW)); colortable[COLOUR_L_YELLOW] = (COLOR_PAIR(PAIR_YELLOW | A_BRIGHT)); colortable[COLOUR_MAGENTA] = (COLOR_PAIR(PAIR_MAGENTA | A_BRIGHT)); colortable[COLOUR_L_TEAL] = (COLOR_PAIR(PAIR_CYAN) | A_BRIGHT); colortable[COLOUR_L_VIOLET] = (COLOR_PAIR(PAIR_MAGENTA) | A_BRIGHT); colortable[COLOUR_L_PINK] = (COLOR_PAIR(PAIR_MAGENTA) | A_BRIGHT); colortable[COLOUR_MUSTARD] = (COLOR_PAIR(PAIR_YELLOW)); colortable[COLOUR_BLUE_SLATE] = (COLOR_PAIR(PAIR_BLUE)); colortable[COLOUR_DEEP_L_BLUE] = (COLOR_PAIR(PAIR_BLUE)); } #endif /* Paranoia -- Assume no waiting */ nodelay(stdscr, FALSE); /* Prepare */ cbreak(); noecho(); nonl(); /* Tell curses to rewrite escape sequences to KEY_UP and friends */ keypad(stdscr, TRUE); /* Extract the game keymap */ keymap_game_prepare(); /* Now prepare the term(s) */ for (i = 0; i < term_count; i++) { /* Get the terminal dimensions; if the user asked for a big screen * then we'll put the whole screen in term 0; otherwise we'll divide * it amongst the available terms */ get_gcu_term_size(i, &rows, &cols, &y, &x); /* Skip non-existant windows */ if (rows <= 0 || cols <= 0) continue; /* Create a term */ term_data_init_gcu(&data[next_win], rows, cols, y, x); /* Remember the term */ angband_term[next_win] = &data[next_win].t; /* One more window */ next_win++; } /* Activate the "Angband" window screen */ Term_activate(&data[0].t); /* Remember the active screen */ term_screen = &data[0].t; /* Success */ return (0); }
/* * Prepare "curses" for use by the file "z-term.c" * * Installs the "hook" functions defined above, and then activates * the main screen "term", which clears the screen and such things. * * Someone should really check the semantics of "initscr()" */ errr init_gcu(int argc, char **argv) { int i; int rows, cols, y, x; int next_win = 0; /* Initialize info about terminal capabilities */ termtype = getenv("TERM"); loaded_terminfo = termtype && tgetent(0, termtype) == 1; /* Let's learn about our terminal */ use_alt_charset = loaded_terminfo && tgetstr("acs_chars", NULL); /* Parse args */ for (i = 1; i < argc; i++) { if (prefix(argv[i], "-b")) use_big_screen = TRUE; #ifdef A_ALTCHARSET else if (prefix(argv[i], "-a")) use_alt_charset = 0; else if (prefix(argv[i], "-g")) use_alt_charset = 1; #endif else plog_fmt("Ignoring option: %s", argv[i]); } /* Extract the normal keymap */ keymap_norm_prepare(); /* We do it like this to prevent a link error with curseses that * lack ESCDELAY. */ if (!getenv("ESCDELAY")) putenv("ESCDELAY=20"); /* Initialize */ if (initscr() == NULL) return (-1); /* Activate hooks */ quit_aux = hook_quit; /* Require standard size screen */ if ((LINES < 24) || (COLS < 80)) { quit("Angband needs at least an 80x24 'curses' screen"); } #ifdef A_COLOR /*** Init the Color-pairs and set up a translation table ***/ /* Do we have color, and enough color, available? */ can_use_color = ((start_color() != ERR) && has_colors() && (COLORS >= 8) && (COLOR_PAIRS >= 8)); #ifdef HAVE_USE_DEFAULT_COLORS /* Should we use curses' "default color" */ if (use_default_colors() == OK) bg_color = -1; #endif #ifdef HAVE_CAN_CHANGE_COLOR /* Can we change colors? */ can_fix_color = (can_use_color && can_change_color() && orig_colors && (COLORS >= 16) && (COLOR_PAIRS > 8)); #endif /* Attempt to use customized colors */ if (can_fix_color) { /* Prepare the color pairs */ for (i = 0; i < (BASIC_COLORS / 2); i++) { /* Reset the color */ if (init_pair(i + 1, i, bg_color) == ERR) { quit("Color pair init failed"); } /* Set up the colormap */ colortable[i] = (COLOR_PAIR(i + 1) | A_NORMAL); colortable[i + (BASIC_COLORS / 2)] = (COLOR_PAIR(i + 1) | A_BRIGHT); } /* Take account of "gamma correction" XXX XXX XXX */ /* Prepare the "Angband Colors" */ Term_xtra_gcu_react(); } /* Attempt to use colors */ else if (can_use_color) { /* Prepare the color pairs */ /* PAIR_WHITE (pair 0) is *always* WHITE on BLACK */ init_pair(PAIR_RED, COLOR_RED, bg_color); init_pair(PAIR_GREEN, COLOR_GREEN, bg_color); init_pair(PAIR_YELLOW, COLOR_YELLOW, bg_color); init_pair(PAIR_BLUE, COLOR_BLUE, bg_color); init_pair(PAIR_MAGENTA, COLOR_MAGENTA, bg_color); init_pair(PAIR_CYAN, COLOR_CYAN, bg_color); init_pair(PAIR_BLACK, COLOR_BLACK, bg_color); /* Prepare the colors */ colortable[TERM_DARK] = (COLOR_PAIR(PAIR_BLACK)); colortable[TERM_WHITE] = (COLOR_PAIR(PAIR_WHITE) | A_BRIGHT); colortable[TERM_SLATE] = (COLOR_PAIR(PAIR_WHITE)); colortable[TERM_ORANGE] = (COLOR_PAIR(PAIR_RED) | A_BRIGHT); colortable[TERM_RED] = (COLOR_PAIR(PAIR_RED)); colortable[TERM_GREEN] = (COLOR_PAIR(PAIR_GREEN)); colortable[TERM_BLUE] = (COLOR_PAIR(PAIR_BLUE)); colortable[TERM_UMBER] = (COLOR_PAIR(PAIR_YELLOW)); colortable[TERM_L_DARK] = (COLOR_PAIR(PAIR_BLACK) | A_BRIGHT); colortable[TERM_L_WHITE] = (COLOR_PAIR(PAIR_WHITE)); colortable[TERM_L_PURPLE] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[TERM_YELLOW] = (COLOR_PAIR(PAIR_YELLOW) | A_BRIGHT); colortable[TERM_L_RED] = (COLOR_PAIR(PAIR_MAGENTA) | A_BRIGHT); colortable[TERM_L_GREEN] = (COLOR_PAIR(PAIR_GREEN) | A_BRIGHT); colortable[TERM_L_BLUE] = (COLOR_PAIR(PAIR_BLUE) | A_BRIGHT); colortable[TERM_L_UMBER] = (COLOR_PAIR(PAIR_YELLOW)); colortable[TERM_PURPLE] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[TERM_VIOLET] = (COLOR_PAIR(PAIR_MAGENTA)); colortable[TERM_TEAL] = (COLOR_PAIR(PAIR_CYAN)); colortable[TERM_MUD] = (COLOR_PAIR(PAIR_YELLOW)); colortable[TERM_L_YELLOW] = (COLOR_PAIR(PAIR_YELLOW | A_BRIGHT)); colortable[TERM_MAGENTA] = (COLOR_PAIR(PAIR_MAGENTA | A_BRIGHT)); colortable[TERM_L_TEAL] = (COLOR_PAIR(PAIR_CYAN | A_BRIGHT)); colortable[TERM_L_VIOLET] = (COLOR_PAIR(PAIR_MAGENTA | A_BRIGHT)); colortable[TERM_L_PINK] = (COLOR_PAIR(PAIR_MAGENTA | A_BRIGHT)); colortable[TERM_MUSTARD] = (COLOR_PAIR(PAIR_YELLOW)); colortable[TERM_BLUE_SLATE] = (COLOR_PAIR(PAIR_BLUE)); colortable[TERM_DEEP_L_BLUE] = (COLOR_PAIR(PAIR_BLUE)); } #endif #ifdef A_ALTCHARSET /* Build a quick access table for the "alternate character set". */ if (use_alt_charset) { acs_table[1] = ACS_DIAMOND; acs_table[16] = ACS_S1; acs_table[2] = ACS_CKBOARD; acs_table[18] = ACS_HLINE; acs_table[7] = ACS_DEGREE; acs_table[20] = ACS_S9; acs_table[8] = ACS_PLMINUS; acs_table[21] = ACS_LTEE; acs_table[11] = ACS_LRCORNER; acs_table[22] = ACS_RTEE; acs_table[12] = ACS_URCORNER; acs_table[23] = ACS_BTEE; acs_table[13] = ACS_ULCORNER; acs_table[24] = ACS_TTEE; acs_table[14] = ACS_LLCORNER; acs_table[25] = ACS_VLINE; acs_table[15] = ACS_PLUS; acs_table[31] = ACS_BULLET; } #endif /*** Low level preparation ***/ /* Paranoia -- Assume no waiting */ nodelay(stdscr, FALSE); /* Prepare */ cbreak(); noecho(); nonl(); /* Tell curses to rewrite escape sequences to KEY_UP and friends */ keypad(stdscr, TRUE); /* Extract the game keymap */ keymap_game_prepare(); /*** Now prepare the term(s) ***/ for (i = 0; i < MAX_TERM_DATA; i++) { if (use_big_screen && i > 0) break; /* Get the terminal dimensions; if the user asked for a big screen * then we'll put the whole screen in term 0; otherwise we'll divide * it amongst the available terms */ get_gcu_term_size(i, &rows, &cols, &y, &x); /* Skip non-existant windows */ if (rows <= 0 || cols <= 0) continue; /* Create a term */ term_data_init_gcu(&data[next_win], rows, cols, y, x); /* Remember the term */ angband_term[next_win] = &data[next_win].t; /* One more window */ next_win++; } /* Activate the "Angband" window screen */ Term_activate(&data[0].t); /* Remember the active screen */ term_screen = &data[0].t; /* Success */ return (0); }