#endif
}
return c;
-}
+} /* xgetchar */
/* Read one line, including the newline, into s. Safely avoids buffer
while ((c = xgetchar()) != '\n')
;
printf("Line too long, truncated to %s\n", s - INPUT_BUFFER_SIZE);
-}
+} /* dumb_getline */
/* Translate in place all the escape characters in s. */
}
}
*dest = '\0';
-}
+} /* translate_special_chars */
/* The time in tenths of seconds that the user is ahead of z time. */
else
time_ahead -= timeout;
return time_ahead != 0;
-}
+} /* check_timeout */
/* If val is '0' or '1', set *var accordingly, otherwise toggle it. */
static void toggle(bool *var, char val)
{
*var = val == '1' || (val != '0' && !*var);
-}
+} /* toggle */
/* Handle input-related user settings and call dumb_output_handle_setting. */
return dumb_output_handle_setting(setting, show_cursor, startup);
}
return TRUE;
-}
+} /* dumb_handle_setting */
/* Read a line, processing commands (lines that start with a backslash
fprintf(stderr, "Enter \\help to see the list of commands\n");
}
}
-}
+} /* dumb_read_line */
/* Read a line that is not part of z-machine input (more prompts and
dumb_read_line(s, prompt, 0, 0, 0, 0);
/* Remove terminating newline */
s[strlen(s) - 1] = '\0';
-}
+} /* dumb_read_misc_line */
/* For allowing the user to input in a single line keys to be returned
}
*out = ch;
return idx;
-}
+} /* utf8_to_zchar */
#endif
/* TODO: error messages for invalid special chars. */
return c;
-}
+} /* os_read_key */
zchar os_read_line (int UNUSED (max), zchar *buf, int timeout, int UNUSED(width), int continued)
timed_out_last_time = FALSE;
return terminator;
-}
+} /* os_read_line */
+
/*
* os_read_file_name
return NULL;
}
return strdup(file_name);
-}
+} /* os_read_file_name */
void os_more_prompt (void)
dumb_read_misc_line(buf, "***MORE***");
} else
dumb_elide_more_prompt();
-}
+} /* os_more_prompt */
void dumb_init_input(void)
if (z_header.version >= V5)
z_header.flags &= ~(MOUSE_FLAG | MENU_FLAG);
-}
+} /* dumb_init_input */
zword os_read_mouse(void)
{
/* NOT IMPLEMENTED */
return 0;
-}
+} /* os_read_mouse */
void os_tick(void)
{
/* Nothing here yet */
-}
+} /* os_tick */
} else {
putchar(c);
}
-}
+} /* zputchar */
#else
#define zputchar(x) putchar(x)
#endif
+
/* if val is '0' or '1', set *var accordingly, else toggle it. */
static void toggle(bool *var, char val)
{
*var = val == '1' || (val != '0' && !*var);
-}
+} /* toggle */
/* Print a cell to stdout using IRC formatting codes. */
lastfg = fg;
lastbg = bg;
-}
+} /* show_cell_irc */
+
static void show_cell_ansi(cell_t cel)
{
zputchar(show_pictures ? cel.c : ' ');
else
zputchar(cel.c);
-}
+} /* show_cell_ansi */
+
static void show_cell_bbcode(cell_t cel)
{
printf(" ");
else
zputchar(cel.c);
-}
+} /* show_cell_bbcode */
#endif /* DISABLE_FORMATS */
zputchar(show_pictures ? cel.c : ' ');
else /* Only NORMAL_STYLE and FIXED_WIDTH_STYLE are left. */
zputchar(cel.c);
-}
+} /* show_cell_normal */
static void show_cell(cell_t cel)
else
#endif
show_cell_normal(cel);
-}
+} /* show_cell */
static bool will_print_blank(cell_t c)
|| ((c.c == ' ')
&& ((c.style != REVERSE_STYLE)
|| (*rv_blank_str == ' '))));
-}
+} /* will_print_blank */
static cell_t make_cell(int style, short fg, short bg, zchar c)
cel.fg = fg;
}
return cel;
-}
+} /* make_cell */
static void show_line_prefix(int row, char c)
/* Add a separator char (unless there's nothing to separate). */
if (show_line_numbers || show_line_types)
show_cell(make_cell(0, DEFAULT_DUMB_COLOUR, DEFAULT_DUMB_COLOUR, ' '));
-}
+} /* show_line_prefix */
static cell_t *dumb_row(int r)
{
return screen_data + r * z_header.screen_cols;
-}
+} /* dumb_row */
/* Print a row to stdout. */
show_cell(dumb_row(r)[c]);
}
show_cell(make_cell (0, DEFAULT_DUMB_COLOUR, DEFAULT_DUMB_COLOUR, '\n'));
-}
+} /* show_row */
static char *dumb_changes_row(int r)
{
return screen_changes + r * z_header.screen_cols;
-}
+} /* dumb_changes_row */
/* Set a cell and update screen_changes. */
dumb_changes_row(row)[col] = (!result);
dumb_row(row)[col] = c;
-}
+} /* dumb_set_cell */
/* put a character in the cell at the cursor and advance the cursor. */
cursor_col = 0;
}
}
-}
+} /* dumb_display_char */
static void mark_all_unchanged(void)
{
memset(screen_changes, 0, screen_cells);
-}
+} /* mark_all_unchanged */
/* Check if a cell is a blank or will display as one.
{
return ((c.c == ' ')
|| ((c.style == PICTURE_STYLE) && !show_pictures));
-}
+} /* is_blank */
static void dumb_copy_cell(int dest_row, int dest_col,
{
dumb_row(dest_row)[dest_col] = dumb_row(src_row)[src_col];
dumb_changes_row(dest_row)[dest_col] = dumb_changes_row(src_row)[src_col];
-}
+} /* dumb_copy_cell */
dumb_display_char(' ');
}
return;
-}
+} /* os_display_char */
/* Haxor your boxor? */
os_display_char (c);
}
}
-}
+} /* os_display_string */
void os_erase_area (int top, int left, int bottom, int right, int UNUSED (win))
for (col = left; col <= right; col++)
dumb_set_cell(row, col, make_cell(current_style, current_fg, current_bg, ' '));
}
-}
+} /* os_erase_area */
void os_scroll_area (int top, int left, int bottom, int right, int units)
}
os_erase_area(top + 1, left + 1, top - units, right + 1 , -1);
}
-}
+} /* os_scroll_area */
int os_font_data(int font, int *height, int *width)
return 1;
}
return 0;
-}
+} /* os_font_data */
void os_set_colour (int newfg, int newbg)
{
current_fg = frotz_to_dumb[newfg];
current_bg = frotz_to_dumb[newbg];
-}
+} /* os_set_colour */
void os_reset_screen(void)
{
dumb_show_screen(FALSE);
-}
+} /* os_reset_screen */
void os_beep (int volume)
printf("[%s-PITCHED BEEP]\n", (volume == 1) ? "HIGH" : "LOW");
else
putchar('\a'); /* so much for dumb. */
-}
+} /* os_beep */
/* To make the common code happy */
{
/* Only UTF-8 output, no input yet. */
return 1;
-}
+} /* os_check_unicode */
int os_char_width (zchar z)
return strchr(p, ' ') - p;
}
return 1;
-}
+} /* os_char_width */
int os_string_width (const zchar *s)
width += os_char_width(c);
}
return width;
-}
+} /* os_string_width */
void os_set_cursor(int row, int col)
cursor_row = row - 1; cursor_col = col - 1;
if (cursor_row >= z_header.screen_rows)
cursor_row = z_header.screen_rows - 1;
-}
+} /* os_set_cursor */
bool os_repaint_window(int UNUSED(win), int UNUSED(ypos_old),
int UNUSED(ysize), int UNUSED(xsize))
{
return FALSE;
-}
+} /* os_repaint_window */
/*
int os_get_text_style(void)
{
return current_style;
-}
+} /* os_get_text_style */
/*
void os_set_text_style(int x)
{
current_style = x;
-}
+} /* os_set_text_style */
/*
{
/* Nothing here yet */
return 0;
-}
+} /* os_from_true_colour */
+
/*
* os_to_true_colour
{
/* Nothing here yet */
return 0;
-}
+} /* os_to_true_colour */
/*
void dumb_set_picture_cell(int row, int col, zchar c)
{
dumb_set_cell(row, col, make_cell(current_style | PICTURE_STYLE, current_fg, current_bg, c));
-}
+} /* dumb_set_picture_cell */
void dumb_init_output(void)
screen_changes = malloc(screen_cells);
os_erase_area(1, 1, z_header.screen_rows, z_header.screen_cols, -2);
memset(screen_changes, 0, screen_cells);
-}
+} /* dumb_init_output */
void dumb_display_user_input(char *s)
/* copy to screen without marking it as a change. */
while (*s)
dumb_row(cursor_row)[cursor_col++] = make_cell(0, DEFAULT_DUMB_COLOUR, DEFAULT_DUMB_COLOUR, *s++);
-}
+} /* dumb_display_user_input */
void dumb_discard_old_input(int num_chars)
cursor_col = 0;
os_erase_area(cursor_row + 1, cursor_col + 1,
cursor_row + 1, cursor_col + num_chars, -1);
-}
+} /* dumb_discard_old_input */
/* Print the part of the cursor row before the cursor. */
for (i = 0; i < cursor_col; i++)
show_cell(dumb_row(cursor_row)[i]);
}
-}
+} /* dumb_show_prompt */
/* Show the current screen contents, or what's changed since the last
show_row((cursor_row == last + 2) ? (last + 1) : -1);
}
mark_all_unchanged();
-}
+} /* dumb_show_screen */
/* Unconditionally show whole screen. For \s user command. */
int r;
for (r = 0; r < z_header.screen_height; r++)
show_row(r);
-}
+} /* dumb_dump_screen */
/* Called when it's time for a more prompt but user has them turned off. */
if (compression_mode == COMPRESSION_SPANS && hide_lines == 0) {
show_row(-1);
}
-}
+} /* dumb_elide_more_prompt */
bool dumb_output_handle_setting(const char *setting, bool show_cursor,
} else
return FALSE;
return TRUE;
-}
+} /* dumb_output_handle_setting */