void CIMToolWin::OnPaint() { CPaintDC dc(this); // device context for painting DrawAll(&dc); }
//--------------------------------------------- // // Main loop of the simulation // //--------------------------------------------- void ParticleGroups::Simulate(SpacingMap* m_spacing, ofImage* m_canvas) { if(!canstop) { BoundaryControl(); Birth_Death(m_spacing); GridsCollisionKill(); UpdateGrids(); DrawAll(m_canvas); Particle* indexPar = &particle[head_par]; int iter = 0; while(iter<numpt) // start from the first particle till the last one { int thisparID = indexPar->id; // mark this par's ID as the current one indexPar = indexPar->next; // let the index pointer point to the next one TiltUpdate(&particle[thisparID]); particle[thisparID].Update(); // update position, speed particle[thisparID].PushBackOrFwd(head_par, rear_par,Is_Foreground); particle[thisparID].advance(); // add random factors to direction particle[thisparID].Move2Middle(Is_Foreground,head_par,rear_par); // coordinate movement TiltControl(&particle[thisparID]); iter++; } // after the first update, create the grids if(!FillGrids) { CreateGrids(); FillGrids = true; } } }
void CBaseView::OnPaint() { CPaintDC dc(this); GiCanvasWin *cv = m_graph->canvas; GiGraphics &gs = m_graph->gs; dc.SetBkColor(m_bkColor); // 在beginPaint()中应用背景色 if (cv->beginPaint(dc)) // 准备绘图,使用绘图缓冲 { // 显示先前保存的正式图形内容 if (m_pan.cx != 0 || m_pan.cy != 0) // 动态平移 cv->clearWindow(); // 清除缓存图外的背景 if (!cv->drawCachedBitmap((float)m_pan.cx, (float)m_pan.cy)) { if (0 == m_pan.cx && 0 == m_pan.cy) cv->clearWindow(); // 清除背景 DrawAll(&gs); // 显示正式图形 cv->saveCachedBitmap(); // 保存正式图形内容 } else if (m_shapeAdded) // 在背景图上添加显示新图形 { m_shapeAdded->draw(gs); cv->saveCachedBitmap(); // 更新正式图形内容 } m_shapeAdded = NULL; OnDynDraw(&gs); // 显示动态图形 cv->endPaint(); // 提交绘图结果到窗口 } }
unsigned char MainWindow::MainMenuLoop() { unsigned char tmp; InitMenu(); while (_mainWindow.isOpen()) { while (_mainWindow.pollEvent(_event)) { if (CloseEvent() || (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num3))) Close(); if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num1)) { tmp = GameListLoop(); if (tmp != 0) return tmp; } if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num2)) CreditsLoop(); } Clear(); DrawAll(); Display(); } return 0; }
void makeGatherPlotsValidation(TString prefix, const std::vector<BabySample*> &babyVector, const float &goodruns_lumi, const float &est_newruns_lumi) { std::cout << "Making validation plots...\n"; // // Define specific cuts for validation plots // unsigned int lastgoodrun = max_run(); unsigned int lastgoodlumi = max_run_max_lumi(); TCut validation_ee ("validation_ee", base_dilep+ee_dilep); TCut validation_mm ("validation_mm", base_dilep+mm_dilep); TCut validation_newrun("validation_newrun", Form("!isdata||(run > %i || (run == %i && ls > %i))", lastgoodrun, lastgoodrun, lastgoodlumi)); TCut validation_goodrun("validation_goodrun", Form("!isdata||(run < %i || (run == %i && ls <= %i))", lastgoodrun, lastgoodrun, lastgoodlumi)); // // Apply preselection cuts to the samples in the baby vector // These preselection cuts will apply to all plots! // PreselectBabies(babyVector, base_dilep); // // Make the plots // // mass in new and goodruns //DrawAll("mass", prefix+"_validation_mass_goodruns_ee", validation_ee+validation_goodrun, goodruns_lumi, 50,0., 200., 0, babyVector); //DrawAll("mass", prefix+"_validation_mass_newruns_ee", validation_ee+validation_newrun, est_newruns_lumi, 50,0., 200., 0, babyVector); //DrawAll("mass", prefix+"_validation_mass_goodruns_mm", validation_mm+validation_goodrun, goodruns_lumi, 50,0., 200., 0, babyVector); //DrawAll("mass", prefix+"_validation_mass_newruns_mm", validation_mm+validation_newrun, est_newruns_lumi, 50,0., 200., 0, babyVector); DrawAll("mass", prefix+"_validation_mass_newruns_ee", validation_ee, est_newruns_lumi, 50,0., 200., 0, babyVector); DrawAll("mass", prefix+"_validation_mass_newruns_mm", validation_mm, est_newruns_lumi, 50,0., 200., 0, babyVector); // hyps with ttbar and dy like selection DrawAll("hyp_type", prefix+"_validation_hyp_type_top", dileptonictopv4_dilep, goodruns_lumi+est_newruns_lumi, 7, -0.5, 7.5, 0, babyVector); DrawAll("hyp_type", prefix+"_validation_hyp_type_base", base_dilep, goodruns_lumi+est_newruns_lumi, 7, -0.5, 6.5, 0, babyVector); }
void CChartLineSerie::Draw(CDC* pDC) { if (!m_bIsVisible) return; // If shadow is enabled, the all series must be redrawn. if (m_bShadow) { DrawAll(pDC); return; } if (pDC->GetSafeHdc()) { CPen NewPen; if (m_iPenStyle != PS_SOLID) { LOGBRUSH lb; lb.lbStyle = BS_SOLID; lb.lbColor = m_ObjectColor; NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb); } else { NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ObjectColor); } CPen* pOldPen; pDC->SetBkMode(TRANSPARENT); //To have lines limited in the drawing rectangle : pDC->IntersectClipRect(m_ObjectRect); pOldPen = pDC->SelectObject(&NewPen); //Draw all points that haven't been drawn yet for (m_iLastDrawnPoint;m_iLastDrawnPoint<(int)GetPointsCount()-1;m_iLastDrawnPoint++) { //We don't draw a line between the origin and the first point -> we must have // a least 2 points before begining drawing // if (m_vPoints<1) // break; CPoint ScreenPoint; ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint); pDC->MoveTo(ScreenPoint.x,ScreenPoint.y); ValueToScreen(m_vPoints[m_iLastDrawnPoint+1].X,m_vPoints[m_iLastDrawnPoint+1].Y,ScreenPoint); pDC->LineTo(ScreenPoint.x,ScreenPoint.y); } pDC->SelectClipRgn(NULL); pDC->SelectObject(pOldPen); DeleteObject(NewPen); } }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // void Next() { GetProjection(event, event); FindEdges(); if( (start[1]-start[0])> MinStartDist ) // limit the burst distance { GetAmpSignals(); GetPMTSignals(); GetShpSignals(); if( !(event%100) ) { DrawAll(); DrawDistributions(); PrintAll(); printf("event: %i\n", event); } } event++; if( event == event_lastt ) { ftimer.Stop(); FitProfiles(); PrintAll(); DrawAll(); DrawDistributions(); WriteAll(); gSystem->Exit(1); } }
void CChartLineSerie::Draw(CDC* pDC) { if (!m_bIsVisible) return; // If shadow or smooth is enabled, then the complete series // must be redrawn. if (m_bShadow || m_bSmooth) { DrawAll(pDC); return; } if (pDC->GetSafeHdc()) { CPen NewPen; if (m_iPenStyle != PS_SOLID) { LOGBRUSH lb; lb.lbStyle = BS_SOLID; lb.lbColor = m_SerieColor; NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb); } else { NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_SerieColor); } CPen* pOldPen; pDC->SetBkMode(TRANSPARENT); //To have lines limited in the drawing rectangle : pDC->IntersectClipRect(m_pParentCtrl->GetPlottingRect()); pOldPen = pDC->SelectObject(&NewPen); //Draw all points that haven't been drawn yet for (m_uLastDrawnPoint;m_uLastDrawnPoint<GetPointsCount()-1;m_uLastDrawnPoint++) { SChartXYPoint Point = GetPoint(m_uLastDrawnPoint); CPoint ScreenPoint; ValueToScreen(Point.X, Point.Y, ScreenPoint); pDC->MoveTo(ScreenPoint.x,ScreenPoint.y); Point = GetPoint(m_uLastDrawnPoint+1); ValueToScreen(Point.X, Point.Y, ScreenPoint); pDC->LineTo(ScreenPoint.x,ScreenPoint.y); } pDC->SelectClipRgn(NULL); pDC->SelectObject(pOldPen); DeleteObject(NewPen); } }
/* Display the submenu pointed to by the passed show: menu item. */ void ShowSubMenu (Menu_Item_Type *i) { int c; Menu_Type *m; /* find matching menu, if any */ if ((m=LookupMenu(i->command)) != NULL) { /* got match -- show it and handle input for it. */ AddWindow(m); DrawAll(); do { c=DoMenu(m,Pdmenu_Action,Handle_Ctrl_C); if ((c==QUIT_EXIT) || (c==Q_KEY_EXIT)) ExitWindow(); } while (c==0); } }
/* * Change the help text */ void ChangeHelpText (Menu_Type *m, Menu_Item_Type *i) { FILE *pcommand; char *str; if (i->command_flag) { pcommand=popen(i->command,"r"); str=pdgetline(pcommand,0); pclose(pcommand); m->helptext = str; } else { m->helptext = i->command; } DrawAll(); }
int MainWindow::CreditsLoop() { while (_mainWindow.isOpen()) { InitCredits(); while (_mainWindow.pollEvent(_event)) { if (CloseEvent()) Close(); if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num1)) return 0; } Clear(); DrawAll(); Display(); } return 0; }
unsigned char MainWindow::GameListLoop() { while (_mainWindow.isOpen()) { InitGameList(); while (_mainWindow.pollEvent(_event)) { if (CloseEvent()) Close(); if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num1)) return 1; if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num2)) return 2; if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num3)) return 3; if (_event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::Num4)) return 0; } Clear(); DrawAll(); Display(); } return 0; }
void GraphView::FilterChanged(Draw *draw) { DrawAll(); }
/* * Run a command, and display its output in a window. * If truncate==1, the output will not be wrapped. * This function is a horrible mess and I hope to do away with it one day. */ void RunShow (char *title, char *command, int truncate) { FILE *pcommand; char *realstr=NULL,*str=NULL; int i=0,j,k; /* Display wait text. */ DrawBase(_("Please wait...")); SLsmg_refresh(); /* allocate memory for the window */ menus->next=malloc(sizeof(Menu_Type)); menus->next->last=menus; menus->next->next=NULL; menus=menus->next; /* load up the menu with the appropriate values */ menus->title=malloc(strlen(title)+1); strcpy(menus->title,title); menus->helptext=malloc(128); strcpy(menus->helptext,_("Press Esc to close window.")); menus->name=malloc(1); strcpy(menus->name,""); menus->selected=0; menus->num_avail=MENU_INC; menus->items=malloc(sizeof(Menu_Item_Type *) * MENU_INC); /* Get the command output and create the menu items */ pcommand=popen(command,"r"); while ((str && strlen(str) > 0) || (str=realstr=pdgetline(pcommand,0))) { /* * If we are not truncating, we have to handle wrapping lines that contain * tabs. This adds a lot of complexity and ugliness here. :-( */ if (!truncate) { k=0; for (j=0;j<strlen(str);j++) { if (k == SLtt_Screen_Cols - 4 - 1) { /* * We have reached the end of the line before we reached the end * of the string. Copy the processed part into the menu array, * saving leftover part of string for later processing. */ if (i >= menus->num_avail) { menus->num_avail+=MENU_INC; menus->items=realloc(menus->items, sizeof(Menu_Item_Type *) * menus->num_avail); } menus->items[i]=malloc(sizeof(Menu_Item_Type)); menus->items[i]->type=MENU_EXIT; menus->items[i]->text=malloc(j+1); strncpy(menus->items[i]->text,str,j); menus->items[i]->text[j]='\0'; menus->items[i]->command=malloc(1); strcpy(menus->items[i]->command,""); menus->items[i]->hotkey=-1; menus->items[i++]->next=NULL; /* keep whittling away at the current string */ str=str+j; /* Set j=0 to indicate we shouldn't add str to the list yet. */ j=0; break; } /* Calculate length of string as it will appear on screen with tabs */ if (str[j] == '\t') { /* Figure out how many characters this tab will take up. */ k+=((j/SLsmg_Tab_Width)+1)*SLsmg_Tab_Width-j-1; } else k++; } /* If j == 0, this is a signal not to add str to the list yet. */ if (j != 0) { if (i >= menus->num_avail) { menus->num_avail+=MENU_INC; menus->items=realloc(menus->items, sizeof(Menu_Item_Type *) * menus->num_avail); } menus->items[i]=malloc(sizeof(Menu_Item_Type)); menus->items[i]->type=MENU_EXIT; menus->items[i]->text=malloc(j+1); strcpy(menus->items[i]->text,str); menus->items[i]->command=malloc(1); strcpy(menus->items[i]->command,""); menus->items[i]->hotkey=-1; menus->items[i++]->next=NULL; free(realstr); str=NULL; } } else { if (i >= menus->num_avail) { menus->num_avail+=MENU_INC; menus->items=realloc(menus->items, sizeof(Menu_Item_Type *) * menus->num_avail); } menus->items[i]=malloc(sizeof(Menu_Item_Type)); menus->items[i]->type=MENU_EXIT; menus->items[i]->text=realstr; menus->items[i]->command=malloc(1); strcpy(menus->items[i]->command,""); menus->items[i]->hotkey=-1; menus->items[i++]->next=NULL; str=NULL; } } pclose(pcommand); menus->num=i; if (i==0) { DrawBase(_("Command returned no output")); SLsmg_refresh(); RemoveMenu(menus); } else { menus->recalc=1; /* display the menu until they hit q or exit */ AddWindow(menus); DrawAll(); DoMenu(menus,NullAction,Handle_Ctrl_C); ExitWindow(); RemoveMenu(menus); } }
int AddIn_main(int isAppli, unsigned short OptionNum) { int collided = 0; unsigned char answer; Bdisp_AllClr_DDVRAM(); Init_SerialPort(); Start_SerialPort(); if(connect() == 0) { isHost = 1; } while(1) { startScreen(); memset(videoBuffer, 0, 1024); DrawBox(0, 0, 127, 63, videoBuffer, BLACK); DrawBox(48, 27, 79, 37, videoBuffer, BLACK); CoolText(51, 29, FONT_FIVE, "Ready?", videoBuffer); DrawAll(videoBuffer); Sleep(1000); SerialTransmit(READY); while(SerialReceive() != READY) { ; } reset(); while(1) { answer = SerialReceive(); if(answer == CRASH) { score++; wonLast = ME; break; } if(answer == EXIT) { Reset_Calc(); } if(answer == COORDS) { receivedX = SerialReceive(); receivedY = SerialReceive(); setBit(videoBuffer, 128, receivedX, receivedY, 1); } checkKeys(); move(); collided = getBit(videoBuffer, 128, playerX, playerY); if(collided) { otherScore++; wonLast = OTHER; SerialTransmit(CRASH); break; } setBit(videoBuffer, 128, playerX, playerY, 1); SerialTransmit(COORDS); SerialTransmit(playerX); SerialTransmit(playerY); DrawAll(videoBuffer); Sleep(delays[speed]); } } return 1; }
void CChartSurfaceSerie::Draw(CDC* pDC) { DrawAll(pDC); }
void Game::GameLoop() { sf::Texture HideHack; HideHack.loadFromFile("Tiles/Hack.png"); for(int y=0; y<24; ++y) { for(int x=0; x<32; ++x) { HideMapHack[y][x].setTexture(HideHack); HideMapHack[y][x].setPosition((float)x*32, (float)y*32); } } while(Window.isOpen()) { sf::Event Event; while(Window.pollEvent(Event)) { if((Event.type == sf::Event::Closed) || ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))) { SaveMap(PathToMap); SavePlayer(); return; } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up)) { switch(Move(NORTH)) { case 0: break; case 1: RandomEncounter(); break; case 2: Encounter(0, -1); break; } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down)) { switch(Move(SOUTH)) { case 0: break; case 1: RandomEncounter(); break; case 2: Encounter(0, 1); break; } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right)) { switch(Move(WEST)) { case 0: break; case 1: RandomEncounter(); break; case 2: Encounter(1, 0); break; } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left)) { switch(Move(EAST)) { case 0: break; case 1: RandomEncounter(); break; case 2: Encounter(-1, 0); break; } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::C)) { CharacterScreen Screen(Player, Window); Screen.MainLoop(); } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::S)) { SaveMap(PathToMap); SavePlayer(); } } Window.clear(); DrawAll(); Window.display(); } }
void startScreen() { unsigned char answer; char scoreText[4], otherScoreText[4], statusText[22], speedText[22], levelText[22]; int isReady = 0, is1Pressed = 0, is2Pressed = 0, is3Pressed = 0, isLeftPressed = 0, isRightPressed = 0; while(!isReady) { if(isHost) { if(isConnected) { strcpy(statusText, "Hosting"); } else { strcpy(statusText, "Waiting"); } } else { strcpy(statusText, "Connected"); } sprintf(scoreText, "%d", score); sprintf(otherScoreText, "%d", otherScore); sprintf(speedText, "SPEED: %d", speed + 1); sprintf(levelText, "LEVEL: %d", level + 1); memset(videoBuffer, 0, 1024); DrawBox(0, 0, 127, 63, videoBuffer, BLACK); DrawLine(0, 8, 127, 8, videoBuffer, BLACK); DrawLine(0, 16, 127, 16, videoBuffer, BLACK); DrawLine(0, 24, 127, 24, videoBuffer, BLACK); DrawLine(64, 16, 64, 24, videoBuffer, BLACK); DrawLine(0, 32, 127, 32, videoBuffer, BLACK); DrawLine(0, 40, 127, 40, videoBuffer, BLACK); CoolText(32, 1, FONT_FIVE, "MTRON by rojet601", videoBuffer); CoolText(48, 9, FONT_FIVE, statusText, videoBuffer); CoolText(27, 17, FONT_FIVE, scoreText, videoBuffer); CoolText(91, 17, FONT_FIVE, otherScoreText, videoBuffer); if(wonLast == ME) { CoolText(48, 25, FONT_FIVE, "You won", videoBuffer); } if(wonLast == OTHER) { CoolText(48, 25, FONT_FIVE, "You lost", videoBuffer); } if(isHost) { CoolText(2, 33, FONT_FIVE, speedText, videoBuffer); CoolText(65, 33, FONT_FIVE, levelText, videoBuffer); CoolText(2, 52, FONT_FIVE, "[1]-[3] SPEED", videoBuffer); CoolText(65, 52, FONT_FIVE, " LEVEL", videoBuffer); DrawLine(65, 55, 71, 55, videoBuffer, BLACK); DrawLine(66, 55, 68, 53, videoBuffer, BLACK); DrawLine(66, 55, 68, 57, videoBuffer, BLACK); DrawLine(73, 55, 79, 55, videoBuffer, BLACK); DrawLine(79, 55, 77, 53, videoBuffer, BLACK); DrawLine(79, 55, 77, 57, videoBuffer, BLACK); if(isConnected) { CoolText(2, 43, FONT_FIVE, "[SHIFT] START", videoBuffer); } } else { CoolText(2, 43, FONT_FIVE, "Only the host can change", videoBuffer); CoolText(2, 52, FONT_FIVE, "the settings", videoBuffer); } DrawAll(videoBuffer); if(IsKeyDown(KEY_CTRL_EXIT) || IsKeyDown(KEY_CTRL_MENU)) { SerialTransmit(EXIT); Stop_SerialPort(); Reset_Calc(); } answer = SerialReceive(); if(answer == EXIT) { Stop_SerialPort(); Reset_Calc(); } if(answer == START) { Sleep(50); speed = SerialReceive(); level = SerialReceive(); isReady = 1; } if(isHost) { if(!isConnected) { if(answer == HELLO_HOST) { SerialTransmit(HELLO_CLIENT); isConnected = 1; } } else { if(IsKeyDown(KEY_CTRL_SHIFT)) { SerialTransmit(START); SerialTransmit(speed); SerialTransmit(level); Sleep(50); isReady = 1; } } if(!IsKeyDown(KEY_CHAR_1)) { is1Pressed = 0; } if(IsKeyDown(KEY_CHAR_1) && !is1Pressed) { is1Pressed = 1; speed = 0; } if(!IsKeyDown(KEY_CHAR_2)) { is2Pressed = 0; } if(IsKeyDown(KEY_CHAR_2) && !is2Pressed) { is2Pressed = 1; speed = 1; } if(!IsKeyDown(KEY_CHAR_3)) { is3Pressed = 0; } if(IsKeyDown(KEY_CHAR_3) && !is3Pressed) { is3Pressed = 1; speed = 2; } if(!IsKeyDown(KEY_CTRL_LEFT)) { isLeftPressed = 0; } if(IsKeyDown(KEY_CTRL_LEFT) && !isLeftPressed) { isLeftPressed = 1; level--; if(level == 255) { level = levels - 1; } } if(!IsKeyDown(KEY_CTRL_RIGHT)) { isRightPressed = 0; } if(IsKeyDown(KEY_CTRL_RIGHT) && !isRightPressed) { isRightPressed = 1; level++; if(level > levels - 1) { level = 0; } } } } }
void GraphView::DrawInfoChanged(Draw *draw) { DrawAll(); }
void GraphView::PeriodChanged(Draw *draw, PeriodType period) { DrawAll(); }
void GraphView::ScreenMoved(Draw *draw, const wxDateTime& time) { DrawAll(); m_graphs->Refresh(); }
void GraphView::Refresh() { DrawAll(); }
/* * Run a command from the menus. */ void RunCommand (Menu_Item_Type *i) { char *command; int must_redraw=0; Conditional_String *cs=NULL; Window_List_Type *this_window=CurrentWindow; if (i->command[0] != '\0') { /* don't try to run a null command */ if (i->edit_flag) { /* edit command on fly */ cs=EditTags(i->command); if (cs->ignore) { /* user hit escape */ free(cs->value); free(cs); return; } else { /* user hit enter */ command=malloc(strlen(cs->value)+1); strcpy(command,cs->value); free(cs->value); free(cs); } } else { /* don't edit command on fly */ command=malloc(strlen(i->command)+1); strcpy(command,i->command); } #ifdef SETENV_FLAG_OK if (i->setenv_flag) { /* a setenv command */ RunSetenv(command); } else #endif if (i->makemenu_flag) { /* process command output as rc file */ ReadRc(command,RC_PREPROC); SanityCheckMenus(); /* * make sure that all modified menus currently on screen * get recalced. */ while (this_window) { if (this_window->menu->recalc) { CalcMenu(this_window->menu); must_redraw=1; } this_window=this_window->last; } if (must_redraw) DrawAll(); } else if (i->truncate_flag) { /* display in a window and truncate */ RunShow(i->text,command,1); } else if (i->display_flag) { /* display in a window and wrap. */ RunShow(i->text,command,0); } else { /* normal display */ if (! i->noclear_flag) { /* clear screen */ SLsmg_cls(); SLsmg_normal_video(); Screen_Reset(); #ifdef GPM_SUPPORT EndMouse(); /* return to normal GPM/selection mode */ #endif } /* * This is what the whole pdmenu program comes down to. * The rest is fluff. ;-) */ /* * start: Steve Blott ([email protected]) * * add capability to exec() (rather than system()) a command, thereby * replacing the current process; if the first word of command is * "exec", then exec() it, otherwise system() it */ char *cp = command; while (isspace(cp[0])) cp++; if ( strncmp(cp, "exec", 4) == 0 && isspace(cp[4]) ) { char *cv[4]; /* command vector */ cv[0] = "sh"; cv[1] = "-c"; cv[2] = cp; cv[3] = 0; execvp(cv[0],cv); /* should not reach here; if the execvp fails, then pdmenu will * continue to run, silently ignoring the failure; if the execvp * succeeds but the subsequent exec fails, then pdmenu will silently * disappear (its process no longer exists), and no feedback will be * received */ } else system(command); if (! i->noclear_flag) { /* redraw screen */ Screen_Init(); if (i->pause_flag) { /* pause 1st */ printf("\n%s",_("Press Enter to return to Pdmenu.")); fflush(stdout); /* make sure above is displayed. */ /* Now wait for the keypress. */ while (1) { int k; k = SLang_getkey(); if (k == '\n' || k == '\r') { break; } } SLang_flush_input(); /* kill any buffered input */ printf("\n"); } #ifdef GPM_SUPPORT gpm_ok=InitMouse(); /* grab mouse pointer again. */ #endif /* * we need to account for the screen size changing behind our backs * while the program was running. */ SetScreensize(); Resize_Screen(); DrawAll(); } } free(command); } }