예제 #1
0
static int  nBinMenu2(int X, int Y, int*nb1, int*nb2)
{                   

static int nb1_=3, nb2_=3;
char   strmen[] =
   "\011"
   " 30      "
   " 15      "
   " 10      "
   "  6      "
   "  5      "
   "  3      "
   "  2      "
   "  1      ";

   void * pscr1=NULL;
   void * pscr2=NULL;

   if(!nb1_) nb1_=3;
   if(!nb2_) nb2_=3;
 
   menu1(X,Y,"N bin1",strmen,"",&pscr1,&nb1_);
   if (nb1_)
   {
     sscanf(strmen+1+strmen[0]*(nb1_-1),"%d",nb1);
     menu1(X+13,Y,"N bin2",strmen,"",&pscr2,&nb2_);
     put_text(&pscr1);
     if (nb2_) 
     { sscanf(strmen+1+strmen[0]*(nb2_-1),"%d",nb2); 
       put_text(&pscr2);
       return 1;
     }
   }
   return 0;
}
예제 #2
0
파일: P_MENU3.C 프로젝트: cepa/pong
void menu3_update()
{
  blit(court,screen_buffer,0,0,0,0,320,200);
  masked_blit(logo,screen_buffer,0,0,160 - logo->w / 2,10,logo->w,logo->h);

  put_text(screen_buffer,font,60,90,32,"PLAYER 1");
  put_text(screen_buffer,font,60,100,58,"HUMAN");
  put_text(screen_buffer,font,60,110,58,"COMPUTER");

  put_text_right(screen_buffer,font,260,90,32,"PLAYER 2");
  put_text_right(screen_buffer,font,260,100,58,"HUMAN");
  put_text_right(screen_buffer,font,260,110,58,"COMPUTER");

  switch(menu3_menu1_index)
  {
    case 0: put_text(screen_buffer,font,60,100,160,"HUMAN"); break;
    case 1: put_text(screen_buffer,font,60,110,160,"COMPUTER"); break;
  }

  switch(menu3_menu2_index)
  {
    case 0: put_text_right(screen_buffer,font,260,100,160,"HUMAN"); break;
    case 1: put_text_right(screen_buffer,font,260,110,160,"COMPUTER"); break;
  }

  draw_screen_buffer(screen_buffer);
}
예제 #3
0
static void
greets_display_effect (sync_info *sync, void *params, int iparam)
{
  greets_data *gdata = (greets_data *) params;
  f32 indmtx[2][3] = { { 0.5, 0.0, 0.0 },
		       { 0.0, 0.5, 0.0 } };
  float scroll = (float) sync->time_offset / 900.0;
  int i, startpos;

  /*world_set_pos_lookat_up (gdata->world,
			   (guVector) spooky_ghost_data_0.scene.pos,
			   (guVector) spooky_ghost_data_0.scene.lookat,
			   (guVector) spooky_ghost_data_0.scene.up);*/

  GX_SetIndTexMatrix (GX_ITM_0, indmtx, 5);

  world_display (gdata->world);
  GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
  
  shader_load (gdata->tile_shader);

  startpos = (int) (scroll * 8.0) - 32;

  for (i = 0; i < 4; i++)
    put_text (gdata->tileidx, i, 0, message, sizeof (message) - 1,
	      startpos * 4 + i, 32);

  GX_SetTevColor (GX_TEVREG0, (GXColor) { 255, 255, 255, 255 });
  render_texture (gdata, 5.5, scroll);

  //screenspace_rect (gdata->tile_shader, GX_VTXFMT0, 0);
}
예제 #4
0
static void f8_key_prog(int x)
{  
  static char FUNC[75]="2*2  % Press ESC to finish, F1 for help, ENTER to calculate";  
  int npos=1;
  void * pscr;
  get_text(1,20,80,21,&pscr);
  scrcolor(Red,White);   
  goto_xy(1,20); print("CALC : ");
  goto_xy(1,21); print("result=");
  scrcolor(Black,White);
  for(;;)
  { double res;
    int err; 
    int key;
    goto_xy(9,20); key=str_redact(FUNC,npos,70); 
    if(key==KB_ESC) break;
    else if(key==KB_F1)  show_help("n_calc");
    else if(key==KB_ENTER)
    {  goto_xy(8,21); 
       err=calcExpression(FUNC,rd_num,&res);
       goto_xy(9,21);
       if(err) {print("Erorr: %s",errmesstxt(err)); npos=rderrpos;}
       else  print("%E                     ",res); 
    }
  }
  put_text(&pscr);
}
예제 #5
0
파일: handlers.c 프로젝트: inuyasha82/uwm
void map_notify_handler(XEvent local_event, Display* display, ScreenInfos infos){
	printf("----------Map Notify\n");
	XWindowAttributes win_attr;
	char *child_name;
	XGetWindowAttributes(display, local_event.xmap.window, &win_attr);
	XFetchName(display, local_event.xmap.window, &child_name);
	printf("\tAttributes: W: %d - H: %d - Name: %s - ID %lu\n", win_attr.width, win_attr.height, child_name, local_event.xmap.window);
	Window trans = None;	
	XGetTransientForHint(display, local_event.xmap.window, &trans);	
	printf("\tIs transient: %ld\n", trans);
	if(child_name!=NULL){
	  if(strcmp(child_name, "Parent") && local_event.xmap.override_redirect == False){
		Window new_win = draw_window_with_name(display, RootWindow(display, infos.screen_num), "Parent", infos.screen_num, 
						   win_attr.x, win_attr.y, win_attr.width, win_attr.height+DECORATION_HEIGHT, 0, 
						   BlackPixel(display, infos.screen_num));
		XMapWindow(display, new_win);
		XReparentWindow(display,local_event.xmap.window, new_win,0, DECORATION_HEIGHT);
		set_window_item(local_event.xmap.window, new_win);
		XSelectInput(display, local_event.xmap.window, StructureNotifyMask);
		printf("\tParent window id: %lu\n", new_win);
		put_text(display, new_win, child_name, "9x15", 10, 10, BlackPixel(display,infos.screen_num), WhitePixel(display, infos.screen_num));
	  } /*else {
		  XWindowAttributes attributes;
		  Status status = XGetWindowAttributes(display, local_event.xmap.window, &attributes);
		  printf("\tStatus: %d\n", attributes.map_state);
		  printf("\tOverride redirect: %d\n", attributes.override_redirect);
		  //XMapWindow(display, trans);
		  XFetchName(display, trans, &child_name);
		  printf("\tChild name: %s\n", child_name);
		  //XRaiseWindow(local_event.xmap.display, local_event.xmap.window);
		  //XCirculateSubwindows(local_event.xmap.display, local_event.xmap.window, RaiseLowest);
	  }*/
	}
	XFree(child_name);
}
예제 #6
0
int main(void)
{
  int x_pos = 0;
  int x_pos_old = 0;
  PCR = CLKDIV_3;                         // ICLK = SYSCLK / 3
  GCR = ZPLL_CLK_DIV_PRE_1;               // SYSCLK = 8 x fOSC
  PCR |= PENABLE;                         // Enable peripherals

  HETDIR  = 0xFFFFFFFF;                   // HETx Output direction
  HETDOUT = 0x00000000;

  init_lcd();
  light_on();

  put_cursor( 0,0 );
  put_text( "0V" );
  put_cursor( 4,0 );
  put_text( "1V" );
  put_cursor( 9,0 );
  put_text( "2V" );
  put_cursor( 14,0 );
  put_text( "3V" );


  ADCR1 |= PS_8;                          // ADCLK prescaler = 8
  ADSAMPEV |= SEN;                        // ADCSAMP1 controls SW
  ADSAMP1 = 62;                           // SW = 62+2
  ADCR1 |= ADC_EN;                        // Enable ADC
  ADISR1 = 0x0006;                        // Convert croup 1 = channel 0
  //ADISR1 = 0x0001;                        // Convert croup 1 = channel 0
  ADCR2 |= G1_MODE;                       // Continuous Conversion

  for (;;)
  {
    while (!(ADSR & GP1_END));            // Wait for conversion to complete
    x_pos_old = x_pos;
    x_pos = ADDR2/64;
    //x_pos = ADDR0/64;
    if( x_pos_old != x_pos )
    {
      put_char(x_pos, 1, SQUARE);
      put_char(x_pos_old, 1, ' ');
    }
    ADSR |= GP1_END;                      // Clears flag
  }
}
예제 #7
0
파일: screen.c 프로젝트: Omer80/wimps
void  sqdiagrmenu(void)
{  void * pscr = NULL ;

   if (subproc_sq == 1) { nsub = 1; return;}
   menu_f(5,15,"NN      Subprocess                                 Del   Calc  Rest ",
       MENUQ_NAME,"s_sq_proc",&pscr,&nsub);
  if(nsub) put_text(&pscr);

}
예제 #8
0
파일: format.c 프로젝트: Hooman3/minix
/*
 * Print a flags field, using known flag names.  The name of the whole field is
 * given as 'name' and may be NULL.  The caller must supply an array of known
 * flags as 'fp' (with 'num' entries).  Each entry in the array has a mask, a
 * value, and a name.  If the given flags 'value', bitwise-ANDed with the mask
 * of an entry, yields the value of that entry, then the name is printed.  This
 * means that certain zero bits may also be printed as actual flags, and that
 * by supplying an all-bits-set mask can print a flag name for a zero value,
 * for example F_OK for access().  See the FLAG macros and their usage for
 * examples.  All matching flag names are printed with a "|" separator, and if
 * after evaluating all 'num' entries in 'fp' there are still bits in 'value'
 * for which nothing has been printed, the remaining bits will be printed with
 * the 'fmt' format string for an integer (generally "%d" should be used).
 */
