mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 00:28:34 +03:00
Minor changes in terminal.
Fixed Sys::parseArguments for emscripten.
This commit is contained in:
+1
-1
@@ -558,7 +558,7 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
end
|
||||
|
||||
if os.is_real("emscripten") then
|
||||
linkoptions{ "--profiling --profiling-funcs -s DEMANGLE_SUPPORT=1" }
|
||||
linkoptions{ "--profiling --profiling-funcs -s DEMANGLE_SUPPORT=1 -s NO_DISABLE_EXCEPTION_CATCHING" }
|
||||
end
|
||||
|
||||
fix_shared_lib_linking_path( package_name, "libeepp-debug" )
|
||||
|
||||
@@ -888,7 +888,6 @@ std::vector<std::string> Sys::parseArguments( int argc, char* argv[] ) {
|
||||
if ( argc < 1 )
|
||||
return {};
|
||||
std::vector<std::string> args;
|
||||
args.emplace_back( argv[0] );
|
||||
for ( int i = 1; i < argc; i++ ) {
|
||||
auto split = String::split( std::string( argv[i] ), '=' );
|
||||
if ( split.size() == 2 ) {
|
||||
|
||||
@@ -152,7 +152,7 @@ class TerminalDisplay : public ITerminalDisplay {
|
||||
|
||||
static std::shared_ptr<TerminalDisplay>
|
||||
create( EE::Window::Window* window, Font* font, const Float& fontSize, const Sizef& pixelsSize,
|
||||
std::string program = "", const std::vector<std::string>& args = {},
|
||||
std::string program = "", std::vector<std::string> args = {},
|
||||
const std::string& workingDir = "", const size_t& historySize = 10000,
|
||||
IProcessFactory* processFactory = nullptr, const bool& useFrameBuffer = false,
|
||||
const bool& keepAlive = true );
|
||||
|
||||
@@ -387,14 +387,14 @@ static Sizei gridSizeFromTermDimensions( Font* font, const Float& fontSize,
|
||||
std::shared_ptr<TerminalDisplay>
|
||||
TerminalDisplay::create( EE::Window::Window* window, Font* font, const Float& fontSize,
|
||||
const Sizef& pixelsSize, std::string program,
|
||||
const std::vector<std::string>& args, const std::string& workingDir,
|
||||
std::vector<std::string> args, const std::string& workingDir,
|
||||
const size_t& historySize, IProcessFactory* processFactory,
|
||||
const bool& useFrameBuffer, const bool& keepAlive ) {
|
||||
if ( program.empty() ) {
|
||||
#ifdef _WIN32
|
||||
program = "cmd.exe";
|
||||
#else
|
||||
const char* shellenv = getenv( "SHELL" );
|
||||
#ifdef _WIN32
|
||||
program = shellenv != nullptr ? shellenv : "cmd.exe";
|
||||
#else
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID
|
||||
program = shellenv != nullptr ? shellenv : "/bin/sh";
|
||||
#else
|
||||
@@ -404,15 +404,23 @@ TerminalDisplay::create( EE::Window::Window* window, Font* font, const Float& fo
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( program.find_first_of( ' ' ) != std::string::npos ) {
|
||||
auto programSplit = String::split( program, ' ' );
|
||||
if ( !programSplit.empty() ) {
|
||||
program = programSplit[0];
|
||||
for ( size_t i = 1; i < programSplit.size(); ++i )
|
||||
args.push_back( programSplit[i] );
|
||||
}
|
||||
}
|
||||
|
||||
bool freeProcessFactory = processFactory == nullptr;
|
||||
if ( processFactory == nullptr )
|
||||
processFactory = eeNew( ProcessFactory, () );
|
||||
|
||||
Sizei termSize( gridSizeFromTermDimensions( font, fontSize, pixelsSize ) );
|
||||
std::unique_ptr<IPseudoTerminal> pseudoTerminal = nullptr;
|
||||
std::vector<std::string> argsV( args.begin(), args.end() );
|
||||
auto process = processFactory->createWithPseudoTerminal(
|
||||
program, argsV, workingDir, termSize.getWidth(), termSize.getHeight(), pseudoTerminal );
|
||||
program, args, workingDir, termSize.getWidth(), termSize.getHeight(), pseudoTerminal );
|
||||
|
||||
if ( !pseudoTerminal ) {
|
||||
fprintf( stderr, "Failed to create pseudo terminal\n" );
|
||||
|
||||
@@ -131,6 +131,8 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
args::HelpFlag help( parser, "help", "Display this help menu", { 'h', "help" } );
|
||||
args::ValueFlag<std::string> shell( parser, "shell", "Shell name or path", { 's', "shell" },
|
||||
"" );
|
||||
args::ValueFlag<std::string> shellArgs( parser, "shell-args", "Shell command line arguments",
|
||||
{ "shell-args" }, "" );
|
||||
args::ValueFlag<size_t> historySize( parser, "scrollback", "Maximum history size (lines)",
|
||||
{ 'l', "scrollback" }, 10000 );
|
||||
args::Flag fb( parser, "framebuffer", "Use frame buffer (more memory usage, less CPU usage)",
|
||||
@@ -261,7 +263,8 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
FileInfo file( wd ? wd.Get() : FileSystem::getCurrentWorkingDirectory() );
|
||||
terminal = TerminalDisplay::create(
|
||||
win, fontMono, PixelDensity::dpToPx( fontSize.Get() ), win->getSize().asFloat(),
|
||||
file.isRegularFile() && file.isExecutable() ? file.getFilepath() : shell.Get(), {},
|
||||
file.isRegularFile() && file.isExecutable() ? file.getFilepath() : shell.Get(),
|
||||
shellArgs ? String::split( shellArgs.Get() ) : std::vector<std::string>(),
|
||||
file.getDirectoryPath(), historySize.Get(), nullptr, fb.Get(),
|
||||
!( file.isRegularFile() && file.isExecutable() ) );
|
||||
terminal->getTerminal()->setAllowMemoryTrimnming( true );
|
||||
@@ -274,6 +277,8 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
win->close();
|
||||
}
|
||||
} );
|
||||
if ( shell )
|
||||
terminal->setKeepAlive( false );
|
||||
|
||||
if ( colorScheme ) {
|
||||
auto selColorScheme = terminalColorSchemes.find( colorScheme.Get() );
|
||||
|
||||
@@ -859,8 +859,7 @@ bool App::onCloseRequestCallback( EE::Window::Window* ) {
|
||||
UIMessageBox::OK_CANCEL,
|
||||
"Do you really want to close the current file?\nAll changes will be lost." );
|
||||
mMsgBox->setTheme( mTheme );
|
||||
mMsgBox->addEventListener( Event::OnConfirm,
|
||||
[&]( const Event* ) { mWindow->close(); } );
|
||||
mMsgBox->addEventListener( Event::OnConfirm, [&]( const Event* ) { mWindow->close(); } );
|
||||
mMsgBox->addEventListener( Event::OnClose, [&]( const Event* ) { mMsgBox = NULL; } );
|
||||
mMsgBox->setTitle( "Close Editor?" );
|
||||
mMsgBox->center();
|
||||
|
||||
Reference in New Issue
Block a user