Exemplo n.º 1
0
void show_params(){
  int maxsize, i, x, y;
  ioctl(1, TIOCGWINSZ, &(gl_env.win));
  // error check?
  gl_env.flag = 0;
  term_clear();
  /*my_int(gl_env.nbelems);
    my_char('\n');*/
  for (i=0,x=0,y=0,maxsize=0;i<gl_env.nbelems;i++,y++){
    if (y >= gl_env.win.ws_row) {
      y = 0;
      x += maxsize + 2;
      maxsize = 0;
    }
    if (maxsize < gl_env.elems[i].size)
      maxsize = gl_env.elems[i].size;
    if (x+maxsize >= gl_env.win.ws_col){
      term_clear();
      term_pos(0, 0);
      my_str("Please enlarge your terminal.");
      gl_env.flag = TRUE;
      break;
    }
    gl_env.elems[i].x = x;
    gl_env.elems[i].y = y;
    term_pos(x, y);
    refreshout(i);
  }
  if (!gl_env.flag)
    refreshin(); //underlines selected
}
Exemplo n.º 2
0
static void dirty_check(void)
{
	if (!dirty || dummy)
		return;

        term_resize_dirty();

	if (full_redraw) {
                full_redraw = FALSE;

		/* first clear the screen so curses will be
		   forced to redraw the screen */
		term_clear();
		term_refresh(NULL);

		mainwindows_redraw();
		statusbar_redraw(NULL, TRUE);
	}

	mainwindows_redraw_dirty();
        statusbar_redraw_dirty();
	term_refresh(NULL);

        dirty = FALSE;
}
void init_terminal()
{
  struct termio line;
  char*  name;
  int   fd;

  ioctl(0, TCGETA, &line);
  gl_env.line_backup = line;

  line.c_lflag &= ~(ICANON | ECHO | ISIG);
  line.c_cc[VMIN] = READMIN;
  line.c_cc[VTIME] = READTIME;

  ioctl(0, TCSETA, &line);
  
  if(ttyname(0) != NULL )
    name = ttyname(0);
  else
    my_panic("Terminal failed.", 1);
    
  fd = open(name, O_WRONLY);

  gl_env.stdio_backup = dup(1);
  dup2(fd, 1);

  term_vi();
  term_clear();
}
Exemplo n.º 4
0
void display(MYD myd, int index, int n_match, int scroll) {
    int i;
    int x, y;

    term_clear();
    print_prompt(edit.text, edit.cursor);

    term_move(0, 1);
    x = 0;
    y = 1;

    i = scroll;

    while(i < n_match) {
        /*  単語の表示  */
        display_word(myd_key(myd, index+i), &x, &y);

        if(y >= term_height - 1)
            break;

        /* 意味の表示  */
        display_mean(myd_text(myd, index+i), &x, &y);

        i ++;

        if(y >= term_height - 1)
            break;
    }

    print_status(myd, n_match);
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    Echiquier B = E;
    double end_game;
    do{//loop to start a new game
    do{//loop to change player until mat

		term_clear(); // un peu mieux ;)

        print_game(&B);
        if(hunt_chess(&B)){
        printf("Vous etes en echec !\n");
        }
        move_piece(&B);
       /* printf("\n----------blacks_positions------------\n");
        print_binary_chess_table(B.blacks_position);
        printf("\n---------whites_position----------\n");
        print_binary_chess_table(B.whites_position);
        printf("\n");
        printf("a6 : %d, %d, (%d,%d), %d\n", B.t[2][0].t, B.t[2][0].c,B.t[2][0].p.posx,B.t[2][0].p.posy,B.t[2][0].m);
        getchar();*/
       //print_game(&B);

    }while(!mat(&B));
    char *player;
    switch (B.joueur){
        case JOUEUR_BLANC : player = "blanc";
        break;
        case JOUEUR_NOIR : player = "noir";
    }
	term_clear();

    print_game(&B);
    printf("\nJoueur %s, vous etes echec et mat !\n",player);
    getchar();
    B = E;
    do{
        printf("Souhaitez-vous refaire une partie ?\n1. Oui\n2. Non\n\n");
        scanf("%lf",&end_game);
        if(end_game != 1 && end_game != 2){
            printf("taper 1 ou 2.\n");
        }
    }while(end_game != 1 && end_game != 2);
    }while(end_game==1);
    return 0;
}
Exemplo n.º 6
0
void	restore_terminal()
{
	term_ve();
	term_clear();
	term_move(0,0);
	tcsetattr(1, TCSAFLUSH, &gl_env.line_backup);
	dup2(gl_env.stdio_backup, 1);
}
Exemplo n.º 7
0
void init_terminal(void)
{
  term_row=0;
  term_column=0;
  term_color=make_color(COLOR_WHITE, COLOR_BLACK);
  term_buffer=(uint16_t*)0xB8000; // frame buffer location, provided by BIOS
  term_clear();
  move_cursor(0); // best to use update_bios_cursor, but this is faster
}
Exemplo n.º 8
0
void	show_elems()
{	
	int i;
	int x;
	int y;
	int max;
	char space = 5;
	
	get_win_size();
	gl_env.flag = 0;
	term_clear();
	//my_int(gl_env.nbelems);
	for(i=0, x=0, y=0, max=0; i<gl_env.nbelems; i++, y++)
	{
		//my_int(gl_env.win.ws_row);
		if(y>= gl_env.win.ws_row)
		{
			x+=(max+ space);
			y=0;
			max=0;
		}
		
		if(max <gl_env.elements[i].size)
			max = gl_env.elements[i].size;
		if((x+max) >= gl_env.win.ws_col)
		{
			term_clear();
			gl_env.flag = 1;
			term_move(0,0);
			my_str("Please Enlarge Window");
			break;
		}
		
		gl_env.elements[i].x = x;		
		gl_env.elements[i].y = y;
		//my_int(max);
		refresh_out(i);
		//my_int(max);
	}
	
	if(!gl_env.flag)
		refresh_in();
}
Exemplo n.º 9
0
/**
 * Updates the applications main terminal screen
 *
 * This is usually called in response to certain events
 */
