Example #1
0
int main()
{
	TEvent init;
	init.what = evCommand;
	init.message.command = cmAbout;     // make a cmAbout command event

	Shell shell;
	shell.putEvent(init);               // put it in the queue to pop up
	shell.run();                        // About box when program starts
	return 0;
}
Example #2
0
int main() {
	Shell s;
	s->run();
	return 0;
}
Example #3
0
int App::run()
{
  // Initialize GUI interface
  if (isGui()) {
    PRINTF("GUI mode\n");

    // Setup the GUI screen
    jmouse_set_cursor(kArrowCursor);
    ui::Manager::getDefault()->invalidate();

    // Create the main window and show it.
    m_mainWindow.reset(new MainWindow);

    // Default status of the main window.
    app_rebuild_documents_tabs();
    app_default_statusbar_message();

    m_mainWindow->openWindow();

    // Redraw the whole screen.
    ui::Manager::getDefault()->invalidate();
  }

  // Set background mode for non-GUI modes
  set_display_switch_mode(SWITCH_BACKGROUND);

  // Procress options
  PRINTF("Processing options...\n");

  {
    Console console;
    for (FileList::iterator
           it  = m_files.begin(),
           end = m_files.end();
         it != end; ++it) {
      // Load the sprite
      Document* document = load_document(it->c_str());
      if (!document) {
        if (!isGui())
          console.printf("Error loading file \"%s\"\n", it->c_str());
      }
      else {
        // Mount and select the sprite
        UIContext* context = UIContext::instance();
        context->addDocument(document);

        if (isGui()) {
          // Recent file
          getRecentFiles()->addRecentFile(it->c_str());
        }
      }
    }
  }

  // Run the GUI
  if (isGui()) {
    // Support to drop files from Windows explorer
    install_drop_files();

#ifdef ENABLE_UPDATER
    // Launch the thread to check for updates.
    app::CheckUpdateThreadLauncher checkUpdate;
    checkUpdate.launch();
#endif

#ifdef ENABLE_WEBSERVER
    // Launch the webserver.
    app::WebServer webServer;
    webServer.start();
#endif

    // Run the GUI main message loop
    gui_run();

    // Uninstall support to drop files
    uninstall_drop_files();

    // Destroy all documents in the UIContext.
    const Documents& docs = m_modules->m_ui_context.getDocuments();
    while (!docs.empty())
      m_modules->m_ui_context.removeDocument(docs.back());

    // Destroy the window.
    m_mainWindow.reset(NULL);
  }
  // Start shell to execute scripts.
  else if (m_isShell) {
    m_systemConsole.prepareShell();

    if (m_modules->m_scriptingEngine.supportEval()) {
      Shell shell;
      shell.run(m_modules->m_scriptingEngine);
    }
    else {
      std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
    }
  }

  return 0;
}
Example #4
0
int App::run()
{
  UIContext* context = UIContext::instance();

  // Initialize GUI interface
  if (isGui()) {
    PRINTF("GUI mode\n");

    // Setup the GUI cursor and redraw screen

    ui::set_use_native_cursors(
      context->settings()->experimental()->useNativeCursor());

    jmouse_set_cursor(kArrowCursor);

    ui::Manager::getDefault()->invalidate();

    // Create the main window and show it.
    m_mainWindow.reset(new MainWindow);

    // Default status of the main window.
    app_rebuild_documents_tabs();
    app_default_statusbar_message();

    // Default window title bar.
    updateDisplayTitleBar();
    
    m_mainWindow->openWindow();

    // Redraw the whole screen.
    ui::Manager::getDefault()->invalidate();
  }

  // Procress options
  PRINTF("Processing options...\n");

  {
    Console console;
    for (const std::string& filename : m_files) {
      // Load the sprite
      Document* document = load_document(context, filename.c_str());
      if (!document) {
        if (!isGui())
          console.printf("Error loading file \"%s\"\n", filename.c_str());
      }
      else {
        // Add the given file in the argument as a "recent file" only
        // if we are running in GUI mode. If the program is executed
        // in batch mode this is not desirable.
        if (isGui())
          getRecentFiles()->addRecentFile(filename.c_str());

        // Add the document to the exporter.
        if (m_exporter != NULL)
          m_exporter->addDocument(document);
      }
    }
  }

  // Export
  if (m_exporter != NULL) {
    PRINTF("Exporting sheet...\n");

    m_exporter->exportSheet();
    m_exporter.reset(NULL);
  }

  // Run the GUI
  if (isGui()) {
#ifdef ENABLE_UPDATER
    // Launch the thread to check for updates.
    app::CheckUpdateThreadLauncher checkUpdate;
    checkUpdate.launch();
#endif

#ifdef ENABLE_WEBSERVER
    // Launch the webserver.
    app::WebServer webServer;
    webServer.start();
#endif

    app::SendCrash sendCrash;
    sendCrash.search();

    // Run the GUI main message loop
    gui_run();

    // Destroy all documents in the UIContext.
    const doc::Documents& docs = m_modules->m_ui_context.documents();
    while (!docs.empty()) {
      doc::Document* doc = docs.back();

      // First we close the document. In this way we receive recent
      // notifications related to the document as an app::Document. If
      // we delete the document directly, we destroy the app::Document
      // too early, and then doc::~Document() call
      // DocumentsObserver::onRemoveDocument(). In this way, observers
      // could think that they have a fully created app::Document when
      // in reality it's a doc::Document (in the middle of a
      // destruction process).
      //
      // TODO: This problem is because we're extending doc::Document,
      // in the future, we should remove app::Document.
      doc->close();
      delete doc;
    }

    // Destroy the window.
    m_mainWindow.reset(NULL);
  }
  // Start shell to execute scripts.
  else if (m_isShell) {
    m_systemConsole.prepareShell();

    if (m_modules->m_scriptingEngine.supportEval()) {
      Shell shell;
      shell.run(m_modules->m_scriptingEngine);
    }
    else {
      std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
    }
  }

  return 0;
}
Example #5
0
int main(int argc, char **argv)
{
    Shell sh;
    FILE *fp;
    struct stat st;
    char *contents;

    /* Verify command-line arguments. */
    if (argc >= 2)
    {
	/* Execute commands in each file. */
	for (int i = 0; i < argc - 1; i++)
	{
	    /* Query the file size. */
	    if (stat(argv[i + 1], &st) != 0)
	    {
		printf("%s: failed to stat() `%s': %s\r\n",
			argv[0], argv[i + 1], strerror(errno));
		continue;
	    }
	    /* Open file. */
	    if ((fp = fopen(argv[i + 1], "r")) == NULL)
	    {
		printf("%s: failed to fopen() `%s': %s\r\n",
			argv[0], argv[i + 1], strerror(errno));
		continue;
	    }
	    /* Allocate buffer storage. */
	    contents = new char[st.st_size];
	    
	    /* Read the entire file into memory. */
	    if (fread(contents, st.st_size, 1, fp) != (size_t) st.st_size)
	    {
		printf("%s: failed to fread() `%s': %s\r\n",
			argv[0], argv[i + 1], strerror(errno));
		fclose(fp);
		continue;
	    }
	    /* Parse it into lines. */
	    List<String> lines = String(contents).split('\n');
	    
	    /* Execute each command. */
	    for (ListIterator<String> i(lines); i.hasCurrent(); i++)
	    {
		sh.executeInput((char *) *i.current());
	    }
	    /* Cleanup. */
	    delete contents;
	    fclose(fp);
	}
    }
    /* Run an interactive Shell. */
    else
    {
        /* Show the user where to get help. */
        printf( "\r\n"
                "Entering interactive Shell. Type 'help' for the command list.\r\n"
                "\r\n");

        /* Begin loop. */
        return sh.run();
    }
    /* Success. */
    return EXIT_SUCCESS;
}
Example #6
0
int App::run()
{
  // Initialize GUI interface
  if (isGui()) {
    PRINTF("GUI mode\n");

    // Setup the GUI screen
    jmouse_set_cursor(kArrowCursor);
    ui::Manager::getDefault()->invalidate();

    // Create the main window and show it.
    m_mainWindow.reset(new MainWindow);

    // Default status of the main window.
    app_rebuild_documents_tabs();
    app_default_statusbar_message();

    m_mainWindow->openWindow();

    // Redraw the whole screen.
    ui::Manager::getDefault()->invalidate();

    // 2013-11-19 - JRM - Force setting active view to NULL, workaround for setting 
    // window title to proper devault value. (Issue #285)
    UIContext::instance()->setActiveView(NULL);
  }

  // Set background mode for non-GUI modes
  set_display_switch_mode(SWITCH_BACKGROUND);

  // Procress options
  PRINTF("Processing options...\n");

  {
    UIContext* context = UIContext::instance();
    Console console;
    for (FileList::iterator
           it  = m_files.begin(),
           end = m_files.end();
         it != end; ++it) {
      // Load the sprite
      Document* document = load_document(it->c_str());
      if (!document) {
        if (!isGui())
          console.printf("Error loading file \"%s\"\n", it->c_str());
      }
      else {
        // Mount and select the sprite
        context->addDocument(document);

        // Add the given file in the argument as a "recent file" only
        // if we are running in GUI mode. If the program is executed
        // in batch mode this is not desirable.
        if (isGui())
          getRecentFiles()->addRecentFile(it->c_str());

        // Add the document to the exporter.
        if (m_exporter != NULL)
          m_exporter->addDocument(document);
      }
    }
  }

  // Export
  if (m_exporter != NULL) {
    PRINTF("Exporting sheet...\n");

    m_exporter->exportSheet();
    m_exporter.reset(NULL);
  }

  // Run the GUI
  if (isGui()) {
#ifdef ENABLE_UPDATER
    // Launch the thread to check for updates.
    app::CheckUpdateThreadLauncher checkUpdate;
    checkUpdate.launch();
#endif

#ifdef ENABLE_WEBSERVER
    // Launch the webserver.
    app::WebServer webServer;
    webServer.start();
#endif

    // Run the GUI main message loop
    gui_run();

    // Destroy all documents in the UIContext.
    const Documents& docs = m_modules->m_ui_context.getDocuments();
    while (!docs.empty())
      m_modules->m_ui_context.removeDocument(docs.back());

    // Destroy the window.
    m_mainWindow.reset(NULL);
  }
  // Start shell to execute scripts.
  else if (m_isShell) {
    m_systemConsole.prepareShell();

    if (m_modules->m_scriptingEngine.supportEval()) {
      Shell shell;
      shell.run(m_modules->m_scriptingEngine);
    }
    else {
      std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
    }
  }

  return 0;
}