void
put_flags(struct trace_proc * proc, const char * name, const struct flags * fp,
	unsigned int num, const char * fmt, unsigned int value)
{
	unsigned int left;
	int first;

	if (valuesonly) {
		put_value(proc, name, fmt, value);

		return;
	}

	put_field(proc, name, "");

	for (first = TRUE, left = value; num > 0; fp++, num--) {
		if ((value & fp->mask) == fp->value) {
			if (first)
				first = FALSE;
			else
				put_text(proc, "|");
			put_text(proc, fp->name);

			left -= fp->value;
		}
	}

	if (left != 0) {
		if (first)
			first = FALSE;
		else
			put_text(proc, "|");

		put_fmt(proc, fmt, left);
	}

	/*
	 * If nothing has been printed so far, simply print a zero.  Ignoring
	 * the given format in this case is intentional: a simple 0 looks
	 * better than 0x0 or 00 etc.
	 */
	if (first)
		put_text(proc, "0");
}
예제 #9
0
파일: format.c 프로젝트: Hooman3/minix
/*
 * Print and clear the next separator for the process, if any.
 */
void
format_push_sep(struct trace_proc * proc)
{

	if (proc->next_sep != NULL) {
		put_text(proc, proc->next_sep);

		proc->next_sep = NULL;
	}
}
예제 #10
0
파일: format.c 프로젝트: Hooman3/minix
/*
 * Version of put_text with variadic arguments.  The given process may be NULL.
 */