void apme_screen_update(void)
{
    struct aion_group_iter iter;
    char buf[256];

    /* Reset screen */
    term_clear();

    term_setcolor(TERM_FG_YELLOW);
    printf("***** APme version %s (by Snowsong @ Nexus)\n\n", APME_VERSION_STRING);

    term_setcolor(TERM_FG_YELLOW);
    term_setcolor(TERM_BG_BLUE);
    printf("=================== Current Group Status ===========");
    term_setcolor(TERM_COLOR_RESET);
    printf("\n\n");

    for (aion_group_first(&iter); !aion_group_end(&iter); aion_group_next(&iter))
    {
        /* Paint ourselves green */
        if (aion_player_is_self(iter.agi_name))
        {
            term_setcolor(TERM_FG_GREEN);
        }
        else
        {
            term_setcolor(TERM_COLOR_RESET);
        }

        printf(" * %-16s (AP: %d) %s\n", iter.agi_name, iter.agi_apvalue, iter.agi_invfull ? " -- FULL INVENTORY" : "");
    }

    printf("\n");
    term_setcolor(TERM_FG_YELLOW);
    term_setcolor(TERM_BG_BLUE);
    printf("====================================================");
    term_setcolor(TERM_COLOR_RESET);
    printf("\n\n");

    if (aion_aploot_rights(buf, sizeof(buf)))
    {
        term_setcolor(TERM_FG_MAGENTA);
        printf("Current AP loot info:\n%s\n", buf);
    }
    term_setcolor(TERM_COLOR_RESET);

    term_setcolor(TERM_FG_CYAN);
    help_usage(buf, sizeof(buf));
    printf("\n%s\n", help_mainscreen);
    printf("%s\n", buf);
    term_setcolor(TERM_COLOR_RESET);

    fflush(stdout);
}
Exemplo n.º 10
0
Arquivo: Test.c Projeto: utayo/typing
	/**
	 * 試験開始前の画面を表示する.
	 */
	void Test_begin()
	{
	  term_clear();
	  
	  term_gotoxy(ref_i("begin_x"),ref_i("begin_y"));
	  term_disp(ref("test_start_message"));
	  
	  Intprt_disp_guide(&test.intprt);
	  
	  Intprt_pause_core(&test.intprt, ref("test_pause_message"), FALSE);
	}
Exemplo n.º 11
0
void show_elems()
{
  int i;
  int x;
  int y;
  int max;

  ioctl(0, TIOCGWINSZ, &(gl_env.win));
  gl_env.flag = 0;
  term_clear();

  for(i = 0, x = 0, y = 0, max = 0; i < gl_env.nbelems; i++, y++)
    {
      if(y >= gl_env.win.ws_row)
	{
	  y = 0;
	  x += max + 5;
	  max = 0;
	}

      if(max < gl_env.elements[i].size)
         max = gl_env.elements[i].size;
	
      if(x + max >= gl_env.win.ws_col)
	{
	  term_clear();
	  my_str("Please enlarge the window");
	  gl_env.flag = 1;
	  break;
	}

      gl_env.elements[i].x = x;
      gl_env.elements[i].y = y;
      refreshout(i);

      if(!gl_env.flag)
	refreshin();
    }
}
Exemplo n.º 12
0
void kern_main(multiboot_info_t *boot_info) {
  term_clear();
  term_color(TERM_GREEN, TERM_BLACK);
  term_print("Booting\n");
  term_print("Initializing memory manager\n");
  if (mm_init(boot_info)) {
    term_print("Failed to initialize memory manager\n");
    return;
  }

  com_init();
  com_print(COM1, "Hello COM1!\n");
  log_info("This is a logging test!");
  return;
}
Exemplo n.º 13
0
Arquivo: Test.c Projeto: utayo/typing
	/**
	 * エラーチェックをする(表示もする)
	 */
	void Test_error_check()
	{
	  int count = 0;
	  int i;
	  Examination * examination2;
	  Test * test2 = Test_get_test();
	  
	  err_start();
	  
	  while(count <= test.y){
	    term_clear();
	    
	    Test_disp_info(ERR_MESS_X+2, ERR_MESS_Y);
	    
	    term_gotoxy(ERR_MESS_X, ERR_MESS_Y+2);
	    term_rev_disp(ref("errchk_message"));
	    
	    Intprt_disp_guide(&test.intprt);
	    
	    //エラー結果を表示する
	    for (i=0; i < ref_i("err_correct_line") && count <= test.y; i++, count++){
	      term_gotoxy(ERR_DISP_X, ERR_DISP_Y+i*4);
	      term_disp(test.text_buf[count % test.text_no]);
	      term_gotoxy(ERR_DISP_X, ERR_DISP_Y+i*4+1);
	      term_disp(test.typed[count]);
	      term_gotoxy(ERR_DISP_X, ERR_DISP_Y+i*4+2);
	      term_disp(err_check(test.text_buf[count % test.text_no],
				  test.typed[count]));
	    }
	    
	    //HIDE_MODEでなければ誤字結果の詳細を表示する
	    examination2 = &(test2->examination);
		if(examination2->mode  == EXAM_MODE){//本番モードの場合
	      if(HIDE_ERR_MODE_EX==0){//エラーチェック画面を表示する
    	    Intprt_long_pause_core(&test.intprt, ref("long_pause_message_test"), FALSE);
	      }
	    }else{//練習モードの場合
	      if(HIDE_ERR_MODE_PRA==0){//エラーチェック画面を表示する
        	Intprt_long_pause_core(&test.intprt, ref("long_pause_message_test"), FALSE);
	      }
	    }
	    if (!test.intprt.status){
	      return;
	    }
	  }
	}
