コード例 #1
0
NODE *lreadchar()
{
    char c;

    charmode_on();
    input_blocking++;
#ifndef TIOCSTI
    if (!setjmp(iblk_buf))
#endif
#ifdef mac
    csetmode(C_RAW, stdin);
    while ((c = (char)getc(readstream)) == EOF && readstream == stdin);
    csetmode(C_ECHO, stdin);
#else
#ifdef ibm
    if (interactive && readstream==stdin)
	c = (char)getch();
    else
	c = (char)getc(readstream);

    if (c == 17) { /* control-q */
	to_pending = 0;
	err_logo(STOP_ERROR,NIL);
    }
    if (c == 23) { /* control-w */
	logo_pause();
	return(lreadchar());
    }
#else
    c = (char)getc(readstream);
#endif
#endif
    input_blocking = 0;
    if (feof(readstream)) {
	return(NIL);
    }
    return(make_strnode(&c, (char *)NULL, 1,
	    (getparity(c) ? STRING : BACKSLASH_STRING), strnzcpy));
}
コード例 #2
0
ファイル: parse.c プロジェクト: Distrotech/ucblogo
int rd_getc(FILE *strm) {
    int c;
#ifdef WIN32
    MSG msg;
#endif

#ifndef WIN32 /* skip this section ... */
#ifdef __RZTC__
    if (strm == stdin) zflush();
    c = ztc_getc(strm);
#else
    c = getc(strm);
#endif
    if (strm == stdin && c != EOF) update_coords(c);
#ifndef mac
    if (c == '\r') return rd_getc(strm);
#endif
#ifdef ibm
    if (c == 17 && interactive && strm==stdin) { /* control-q */
	to_pending = 0;
	err_logo(STOP_ERROR,NIL);
	if (input_blocking) {
#ifdef SIG_TAKES_ARG
	    logo_stop(0);
#else
	    logo_stop();
#endif
	}
    }
    if (c == 23 && interactive && strm==stdin) { /* control-w */
#ifndef __RZTC__
	getc(strm); /* eat up the return */
#endif

#ifdef SIG_TAKES_ARG
	logo_pause(0);
#else
	logo_pause();
#endif

	return(rd_getc(strm));
    }
#endif
#else /* WIN32 */
    if (strm == stdin) {
	if (winPasteText && !line_avail) winDoPaste();
	if (!line_avail) {
	    win32_text_cursor();
	    while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
		if (line_avail)
		    break;
		}
	    }
      c = read_line[read_index++];
      if (c == 17 && interactive && strm==stdin) { /* control-q */
	to_pending = 0;
	err_logo(STOP_ERROR,NIL);
	line_avail = 0;
	free(read_line);
	if (input_blocking) logo_stop(0);
	return('\n');
    }
    if (c == 23 && interactive && strm==stdin) { /* control-w */
	line_avail = 0;
	free(read_line);
	logo_pause(0);
	return(rd_getc(strm));
    }
      if (c == '\n') {
	line_avail = 0;
	free(read_line);
      }
    }
    else /* reading from a file */
      c = getc(strm);
#endif /* WIN32 */

#ifdef ecma
    return((c == EOF) ? c : ecma_clear(c));
#else
    return(c);
#endif
}