示例#1
0
文件: ansi.c 项目: gsrr/Python
void textgfx_init()
{
	set_input_mode();
#ifdef UNIX
	printf("\033[?25l");	/* hide cursor */
#endif
}
示例#2
0
static void search_mode_key(enum term_key_type type, unsigned int key)
{
	switch (type) {
	case KEY_NORMAL:
		switch (key) {
		case '\r':
			if (cmdline.buf.buffer[0]) {
				search_set_regexp(cmdline.buf.buffer);
				search_next();
				history_add(&search_history, cmdline.buf.buffer, search_history_size);
			} else {
				search_next();
			}
			cmdline_clear(&cmdline);
			set_input_mode(INPUT_NORMAL);
			break;
		}
		break;
	case KEY_META:
		switch (key) {
		case 'c':
			options.case_sensitive_search = (options.case_sensitive_search + 1) % 3;
			break;
		case 'r':
			search_set_direction(current_search_direction() ^ 1);
			break;
		}
		break;
	case KEY_SPECIAL:
		break;
	case KEY_PASTE:
		break;
	}
}
示例#3
0
void
edit_interface_rep::complete_start (string prefix, array<string> compls) {
  // check consistency
  tree st= subtree (et, path_up (tp));
  if (is_compound (st)) return;
  string s= st->label;
  int end= last_item (tp);
  if ((end<N(prefix)) || (s (end-N(prefix), end) != prefix)) return;

  // perform first completion and switch to completion mode if necessary
  if (N (compls) == 1) {
    string s= compls[0];
    if (ends (s, "()")) // temporary fix for Pari
      insert_tree (s, path (N(s)-1));
    else insert_tree (s);
    completions= array<string> ();
  }
  else {
    completion_prefix= prefix;
    completions      = close_completions (compls);
    completion_pos   = 0;
    insert_tree (completions[0]);
    complete_message ();
    beep ();
    set_input_mode (INPUT_COMPLETE);
  }
}
示例#4
0
文件: init.c 项目: zswek/bitch
void dev_init(void) {
    
    //console_init();
    
    keyboard_init();
    
    set_input_mode(2);
    
    disk_init();
    
}
示例#5
0
文件: sol06.3.c 项目: benbee/Learning
main()
{
	int	response;

	tty_mode(0);				/* save current mode	*/
	set_input_mode(TIMEOUT);		/* -icanon -echo vtime	*/
	response = get_response(ASK);		/* get some answer	*/
	tty_mode(1);				/* restore orig mode	*/
	putchar('\n');
	return response;
}
示例#6
0
文件: endec.c 项目: Ryuho/CPE357
int
main (void)
{
  unsigned char c;
  set_input_mode ();
  while ((c = getchar()) != '\004'){
		endec(c);
  }
   //fprintf(stdout,"\n");
   fflush(stdout);
  return EXIT_SUCCESS;
}
示例#7
0
static void search_mode_keypress(enum term_key_type type, unsigned int key)
{
	switch (cmdline_handle_key(&cmdline, &search_history, type, key)) {
	case CMDLINE_UNKNOWN_KEY:
		search_mode_key(type, key);
		break;
	case CMDLINE_KEY_HANDLED:
		break;
	case CMDLINE_CANCEL:
		set_input_mode(INPUT_NORMAL);
		break;
	}
}
示例#8
0
// Read a cuepoint from STDIN
float read_cuepoint()
{
	float cue;

	reset_input_mode();

	printf("Enter new cue point: ");
	fscanf( stdin, "%f", &cue );

	set_input_mode( );

	return cue;
}
示例#9
0
void handle_keypresses()
{
	struct timeval timeout;
	fd_set readfds;
	int retval = -1;

	// Make STDOUT unbuffered (if it is a terminal)
	if (isatty(STDOUT_FILENO))
		setbuf(stdout, NULL);

	// Turn off input buffering on STDIN
	set_input_mode( );
	
	// Check for keypresses
	while (get_state() != MADJACK_STATE_QUIT) {

		// Display position
		if (!quiet && isatty(STDOUT_FILENO)) {
			printf("[%1.1f/%1.1f]         \r", input_file->position, input_file->duration);
		}

		// Set timeout to 1/10 second
		timeout.tv_sec = 0;
		timeout.tv_usec = 100000;

		// Watch socket to see when it has input.
		FD_ZERO(&readfds);
		FD_SET(STDIN_FILENO, &readfds);
		retval = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);

		// Check return value 
		if (retval < 0) {
			// Something went wrong
			perror("select()");
			break;
			
		} else if (retval > 0) {
		
			read_keypress();

		}
	}

	// Restore the input mode
	reset_input_mode();
}
示例#10
0
文件: termios.c 项目: Xilinx/eglibc
int
main (void)
{
  char c;

  set_input_mode ();

  while (1)
    {
      read (STDIN_FILENO, &c, 1);
      if (c == '\004')		/* @kbd{C-d} */
	break;
      else
	putchar (c);
    }

  return EXIT_SUCCESS;
}
示例#11
0
文件: MsgScroll.cpp 项目: nuvie/nuvie
bool MsgScroll::init(char *player_name)
{
 std::string prompt_string;

 prompt_string.append(player_name);
 if(game_type==NUVIE_GAME_U6)
 {
   prompt_string.append(":\n");
 }

 prompt_string.append(">");

 if(set_prompt((char *)prompt_string.c_str(),font) == false)
   return false;

 set_input_mode(false);

 return true;
}
示例#12
0
// Read in the name of a file from STDIN
static
char* read_filepath()
{
	char *filepath = malloc(MAX_FILENAME_LEN);
	int i;
	
	reset_input_mode();

	printf("Enter name of file to load: ");
	fgets( filepath, MAX_FILENAME_LEN-1, stdin );
	
	// Remove carrage return from end of filepath
	for(i=0; i<MAX_FILENAME_LEN; i++) {
		if (filepath[i]==10 || filepath[i]==13) filepath[i]=0;
	}

	set_input_mode( );
	
	return filepath;
}
示例#13
0
文件: mytimer.c 项目: Ryuho/CPE357
/** The main thing.
 * @param argc count of command-line tokens.
 * @param argv array of command-line tokens.
 * @return 0 on success, 1-255 on failure.
 */
int main(int argc, char* argv[]){
   if(argc != 2){
      printf("usage: mytimer <seconds>\n");
      return EXIT_FAILURE;
   }
   
   if(sscanf(argv[1], "%lf",&time) != 1){
      printf("\"%s\" is not a number.\n", argv[1]);
      return EXIT_FAILURE;
   }
   if(time <= 0){
      printf("Invalid time(%lf). Must be >= 0.\n",time);
      return EXIT_FAILURE;
   }
   
   running = TRUE;
   
   char c = 'z';
   
   set_input_mode();
   
   //setup the signal stuff
   timerSetup();
   
   while(1){
      read (STDIN_FILENO, &c, 1);
      if(c == 'q'){
         fprintf(stdout,"\n");
         fflush(stdout);
         return EXIT_SUCCESS;
      }
      if(c == 'h' || c == 'H' || c == 'm' ||
      c == 'M' || c == 's' || c == 'S' ||
      c == 'c' || c == 'r'){
         changeTime(c);
         c = 'z';
      }
   }
   return EXIT_SUCCESS;
}
示例#14
0
文件: kblib.c 项目: 8l/bcpl
int init_keyb(void)
{ set_input_mode();
  return 0;
}
示例#15
0
void
edit_interface_rep::set_input_normal () {
  set_input_mode (INPUT_NORMAL);
}