Exemplo n.º 14
0
void parse_userinput(uint8_t *buf){
	uint8_t input[256] = {0};	
	int i1;

	//These work everywhere.
	sscanf(buf,"%s %i",input,&i1);
	if (strcmp(input,"clear") == 0){
		term_clear();
		return;
	}else if (strcmp(input,"debug") == 0){
		return;
	}else if (strcmp(input,"open") == 0){
		app_openuart();
		return;
	}
	printf("Unknown command.\n");
}
Exemplo n.º 15
0
Terminal* term_create(unsigned int w, unsigned int h, const char* fn) {
	SDL_Surface* temp = IMG_Load(fn);
	if (temp == NULL) {
		printf("Unable to load image: %s\n", fn);
		exit(1);
	}

	Terminal* newterm = calloc(1, sizeof(Terminal));
	char* textbuff = calloc(w*h, sizeof(char));

	newterm->font = temp;
	newterm->width = w;
	newterm->height = h;
	newterm->text = textbuff;

	term_clear(newterm);

	return newterm;
}
Exemplo n.º 16
0
//------------------------------------------------------------------------------
void term_init(tTermState * ts, float widthPer, float heightPer, int width, int height)
{
    ts->image = 0;
    if(ts->image == 0)
    {
        if(width <= 0 || height <= 0)
        {
            ts->term_w = VTERM_WIDTH;
            ts->term_h = VTERM_HEIGHT;
        }
        else
        {
            ts->term_w = width;
            ts->term_h = height;
        }
        ts->term_vbuff = malloc(ts->term_w * ts->term_h * sizeof(tScrChr));
        int w  = (state->screen_width  * widthPer);
        int h  = (state->screen_height * heightPer);
        ts->image = create_image_from_buf((unsigned char *) tv_jpeg_raw_data, tv_jpeg_raw_size, w, h);
        term_clear(ts, VTERM_CLR);
        ts->tv_width     = vgGetParameteri(ts->image, VG_IMAGE_WIDTH);
        ts->tv_height    = vgGetParameteri(ts->image, VG_IMAGE_HEIGHT);
        ts->offsetXY.y   = (ts->tv_height * .14f);
        ts->offsetXY.x   = (ts->tv_width  * .10f);
        ts->tvXY.x       = (state->screen_width  - ts->tv_width) / 2;
        ts->tvXY.y       = (state->screen_height - ts->tv_height) / 2;
        ts->image_height = ts->tv_height - (ts->offsetXY.y * 2);
        ts->image_width  = ts->tv_width  - (ts->offsetXY.x * 2);
        ts->imageXY.x    = (state->screen_width - ts->image_width)   / 2;
        ts->imageXY.y    = (state->screen_height - ts->image_height) / 2;
        ts->term_x_inc   = ts->image_width  / ts->term_w;
        ts->term_y_inc   = ts->image_height / ts->term_h;
        ts->txtXY.x      = ts->imageXY.x + ts->term_x_inc;
        ts->txtXY.y      = state->screen_height - ts->imageXY.y - ts->term_y_inc * 1.5;
        ts->numPointFont = numPointFontMed; //med default
        ts->numFont      = 1; //topaz font
        ts->term_color   = 0;
    }
}
Exemplo n.º 17
0
void term_init( SDL_Surface *scr ) {
  SDL_Surface* temp;
  char *p_pixel;

  screen = scr;
  
  term_w = screen->w >> 4;
  term_h = screen->h >> 4;
  term = malloc( sizeof( termchar_t ) * term_w * term_h );
  term_clear();

  temp = SDL_LoadBMP( "font1.bmp" );
  if( !temp ) printf( "KiwiDriveClient [error]: Unable to load font1.bmp\n" );
  font[ 0 ] = SDL_DisplayFormat( temp );
  SDL_FreeSurface( temp );
  
  temp = SDL_LoadBMP( "font2.bmp" );
  if( !temp ) printf( "KiwiDriveClient [error]: Unable to load font2.bmp\n" );
  font[ 1 ] = SDL_DisplayFormat( temp );
  SDL_FreeSurface( temp );
  
  SDL_SetColorKey( font[ 0 ], SDL_SRCCOLORKEY, SDL_MapRGB( screen->format, 0xFF, 0x00, 0xFF ) );
  SDL_SetColorKey( font[ 1 ], SDL_SRCCOLORKEY, SDL_MapRGB( screen->format, 0xFF, 0x00, 0xFF ) );
}
Exemplo n.º 18
0
Arquivo: graf.c Projeto: imr/ngspice
void
gr_iplot(struct plot *plot)
{
    struct dbcomm *db;
    int dontpop;        /* So we don't pop w/o push. */
    char buf[30];

    hit = 0;
    for (db = dbs; db; db = db->db_next) {
        if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) {

            if (db->db_graphid)
                PushGraphContext(FindGraph(db->db_graphid));

            set(plot, db, FALSE, VF_PLOT);

            dontpop = 0;
            if (iplot(plot, db->db_graphid)) {
                /* graph just assigned */
                db->db_graphid = currentgraph->graphid;
                dontpop = 1;
            }

            set(plot, db, TRUE, VF_PLOT);

            if (!dontpop && db->db_graphid)
                PopGraphContext();

        } else if (db->db_type == DB_TRACENODE || db->db_type == DB_TRACEALL) {

            struct dvec *v, *u;
            int len;

            set(plot, db, FALSE, VF_PRINT);

            len = plot->pl_scale->v_length;

            dontpop = 0;
            for (v = plot->pl_dvecs; v; v = v->v_next) {
                if (v->v_flags & VF_PRINT) {
                    u = plot->pl_scale;
                    if (len <= 1 || hit <= 0 || hit2 < 0) {
                        if (len <= 1 || hit2 < 0)
                            term_clear();
                        else
                            term_home();
                        hit = 1;
                        hit2 = 1;
                        printf(
                            "\tExecution trace (remove with the \"delete\" command)");
                        term_cleol();
                        printf("\n");

                        if (u) {
                            printf("%12s:", u->v_name);
                            if (isreal(u)) {
                                printf("%s",
                                       getitright(buf, u->v_realdata[len - 1]));
                            } else {
                                /* MW. Complex data here, realdata is NULL
                                   (why someone use realdata here again) */
                                printf("%s",
                                       getitright(buf, u->v_compdata[len - 1].cx_real));
                                printf(", %s",
                                       getitright(buf, u->v_compdata[len - 1].cx_imag));
                            }
                            term_cleol();
                            printf("\n");
                        }
                    }
                    if (v == u)
                        continue;
                    printf("%12s:", v->v_name);
                    if (isreal(v)) {
                        printf("%s", getitright(buf, v->v_realdata[len - 1]));
                    } else {
                        /* MW. Complex data again */
                        printf("%s", getitright(buf, v->v_compdata[len - 1].cx_real));
                        printf(", %s", getitright(buf, v->v_compdata[len - 1].cx_imag));
                    }
                    term_cleol();
                    printf("\n");
                }
            }
            set(plot, db, TRUE, VF_PRINT);
        }
    }
}
Exemplo n.º 19
0
int main(int argc, char *argv[]){
	
	term_clear();

	//Test
	parse_userinput("open");

	user_input.inpptr = 0;


	


	while(1){
		

		//Print state
		term_clear();

		printf("Input: %s\n", user_input.buffer);

		printf("Motor:\n");
		printf("  Speed    : %hu\n"    ,motor.speed);
		printf("  Mode     : %u\n"      ,motor.mode);
		printf("  Throttle : %u\n"  ,motor.throttle);
		printf("  Brake    : %u\n"     ,motor.brake);
		printf("  Status   : %u\n"    ,motor.status);		
		printf("  Voltage  : %hu\n"  ,motor.voltage);
		printf("  current  : %hi\n"  ,motor.current);

		printf("Display:\n");
		printf("  Distance : %lu\n"    ,display.distance);
		printf("  Speed    : %hu\n"    ,display.speed);
		printf("  SOC      : %u\n"       ,display.soc);
		printf("  Throttle : %u\n"  ,display.throttle);

		

		int n = uart_read_start(uart,20);

		//Read it:
		int len = 20;
		uint8_t buffer[20];
		int size = stream_read(stream,buffer,len);
		
		
		
		//Parse the data:
		for (int i=0;i<size;i++){
			bus_receive(bus,buffer[i]);

		}

		//Message?
		if (bus_check_for_message(bus)){
			printf_clr(CLR_GREEN,"MSG OK\n");
		}else{
			printf_clr(CLR_YELLOW,"MSG  NOT OK\n");
			printf("Read %i bytes into buffer.\n",size );
			printf_hex_block(buffer,size,true);
		}

		select_term();

	}



	return 0;
}
Exemplo n.º 20
0
Arquivo: Test.c Projeto: utayo/typing
	/**
	 * タイピングの結果を表示する.
	 */
	void Test_result()
	{
	  char buf[MAXSTRLEN];
	  int writeResult = TRUE;
	  Examination * examination2;
	  Test * test2 = Test_get_test();
	  
	  //合格情報を記録する for typingtestex拡張
	  Examination_writePassInfoAndShowResult(&(test.examination), &(test.user));
	 
	  term_clear();
	  
	  Test_disp_info(RESULT_X+2, RESULT_Y);
	  
	  term_gotoxy(RESULT_X, RESULT_Y+1);
	  term_rev_disp(ref("result_message"));
	  
	  //合否を表示
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 3);
	  term_disp(ref("exam_result"));
	  if(exam_result(typing_second)==TRUE){    
	    term_disp(ref("pass_message"));
	  }else{
	    term_disp(ref("fail_message"));
	  }    
	  
	  //試験日を表示
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 4);
	  term_disp(ref("exam_date"));
	  get_date(buf);
	  term_disp(buf);
	  
	  //タイピング時間を表示
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 5);
	  term_disp(ref("typing_time"));
	  sprintf(buf, "%d ", typing_second);
	  term_disp(buf);
	  term_disp(ref("second_message"));
	  
	  //端末名を表示
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 6);
	  term_disp(ref("machine_name"));
	  get_hostname(buf);
	  term_disp(buf);
	  
	  //正打鍵数を表示    
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 7);
	  term_disp(ref("correct_type"));
	  sprintf(buf, "%d ", err_correct_type());
	  term_disp(buf);
	  term_disp(ref("word_message"));
	  
	  //ミスタッチ数を表示    
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 8);
	  term_disp(ref("miss_count"));
	  sprintf(buf, "%d ", err_error_type());
	  term_disp(buf);
	  term_disp(ref("word_message"));
	  
	  //1分あたりの正しいタッチ数を表示    
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 9);
	  term_disp(ref("correct_type_per_min"));
	  sprintf(buf, "%d ", correct_type_per_min(typing_second));
	  term_disp(buf);
	  term_disp(ref("per_min_message"));
	  
	  
	  //テキスト情報のタイトル表示
	  term_gotoxy(RESULT_X, RESULT_Y + 11);
	  term_rev_disp(ref("exam_info_message"));
	  
	  //問題名を表示
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 13);
	  term_disp(ref("exam_title"));
	  term_disp(ref("title"));
	  
	  //最大誤字数
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 14);
	  term_disp(ref("max_error_type_msg"));
	  term_disp(ref("max_error_type"));
	  term_disp(ref("word_message"));
	  
	  //制限時間
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 15);
	  term_disp(ref("time_limit_msg"));
	  term_disp(ref("time_limit"));
	  term_disp(ref("second_message"));
	  
	  //テキスト総文字数
	  term_gotoxy(RESULT_X + 5, RESULT_Y + 16);
	  term_disp(ref("text_length_msg"));
	  term_disp(ref("total_text_length"));
	  term_disp(ref("word_message"));
	  
	  Intprt_disp_guide(&test.intprt);
	  
	  //次の画面遷移のメッセージを表示する
	  examination2 = &(test2->examination);
	  if(examination2->mode  == EXAM_MODE){//本番モードの場合
	    if(HIDE_ERR_MODE_EX){  
	      Intprt_pause_core(&test.intprt, ref("result_end_message"), FALSE);
	    }else{
      	  Intprt_pause_core(&test.intprt, ref("go_error_check_message"), FALSE);
	    }
	  }else{//練習モードの場合
	    if(HIDE_ERR_MODE_PRA){
	      Intprt_pause_core(&test.intprt, ref("result_end_message"), FALSE);
	    }else{
     	  Intprt_pause_core(&test.intprt, ref("go_error_check_message"), FALSE);
	    }
	  }
	}
