HRESULT ezUwpApplication::OnActivated(ICoreApplicationView* view, IActivatedEventArgs* args) { view->remove_Activated(m_activateRegistrationToken); ActivationKind activationKind; EZ_SUCCEED_OR_RETURN(args->get_Kind(&activationKind)); if (activationKind == ActivationKind_Launch) { ComPtr<ILaunchActivatedEventArgs> launchArgs; EZ_SUCCEED_OR_RETURN(args->QueryInterface(launchArgs.GetAddressOf())); HString argHString; EZ_SUCCEED_OR_RETURN(launchArgs->get_Arguments(argHString.GetAddressOf())); ezDynamicArray<const char*> argv; ezCommandLineUtils::SplitCommandLineString(ezStringUtf8(argHString).GetData(), true, m_commandLineArgs, argv); m_application->SetCommandLineArguments(argv.GetCount(), argv.GetData()); } // Activate main window together with the application! ComPtr<ABI::Windows::UI::Core::ICoreWindow> pCoreWindow; EZ_SUCCEED_OR_RETURN(view->get_CoreWindow(pCoreWindow.GetAddressOf())); EZ_SUCCEED_OR_RETURN(pCoreWindow->Activate()); return S_OK; }
void ezConsole::AddInputCharacter(ezUInt32 uiChar) { if (uiChar == '\0') return; if (!ProcessInputCharacter(uiChar)) return; if (!FilterInputCharacter(uiChar)) return; ClampCaretPosition(); auto it = m_sInputLine.GetIteratorFront(); it += m_iCaretPosition; ezUInt32 uiString[2] = { uiChar, 0 }; m_sInputLine.Insert(it.GetData(), ezStringUtf8(uiString).GetData()); MoveCaret(1); }
void ezCommandLineUtils::SplitCommandLineString(const char* commandString, bool addExecutableDir, ezDynamicArray<ezString>& outArgs, ezDynamicArray<const char*>& outArgsV) { // Add application dir as first argument as customary on other platforms. if (addExecutableDir) { #if EZ_ENABLED(EZ_PLATFORM_WINDOWS) wchar_t moduleFilename[256]; GetModuleFileNameW(nullptr, moduleFilename, 256); outArgs.PushBack(ezStringUtf8(moduleFilename).GetData()); #else EZ_ASSERT_NOT_IMPLEMENTED; #endif } // Simple args splitting. Not as powerful as Win32's CommandLineToArgvW. const char* currentChar = commandString; const char* lastEnd = currentChar; bool inQuotes = false; while (*currentChar != '\0') { if (*currentChar == '\"') inQuotes = !inQuotes; else if (*currentChar == ' ' && !inQuotes) { ezStringBuilder path = ezStringView(lastEnd, currentChar); path.Trim(" \""); outArgs.PushBack(path); lastEnd = currentChar + 1; } ezUnicodeUtils::MoveToNextUtf8(currentChar); } outArgsV.Reserve(outArgsV.GetCount()); for (ezString& str : outArgs) outArgsV.PushBack(str.GetData()); }