void
put_fmt(struct trace_proc * proc, const char * fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)vsnprintf(formatbuf, sizeof(formatbuf), fmt, ap);
	va_end(ap);

	put_text(proc, formatbuf);
}
예제 #11
0
//right justify to edge of screen
Rect FontTTF::put_text_right(Surface *s, int y, int xDelta, const char *textstr, const SDL_Color &textColour, bool bShadow /*= false*/)
{
    int textW(0);
	SDL_Surface *text = TTF_RenderText_Solid( _font, textstr, textColour );
	if (text)
	{
        textW = text->w;
        SDL_FreeSurface(text);
	}
	return put_text(s, s->surface()->w - textW - xDelta, y, textstr, textColour, bShadow);
}
예제 #12
0
Rect FontTTF::put_number_right(Surface *s, int y, int xDelta, int number, const char *format, const SDL_Color &textColour, bool bShadow /*= false*/)
{
	snprintf(_buffer, 100, format, number);
	int textW(0);
	SDL_Surface *text = TTF_RenderText_Solid( _font, _buffer, textColour );
	if (text)
	{
	    textW = text->w;
	    SDL_FreeSurface(text);
	}
	return put_text(s, s->surface()->w - textW - xDelta, y, _buffer, textColour, bShadow);
}
예제 #13
0
파일: crt_util.c 프로젝트: Omer80/wimps
static int  message(int x1,int y1,char* txt1)
{  char     txt[STRSIZ];
   int      mess, marg, i=0, x2, y2;
   void *      dump;
   int         xold, yold;
   char * c;   

     strcpy(txt,txt1);
     c=txt;
     xold = where_x();
     yold = where_y();  
     x2 = x1 + maxline(&y2,txt) /*+4*/;
     y2 = y1 + y2 + 1;
     get_text(x1,y1,x2,y2,&dump); 
     chepbox(x1,y1,x2,y2);     
     be_be();
     c=strtok(txt,"\n");
     
     while(c)
     {
        ++(i);
        marg = (x2 - x1 - strlen(c)) / 2;
        if (y1+i == y2) 
        {  goto_xy(x1+1+marg ,y1 + i);
           print("%s",c);
        }else
        {  char buff[STRSIZ];
           memset(buff,' ',x2-x1 -1);
           memcpy(buff+marg,c,strlen(c));
           buff[x2-x1-1]=0;
           goto_xy(x1+1,y1+i);
           print(buff);
        }
        c=strtok(NULL,"\n");   
     }
ret_:
     if (blind) mess='Y' ; else  do{mess = inkey();} while (mess == KB_SIZE);
/* mouse filter */
     if (mess == KB_MOUSE)
     {
        if (  (mouse_info.but1 !=2) ||
              (mouse_info.row < y1) || (mouse_info.row > y2) ||
              (mouse_info.col < x1) || (mouse_info.col > x2)   ) goto ret_;
        if (mouse_info.row == y2 )
        {  if (mouse_info.col < (x1+x2)/2 /* -1*/ ) mess='Y';
           if (mouse_info.col > (x1+x2)/2 /*+1 */) mess='N';
        }       
     }   
/* end of filter */         
     put_text(&dump); 
     goto_xy(xold,yold);     
     return mess;
}   /* message */
예제 #14
0
파일: format.c 프로젝트: Hooman3/minix
/*
 * Print a field, e.g. a parameter or a field from a structure, separated from
 * other fields at the same nesting depth as appropriate.  If the given field
 * name is not NULL, it may or may not be printed.  The given text is what will
 * be printed for this field so far, but the caller is allowed to continue
 * printing text for the same field with e.g. put_text().  As such, the given
 * text may even be an empty string.
 */
void
put_field(struct trace_proc * proc, const char * name, const char * text)
{

	/*
	 * At depth -1 (the basic line level), names are not used.  A name
	 * should not be supplied by the caller in that case, but, it happens.
	 */
	if (proc->depth < 0)
		name = NULL;

	format_push_sep(proc);

	if (name != NULL && (proc->depths[proc->depth].name || allnames)) {
		put_text(proc, name);
		put_text(proc, "=");
	}

	put_text(proc, text);

	format_set_sep(proc, proc->depths[proc->depth].sep);
}
예제 #15
0
파일: mc_menu.c 프로젝트: restrepo/CalcHEP
static int sub_men__(void)
{
    int  n, npr, mode=0;
    char * strmen;
    void * pscr = NULL;
    int width,width_;
    int nprc_old=Nsub;
    
    if(nprc_int==1 && !blind ) return 0;
 
    width=0;
    for(npr = 1; npr <= nprc_int; ++npr)
    for(n=1;n<=nin_int+nout_int;n++) 
    width=MAX(width,strlen(pinf_int(npr,n,NULL,NULL)));
    
    width++;
    width_=6+width*(nin_int+nout_int);
       
    strmen=malloc(2+nprc_int*width_);

    for(n=1;n<=width_*nprc_int;n++) strmen[n]=' ';
    strmen[0]= width_;
    strmen[1+nprc_int*width_]=0;

    for(npr = 1; npr <= nprc_int; ++npr)
    { 
      for(n=1;n<=nin_int;n++) 
      { char *s=pinf_int(npr, n,NULL,NULL);
        memcpy(strmen+(npr-1)*width_+2+(n-1)*width ,s,strlen(s));
      }                

      memcpy(strmen+(npr-1)*width_+2+(nin_int)*width ," -> ",4);

      for(n=nin_int+1;n<=nin_int+nout_int;n++) 
      { char* s=pinf_int(npr, n,NULL,NULL);
          memcpy(strmen+(npr-1)*width_+6+(n-1)*width ,s,strlen(s));
      }                
    }         
    menu1(76-width_,6,"",strmen,NULL,&pscr,&mode);
    free(strmen);
           
    if(mode)put_text(&pscr);
    if(mode && mode!=nprc_old) 
    { 
       Nsub = mode;
       wrtprc_();
       if(nin_int==2) initStrFun(0);
       return 1;
    } 
    return 0;
}
예제 #16
0
int message_log() {
    bool done = false;
    while (!done) {
        
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            // check for messages
            switch (event.type) {
                // exit if the window is closed
            case SDL_QUIT:
                return -1;
                break;
                // check for keypresses
            case SDL_KEYDOWN:
                {
                    return STATE_MAPMODE;
                    break;
                }
            } // end switch
        } // end of message processing
        
        clear_screen();
        
        put_text(4,2,"Messages (newest first):");
        
        for (int i=0;i<MAX_STATUS_MESSAGES;i++) {
            put_text(5,4+i,game.status_msgs[i]);
        }
        
        put_text(4,37,"Press any key to go back to map mode.",COLORS[COLOR_HELPTEXT],COLORS[COLOR_DEFAULT_BG]);

        SDL_Flip(MAIN_SCREEN);
        SDL_Delay(10); // manipulate at will
  
    }
    
    return STATE_MAPMODE;
}
예제 #17
0
static void improveEvents(vegasGrid * vegPtr,double (*func)(double *,double,double*))
{ int mode;
   void * pscr_=NULL;
   double eff0;

  for(mode=1;mode!=4; )
  {
      char strmen[]="\030"
                    " sub-cubes = N1         "
                    " random search = N2     "
                    " simplex search= N3     "
                    " Start search of maxima "; 
      improveStr(strmen,"N1","%d",n_cube);
      improveStr(strmen,"N2","%d",nRandom);
      improveStr(strmen,"N3","%d",nSimplex1);
      menu1(54,14,"Preparing of generator",strmen,"n_prep_gen_*",&pscr_,&mode);
      switch(mode)
      {
        case 0: return;
        case 1: if(correctLong(50,15,"Number of sub-cubes:",&n_cube,1))
                {
                    free(vegPtr->fMax); 
                    vegPtr->fMax=NULL;
                    vegPtr->nCubes=0;
                }  break;
        case 2: correctLong(50,15,"Random search:",&nRandom,1);break;
        case 3: correctLong(50,15,"Simplex steps :",&nSimplex1,1); break; 

/*                    " milk      = N3         "  
      improveStr(strmen,"N3","%.1f",milk);
        case 4: correctDouble(50,15,"Content of milk:",&milk,1); break;
*/
        case 4: if(n_cube < 1 ) n_cube=1; 
        { 
            int mCheck=vegas_max(vegPtr,n_cube, nRandom,nSimplex1, milk, func,&eff0);
            if(mCheck==0)
            { char mess[50];
              sprintf(mess,"Expected efficiency %f",eff0/max);
              messanykey(25,15,mess);
              put_text(&pscr_);
            } else
            {  mode=1;
               if(mCheck==2) messanykey(25,15,"Not enough memory.\n"
                                    "Decrease the number of sub-cubes");
            }                                                                                                         
        }                                                                             
      }
  }
}
예제 #18
0
파일: format.c 프로젝트: Hooman3/minix
/*
 * Decrease the nesting depth by ending a nested block of fields.  The given
 * string is the closing parenthesis, bracket, etcetera.
 */