Exemplo n.º 21
0
void term_full_redisplay(void)
{
  term_clear();
  term_redisplay();
}
Exemplo n.º 22
0
static int cmd_clear(const char *args[])
{
         term_clear();
}
Exemplo n.º 23
0
Arquivo: view.c Projeto: vocho/openqnx
int view(int laddr) {
	int n, c;
	char c1;

	if(laddr < 0)
		return(ERROR5);

	if(laddr)
		curln = laddr;

	switch(c1 = *lp++) {

	case 'a':
		if((c  = getint() - 1) < STATUS_AREA   ||  c  > TEXT_AREA)
			return(ERROR5);
		if(*lp++ != ' ')
			return(ERROR5);

/*
		n = ((n = getint()) > 7) ? (n << 8) | 0x02 : n << 8;
		attributes[c] = (attributes[c] & 0x00fd) | n | 0x8000;
*/
/*	n = ((n = getint()) > 7 && dev_type < 3) ? (n << 8) | 0x02 : n << 8;	@@@	*/
		n = ((n = getint()) > 7) ? (n << 8) | 0x02 : n << 8;
		if(*lp++ != ' ')
			return(ERROR5);
		n = (n & 0x0fff) | ((getint() & 0x7) << 12);
		attributes[c] = (attributes[c] & 0x00fd) | n | 0x8000;
		if(c == 2) {
			term_fill(attributes[2]);
			term_color(attributes[2]);
			term_clear(TERM_CLS_SCR);
			}
		mark_line(0);
		clr_flag = 1;
		return(OK);

	case 'c':
		if((n = getint()) < 0  ||  n > screen_height-SCREEN_OFFSET)
			return(ERROR5);

		if(n)
			center_line = n - 1;
		else {
			screen_row = imax(1, imin(lastln - center_line, curln + 1));
			clear_screen1(1);
			clr_flag = 1;
			mark_line(0);
			update_screen();
			}

		return(OK);

	case 'f':
	case 'q':
		view_quick = !view_quick;
		return(OK);

	case 'l':
		n = left_margin;
		goto marg;
	case 'r':
		n = right_margin;
marg:
		if((c = *lp++) == '+')
			n += getint();
		else if(c == '-')
			n -= getint();
		else if(c == '.')
			n = curcol;
		else {
			--lp;
			n = getint();
			}

		if(c1 == 'l') {
			left_margin = imin(right_margin-1, imax(1, n));
			cc_reg = (n == left_margin);
			}
		else {
			right_margin = imax(left_margin+1, imin(LINE_LENGTH, n));
			cc_reg = (n == right_margin);
			}

		firstp->lflags |= DIRTY_FLAG;
		if(nmarks)
			mark_line(marker1);

		return(OK);

/*
	case 'm':
		menu = !menu;
		return(OK);
*/

	case 's':
		if(*lp == '-') {
			++lp;
			n = -getint();
			}
		else
			n = getint();

		screen_row = imax(1, imin(lastln - center_line, screen_row + n));
		curln = imax(1, imin(lastln, curln + n));

		clear_screen1(1);
		clr_flag = 1;
		mark_line(0);
		update_screen();
		return(OK);

	case 't':
		if((n = getint()) == 2  ||  n == 4  ||  n == 8) {
			tab_len = n - 1;
			mark_line(0);
			update_screen();
			}
		return(OK);

	case 'z':
/*
		if(zoom > NSCREEN_SIZES  ||  screen_sizes[zoom] == 0)
			zoom = 1;
		set_video_size(zoom);
*/
		clear_screen1(1);
		clr_flag = 1;
		mark_line(0);
		update_screen();
		return(OK);
		}

	return(ERROR2);
	}
