static void edition_pre_exec (void) { if (clear_before_exec) clr_scr (); else { if (!(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)) printf ("\n\n"); } channels_down (); disable_mouse (); disable_bracketed_paste (); tty_reset_shell_mode (); tty_keypad (FALSE); tty_reset_screen (); numeric_keypad_mode (); /* on xterms: maybe endwin did not leave the terminal on the shell * screen page: do it now. * * Do not move this before endwin: in some systems rmcup includes * a call to clear screen, so it will end up clearing the shell screen. */ do_exit_ca_mode (); }
void term_clear() { #ifdef CURSES clear(); #else clr_scr(); #endif term_color(COL_WHITE); }
/* re-init the menu, because perhaps there was a change in the way how the panel are split (horizontal/vertical). */ done_menu(); init_menu(); menubar_arrange(the_menubar); #endif } void layout_cmd (void) { int result; int i; init_layout (); run_dlg (layout_dlg); result = layout_dlg->ret_value; if (result == B_ENTER || result == B_EXIT){ for (i = 0; check_options [i].text; i++) if (check_options [i].widget) *check_options [i].variable = check_options [i].widget->state & C_BOOL; #ifndef HAVE_X horizontal_split = radio_widget->sel; first_panel_size = _first_panel_size; output_lines = _output_lines; layout_do_change = 1; #endif } if (result == B_EXIT){ save_layout (); sync_profiles (); } destroy_dlg (layout_dlg); if (layout_do_change) layout_change (); } static void check_split (void) { if (horizontal_split){ if (equal_split) first_panel_size = height / 2; else if (first_panel_size < MINHEIGHT) first_panel_size = MINHEIGHT; else if (first_panel_size > height - MINHEIGHT) first_panel_size = height - MINHEIGHT; } else { if (equal_split) first_panel_size = COLS / 2; else if (first_panel_size < MINWIDTH) first_panel_size = MINWIDTH; else if (first_panel_size > COLS - MINWIDTH) first_panel_size = COLS - MINWIDTH; } } int panel_event (Gpm_Event *event, WPanel *panel); int menu_bar_event (Gpm_Event *event, void *); extern char *prompt; #ifndef HAVE_X #ifdef HAVE_SLANG void init_curses () { extern int force_ugly_line_drawing; extern int SLtt_Has_Alt_Charset; SLtt_get_terminfo (); #ifndef OS2_NT if (force_ugly_line_drawing) SLtt_Has_Alt_Charset = 0; #endif SLsmg_init_smg (); do_enter_ca_mode (); init_colors (); keypad (stdscr, TRUE); nodelay (stdscr, FALSE); } #else void init_curses (void) { initscr(); if (!status_using_ncurses) do_enter_ca_mode (); mc_raw_mode (); noecho (); keypad (stdscr, TRUE); nodelay (stdscr, FALSE); init_colors (); } #endif /* ! HAVE_SLANG */ void done_screen () { if (!(quit & SUBSHELL_EXIT)) clr_scr (); reset_shell_mode (); mc_noraw_mode (); if (use_mouse_p) shut_mouse (); keypad (stdscr, FALSE); }
void done_screen () { if (!(quit & SUBSHELL_EXIT)) clr_scr (); reset_shell_mode (); mc_noraw_mode (); keypad (stdscr, FALSE); done_colors (); }
static void refresh_cmd (void) { #ifdef HAVE_SLANG tty_touch_screen (); mc_refresh (); #else /* Use this if the refreshes fail */ clr_scr (); repaint_screen (); #endif /* HAVE_SLANG */ }
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; }
void n_comphep(void) { clr_scr(FGmain,BGmain); while(checkParam()) if(mess_y_n(15,15, "Quit the session?")) {w_sess__(NULL); return;} else change_parameter(54,7,0); do { int err=monte_carlo_menu(); switch(err) { case 1:printf("Energy is too small!\n"); sortie(123); case 2:printf("Can not evaluate cuts limlts\n"); sortie(124); case 3:printf("Can not evaluate regularization paremeters"); sortie(125); } } while(!mess_y_n(15,15,"Quit session?")); w_sess__(NULL); }
int main() { int e = 0; int i; TETO t[2]; int dll[2]; int wt=10; int cwt=0; int dp=0; init_sys(); initTETO(&t[0], NINGEN, 1, -4, 15,7 ); initTETO(&t[1], KIKAI, 27, -4, -4,7 ); // initTETO(&t[0], KIKAI, 1, -4, 15,7 ); initTETO(&t[1], KIKAI, 27, -4, -4,7 ); // initTETO(&t[0], NINGEN, 1, -4, 15,7 ); initTETO(&t[1], MUJINKUN,27, -4, -4,7 ); clr_scr(); prtP(&t[0].P); prtP(&t[1].P); prtNP(&t[0].NP, &t[0].P); prtNP(&t[1].NP,&t[1].P); prtMINO(&t[0].next_mino, &t[0].P); prtMINO(&t[1].next_mino, &t[0].P); do{ dll[0] = calcTETO(&t[0],PAD1,dp); dll[1] = calcTETO(&t[1],PAD2,dp); if( dll[0] >= 1 ){ t[1].ojl += dll[0]-1; } if( dll[1] >= 1 ){ t[0].ojl += dll[1]-1; } vsync(1); syncPAD(); dp=0;if(cwt++>=wt){dp=1;cwt=0;} } while((PAD1&PAD_START)==0); close_sys(); return(0); }
main ( int argc, char *argv[] ) { long cnt = 1000L ; int needPause = 0 ; for ( int i = 1 ; i < argc ; i++ ) { switch( argv[i][0] ) { case 'P' : case 'p' : needPause = 1 ; break ; case 'V' : case 'v' : directvideo = 1 ; break ; case 'B' : case 'b' : directvideo = 0 ; break ; default : if ( argv[i][0] >= '0' && argv[i][0] <= '9' ) cnt = atol(argv[i]) ; break ; } } stdscr.cursor_off() ; stdscr.set_toVideo(directvideo) ; stdscr.set_toBios(directvideo^1) ; // stdscr.set_attr(0x10) ; set_attr(0x10) ; // stdscr.clr_scr() ; clr_scr() ; { twin X( 1, 1,10,80) ; twin L(11, 1,20,40) ; twin R(11,41,20,80) ; test1(X,L,R,cnt) ; X.save_image() ; L.save_image() ; R.save_image() ; test2(X,L,R,cnt) ; test3(X,L,R,cnt) ; // stdscr.set_attr(0x07) ; set_attr(0x07) ; if ( needPause ) { // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> press any key to continue ...") ; outs(">>>> press any key to continue ...") ; clr_key() ; wait_key() ; } X.restore_image() ; L.restore_image() ; R.restore_image() ; if ( needPause ) { // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> press any key to continue ...") ; outs(">>>> press any key to continue ...") ; clr_key() ; wait_key() ; } } { twin A( 6,28,10,47) ; twin B( 8,31,12,50) ; twin C(10,34,14,53) ; Wfptr p[3] ; p[0] = A.save_screen() ; p[1] = B.save_screen() ; p[2] = C.save_screen() ; int k = 0 ; for ( int n = 0 ; n < 100 ; n++ ) { for ( int i = 1 ; i <= 20 ; i += 5 ) { for ( int j = 1 ; j <= 80 ; j += 20 ) { twin D(i,j,i+4,j+19) ; D.restore_screen(p[k]) ; k = (k+1) % 3 ; } } } } stdscr.cursor_on() ; // stdscr.clr_scr(24,25) ; clr_scr(24,25) ; // stdscr.locate(24,1) ; locate(24,1) ; // stdscr.outs(">>>> end of testing ...") ; outs(">>>> end of testing ...") ; clr_key() ; return 0 ; }
void cheplabel(void) { int key; char fname[STRSIZ]; FILE *f; while(1) { { int X=20,Y=1; scrcolor(FGmain,BGmain); goto_xy(X,Y); print("Skobeltsyn Institute of Nuclear Physics,"); goto_xy(X+8,Y+1); print("Moscow State University."); } { int Y=5; scrcolor(Blue,LightGray); goto_xy(7,Y); print("CalcHEP - a package for Calculation in High Energy Physics"); scrcolor(FGmain,BGmain); goto_xy(15,Y+1); print("Version 2.4.4; Last correction August 23,2006"); } { int Y=7; scrcolor(FGmain,BGmain); goto_xy(3,Y+2);print(" Author of the package:"); scrcolor(Blue,LightGray); print(" Alexander Pukhov"); scrcolor(FGmain,BGmain); goto_xy(14,Y+3);print("For contacts:"); scrcolor(Blue,LightGray); goto_xy(28,Y+3);print("email: <*****@*****.**>"); goto_xy(28,Y+4);print("http://theory.sinp.msu.ru/~pukhov/calchep.html"); goto_xy(28,Y+5);print("http://www.ifh.de/~pukhov/calchep.html"); } { int Y=14; scrcolor(FGmain,BGmain); goto_xy(5,Y);print("The package contains codes written by:"); scrcolor(Blue,LightGray); goto_xy(10,Y+1); scrcolor(Blue,LightGray); print("M.Donckt,V.Edneral,V.Ilyin,D.Kovalenko,A.Kryukov,G.Lepage,A.Semenov"); /* print("G.Belanger,F.Boudjema,A.Djouadi,V.Edneral,V.Ilyin,J.-L.Kneur,"); goto_xy(10,Y+2); print("A.Kryukov,G.Lepage,G.Moultaka,A.Semenov"); */ } { int Y=17; scrcolor(FGmain,BGmain); goto_xy(5,Y);print("The BS models for CalcHEP were developed in collaboration with:"); scrcolor(Blue,LightGray); goto_xy(10,Y+1); scrcolor(Blue,LightGray); print("G.Belanger,A.Belyaev,F.Boudjema,A.Semenov"); } { int X1=19, X2=61, Y1=21, Y2=Y1+2; scrcolor(FGmain,BGmain); goto_xy(X1+2,Y1-1); print("Press F9 or click the box below to get"); scrcolor(Blue,LightGray); chepbox(X1,Y1,X2,Y2); goto_xy(X1+3,Y1+1); print("References and Contributions "); /* goto_xy(X1+3,Y1+2); print(" and relative information. "); */ scrcolor(FGmain,BGmain); goto_xy(3,Y2+1); print("This information is available during the session by means of the F9 key"); clearTypeAhead(); key= inkey(); if(key==KB_F9 || ( key==KB_MOUSE && mouse_info.row>=Y1 && mouse_info.row<=Y2 && mouse_info.col >=X1 && mouse_info.col<=X2 ) ) { sprintf(fname,"%s%cCITE",pathtocomphep,f_slash); f=fopen(fname,"r"); showtext (1, 1, 80,1,"",f); fclose(f); break; } if(key !=KB_MOUSE) break; } } clr_scr(FGmain,BGmain); }
void toggle_panels (void) { #ifdef ENABLE_SUBSHELL vfs_path_t *new_dir_vpath = NULL; #endif /* ENABLE_SUBSHELL */ SIG_ATOMIC_VOLATILE_T was_sigwinch = 0; channels_down (); disable_mouse (); disable_bracketed_paste (); if (clear_before_exec) clr_scr (); if (mc_global.tty.alternate_plus_minus) numeric_keypad_mode (); #ifndef HAVE_SLANG /* With slang we don't want any of this, since there * is no raw_mode supported */ tty_reset_shell_mode (); #endif /* !HAVE_SLANG */ tty_noecho (); tty_keypad (FALSE); tty_reset_screen (); do_exit_ca_mode (); tty_raw_mode (); if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_RESTORE); #ifdef ENABLE_SUBSHELL if (mc_global.tty.use_subshell) { vfs_path_t **new_dir_p; new_dir_p = vfs_current_is_local ()? &new_dir_vpath : NULL; invoke_subshell (NULL, VISIBLY, new_dir_p); } else #endif /* ENABLE_SUBSHELL */ { if (output_starts_shell) { fprintf (stderr, _("Type 'exit' to return to the Midnight Commander")); fprintf (stderr, "\n\r\n\r"); my_system (EXECUTE_INTERNAL, mc_global.tty.shell, NULL); } else get_key_code (0); } if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_SAVE); do_enter_ca_mode (); tty_reset_prog_mode (); tty_keypad (TRUE); /* Prevent screen flash when user did 'exit' or 'logout' within subshell */ if ((quit & SUBSHELL_EXIT) != 0) { /* User did 'exit' or 'logout': quit MC */ if (quiet_quit_cmd ()) return; quit = 0; #ifdef ENABLE_SUBSHELL /* restart subshell */ if (mc_global.tty.use_subshell) init_subshell (); #endif /* ENABLE_SUBSHELL */ } enable_mouse (); enable_bracketed_paste (); channels_up (); if (mc_global.tty.alternate_plus_minus) application_keypad_mode (); /* HACK: * Save sigwinch flag that will be reset in mc_refresh() called via update_panels(). * There is some problem with screen redraw in ncurses-based mc in this situation. */ was_sigwinch = mc_global.tty.winch_flag; mc_global.tty.winch_flag = 0; #ifdef ENABLE_SUBSHELL if (mc_global.tty.use_subshell) { do_load_prompt (); if (new_dir_vpath != NULL) do_possible_cd (new_dir_vpath); if (mc_global.tty.console_flag != '\0' && output_lines) show_console_contents (output_start_y, LINES - mc_global.keybar_visible - output_lines - 1, LINES - mc_global.keybar_visible - 1); } vfs_path_free (new_dir_vpath); #endif /* ENABLE_SUBSHELL */ if (mc_global.mc_run_mode == MC_RUN_FULL) { update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_xterm_title_path (); } if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) dialog_change_screen_size (); else repaint_screen (); }
int main(int argc,char** argv) { /*=================================== 0 - First start. 1 - Model menu. 2 - Enter process menu. 3 - Feynman diagrams menu; squaring. 4 - Squared diagram menu; symbolic calculation. 5 - Write results; new process. 10 -Restart symbolic calculations ==========================================================*/ /* 0-Start; 1-Restart; 2-Heap Error,3-Edit Model,4-UserBreak */ void *pscr1=NULL,*pscr2=NULL,*pscr3=NULL,*pscr4=NULL,*pscr5=NULL; int k1=1,k2=1,k3=1,k4=1,k5=1; int n; int pid=0; char LOCKtxt[]="Directory 'results/' contains the .lock file created by n_calchep.\n" "To continue you may a)Close the n_calchep session, or b)Rename 'results/',\n"; blind=0; strcpy(pathtocomphep,argv[0]); for(n=strlen(pathtocomphep)-1; n && pathtocomphep[n]!=f_slash; n--); pathtocomphep[n-3]=0; for ( n=1;n<argc;n++) { if (strcmp(argv[n],"-blind")==0 && n<argc-1 ) { blind=1; inkeyString=argv[++n]; } if (strcmp(argv[n],"+blind")==0 ) blind=2; } if(!writeLockFile(".lock")) { fprintf(stderr,"locked by other s_calchep. See .lock file\n"); exit(100); } strcpy(pathtouser,""); sprintf(pathtohelp,"%shelp%c",pathtocomphep,f_slash); outputDir="results/"; { char * icon=(char *) malloc(strlen(pathtocomphep)+10); int err; sprintf(icon,"%sicon",pathtocomphep); err=start1("CalcHEP/symb",icon,"calchep.ini",&xw_error); if(err && blind==0) { printf("Error:You have launched interactive session for version compiled without X11 library.\n"); printf("Options: a) Use blind session; b) Recompile CalcHEP with X11\n"); exit(66); } free(icon); } fillModelMenu(); f3_key[0]=f3_key_prog; f3_mess[0]="Model"; f3_key[1]=f4_key_prog; f3_mess[1]="Diagrams"; f3_key[2]=f5_key_prog; f3_mess[2]="Switches"; f3_key[3]=f6_key_prog; f3_mess[3]="Results"; f3_mess[4]="Del"; f3_mess[5]="UnDel"; f3_key[6]=f9_key_prog; f3_mess[6]="Ref"; f3_key[7]=f10_key_prog; f3_mess[7]="Quit"; restoreent(&menulevel); if(!blind && menulevel<2) cheplabel(); switch (menulevel) { case 10: case 6: case 5: case 4: case 3: readModelFiles("./models",n_model); modelinfo(); loadModel(0,forceUG); processinfo(); diagramsinfo(); case 2: k1=n_model; case 1: break; } switch (menulevel) { case 2: menuhelp(); goto label_20; case 3: goto label_31; case 4: goto label_40; case 5: goto label_50; case 6: case 10: goto restart2; } label_10: /* Menu2(ModelMenu): */ f3_key[0]=NULL; /*models*/ f3_key[1]=NULL; /*diagrams*/ menulevel = 1; forceUG=0; menuhelp(); for(;;) { showheap(); k1=n_model; menu1(56,4,"",modelmenu,"s_1",&pscr1,&k1); n_model=k1; if(n_model == 0) { if( mess_y_n(56,4,"Quit session")) { saveent(menulevel); goto exi; } } else if(n_model == maxmodel+1) { clrbox(1,4,55,18); makenewmodel(); menuhelp(); } else if (n_model > 0) { put_text(&pscr1); goto label_20; } } label_20: /* Menu3:Enter Process */ f3_key[0]=NULL; f3_key[1]=NULL; menulevel = 2; saveent(menulevel); readModelFiles("./models",n_model); modelinfo(); k2 = 1; do { char strmen[]="\026" " Enter Process " " Force Unit.Gauge OFF " " Edit model " " Delete model "; if(forceUG)improveStr(strmen,"OFF","ON"); menu1(56,4,"",strmen,"s_2_*",&pscr2,&k2); switch (k2) { case 0: goto_xy(1,1); clr_eol(); goto label_10; case 2: forceUG=!forceUG; modelinfo(); break; case 3: editModel(1); break; case 4: if ( deletemodel(n_model) ) { goto_xy(1,1); clr_eol(); n_model=1; fillModelMenu(); goto label_10; } else readModelFiles("./models",n_model); } } while (k2 != 1); loadModel(0,forceUG); label_21: f3_key[0]=NULL; f3_key[1]=NULL; menulevel=2; errorcode=enter(); /* Enter a process */ newCodes=0; showheap(); if (errorcode) /* 'Esc' pressed */ { menuhelp(); goto label_20;} errorcode=construct(); /* unSquared diagrams */ if (errorcode) { if(blind) { printf("Processes of this type are absent\n"); sortie(111); } else { messanykey(5,22,"Processes of this type are absent"); clrbox(1,19,80,24); goto label_21; } } else if(!blind) { int dirStat=checkDir("results"); if(dirStat!=0) { messanykey( 10,10,"There are files in directory 'results/'.\n" "To continue you has to clean or rename this directory."); viewresults(); if(checkDir("results")!=0) goto label_21; } clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); goto label_31; } label_30: /* Menu4: Squaring,...*/ clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); label_31: f3_key[0]=f3_key_prog; f3_key[1]=NULL; menulevel=3; k3 = 1; do { menu1(56,4,"","\026" " View diagrams " /* " Amplitude calculation" */ " Squaring technique " " Write down processes ","s_squa_*",&pscr3,&k3); switch (k3) { case 0: clrbox(1,2,55,11); menuhelp(); goto label_20; case 1: viewfeyndiag(1); break; case 3: { FILE*f=fopen("results/list_prc.txt","w"); int k,ndel,ncalc,nrest; char process[100]; long recpos; menup=fopen(MENUP_NAME,"r"); for(k=1;;k++) { int err=rd_menu(1,k,process,&ndel,&ncalc,&nrest,&recpos); if(!err) break; trim(process); fprintf(f,"%s\n",process); } fclose(f); fclose(menup); messanykey(20,14,"See file 'results/list_prc.txt'"); } break; /* case 2: messanykey(10,10,"Not implemented yet"); Amplitudes(); */ } } while (k3 != 2); if (!squaring()) goto label_30; /* process is absent */ clear_tmp(); saveent(menulevel); restoreent(&menulevel); label_40: /* Menu5: View squared diagrams..... */ f3_key[0]=f3_key_prog; f3_key[1]=f4_key_prog; menulevel=4; clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); sq_diagramsinfo(); /* ???????? */ k4=1; saveent(menulevel); pscr4=NULL; for(;;) { int res; menu1(56,4,"","\026" " View squared diagrams" " Symbolic calculations" " Make&Launch n_calchep" " Make n_calchep " " REDUCE program " ,"s_calc_*",&pscr4,&k4); res=checkDir("results"); if(res==1) { int n_calchep_id=setLockFile("results/.lock"); if(n_calchep_id) unLockFile(n_calchep_id); else res=2; } switch (k4) { case 0: if (mess_y_n(50,3,"Return to previous menu?"))goto label_30; break; case 1: viewsqdiagr(); break; case 2: /* Compute all diagrams */ restart2: f3_key[0]=f3_key_prog; f3_key[1]=f4_key_prog; menulevel=4; calcallproc(); sq_diagramsinfo(); if(!continuetest()) break; showheap(); put_text(&pscr4); break; case 3: { static char keystr[12]="]{{[{"; if(res==2) messanykey(3,10,LOCKtxt); else inkeyString=keystr; } break; case 4: if(res==2) messanykey(3,10,LOCKtxt); else { char command[100]; FILE *f=fopen("results/EXTLIB","w"); fprintf(f,"EXTLIB=\"%s\"\nexport EXTLIB\n",EXTLIB); fclose(f); saveent(menulevel); { char command[100]; sprintf(command,"cd results; $CALCHEP/bin/make_VandP ../models %d",n_model); system(command); } finish(); sortie(22); } case 5: mk_reduceprograms(); break; } if(k4==2 && continuetest()) { put_text(&pscr4); break; } } label_50: k5=1; pscr5=NULL; menulevel=5; saveent(menulevel); for(;;) { int n_calchep_id; menu1(56,4,"","\026" " C code " " C-compiler " " Edit Linker " " REDUCE code " " MATHEMATICA code " " FORM code " " Enter new process " ,"s_out_*",&pscr5,&k5); if((k5==1||k5==2)&&pid) { int epid=waitpid(pid,NULL,WNOHANG); if(epid) pid=0; else { messanykey(3,10,"This option is frozen while n_calchep runs or is compiled"); continue; } } switch (k5) { case 0: goto label_40; break; case 1: c_prog(); newCodes=0; saveent(menulevel); break; case 2: if(newCodes) { c_prog(); newCodes=0; saveent(menulevel);} pid=fork(); if(pid==0) { char * command; n_calchep_id=setLockFile("results/.lock"); if(n_calchep_id) { command=(char*)malloc(strlen(pathtocomphep)+strlen(EXTLIB)+100); sprintf(command,"EXTLIB=\"%s\"\n" "export EXTLIB\n" "cd results\n" "xterm -e %s/make__n_calchep %d", EXTLIB,pathtocomphep,n_model); system(command); sprintf(command,"cd results; ./n_calchep"); unLockFile(n_calchep_id); system(command); free(command); } exit(0); } break; case 3: if(edittable(1,1,&modelTab[4],1," ",0)) { char fName[STRSIZ]; readEXTLIB(); sprintf(fName,"%smodels%c%s%d.mdl",pathtouser,f_slash,mdFls[4],n_model); writetable( &modelTab[4],fName); } break; case 4: makeReduceOutput(); break; case 5: makeMathOutput(); break; case 6: makeFormOutput(); break; case 7: put_text(&pscr5); clrbox(1,2,55,11); menuhelp(); goto label_20; } } exi: finish(); sortie(0); return 0; }
void toggle_panels (void) { #ifdef HAVE_SUBSHELL_SUPPORT char *new_dir = NULL; char **new_dir_p; #endif /* HAVE_SUBSHELL_SUPPORT */ channels_down (); disable_mouse (); if (clear_before_exec) clr_scr (); if (alternate_plus_minus) numeric_keypad_mode (); #ifndef HAVE_SLANG /* With slang we don't want any of this, since there * is no mc_raw_mode supported */ reset_shell_mode (); noecho (); #endif /* !HAVE_SLANG */ keypad (stdscr, FALSE); endwin (); do_exit_ca_mode (); mc_raw_mode (); if (console_flag) handle_console (CONSOLE_RESTORE); #ifdef HAVE_SUBSHELL_SUPPORT if (use_subshell) { new_dir_p = vfs_current_is_local ()? &new_dir : NULL; if (invoke_subshell (NULL, VISIBLY, new_dir_p)) quiet_quit_cmd (); /* User did `exit' or `logout': quit MC quietly */ } else #endif /* HAVE_SUBSHELL_SUPPORT */ { if (output_starts_shell) { fprintf (stderr, _("Type `exit' to return to the Midnight Commander")); fprintf (stderr, "\n\r\n\r"); my_system (EXECUTE_INTERNAL, shell, NULL); } else get_key_code (0); } if (console_flag) handle_console (CONSOLE_SAVE); do_enter_ca_mode (); reset_prog_mode (); keypad (stdscr, TRUE); /* Prevent screen flash when user did 'exit' or 'logout' within subshell */ if (quit) return; enable_mouse (); channels_up (); if (alternate_plus_minus) application_keypad_mode (); #ifdef HAVE_SUBSHELL_SUPPORT if (use_subshell) { load_prompt (0, 0); if (new_dir) do_possible_cd (new_dir); if (console_flag && output_lines) show_console_contents (output_start_y, LINES - keybar_visible - output_lines - 1, LINES - keybar_visible - 1); } #endif /* HAVE_SUBSHELL_SUPPORT */ update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_xterm_title_path (); do_refresh (); }
int main(int argc,char** argv) { /*=================================== 0 - First start. 1 - Model menu. 2 - Enter process menu. 3 - Feynman diagrams menu; squaring. 4 - Squared diagram menu; symbolic calculation. 5 - Write results; new process. 10 -Restart symbolic calculations ==========================================================*/ /* 0-Start; 1-Restart; 2-Heap Error,3-Edit Model,4-UserBreak */ void *pscr1=NULL,*pscr2=NULL,*pscr3=NULL,*pscr4=NULL,*pscr5=NULL; int k1=1,k2=1,k3=1,k4=1,k5=1; int n; int pid=0; char LOCKtxt[]="Directory 'results/' contains the .lock file created by n_calchep.\n" "To continue you may a)Close the n_calchep session, or b)Rename 'results/',\n"; blind=0; strcpy(pathtocalchep,argv[0]); for(n=strlen(pathtocalchep)-1; n && pathtocalchep[n]!=f_slash; n--); pathtocalchep[n-3]=0; for ( n=1;n<argc;n++) { if (strcmp(argv[n],"-blind")==0 && n<argc-1 ) { blind=1; inkeyString=argv[++n]; } if (strcmp(argv[n],"+blind")==0 ) blind=2; if (strcmp(argv[n],"--version")==0 ) { printf("%s\n", VERSION_); exit(0);} } if(!writeLockFile(".lock")) { fprintf(stderr,"locked by other s_calchep. See .lock file\n"); exit(100); } strcpy(pathtouser,""); sprintf(pathtohelp,"%shelp%c",pathtocalchep,f_slash); outputDir="results/"; { char * icon=(char *) malloc(strlen(pathtocalchep)+20); char title[30]; int err; sprintf(icon,"%s/include/icon",pathtocalchep); sprintf(title,"CalcHEP_%s/symb", VERSION); err=start1(title,icon,"calchep.ini",&xw_error); if(err && blind==0) { printf("Error:You have launched interactive session for version compiled without X11 library.\n"); printf(" Presumably X11 development package is not installed in your computer.\n"); printf(" In this case directory /usr/include/X11/ is empty.\n"); printf("Options: a) Use blind session; b) Update Linux and recompile CalcHEP \n"); printf("Name of needed package\n"); printf(" libX11-devel Fedora/Scientific Linux/CYGWIN/Darwin(MAC)\n"); printf(" libX11-dev Ubuntu/Debian\n"); printf(" xorg-x11-devel SUSE\n"); exit(66); } free(icon); } fillModelMenu(); f3_key[0]=f3_key_prog; f3_mess[0]="Model"; f3_key[1]=f4_key_prog; f3_mess[1]="Diagrams"; f3_key[2]=f5_key_prog; f3_mess[2]="Switches"; f3_key[3]=f6_key_prog; f3_mess[3]="Results"; f3_mess[4]="Del"; f3_mess[5]="UnDel"; f3_key[6]=f9_key_prog; f3_mess[6]="Ref"; f3_key[7]=f10_key_prog; f3_mess[7]="Quit"; restoreent(&menulevel); if(!blind && menulevel<2) cheplabel(); switch (menulevel) { case 10: case 6: case 5: case 4: case 3: readModelFiles("./models",n_model); modelinfo(); loadModel(0,forceUG); processinfo(); diagramsinfo(); k1=n_model; break; case 2: k1=n_model; readModelFiles("./models",n_model); break; } switch (menulevel) { case 2: menuhelp(); goto label_20; case 3: goto label_31; case 4: goto label_40; case 5: goto label_50; case 6: case 10: goto restart2; } label_10: /* Menu2(ModelMenu): */ f3_key[0]=NULL; /*models*/ f3_key[1]=NULL; /*diagrams*/ menulevel = 1; forceUG=0; menuhelp(); for(;;) { showheap(); k1=n_model; menu1(56,4,"",modelmenu,"s_1",&pscr1,&k1); if(k1 == 0) { if( mess_y_n(56,4,"Quit session")) {n_model=0; saveent(menulevel); goto exi; } } else if(k1 == maxmodel+1) { clrbox(1,4,55,18); makenewmodel(); menuhelp(); } else if (k1 > 0) { int err=0; put_text(&pscr1); if(k1!=n_model || ldModelStatus==0) { err=readModelFiles("./models",k1);} n_model=k1; if(err){ if(blind) sortie(133); else goto label_10;} else goto label_20; } } label_20: /* Menu3:Enter Process */ f3_key[0]=NULL; f3_key[1]=NULL; menulevel = 2; saveent(menulevel); modelinfo(); k2 = 1; do { char strmen[]="\026" " Enter Process " " Force Unit.Gauge= OFF" " Edit model " " Numerical Evaluation " "======================" " Delete model "; if(forceUG)improveStr(strmen,"OFF","ON"); menu1(56,4,"",strmen,"s_2_*",&pscr2,&k2); switch (k2) { case 0: goto_xy(1,1); clr_eol(); goto label_10; case 2: forceUG=!forceUG; modelinfo(); break; case 3: editModel(1); break; case 4: numcheck(); case 5: break; case 6: if(deletemodel(n_model)) { goto_xy(1,1); clr_eol(); n_model=1; ldModelStatus=0; fillModelMenu(); goto label_10; } } } while (k2 != 1); if(!loadModel(0,forceUG)) goto label_20; label_21: f3_key[0]=NULL; f3_key[1]=NULL; menulevel=2; checkAuxDir(n_model); errorcode=enter(); /* Enter a process */ newCodes=0; showheap(); if (errorcode) /* 'Esc' pressed */ { menuhelp(); goto label_20;} errorcode=construct(); /* unSquared diagrams */ if (errorcode) { if(blind) { printf("Processes of this type are absent\n"); sortie(111); } else { messanykey(5,22,"Processes of this type are absent"); clrbox(1,19,80,24); goto label_21; } } else if(!blind) { int dirStat=checkDir("results"); if(dirStat!=0) { messanykey( 10,10,"There are files in directory 'results/'.\n" "To continue you has to clean or rename this directory."); viewresults(); if(checkDir("results")!=0) goto label_21; } clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); goto label_31; } label_30: /* Menu4: Squaring,...*/ clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); label_31: f3_key[0]=f3_key_prog; f3_key[1]=NULL; menulevel=3; k3 = 1; do { menu1(56,4,"","\026" " View diagrams " /* " Amplitude calculation" */ " Square diagrams " " Write down processes ","s_squa_*",&pscr3,&k3); switch (k3) { case 0: clrbox(1,2,55,11); menuhelp(); goto label_20; case 1: viewfeyndiag(1); break; case 3: { FILE*f=fopen("results/list_prc.txt","w"); int k,ndel,ncalc,nrest; char process[100]; long recpos; menup=fopen(MENUP_NAME,"r"); for(k=1;;k++) { int err=rd_menu(1,k,process,&ndel,&ncalc,&nrest,&recpos); if(!err) break; trim(process); fprintf(f,"%s\n",process); } fclose(f); fclose(menup); messanykey(20,14,"See file 'results/list_prc.txt'"); } break; /* case 2: messanykey(10,10,"Not implemented yet"); Amplitudes(); */ } } while (k3 != 2); if (!squaring()) goto label_30; /* process is absent */ clear_tmp(); saveent(menulevel); restoreent(&menulevel); label_40: /* Menu5: View squared diagrams..... */ f3_key[0]=f3_key_prog; f3_key[1]=f4_key_prog; menulevel=4; clr_scr(FGmain,BGmain); modelinfo(); processinfo(); diagramsinfo(); sq_diagramsinfo(); /* ???????? */ k4=1; saveent(menulevel); pscr4=NULL; for(;;) { int res; menu1(56,4,"","\026" " View squared diagrams" " Symbolic calculations" " Make&Launch n_calchep" " Make n_calchep " " REDUCE program " ,"s_calc_*",&pscr4,&k4); res=checkDir("results"); if(res==1) { int n_calchep_id=setLockFile("results/.lock"); if(n_calchep_id) unLockFile(n_calchep_id); else res=2; } switch (k4) { case 0: if (mess_y_n(50,3,"Return to previous menu?"))goto label_30; break; case 1: viewsqdiagr(); break; case 2: /* Compute all diagrams */ restart2: f3_key[0]=f3_key_prog; f3_key[1]=f4_key_prog; menulevel=4; if(!nPROCSS ) calcallproc(); else { int *pids=malloc(sizeof(int)*nPROCSS); int *pipes=malloc(2*sizeof(int)*nPROCSS); int **qd=malloc(sizeof(int*)*nPROCSS); int totD=sqDiagList(qd, nPROCSS); int totC,nProc; int k; fflush(NULL); for(k=0;k<nPROCSS;k++) { int* kpipe=pipes+2*k; pipe(kpipe); pids[k]=fork(); if(pids[k]==0) { close(kpipe[0]); calcWithFork(k,qd[k],kpipe[1]); exit(0); } } for(k=0;k<nPROCSS;k++) close(pipes[2*k+1]); infoLine(0.); for(nProc=nPROCSS,totC=0;nProc;) { int one; int err; nProc=0; for(k=0;k<nPROCSS;k++) if(pids[k]) { if(waitpid(pids[k],NULL,WNOHANG)==0) { nProc++; if(read(pipes[2*k],&one,sizeof(int)))totC+=one; } else { for(;read(pipes[2*k],&one,sizeof(int))>0;) totC+=one; pids[k]=0; } } if(infoLine((double)totC/(double)totD)) for(k=0;k<nPROCSS;k++) if(pids[k]) kill(pids[k],SIGUSR1); } infoLine(2); for(k=0;k<nPROCSS;k++) { char ctlgName[100]; char command[200]; sprintf(ctlgName,"%s_%d",CATALOG_NAME,k); if(access(ctlgName,R_OK)==0) { sprintf(command," cat %s >> %s", ctlgName,CATALOG_NAME); system(command); unlink(ctlgName); } } if(totC) newCodes=1; updateMenuQ(); for(k=0;k<nPROCSS;k++) close(pipes[2*k]); free(pids); free(pipes); for(k=0;k<nPROCSS;k++) free(qd[k]); free(qd); } sq_diagramsinfo(); if(!continuetest()) break; showheap(); put_text(&pscr4); break; case 3: { static char keystr[12]="]{{[{"; if(res==2) messanykey(3,10,LOCKtxt); else inkeyString=keystr; } break; case 4: if(res==2) messanykey(3,10,LOCKtxt); else { char command[100]; saveent(menulevel); chdir("results"); makeVandP(0,"../models",n_model,2,pathtocalchep); finish(); sortie(22); } case 5: mk_reduceprograms(); break; } if(k4==2 && continuetest()) { put_text(&pscr4); break; } } label_50: k5=1; pscr5=NULL; menulevel=5; saveent(menulevel); sq_diagramsinfo(); for(;;) { int n_calchep_id; menu1(56,4,"","\026" " C code " " C-compiler " " Edit Linker " " REDUCE code " " MATHEMATICA code " " FORM code " " Enter new process " ,"s_out_*",&pscr5,&k5); if((k5==1||k5==2)&&pid) { int epid=waitpid(pid,NULL,WNOHANG); if(epid) pid=0; else { messanykey(3,10,"This option is frozen while n_calchep runs or is compiled"); continue; } } switch (k5) { case 0: goto label_40; break; case 1: c_prog(); newCodes=0; saveent(menulevel); break; case 2: if(newCodes) { c_prog(); newCodes=0; saveent(menulevel);} n_calchep_id=setLockFile("results/.lock"); if(n_calchep_id) { if(nPROCSS) { chdir("results"); makeVandP(0,"../models",n_model,2,pathtocalchep); pCompile(); if(access("./n_calchep",X_OK)==0) { fflush(NULL); pid=fork(); if(pid==0) { system("./n_calchep"); exit(0); } } else messanykey(15,15,"n_calchep is not generated"); chdir("../"); } else { fflush(NULL); pid=fork(); if(pid==0) { if(chdir("results")==0) { char*command=malloc(100+strlen(pathtocalchep)); makeVandP(0,"../models",n_model,2,pathtocalchep); sprintf(command,"xterm -e %s/sbin/make__n_calchep %d", pathtocalchep,n_model); system(command); free(command); system("./n_calchep"); } exit(0); } } unLockFile(n_calchep_id); } break; case 3: if(edittable(1,1,&modelTab[4],1," ",0)) { char fName[STRSIZ]; sprintf(fName,"%smodels%c%s%d.mdl",pathtouser,f_slash,mdFls[4],n_model); writetable( &modelTab[4],fName); } break; case 4: makeReduceOutput(); break; case 5: makeMathOutput(); break; case 6: makeFormOutput(); break; case 7: put_text(&pscr5); clrbox(1,2,55,11); menuhelp(); goto label_20; } } exi: finish(); sortie(0); return 0; }