void
put_close(struct trace_proc * proc, const char * string)
{

	assert(proc->depth >= 0);

	put_text(proc, string);

	proc->depth--;

	if (proc->depth >= 0)
		format_set_sep(proc, proc->depths[proc->depth].sep);
	else
		format_set_sep(proc, NULL);
}
예제 #19
0
파일: trace.c 프로젝트: Hooman3/minix
/*
 * A process has terminated or is being detached.  Print the resulting status.
 */
static void
discard_proc(struct trace_proc * proc, int status)
{
	const char *signame;

	/*
	 * The exit() calls are of type no-return, meaning they are expected
	 * not to return.  However, calls of this type may in fact return an
	 * error, in which case the error must be printed.  Thus, such calls
	 * are not actually finished until the end of the call-leave phase.
	 * For exit() calls, a successful call will never get to the call-leave
	 * phase.  The result is that such calls will end up being shown as
	 * suspended, which is unintuitive.  To counter this, we pretend that a
	 * clean process exit is in fact preceded by a call-leave event, thus
	 * allowing the call to be printed without suspension.  An example:
	 *
	 *        3| exit(0) <..>
	 *        2| setsid() = 2
	 * [A]    3| exit(0)
	 *        3| Process exited normally with code 0
	 *
	 * The [A] line is the result of the following code.
	 */
	if (WIFEXITED(status) && (proc->trace_flags & TF_INCALL))
		call_leave(proc, TRUE /*skip*/);

	put_newline();
	if (WIFEXITED(status)) {
		put_fmt(proc, "Process exited normally with code %d",
		    WEXITSTATUS(status));
	} else if (WIFSIGNALED(status)) {
		if ((signame = get_signal_name(WTERMSIG(status))) != NULL)
			put_fmt(proc, "Process terminated from signal %s",
			    signame);
		else
			put_fmt(proc, "Process terminated from signal %d",
			    WTERMSIG(status));
	} else if (WIFSTOPPED(status))
		put_text(proc, "Process detached");
	else
		put_fmt(proc, "Bogus wait result (%04x)", status);
	put_newline();

	proc_del(proc);
}
예제 #20
0
int sf_menu(int i)
{
    int  k;
    char name[STRSIZ];
    int  nfun[MAXFUN];
    long N;
    char strmen[2+MAXFUN*(FUNLEN+1)];

    void * pscr =NULL;
    int mode,l;

    strmen[0]=FUNLEN+1;

    pinf_int(Nsub,i,NULL,&N);
    
    sprintf(strmen+1," %-*.*s",FUNLEN,FUNLEN,"OFF");

    k = 0;          
    for(l=0;l<MAXFUN;l++)
    {    
       if ( strFun[l].myParticle(allInP(i))  ) 
       {  
          nfun[k++] = l;
          strFun[l].fullName(i, name); 
	  sprintf(strmen+1+(FUNLEN+1)*k," %-*.*s",FUNLEN,FUNLEN,name);
       }
    }
    if(!k) 
    { messanykey(15,15,"Structure functions for this particle\n"
                       "are not known\n");
      return 0;
    }

    menu1(77-FUNLEN,7,"",strmen, "n_strfun", &pscr, &mode);
    if (mode == 0) return 0;
    put_text(&pscr);
    if (mode == 1) sf_num[i-1]=0;
    else
    {  int ok=strFun[nfun[mode - 2]].menu(i,allInP(i));
       if(ok) sf_num[i-1]=nfun[mode -2]+1; else{ sf_num[i-1]=0; return 0;}
    }
    return 1;
} /* sf_menu__ */
예제 #21
0
void interpretator(void)
{
 marktp   heapbg;
 void * pscr;
 double sqrts_mem=sqrts;
   get_text(1,1,maxCol(),maxRow(),&pscr);   
   clr_scr(FGmain,BGmain);
   
   allcanal=(canal*)m_alloc(subproc_sq*sizeof(*allcanal));
   mark_(&heapbg);

   if(compileall()==0) { n_comphep(); free(calcCoef); calcCoef=NULL;} 


   release_(&heapbg);
   free(allcanal);

   clr_scr(FGmain,BGmain);
   put_text(&pscr);
   sqrts=sqrts_mem;
}
예제 #22
0
static int nBinMenu(int X, int Y)
{                   

static int kBinMenu=3;
char   strmen[] =
   "\015"
   " 300         "
   " 150         "
   " 100         "
   "  75         "
   "  60         "
   "  50         "
   "  30         " 
   "  25         "
   "  20         "
   "  15         "
   "  12         "
   "  10         "
   "  6          "
   "  5          "
   "  4          "
   "  3          "
   "  2          ";

   void * pscr=NULL;
   
   int n;
   if(!kBinMenu) kBinMenu=3;
           
   menu1(X,Y,"number of bins",strmen,"",&pscr,&kBinMenu);
   if (kBinMenu)
   {
     sscanf(strmen+1+strmen[0]*(kBinMenu-1),"%d",&n);
     put_text(&pscr);
     return n;
   }
   return 0;
}
예제 #23
0
파일: crt_util.c 프로젝트: Omer80/wimps
void  menu0(int col,int row,char* label, char* menstr ,
	  void (**funcKey)(int) ,char** funcKeyMess, void ** hscr, int* kk)
{  int    i, j, k, col1, npage,lastrow;
   long	  lastpage;
   int    ink;
   int    ncol;
   void * pscr;
   int  fkPos[11];
   int  height;
   char fmt[20];
   int  lastLine;

/* colors */
   int label_fg  =Yellow;
   int label_bg  =Blue;
   int help_fg1  =White;
   int help_fg2  =Black;
   int help_bg   =DarkGray;
   int box_fg    =White;
   int box_bg    =DarkGray;
   int star_fg   =Red;
   int page_fg   =Black;
   int actFunc_fg=Black;
   int actFunc_bg=White;
   int pasFunc_fg=White;
   int pasFunc_bg=DarkGray;

/* save colors */
   int      fcolor_tmp=fColor;
   int      bcolor_tmp=bColor;
   void *hscr_=NULL;
   
   if(hscr==NULL) hscr=&hscr_;
   lastLine=maxRow();
   if (funcKey == NULL) for (i=0;i<11;i++) fkPos[i]=0; else
   {  int xx;
      scrcolor(FGmain,BGmain);
      goto_xy(1,lastLine); clr_eol();
      xx=0;
      for (j=0;j<10;j++) { if(funcKey[j] && funcKeyMess[j]) 
                                          xx=xx+4+strlen(funcKeyMess[j]);}
      xx= (80 - xx )/2 ;
      goto_xy(xx,lastLine);
      for (i=0;i<10;i++)
      { fkPos[i]=where_x();
        if (funcKey[i] && funcKeyMess[i])
        { scrcolor(help_fg1,help_bg); print(" F%i-",i+1);
          scrcolor(help_fg2,help_bg); print(funcKeyMess[i]);
        }
      }
      fkPos[10]=where_x();
   }

   clearTypeAhead();

   if (*kk < 0) *kk = -(*kk);
      ncol=menstr[0];
      sprintf(fmt,"%%%d.%ds",ncol,ncol);
      height=strlen(menstr)/ncol;
      if(height==0) { *kk=0; return; }
      if (row+height+1 >lastLine-2) height=lastLine-3-row;
      lastpage = 1+    (strlen(menstr)/ncol -1)/height ;
   if(label[0] ==0 || row == 1) 
   { if (*hscr == NULL)  get_text(col,row,col+ncol+1,row+2,hscr);} 
   else
   {  char label_[STRSIZ];
      int shft,sz;
      if (*hscr == NULL) get_text(col,row-1,col+ncol+1,row+2,hscr); 
      for(i=0;i<ncol+2;i++) label_[i]=' ';
      label_[ncol+2]=0;  
      sz=strlen(label);
      if(sz >ncol+2) {shft=0;sz=ncol+2;} else shft=(ncol+2 -sz)/2;  
      memcpy(label_+shft,label,sz); 
      scrcolor(label_fg,label_bg);
      goto_xy(col,row-1);
      print(label_);
   }

   get_text(col,row + 3,col + ncol + 1,row + height + 1,&pscr);

   if (*kk <= 0  || *kk > lastpage * height   )
   {  npage = 1;
      k = 1;
   }
   else {
      k = ((*kk) - 1) % height + 1;
      npage = ((*kk) - 1) / height + 1;
   }
   col1 = col + 1;

label_1:
      scrcolor(box_fg,box_bg);
      chepbox(col,row,col + ncol + 1,row + height + 1);
      scrcolor(star_fg,box_bg);
      goto_xy(col+1,row); print("<");
/*      goto_xy(col+1,row + height+1);  print("?"); */
      scrcolor(page_fg,box_bg);
      if (npage > 1)
      {
         goto_xy(col + ncol - 2,row);
         print("PgUp");
      }
      if (npage < lastpage)
      {
         goto_xy(col + ncol - 2,row + height + 1);
         print("PgDn");
      }

      if(npage<lastpage) lastrow=height;
		  else   lastrow = (strlen(menstr)/ncol)%height;

   lastrow=0;
   scrcolor(pasFunc_fg,pasFunc_bg);
   for (j = 1; j <= height; j++)
   {  int shift;
      goto_xy(col + 1,row + j);
      shift=1+(j-1 + (npage-1)*height)*ncol;
      if(shift<strlen(menstr)) {print(fmt,menstr+shift );lastrow++;}
		 else           print(fmt," ");

   }

   scrcolor(actFunc_fg,actFunc_bg);
   if (k > lastrow) k = lastrow;
   goto_xy(col + 1,row + k);
   if (lastrow) print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
   while (1)
   {  int jump=1,mousePos;

      scrcolor(pasFunc_fg,pasFunc_bg); 

      ink = inkey();
/* mouse filter */
      if ((ink==KB_MOUSE)&&(mouse_info.but1 == 2))
      {
         if (mouse_info.row == lastLine )
         for(i=0; i<10;i++)
         if ((mouse_info.col > fkPos[i]) && (mouse_info.col < fkPos[i+1]))
         {  if (i==9)ink='0'; else ink='1'+i;}

         if ( (mouse_info.col >= col ) && (mouse_info.col <=col+ncol+1) )
         {  mousePos = mouse_info.row - row;

            if (col+ncol+1-mouse_info.col <4)
            {
               if (mousePos==0)        ink=KB_PAGEU;
               if (mousePos==height+1) ink=KB_PAGED;
            }

            if ((mousePos == 0 ) && ( mouse_info.col-col <4)) ink=KB_ESC;

            if ((mousePos < 0)&&(mousePos >= height))
            {
               if (mousePos > k)  {ink=KB_DOWN; jump=mousePos - k;}
               if (mousePos < k)  {ink=KB_UP;   jump=k - mousePos;}
               if (mousePos==k )   ink=KB_ENTER;
            }
         }
      }
/* end of filter */
      if (lastrow == 0) goto label_3;
label_4:
      switch (ink)
      {
        case KB_MOUSE:
        if (mouse_info.but1 != 2) break;
        if (mouse_info.row == lastLine )
        for(i=0; i<10;i++)
          if ((mouse_info.col > fkPos[i]) && (mouse_info.col < fkPos[i+1]))
          {  if (i==9)ink='0'; else ink='1'+i;
             goto label_4;
          }

        if ( (mouse_info.col < col ) || (mouse_info.col >col+ncol+1) ||
             (mouse_info.row < row ) || (mouse_info.row >row+height+1) ) break;

           mousePos = mouse_info.row - row;
           if ((mousePos == 0 ) && ( mouse_info.col-col <4)) ink=KB_ESC;
           if ((mousePos != 0)&&(mousePos != height+1))
           {
              if  (mousePos > k)  { ink=KB_DOWN; jump=mousePos - k;}
              if (mousePos < k      ) { ink=KB_UP;   jump=k - mousePos;}
           }
           if (col+ncol+1-mouse_info.col <4)
           {
              if (mousePos==0)        ink=KB_PAGEU;
              if (mousePos==height+1) ink=KB_PAGED;
           }
           if (mousePos==k       ) ink=KB_ENTER;
           if (ink!=KB_MOUSE) goto label_4;

          break;

		  case  KB_DOWN: 
           if(k==lastrow)
           { 
              if(npage < lastpage)
              {  k=1;
                 npage++;
                 goto label_1;
              } else { be_be(); break; }           
           }else {ink= KB_RIGHT; goto label_4;}

		  case  KB_UP: 
           if(k==1)
           {
              if (npage > 1)
	      {
                 k=height;
		 npage--;
		 goto label_1;
              }
              else{ be_be(); break; }           
           }
           else {ink= KB_LEFT; goto label_4;}

		  case KB_LEFT: 
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            k = k - jump;
            if (k == 0) k = lastrow;
            scrcolor(actFunc_fg,actFunc_bg);
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
         break;

                  case KB_RIGHT:
	    goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            k = k + jump ;
            if(k > lastrow) k = 1;
            scrcolor(actFunc_fg,actFunc_bg);   
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
         break;

                  case KB_ENTER:
            scrcolor(box_fg,box_bg);
            chepbox(col,row,col+ncol+1,row+2);
            put_text(&pscr);
            goto_xy(col1,row + 1);
            scrcolor(actFunc_fg,actFunc_bg);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            *kk = (npage - 1) * height + k;
            goto_xy(1,lastLine);scrcolor(FGmain,BGmain); clr_eol();
            if(hscr==&hscr_) put_text(hscr); 
            refresh_scr();
            escpressed();
            return;

			case  KB_BACKSP:
			case  KB_ESC:
            goto label_3;

			case KB_PAGEU:
            if (npage > 1)
            {
               npage--;
               goto label_1;
            }
            else
               be_be();
         break;

			case KB_PAGED:
            if (npage < lastpage)
            {
               npage++;
               goto label_1;
            }
            else
               be_be();
	    break;

	case  '1':  case'2':	   case  '3':	case  '4':	case  '5':
	case '6':   case '7':	case  '8':	case  '9':	case  '0':
	case KB_F1: case KB_F2: case KB_F3: case KB_F4: case KB_F5:
	case KB_F6: case KB_F7: case KB_F8: case KB_F9: case KB_F10:
	{  int fk;
           if (funcKey==NULL) break;
	   if ( ink>='0' && ink <='9') { fk=ink-'0';if (fk==0) fk=10;}
	      else fk=ink-KB_F1+1;
	   if ((funcKey[fk-1]) != NULL)
           {  void * saveHlp;
	      get_text(1,lastLine,maxCol(),lastLine,&saveHlp);
	      scrcolor(box_fg,box_bg);
	      goto_xy(col+1,row); print("%c",boxFrame[1]);
	      goto_xy(1,lastLine);scrcolor(FGmain,BGmain);clr_eol();
	      (*funcKey[fk-1])((npage-1)*height+k);	 
	      put_text(&saveHlp);
	      scrcolor(star_fg,box_bg);
	      goto_xy(col+1,row); print("<");
	   }
           break;
        }
        case 6:  /* ^F */
        case 'f':
        case 'F':
        {  char name[32]="";
           int key=correctStr(5,23,"Enter name(Esc for exit):",name,30,1);
           if(key)
           { char * x=strstr(menstr+1,name);
             if(x==NULL) 
             {
               if(blind) sortie(121); else messanykey(10,10, "Not detected"); 
               break;
             }
             k= ((x-menstr)-1)/menstr[0];
             npage = k/ height + 1;
             k = k% height + 1;
             goto label_1;
           }
        } break; 
     }
  }

label_3:
   put_text(hscr);
   put_text(&pscr);
   scrcolor(fcolor_tmp,bcolor_tmp);
   goto_xy(1,lastLine); clr_eol();
   *kk = 0;
}
예제 #24
0
파일: mc_menu.c 프로젝트: restrepo/CalcHEP
static void f7_prog(int mode)
{ int pos=1;
  void *pscr=NULL;
  f3_key[4]=NULL;

  for(;;)
  {  static double xMin=1E-5, xMax=1.0, q0 = 91.187,qMin=1.5,qMax=1.E4,x0=0.1;
     static int nPoints=100;
     static int both=1,LOG=1;  
     int on[2]={0,0};


     char strmen[]="\030"
                  " x-Min = XXX            "
                  " x-Max = YYY            "
                  " q-Min = QXX            "
                  " q-Max = QYY            " 
                  " Npoints = NNN          "
                  " q0      = QQQ          "
                  " x0      = xXX          "
                  " log scale argument LOG "  
                  " Display plot x*F(x)    "
                  " Display plot   F(x)    "
                  " Display plot   F(Q)    "
                  " both PDF1&PDF2    BOTH ";

               
     improveStr(strmen,"XXX","%.3E",xMin); 
     improveStr(strmen,"YYY","%.3E",xMax);
     improveStr(strmen,"QXX","%.3E",qMin);
     improveStr(strmen,"QYY","%.3E",qMax);
     improveStr(strmen,"NNN","%d",nPoints);
     improveStr(strmen,"QQQ","%.2fGeV",q0); 
     improveStr(strmen,"xXX","%.2E",x0);
     if(LOG) improveStr(strmen,"LOG","ON"); else improveStr(strmen,"LOG","OFF");
     
     if(mode>2) both=1;
     if(both){ on[0]=1,on[1]=1;} else  on[mode-1]=1;

     if(!sf_num[0]) on[0]=0;
     if(!sf_num[1]) on[1]=0;
     if(sf_num[0]==0 && sf_num[1]==0) return;
      
     if(both) improveStr(strmen,"BOTH","ON"); else improveStr(strmen,"BOTH","OFF");
     menu1(54,10,"PDF plots",strmen,"n_pdf_plots_*",&pscr,&pos);

     switch(pos)
     {  case 0: f3_key[4]=f7_prog; 
                return;
        case 1:
          correctDouble(55,18,"xMin = ",&xMin,1);                  
          break; 
        case 2:
          correctDouble(55,18,"xMax = ",&xMax,1);                  
          break; 
        case 3:
          correctDouble(55,18,"qMin = ",&qMin,1);
          break; 
        case 4:  
          correctDouble(55,18,"qMax = ",&qMax,1);
          break; 
        case 5:
          correctInt(50,18,"nPoints = ",&nPoints,1);
          break; 
        case 6: 
          correctDouble(50,18,"q0 = ",&q0,1);
          break;
        case 7:
          correctDouble(50,18,"x0 = ",&x0,1);
           break;
        case 8: LOG=!LOG; break;             
        case 9: case 10: case 11:
        { double z1,z2;
          if(pos==11) {z1=qMin;z2=qMax;} else {z1=xMin;z2=xMax;}

          if(z1>=0 && (!LOG||(z2/z1>10) ) && z2>z1 && nPoints>=3 && nPoints<=150 )
         { int l,i;
           double * df[2]={NULL,NULL};
           double f[2][250];
           char p_name[2][100], title[100];
           char*xName;
           void * screen;
           
           get_text(1,1,maxCol(),maxRow(),&screen);
//           if(LOG) {z1=log10(z1); z2=log10(z2);}
           for(l=0;l<2; l++) if(on[l])
           {  double be=sf_be[l];
              strFunName(l+1,p_name[l]);
              sprintf(p_name[l]+strlen(p_name[l]),"(%s)", pinf_int(Nsub,l+1,NULL,NULL));              
//              sprintf(p_name[l],"pdf%d(%s)", l+1,pinf_int(Nsub,l+1,NULL,NULL) ); 
              for(i=0;i<nPoints;i++)
              {  double x=x0,q=q0,z,al;
                 al=(i+0.5)/(double)nPoints;
                 if(LOG)  z=pow(z1,1-al)*pow(z2,al); 
                 else     z=z1+al*(z2-z1);
                 
                 if(pos==11) q=z; else x=z;
                 f[l][i]=strfun_(l+1,x,q);
                 if(pos==9) f[l][i]*=x;
//          if(pos==11) f[l][i]/=q*q;
                 if(be!=1.) f[l][i]*=be*pow(1.-x,be-1.);
              }
           }
//           strcpy(title,"Incoming particle distribution");
           title[0]=0;  
           
           switch(pos)
           { case  9: sprintf(title+strlen(title)," x*F(x,Q=%.2E)",q0);   break;
             case 10: sprintf(title+strlen(title)," F(x,Q= %.2E)",q0);     break;
             case 11: sprintf(title+strlen(title)," F(x=%.2E,Q)",x0);     break;
           }
           if(pos==11) xName="Q"; else xName="x";
           if(on[0]&&on[1]) plot_N(title,z1,z2, xName, LOG, 2, nPoints, f[0],NULL,p_name[0],nPoints,f[1],NULL,p_name[1]);
           else 
           { if(on[0]) l=0; else l=1;
              plot_N(title,z1,z2, xName, LOG,1, nPoints, f[l],NULL,p_name[l]);   
           }  
           put_text(&screen);
         } else messanykey(16,5," Correct input is \n"
                                "  0<=xMin<xMax<=1,\n"
                                " 3<=nPoints<=150");
        }                        
        break;                        
        case 12: both=!both;    
        break; 
      }
   }
}
예제 #25
0
//centered text
Rect FontTTF::put_text(Surface *s, int y, const char *textstr, const SDL_Color &textColour, bool bShadow /*= false*/)
{
	return put_text(s, -999, y, textstr, textColour, bShadow);
}
예제 #26
0
Rect FontTTF::put_text_mid(Surface *s, int y, int xStart, const char *textstr, const SDL_Color &textColour, bool bShadow /*= false*/)
{
	const int len = calc_text_length(textstr);
	return put_text(s, xStart - (len / 2), y, textstr, textColour, bShadow);
}
예제 #27
0
//center a integer number string to the destination surface
Rect FontTTF::put_number(Surface *s, int y, int number, const char *format, const SDL_Color &textColor, bool bShadow /*= false*/)
{
	snprintf(_buffer, 100, format, number);
	return put_text(s, -999, y, _buffer, textColor, bShadow);
}
예제 #28
0
//place number mid point at xStart position i.e "NNNxNNN" gixing x as the mid point
Rect FontTTF::put_number_mid(Surface *s, int y, int xStart, int number, const char *format, const SDL_Color &textColour, bool bShadow /*= false*/)
{
	snprintf(_buffer, 100, format, number);
	const int len = calc_text_length(_buffer);
	return put_text(s, xStart - (len / 2), y, _buffer, textColour, bShadow);
}
예제 #29
0
파일: crt_util.c 프로젝트: Omer80/wimps
static int  correctVar(char* txt,int x,int y, int  type, void * var,int clear)
{  int         npos,key,err;
   int xx;
   void *     pscr; 
   char * buff;
   int *  I;
   long * L;
   double * D;
   int maxLen;

   get_text(x,y,maxCol(),y,&pscr);   
   scrcolor(White,Black);
   goto_xy(x,y);
   print(txt);
   xx=where_x();
   

   if(type<0) {buff=var; maxLen=-type;} else 
   { buff=malloc(100); 
     switch (type)
     {
        case 'L':  L=var;  sprintf(buff,"%ld",*L); break;
        case 'D':  D=var;  sprintf(buff,"%lg",*D); break;
        case 'I':  I=var;  sprintf(buff,"%d" ,*I); break;
     }
     maxLen=MAX(15,strlen(buff));
   }    
   npos = 1;      

   do
   { 
      goto_xy(xx,y);
      key  = str_redact(buff,npos,maxLen);

      if (key == KB_ESC)
      {  
         put_text(&pscr);
         if(type>=0) free(buff);
         return 0;
      }
      err=0;
      if (key == KB_ENTER)
      {
/*         trim(buff); */
         if(type<0) err=1; else
         {
            switch (type)
            {   
              case 'L':   err=sscanf(buff,"%ld",L); break;
              case 'D':   err=sscanf(buff,"%lf",D); break;
              case 'I':   err=sscanf(buff,"%d" ,I); break;
            }
         }                                     
         if (err<=0)   messanykey(10,10," incorrect number"); 
      }
      
   }  while (err<=0);
   
   if(clear)put_text(&pscr); else free(pscr); 
   if(type>=0) free(buff);   
   return 1;   
} 
예제 #30
0
파일: screen.c 프로젝트: Omer80/wimps
int  viewresults(void)
{  
   int  k,kmenu;
   void *  pscr  = NULL;
 
   shortstr  newname;
   int dirStat=checkDir("results");

   if(dirStat==0){messanykey(10,15,"directory RESULTS is empty"); return 1;}

   kmenu = 1;   
label_1:

   menu1(10,10,"","\010"
      " View   "
      " Delete "
      " Rename ","s_res",&pscr,&kmenu);
      
   switch (kmenu)
   {
     case 0:
       return 0;         
     case 1: 
      viewDir("results");    
      break;

     case 2:
      if(dirStat==2)
      { char mess[]="Can not clean dir 'results' because it contains the LOCK file";
        if(blind) { printf("%s\n",mess); sortie(102);} 
        else { messanykey(3,13,mess); break;}
      } 
      if ( mess_y_n( 6,13," Delete files ") ) 
      {  struct dirent **namelist;
         int n,i;
         n = scandir("./results", &namelist, NULL, NULL);
         for(i=0; i<n;i++)
         { 
           char buff[100];
           if(strcmp(namelist[i]->d_name,"aux") && strcmp(namelist[i]->d_name,"..") && strcmp(namelist[i]->d_name,".")  )
           { 
             sprintf(buff,"rm -rf results/%s",namelist[i]->d_name);  
             if(unlink(buff+7)) system(buff);
           }  
         }
         free(namelist);
      }
      put_text(&pscr);
      return 1;
     case 3:
      strcpy(newname," ");
      while(1)
      {  void * pscr3;
         get_text(1,maxRow(),maxCol(),maxRow(),&pscr3); 
         goto_xy(1,maxRow());
         print("Enter new name: ");
	 k = str_redact(newname,1,30);
	 if (k == KB_ESC)
	 {   goto_xy(1,24);
             clr_eol();
             goto label_1;
         }
	 if (k == KB_ENTER)
         {
            trim(newname);
            if(rename("results",newname)==0)
            {  char command[200];
               mkdir("results",0755);
               sprintf(command," cp -rp  %s/aux results",newname);
               system(command);
               
               put_text(&pscr);
               put_text(&pscr3);
               return 1;
            }
             else  messanykey(10,15," Can't rename the directory");
         }
         put_text(&pscr3);   
      }
   } 
   goto label_1;
}