Exemplo n.º 24
0
Arquivo: Test.c Projeto: utayo/typing
	/**
	 * タイピングを始めた時の処理
	 */
	void Test_typing()
	{
	  Bool cursor = ref_i("cursor");
	  Bool esc_begin = FALSE;//ESCシーケンスが始まったか
	  Bool fnc_begin = FALSE;//Fキーが始まったか
	  int test_time;
	  unsigned char code;
	  char dispcode[2] = {'\0','\0'};
	  Examination * examination;
	  
	  term_clear();
	  
	  test.x = 0;
	  test.y = 0;
	  
	  /*
	    if (ref_i("hand")){
	    Intprt_disp_hand_core(&test.intprt, TEST_HAND_X, TEST_HAND_Y);
	    }
	  */
	
	  //開始時間を記録する typingtestex用拡張
	  examination = &(test.examination);
	  Examination_setTestStartDate(examination);
	  
	  Test_disp_info(TEST_HAND_X+12, 2);
	  
	  Intprt_disp_guide(&test.intprt);
	  
	  time_start();
	  
	  Test_disp_text();
	  
	  test_time = ref_i("time_limit");
	  test.typed[test.y] = Test_alloc(MAX_TYPE+1);
	  while(1){
	    code = term_getkey();
	    typing_second = time_now();
	    
	    //時間が来たら終了する
	    if (time_now() >= test_time){
	      *(test.typed[test.y]+test.x) = '\0';
	      term_keyclear();
	      return;
	    }
	    
	    switch(code){
	    case 0xff://escape sequenseが始まった場合
	      esc_begin = TRUE;
	      continue;
	    case DEL:
	    case BS:
	      continue;
	    case ESC:
	      test.intprt.status = FALSE;
	      return;
	    case CR:
				//if (test.y < MAX_TYPE_LINE-1){//タイプの最大行を指定する時は使う      
	      if(test.text_no-1 <= test.y){
			return;
	      }
	      
	      *(test.typed[test.y]+test.x) = '\0';
	      test.x = 0;
	      test.y++;
	      test.typed[test.y] = Test_alloc(MAX_TYPE+1);
	      Test_disp_text(test);
	      
	      //} else{
	      //return;
	      //}
	      break;
	    default:
	      dispcode[0] = code;
	
	      //ESCシーケンスの場合無視する
    	  if(esc_begin == TRUE && 0x30 <= dispcode[0] && dispcode[0] < 0x40){//ファンクションキーの場合
			fnc_begin = TRUE;
			continue;
	 	  }else if(esc_begin == TRUE){
			esc_begin = FALSE;
			continue;
    	  }else if(fnc_begin == TRUE){
			esc_begin = FALSE;
			fnc_begin = FALSE;
		  }
	      
		  if (test.x < MAX_TYPE){//行内でタイプしている場合
		
		
			*(test.typed[test.y]+test.x) = code;
			test.x++;
			if (cursor){
				Examination * examination;
				Test * test = Test_get_test();
				examination = &(test->examination);
				if(examination->mode  == EXAM_MODE){//本番モードの場合
	  	            if(HIDE_TYPE_MODE_EX==1){//本番モードでタイプエコーを隠す場合
	     		        term_disp(" ");
	     	        }else{//本番モードでタイプエコーを隠さない場合				
	          		    term_disp(dispcode);
	           		}
	       		}else{//練習モードの場合
	            	if(HIDE_TYPE_MODE_PRA){//練習モードでタイプエコーを隠す場合
	             		term_disp(" ");
	            	}else{//練習モードでタイプエコーを隠さない場合
	            		term_disp(dispcode);
	           		}
	        	}
			}
		  }else{//行末にカーソルが行った場合
			*(test.typed[test.y]+test.x) = '\0';
			test.x = 0;
			test.y++;
			test.typed[test.y] = Test_alloc(MAX_TYPE+1);
			Test_disp_text(test);
		  }
		}
	  }
	}
