Changeset - 5e822fe9c265
[Not reviewed]
0 1 0
Vitaly Takmazov - 14 years ago 2011-10-21 08:13:46
vitalyster@gmail.com
fixed dfrotz target
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
backends/frotz/dfrotz/dumb/dumb_input.c
Show inline comments
 
@@ -36,99 +36,102 @@ static char runtime_usage[] =
 
  "    \\vb      Toggle visual bell.\n"
 
  "    \\pb      Toggle display of picture outline boxes.\n"
 
  "    (Toggle commands can be followed by a 1 or 0 to set value ON or OFF.)\n"
 
  "  Character Escapes:\n"
 
  "    \\\\  backslash    \\#  backspace    \\[  escape    \\_  return\n"
 
  "    \\< \\> \\^ \\.  cursor motion        \\1 ..\\0  f1..f10\n"
 
  "    \\D ..\\X   Standard Frotz hotkeys.  Use \\H (help) to see the list.\n"
 
  "  Line Type Identification Characters:\n"
 
  "    Input lines:\n"
 
  "      untimed  timed\n"
 
  "      >        T      A regular line-oriented input\n"
 
  "      )        t      A single-character input\n"
 
  "      }        D      A line input with some input before the cursor.\n"
 
  "                         (Use \\d to discard it.)\n"
 
  "    Output lines:\n"
 
  "      ]     Output line that contains the cursor.\n"
 
  "      .     A blank line emitted as part of span compression.\n"
 
  "            (blank) Any other output line.\n"
 
;
 

	
 
static float speed = 1;
 
static bool do_more_prompts = FALSE;
 

	
 
enum input_type {
 
  INPUT_CHAR,
 
  INPUT_LINE,
 
  INPUT_LINE_CONTINUED,
 
};
 

	
 
/* get a character.  Exit with no fuss on EOF.  */
 
static int xgetchar(void)
 
{
 
  int c = getchar();
 
  if (c == EOF) {
 
    if (feof(stdin)) {
 
      fprintf(stderr, "\nEOT\n");
 
      exit(0);
 
    }
 
    os_fatal(strerror(errno));
 
  }
 
  return c;
 
}
 

	
 
/* Read one line, including the newline, into s.  Safely avoids buffer
 
 * overruns (but that's kind of pointless because there are several
 
 * other places where I'm not so careful).  */
 
static void getline_(char *s)
 
{
 
	fflush(stdout);
 
  int c;
 
  char *p = s;
 
  char *p;
 
	
 
  fflush(stdout);
 
  
 
  p = s;
 
  while (p < s + INPUT_BUFFER_SIZE - 1)
 
    if ((*p++ = xgetchar()) == '\n') {
 
      *p = '\0';
 
      return;
 
    }
 
  p[-1] = '\n';
 
  p[0] = '\0';
 
  while ((c = xgetchar()) != '\n')
 
    ;
 
  printf("Line too long, truncated to %s\n", s - INPUT_BUFFER_SIZE);
 
}
 

	
 
/* Translate in place all the escape characters in s.  */
 
static void translate_special_chars(char *s)
 
{
 
  char *src = s, *dest = s;
 
  while (*src)
 
    switch(*src++) {
 
    default: *dest++ = src[-1]; break;
 
    case '\n': *dest++ = ZC_RETURN; break;
 
    case '\\':
 
      switch (*src++) {
 
      case '\n': *dest++ = ZC_RETURN; break;
 
      case '\\': *dest++ = '\\'; break;
 
      case '?': *dest++ = ZC_BACKSPACE; break;
 
      case '[': *dest++ = ZC_ESCAPE; break;
 
      case '_': *dest++ = ZC_RETURN; break;
 
      case '^': *dest++ = ZC_ARROW_UP; break;
 
      case '.': *dest++ = ZC_ARROW_DOWN; break;
 
      case '<': *dest++ = ZC_ARROW_LEFT; break;
 
      case '>': *dest++ = ZC_ARROW_RIGHT; break;
 
      case 'R': *dest++ = ZC_HKEY_RECORD; break;
 
      case 'P': *dest++ = ZC_HKEY_PLAYBACK; break;
 
      case 'S': *dest++ = ZC_HKEY_SEED; break;
 
      case 'U': *dest++ = ZC_HKEY_UNDO; break;
 
      case 'N': *dest++ = ZC_HKEY_RESTART; break;
 
      case 'X': *dest++ = ZC_HKEY_QUIT; break;
 
      case 'D': *dest++ = ZC_HKEY_DEBUG; break;
 
      case 'H': *dest++ = ZC_HKEY_HELP; break;
 
      case '1': case '2': case '3': case '4':
 
      case '5': case '6': case '7': case '8': case '9':
 
	*dest++ = ZC_FKEY_MIN + src[-1] - '0' - 1; break;
 
      case '0': *dest++ = ZC_FKEY_MIN + 9; break;
 
      default:
 
	fprintf(stderr, "DUMB-FROTZ: unknown escape char: %c\n", src[-1]);
 
	fprintf(stderr, "Enter \\help to see the list\n");
 
      }
 
    }
0 comments (0 inline, 0 general)