The R Project SVN R

Rev

Rev 88580 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88580 Rev 89281
Line 136... Line 136...
136
   if (!Win32InputStream) {
136
   if (!Win32InputStream) {
137
       Win32InputStream = GetStdHandle(STD_INPUT_HANDLE);
137
       Win32InputStream = GetStdHandle(STD_INPUT_HANDLE);
138
       Win32OutputStream = GetStdHandle(STD_OUTPUT_HANDLE);	
138
       Win32OutputStream = GetStdHandle(STD_OUTPUT_HANDLE);	
139
   }
139
   }
140
   GetConsoleMode(Win32InputStream,&OldWin32Mode);
140
   GetConsoleMode(Win32InputStream,&OldWin32Mode);
-
 
141
 
-
 
142
   /* to capture ^C and set R_interrupts_pending */
-
 
143
   DWORD mode;
-
 
144
   GetConsoleMode(Win32InputStream, &mode);
-
 
145
   mode &= ~ENABLE_PROCESSED_INPUT;
141
   SetConsoleMode(Win32InputStream, ENABLE_PROCESSED_INPUT); /* So ^C works */
146
   SetConsoleMode(Win32InputStream, mode);
-
 
147
 
142
   AltIsDown = 0;
148
   AltIsDown = 0;
143
}
149
}
144
 
150
 
145
static void
151
static void
146
gl_char_cleanup(void)		/* undo effects of w_gl_char_init */
152
gl_char_cleanup(void)		/* undo effects of w_gl_char_init */
Line 708... Line 714...
708
    }
714
    }
709
    gl_w_cnt = w;
715
    gl_w_cnt = w;
710
    return 0;
716
    return 0;
711
}
717
}
712
 
718
 
713
/* Returns 1 on EOF */
719
/* Returns 1 on EOF, -1 on ^C */
714
static int
720
static int
715
getline0(const char *prompt)
721
getline0(const char *prompt)
716
{
722
{
717
    int c, loc, tmp;
723
    int c, loc, tmp;
718
    char *stmp;
724
    char *stmp;
Line 764... Line 770...
764
	      case '\002': 	/* ^B, VK_LEFT */
770
	      case '\002': 	/* ^B, VK_LEFT */
765
		gl_fixup(gl_prompt, -1, gl_pos - gl_edit_unit_size_left());
771
		gl_fixup(gl_prompt, -1, gl_pos - gl_edit_unit_size_left());
766
		break;
772
		break;
767
	      case '\003':                                      /* ^C */
773
	      case '\003':                                      /* ^C */
768
		  gl_fixup(gl_prompt, -1, gl_cnt);
774
		  gl_fixup(gl_prompt, -1, gl_cnt);
769
		  gl_puts("^C\n");
775
		  gl_puts("^C");
770
		  gl_kill(0);
776
		  gl_cleanup();
771
		  gl_fixup(gl_prompt, -2, BUF_SIZE);
777
		  return -1;
772
		break;
778
		break;
773
	      case '\004':					/* ^D */
779
	      case '\004':					/* ^D */
774
		if (gl_cnt == 0) {
780
		if (gl_cnt == 0) {
775
		    gl_buf[0] = 0;
781
		    gl_buf[0] = 0;
776
		    gl_cleanup();
782
		    gl_cleanup();
Line 890... Line 896...
890
    gl_newline();
896
    gl_newline();
891
    gl_cleanup();
897
    gl_cleanup();
892
    return 0;
898
    return 0;
893
}
899
}
894
 
900
 
895
/* returns 1 on eof */
901
/* returns 1 on eof, -1 on ^C */
896
/* The line is stored into buf of size buflen, attempts to enter a longer line
902
/* The line is stored into buf of size buflen, attempts to enter a longer line
897
   are ignored with a beep signal. */
903
   are ignored with a beep signal. */
898
int
904
int
899
getline(const char *prompt, char *buf, int buflen)
905
getline(const char *prompt, char *buf, int buflen)
900
{
906
{
Line 903... Line 909...
903
    gl_buf = buf;
909
    gl_buf = buf;
904
    gl_buf[0] = '\0';
910
    gl_buf[0] = '\0';
905
    return getline0(prompt);
911
    return getline0(prompt);
906
}
912
}
907
 
913
 
908
/* returns 1 on eof */
914
/* returns 1 on eof, -1 on ^C */
909
/* The line is stored into a dynamically allocated buffer. The buffer has to
915
/* The line is stored into a dynamically allocated buffer. The buffer has to
910
   be freed by the caller using gl_free() when no longer needed. */
916
   be freed by the caller using gl_free() when no longer needed. */
911
int
917
int
912
getline2(const char *prompt, char **buf)
918
getline2(const char *prompt, char **buf)
913
{
919
{