Exemplo n.º 25
0
void
entry (unsigned long magic, unsigned long addr)
{
	multiboot_info_t *mbi;

	/* Clear the screen. */
	clear();

	/* Am I booted by a Multiboot-compliant boot loader? */
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
	{
		printf ("Invalid magic number: 0x%#x\n", (unsigned) magic);
		return;
	}

	/* Set MBI to the address of the Multiboot information structure. */
	mbi = (multiboot_info_t *) addr;

	/* Print out the flags. */
	printf ("flags = 0x%#x\n", (unsigned) mbi->flags);

	/* Are mem_* valid? */
	if (CHECK_FLAG (mbi->flags, 0))
		printf ("mem_lower = %uKB, mem_upper = %uKB\n",
				(unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper);

	/* Is boot_device valid? */
	if (CHECK_FLAG (mbi->flags, 1))
		printf ("boot_device = 0x%#x\n", (unsigned) mbi->boot_device);

	/* Is the command line passed? */
	if (CHECK_FLAG (mbi->flags, 2))
		printf ("cmdline = %s\n", (char *) mbi->cmdline);

	void * zbigfs_location = NULL;
	if (CHECK_FLAG (mbi->flags, 3)) {
		int mod_count = 0;
		int i;
		module_t* mod = (module_t*)mbi->mods_addr;
		while(mod_count < mbi->mods_count) {
			printf("Module %d loaded at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_start);
			printf("Module %d ends at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_end);
			printf("First few bytes of module:\n");
			for(i = 0; i < 16; i++) {
				printf("0x%x ", *((char*)(mod->mod_start+i)));
			}
			printf("\n");
			mod_count++;
			mod++;
		}
		if (mod_count){
			module_t* zbigfsmod = (module_t*)mbi->mods_addr;
			zbigfs_location = (void *) zbigfsmod->mod_start;
		} else {
			printf("No module 0, zbigfs will FAIL!");
		}
	}
	/* Bits 4 and 5 are mutually exclusive! */
	if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5))
	{
		printf ("Both bits 4 and 5 are set.\n");
		return;
	}

	/* Is the section header table of ELF valid? */
	if (CHECK_FLAG (mbi->flags, 5))
	{
		elf_section_header_table_t *elf_sec = &(mbi->elf_sec);

		printf ("elf_sec: num = %u, size = 0x%#x,"
				" addr = 0x%#x, shndx = 0x%#x\n",
				(unsigned) elf_sec->num, (unsigned) elf_sec->size,
				(unsigned) elf_sec->addr, (unsigned) elf_sec->shndx);
	}

	/* Are mmap_* valid? */
	if (CHECK_FLAG (mbi->flags, 6))
	{
		memory_map_t *mmap;

		printf ("mmap_addr = 0x%#x, mmap_length = 0x%x\n",
				(unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
		for (mmap = (memory_map_t *) mbi->mmap_addr;
				(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
				mmap = (memory_map_t *) ((unsigned long) mmap
					+ mmap->size + sizeof (mmap->size)))
			printf (" size = 0x%x,     base_addr = 0x%#x%#x\n"
					"     type = 0x%x,  length    = 0x%#x%#x\n",
					(unsigned) mmap->size,
					(unsigned) mmap->base_addr_high,
					(unsigned) mmap->base_addr_low,
					(unsigned) mmap->type,
					(unsigned) mmap->length_high,
					(unsigned) mmap->length_low);
	}

	/* Construct an LDT entry in the GDT */
	{
		seg_desc_t the_ldt_desc;
		the_ldt_desc.granularity    = 0;
		the_ldt_desc.opsize         = 1;
		the_ldt_desc.reserved       = 0;
		the_ldt_desc.avail          = 0;
		the_ldt_desc.present        = 1;
		the_ldt_desc.dpl            = 0x0;
		the_ldt_desc.sys            = 0;
		the_ldt_desc.type           = 0x2;

		SET_LDT_PARAMS(the_ldt_desc, &ldt, ldt_size);
		ldt_desc_ptr = the_ldt_desc;
		lldt(KERNEL_LDT);
	}

	/* Construct a TSS entry in the GDT */
	{
		seg_desc_t the_tss_desc;
		the_tss_desc.granularity    = 0;
		the_tss_desc.opsize         = 0;
		the_tss_desc.reserved       = 0;
		the_tss_desc.avail          = 0;
		the_tss_desc.seg_lim_19_16  = TSS_SIZE & 0x000F0000;
		the_tss_desc.present        = 1;
		the_tss_desc.dpl            = 0x0;
		the_tss_desc.sys            = 0;
		the_tss_desc.type           = 0x9;
		the_tss_desc.seg_lim_15_00  = TSS_SIZE & 0x0000FFFF;

		SET_TSS_PARAMS(the_tss_desc, &tss, tss_size);

		tss_desc_ptr = the_tss_desc;

		tss.ldt_segment_selector = KERNEL_LDT;
		tss.ss0 = KERNEL_DS;
		tss.esp0 = 0x800000; //8MB
		ltr(KERNEL_TSS);
	}
	//printf("Enabling Interrupts\n");


	
	/* Init the PIC */

	populate_idt();

	i8259_init();
	rtc_init();
	outb(PIT_MODIFY_LOW | PIT_MODIFY_HIGH | PIT_MODE_2 ,PIT_CTRL_ADDR);
	outb(PIT_DEFAULT_RATE_LOW,PIT_PORT0_CTRL_ADDR); //set low byte
	outb(PIT_DEFAULT_RATE_HIGH,PIT_PORT0_CTRL_ADDR); //set high byte

/*
 * pc speaker code from osdev
 *
	uint32_t Div;
	uint8_t tmp;
		 
	//Set the PIT to the desired frequency
	Div = 1193180 / 1000;
	outb(0x43, 0xb6);
	outb(0x42, (uint8_t) (Div) );
	outb(0x42, (uint8_t) (Div >> 8));
							 
	 //And play the sound using the PC speaker
	tmp = inb(0x61);
	if (tmp != (tmp | 3)) {
		outb(0x61, tmp | 3);
	}
*/
	disable_irq(0);



	/* Initialize devices, memory, filesystem, enable device interrupts on the
	 * PIC, any other initialization stuff... */

	/* Enable interrupts */
	/* Do not enable the following until after you have set up your
	 * IDT correctly otherwise QEMU will triple fault and simple close
	 * without showing you any output */


	//Enable interrupts for the first time
	printf("Enabling Interrupts\n");
	sti();

	//Initialize paging and mount the filesysem
	init_paging();
	printf("Mounting module 0 as read-only zbigfs filesystem\n");
	zbigfs_mount(zbigfs_location);


	//Initialize PCBs and then clear the terminal so it looks nice
	init_pcbs();
	term_clear();

	/* Spin (nicely, so we don't chew up cycles) */
	asm volatile(".1: hlt; jmp .1;");
}
Exemplo n.º 26
0
int main(int argc, char **argv){
  int n, i;
  char c[4], bp[1024], area[2048], print=FALSE;
  struct termio line;
  
  if (argc < 2) {
    my_str("Usage: ./select <file(s)>\n");
    return 1;
  }

  init_tty();
  fill_elems(argc, argv);
  signal(SIGWINCH, show_params);
  term_vi();
  term_init(bp, area);
  ioctl(0, TCGETA, &line);
  gl_env.line = line;
  line.c_lflag &= ~(ECHO | ISIG | ICANON);
  line.c_cc[VMIN] = 3;
  line.c_cc[VTIME] = VTI;
  ioctl(0, TCSETA, &line);
  show_params();

  while(1){
    n = read(0, c, 3);
    c[n] = '\0';

    /*my_str("\n");
    for(i=0;i<n;i++){
      my_int(c[i]);
      my_char('\n');
    }
    my_str("\n");*/
    if (my_strcmp(c, gl_env.esc) == 0) {
      // esc
      break;
    } else if (my_strcmp(c, "\n") == 0) {
      // enter
      print = TRUE;
      break;
    } else if (my_strcmp(c, " ") == 0) {
      // space
      gl_env.elems[gl_env.current].mode = 1 - gl_env.elems[gl_env.current].mode;
      if (gl_env.elems[gl_env.current].mode) {
	gl_env.current = gl_env.current + 1;
	if (gl_env.current >= gl_env.nbelems)
	  gl_env.current = 0;
      }
      show_params();
    } else if (my_strcmp(c, KU) == 0) {
      // up
      gl_env.current -= 1;
      if (gl_env.current < 0)
	gl_env.current = gl_env.nbelems - 1;
      show_params();
    } else if (my_strcmp(c, KD) == 0) {
      // down
      gl_env.current += 1;
      if (gl_env.current >= gl_env.nbelems)
	gl_env.current = 0;
      show_params();
    } else if (my_strcmp(c, KL) == 0) {
      // left
      gl_env.current -= gl_env.win.ws_row;
      if (gl_env.current < 0)
	gl_env.current = 0;
      show_params();
    } else if (my_strcmp(c, KR) == 0) {
      //right
      gl_env.current += gl_env.win.ws_row;
      if (gl_env.current >= gl_env.nbelems)
	gl_env.current = gl_env.nbelems-1;
      show_params();
    }
  }
  term_clear();
  ioctl(0, TCSETA, &(gl_env.line));
  term_ve();
  restore_tty();
  
  if (print) {
    //term_clear();
    //term_pos(0, 0);
    for (i=0;i<gl_env.nbelems;i++){
      if (gl_env.elems[i].mode) {
	my_str(gl_env.elems[i].elem);
	my_char(' ');
      }
    }
  }

  return 0;
}