Пример #1
0
int m_epa__(int i, int * pString)
{   
    void * pscr = NULL;
    i--;
    for(;;)
    { char mstr[]="\007"
                  "mu^-   "
                  "e^-    "
                  "e^+    "
                  "mu^+   ";


      char strmen[]="\050"
      " Incoming particle XXX                  "
      " |Q|max = ZZZ                           ";
      int mode=1;
      int n;
      if(pc[i]<0) n=3+pc[i]; else n=2+pc[i];
   
      improveStr(strmen,"XXX","%4.4s",mstr+1+(n-1)*mstr[0]);
      improveStr(strmen,"ZZZ","%s GeV",q_max_txt[i]);
      menu1(38,10,"",strmen, "n_sf_epa",&pscr,&mode);
    
      switch(mode)
      {
      case 0: { double v;
                if(1==sscanf(q_max_txt[i],"%lf",&v))
                {  
                   q_max_val[i]=v;
                   q_max_ptr[i]=q_max_val+i;
                   return 1;
                } else 
                { trim(q_max_txt[i]);
                  q_max_ptr[i]=varAddress(q_max_txt[i]);
                  if(!q_max_ptr[i]) 
                  { char buff[50];
                    sprintf(buff,"Can not find parameter '%s'",q_max_txt[i]);
                    continue;   
                  }
                }
                return 1;
              }      
      
      case 1: menu1(38,13,"",mstr,"",NULL,&n);
              if(n<3) pc[i]=n-3; else pc[i]=n-2; 
              break;
      case 2: correctStr (40,16,"Enter new value ",q_max_txt[i],19,1);
 break;
      }
    }
    return 1;     
}
Пример #2
0
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;
}
Пример #3
0
void  editModel( int  edit)
{ int  n,i,j;
  void *  pscr = NULL;
  int edited=0,renamed=0;
  int ok=1;
  char  tabMenu[STRSIZ], tabName[80];
  char menuName[30]; 
  char * tabhelp[5]={ "s_mdl_1", "s_mdl_2", "s_mdl_3", "s_mdl_4","s_mdl_5"};

  n = 1;
 
cont:
  if(edit) f3_key[7]=NULL;
  do
  { 
    if(edit) strcpy(menuName,"Edit  model"); else strcpy(menuName,"View   model");
    strcpy(tabMenu,"\017");
    for (i=0;i<5;i++)
    { strcpy(tabName,modelTab[i].headln);
      trim(tabName);
      for(j=strlen(tabName);j<14;j++) tabName[j]=' ';
      tabName[14]=0;
      strcat(tabMenu," "); strcat(tabMenu,tabName);
    }
    if(edit)  strcat(tabMenu,"      RENAME   "
                             "   CHECK MODEL ");
    if(edit) menu1(56,7,"",tabMenu,"s_mdl_e",&pscr,&n);
       else  menu1(17,15,"",tabMenu,"s_mdl_v",&pscr,&n); 
    
    switch(n) 
    { case 0:
        if( edited || renamed )
        {
          if(mess_y_n(15,19," Save corrections ?") )
          {
            if (ok||loadModel(1,0) ) writeModelFiles(n_model); else  goto cont;
            if(renamed) 
            { int i,size=modelmenu[0]; 
              for(i=0;modelTab[0].mdlName[i]&&i<size-1;i++)
              modelmenu[(n_model-1)*size +2+i]=modelTab[0].mdlName[i];
              for(;i<size-1;i++) modelmenu[(n_model-1)*size +2+i]=' ';
              modelinfo();
            }       
          }else  readModelFiles("./models",n_model);   
        }
        f3_key[7]=f10_key_prog;
        return;
    
      case 1: case 2: case 3: case 4: case 5:    
        edited=edittable(1,1,&modelTab[n-1],1,tabhelp[n-1],!edit) || edited;
	if(edited) ok=0;
    	break; 
      case 6:
        if(correctStr (10,17,"New name:",modelTab[0].mdlName,29,1))
        { trim(modelTab[0].mdlName);
          for(i=1;i<5;i++)strcpy(modelTab[i].mdlName,modelTab[0].mdlName);
          renamed=1;
        }         
        break;
      case 7:
        if (!loadModel(1,0) ) goto cont; 
        else {ok=1; messanykey(10,15,"The model is Ok");}
        break;
    }       
  }while(n);

}