/* * os_erase_area * * Fill a rectangular area of the screen with the current background * colour. Top left coordinates are (1,1). The cursor does not move. * * The final argument gives the window being changed, -1 if only a * portion of a window is being erased, or -2 if the whole screen is * being erased. This is not relevant for the curses interface. * */ void os_erase_area (int top, int left, int bottom, int right, int win) { int y, x, i, j; /* Catch the most common situation and do things the easy way */ if ((top == 1) && (bottom == h_screen_rows) && (left == 1) && (right == h_screen_cols)) { #ifdef COLOR_SUPPORT /* Only set the curses background when doing an erase, so it won't * interfere with the copying we do in os_scroll_area. */ bkgdset(u_setup.current_color | ' '); erase(); bkgdset(0); #else erase(); #endif } else { /* Sigh... */ int saved_style = u_setup.current_text_style; os_set_text_style(u_setup.current_color); getyx(stdscr, y, x); top--; left--; bottom--; right--; for (i = top; i <= bottom; i++) { move(i, left); for (j = left; j <= right; j++) addch(' '); } move(y, x); os_set_text_style(saved_style); } }/* os_erase_area */
static void set_window (zword win) { flush_buffer (); cwin = win; cwp = wp + win; update_attributes (); if (h_version == V6) { os_set_colour (lo (cwp->colour), hi (cwp->colour)); if (os_font_data (cwp->font, &font_height, &font_width)) os_set_font (cwp->font); os_set_text_style (cwp->style); } else refresh_text_style (); if (h_version != V6 && win != 0) { wp[win].y_cursor = 1; wp[win].x_cursor = 1; } update_cursor (); }/* set_window */
/* * os_more_prompt * * Display a MORE prompt, wait for a keypress and remove the MORE * prompt from the screen. * */ void os_more_prompt (void) { int saved_style, saved_x, saved_y; /* Save some useful information */ saved_style = u_setup.current_text_style; getyx(stdscr, saved_y, saved_x); os_set_text_style(0); addstr("[MORE]"); os_read_key(0, TRUE); move(saved_y, saved_x); addstr(" "); move(saved_y, saved_x); os_set_text_style(saved_style); }/* os_more_prompt */
void restart_screen (void) { /* Use default settings */ os_set_colour (h_default_foreground, h_default_background); if (os_font_data (TEXT_FONT, &font_height, &font_width)) os_set_font (TEXT_FONT); os_set_text_style (0); cursor = TRUE; /* Initialise window properties */ mwin = 1; for (cwp = wp; cwp < wp + 8; cwp++) { cwp->y_pos = 1; cwp->x_pos = 1; cwp->y_size = 0; cwp->x_size = 0; cwp->y_cursor = 1; cwp->x_cursor = 1; cwp->left = 0; cwp->right = 0; cwp->nl_routine = 0; cwp->nl_countdown = 0; cwp->style = 0; cwp->colour = (h_default_background << 8) | h_default_foreground; cwp->font = TEXT_FONT; cwp->font_size = (font_height << 8) | font_width; cwp->attribute = 8; cwp->true_fore = hx_fore_colour; cwp->true_back = hx_back_colour; } /* Prepare lower/upper windows and status line */ wp[0].attribute = 15; wp[0].left = option_left_margin; wp[0].right = option_right_margin; wp[0].x_size = h_screen_width; wp[1].x_size = h_screen_width; if (h_version <= V3) wp[7].x_size = h_screen_width; os_restart_game (RESTART_WPROP_SET); /* Clear the screen, unsplit it and select window 0 */ erase_screen ((zword) (-1)); }/* restart_screen */
void os_reset_screen (void) { os_stop_sample(0); os_set_text_style(0); os_display_string((zchar *) "[Hit any key to exit.]"); os_read_key(0, FALSE); }/* os_reset_screen */
void os_reset_screen (void) { os_stop_sample(0); os_set_text_style(0); print_string("[Hit any key to exit.]\n"); os_read_key(0, FALSE); scrollok(stdscr, TRUE); scroll(stdscr); refresh(); endwin(); }/* os_reset_screen */
/* Haxor your boxor? */ void os_display_string (const zchar *s) { zchar c; while ((c = *s++) != 0) if (c == ZC_NEW_FONT) s++; else if (c == ZC_NEW_STYLE) os_set_text_style(*s++); else { os_display_char (c); } }
/* * screen_mssg_on * * Start printing a so-called debugging message. The contents of the * message are passed to the message stream, a Frotz specific output * stream with maximum priority. * */ void screen_mssg_on (void) { if (cwin == 0) { /* messages in window 0 only */ os_set_text_style (0); if (cwp->x_cursor != cwp->left + 1) screen_new_line (); screen_char (ZC_INDENT); } else discarding = TRUE; /* discard messages in other windows */ }/* screen_mssg_on */
void os_fatal (const char *s) { if (u_setup.curses_active) { os_display_string((zchar *)"\n\n"); os_beep(BEEP_HIGH); os_set_text_style(BOLDFACE_STYLE); os_display_string((zchar *)"Fatal error: "); os_set_text_style(0); os_display_string((zchar *)s); os_display_string((zchar *)"\n"); new_line(); os_reset_screen(); exit(1); } fputs ("\nFatal error: ", stderr); fputs (s, stderr); fputs ("\n\n", stderr); exit (1); }/* os_fatal */
void os_fatal (const char *s, ...) { if (u_setup.curses_active) { /* Solaris 2.6's cc complains if the below cast is missing */ os_display_string((zchar *)"\n\n"); os_beep(BEEP_HIGH); os_set_text_style(BOLDFACE_STYLE); os_display_string((zchar *)"Fatal error: "); os_set_text_style(0); os_display_string((zchar *)s); os_display_string((zchar *)"\n"); new_line(); os_reset_screen(); exit(1); } fputs ("\nFatal error: ", stderr); fputs (s, stderr); fputs ("\n\n", stderr); exit (1); }/* os_fatal */
/* * screen_word * * Display a string of characters on the screen. If the word doesn't fit * then use wrapping or clipping depending on the current setting of the * enable_wrapping flag. * */ void screen_word (const zchar *s) { int width; if (discarding) return; if (*s == ZC_INDENT && cwp->x_cursor != cwp->left + 1) screen_char (*s++); if (units_left () < (width = os_string_width (s))) { if (!enable_wrapping) { zchar c; while ((c = *s++) != 0) if (c == ZC_NEW_FONT || c == ZC_NEW_STYLE) { int arg = (int) *s++; if (c == ZC_NEW_FONT) os_set_font (arg); if (c == ZC_NEW_STYLE) os_set_text_style (arg); } else screen_char (c); return; } if (*s == ' ' || *s == ZC_INDENT || *s == ZC_GAP) width = os_string_width (++s); #ifdef AMIGA if (cwin == 0) Justifiable (); #endif screen_new_line (); } os_display_string (s); cwp->x_cursor += width; }/* screen_word */
/* * os_scroll_area * * Scroll a rectangular area of the screen up (units > 0) or down * (units < 0) and fill the empty space with the current background * colour. Top left coordinates are (1,1). The cursor stays put. * */ void os_scroll_area (int top, int left, int bottom, int right, int units) { top--; left--; bottom--; right--; if ((left == 0) && (right == h_screen_cols - 1)) { static int old_scroll_top = 0; static int old_scroll_bottom = 0; if (!((old_scroll_top == top) && (old_scroll_bottom == bottom))) { old_scroll_top = top; old_scroll_bottom = bottom; setscrreg(top, bottom); } scrollok(stdscr, TRUE); scrl(units); scrollok(stdscr, FALSE); } else { int row, col, x, y; chtype ch; getyx(stdscr, y, x); /* Must turn off attributes during copying. */ attrset(0); if (units > 0) { for (row = top; row <= bottom - units; row++) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } else if (units < 0) { for (row = bottom; row >= top - units; row--) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } /* Restore attributes. */ os_set_text_style(u_setup.current_text_style); move(y, x); } if (units > 0) os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, 0); else if (units < 0) os_erase_area(top + 1, left + 1, top - units, right + 1, 0); }/* os_scroll_area */
void os_display_string (const zchar *s) { zchar c; while ((c = (unsigned char) *s++) != 0) if (c == ZC_NEW_FONT || c == ZC_NEW_STYLE) { int arg = (unsigned char) *s++; if (c == ZC_NEW_FONT) os_set_font (arg); if (c == ZC_NEW_STYLE) os_set_text_style (arg); } else os_display_char (c); }/* os_display_string */
void os_display_string (const zchar *s) { zchar c; while ((c = (unsigned char) *s++) != 0) /* Is this superfluous given it's also done in screen_word()? */ if (c == ZC_NEW_FONT || c == ZC_NEW_STYLE) { int arg = (unsigned char) *s++; if (c == ZC_NEW_FONT) os_set_font (arg); if (c == ZC_NEW_STYLE) os_set_text_style (arg); } else os_display_char (c); }/* os_display_string */
void refresh_text_style (void) { zword style; if (h_version != V6) { style = wp[0].style; if (cwin != 0 || h_flags & FIXED_FONT_FLAG) style |= FIXED_WIDTH_STYLE; } else style = cwp->style; if (!ostream_memory && ostream_screen && enable_buffering) { print_char (ZC_NEW_STYLE); print_char (style); } else os_set_text_style (style); }/* refresh_text_style */
void os_set_colour (int new_foreground, int new_background) { if (new_foreground == 1) new_foreground = h_default_foreground; if (new_background == 1) new_background = h_default_background; if (u_setup.color_enabled) { #ifdef COLOR_SUPPORT static int colorspace[10][10]; static int n_colors = 0; if (!colorspace[new_foreground][new_background]) { init_pair(++n_colors, unix_convert(new_foreground), unix_convert(new_background)); colorspace[new_foreground][new_background] = n_colors; } u_setup.current_color = COLOR_PAIR(colorspace[new_foreground][new_background]); #endif } else u_setup.current_color = (((new_foreground == h_default_background) && (new_background == h_default_foreground)) ? A_REVERSE : 0); os_set_text_style(u_setup.current_text_style); }/* os_set_colour */