bool VpeMain::execute( const WString& cmd ) { if( _config->debug() && !confirm( "Starting '%s'", cmd ) ) { return( false ); } startWait(); size_t icount = strlen( cmd ); for( size_t i = 0; i < icount; ) { WString cbuff; while( isspace( cmd[i] ) ) i++; for( ; i < icount; ) { char ch = cmd[i]; i++; if( ch == '\n' || ch == '\r' ) break; cbuff.concat( ch ); } if( cbuff.size() > 0 ) { if( strnicmp( cbuff, "!Error ", 7 ) == 0 ) { WString msg; for( size_t i = 7; i < cbuff.size() && cbuff[i] != '$'; i++ ) { msg.concat( cbuff[i] ); } WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, msg ); return( false ); } else { if( !executeOne( cbuff ) ) { return( false ); } } } } return( true ); }
bool VpeMain::reallyClose() { WRect rect; show( WWinStateShowNormal ); if( _quitAnyways || okToQuit() ) { startWait(); clearProject(); stopWait(); // write out .INI file stuff char buff[_MAX_PATH]; _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (char*)_editor.gets() ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL, _editorIsDll ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, _editorParms.gets() ); for( int i=0; i<_oldProjects.count(); i++ ) { itoa( i+1, buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, buff, (const char*)*((WFileName*)_oldProjects[i]) ); } _ini.write( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, _toolBarActive ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_STATWND, (_statusBar != NULL) ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_AUTOREFRESH, _autoRefresh ? "1" : "0" ); getRectangle( rect ); itoa( rect.w(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, buff ); itoa( rect.h(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, buff ); itoa( rect.x(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_X, buff ); itoa( rect.y(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_Y, buff ); if( _otherhelp != NULL ) { delete _otherhelp; _otherhelp = NULL; } delete _help; _help = NULL; return( true ); } return( false ); }
bool VpeMain::executeCommand( const char *cmdl, int location, const char* title ) { int i; if( cmdl != NULL && strlen( cmdl ) > 0 ) { WString* cur = NULL; WStringList opts; for( i=0; cmdl[i]!= '\0'; i++ ) { if( cur ) { if( cmdl[i] == '"' ) { opts.add( cur ); cur = NULL; } else { cur->concat( cmdl[i] ); } } else if( cmdl[i] == '$' && cmdl[i+1] == '"' ) { i++; cur = new WString(); } } delete cur; cur = NULL; WStringList reps; if( opts.count() > 0 ) { WString dTitle( title ); if( dTitle.size() == 0 ) dTitle = "AutoDialog"; WAutoDialog prompts( this, dTitle, opts ); if( !prompts.getInput( reps ) ) { setStatus( NULL ); return( false ); } } WString cmd; int j = 0; for( i=0; cmdl[i]!= '\0'; i++ ) { if( !cur ) { if( cmdl[i] == '$' && cmdl[i+1] == '"' ) { i++; cur = &reps.stringAt( j ); j++; } else { cmd.concat( cmdl[i] ); } } else if( cmdl[i] == '"' ) { cmd.concat( *cur ); cur = NULL; } } startWait(); switch( location ) { case EXECUTE_NORMAL: { setStatus( "Executing..." ); execute( cmd ); break; } case EXECUTE_BATCH: { runBatch( cmd ); break; } case EXECUTE_MAKE: { if( makeMake() ) { runBatch( cmd ); } break; } case EXECUTE_BROWSE: { executeBrowse( cmd ); break; } case EXECUTE_EDITOR: { executeEditor( cmd ); break; } case EXECUTE_TOUCH_ALL: { MsgRetType rc; unsigned i; VComponent *comp; rc = WMessageDialog::messagef( this, MsgQuestion, MsgYesNo, _viperRequest, "Do you really want to remake all targets and their components?" ); if( rc == MsgRetYes ) { i = _compViews.count(); while( i > 0 ) { comp = (VComponent *)_compViews[i-1]; comp->touchComponent( true ); i--; } } break; } case EXECUTE_HELP: { if( _otherhelp == NULL ) { delete _otherhelp; } _otherhelp = new WSystemHelp( this, "", cmd ); _otherhelp->sysHelpContent(); break; } } stopWait(); setStatus( NULL ); if( _quitAnyways ) { exit( NULL ); } } return( true ); }
/* ARGSUSED */ void SetCommand(Widget w, ResCommand command, char *msg) { XClientMessageEvent client_event; Display *dpy = XtDisplay(w); if (msg == NULL) { /* "Click the mouse pointer on any toolkit client" */ msg = res_labels[6]; } SetMessage(global_screen_data.info_label, msg, "Click the mouse pointer on any toolkit client"); if (global_client.window == None) { if ( (global_client.window = GetClientWindow(w, NULL, NULL)) == None ) { return; } } /* printf("[SetCommand] global_client.window: %d 0x%x\n", */ /* global_client.window, */ /* global_client.window); */ global_client.ident = GetNewIdent(); global_client.command = command; global_client.atom = atom_comm; BuildHeader(&(global_client)); if (!XtOwnSelection(w, global_client.atom, CurrentTime, ConvertCommand, LoseSelection, SelectionDone)) { /* "Unable to own the Resource/Attribute Selection" */ SetMessage(global_screen_data.info_label, res_labels[7], "Unable to own the Resource/Attribute Selection"); } client_event.window = global_client.window; client_event.type = ClientMessage; client_event.message_type = atom_resource_editor; client_event.format = EDITRES_SEND_EVENT_FORMAT; client_event.data.l[0] = XtLastTimestampProcessed(dpy); client_event.data.l[1] = global_client.atom; client_event.data.l[2] = (long) global_client.ident; client_event.data.l[3] = global_effective_protocol_version; global_error_code = NO_ERROR; /* Reset Error code. */ global_old_error_handler = XSetErrorHandler(HandleXErrors); global_serial_num = NextRequest(dpy); XSendEvent(dpy, global_client.window, FALSE, (long)0, (XEvent*)&client_event); XSync(dpy, FALSE); XSetErrorHandler(global_old_error_handler); if (global_error_code == NO_WINDOW) { char error_buf[BUFSIZ]; global_error_code = NO_ERROR; /* Reset Error code. */ sprintf(error_buf, "The communication window with%s%s.", " application is no longer available\n", "Please select a new widget tree"); global_client.window = None; SetCommand(w, LocalSendWidgetTree, error_buf); return; } TellUserAboutMessage(global_screen_data.info_label, command); global_client.timeout = XtAppAddTimeOut(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT, ClientTimedOut, (XtPointer)w); startWait(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT / 1000); } /* SetCommand() */