diff --git a/src/eepp/window/backend/SDL2/inputsdl2.cpp b/src/eepp/window/backend/SDL2/inputsdl2.cpp index 806cf331e..2b2c6bb9b 100644 --- a/src/eepp/window/backend/SDL2/inputsdl2.cpp +++ b/src/eepp/window/backend/SDL2/inputsdl2.cpp @@ -52,18 +52,18 @@ void InputSDL::waitEvent( const Time& timeout ) { } bool InputSDL::grabInput() { - return ( SDL_GetWindowGrab( static_cast( mWindow )->GetSDLWindow() ) == SDL_TRUE ) + return ( SDL_GetWindowGrab( static_cast( mWindow )->getSDLWindow() ) == SDL_TRUE ) ? true : false; } void InputSDL::grabInput( const bool& Grab ) { - SDL_SetWindowGrab( static_cast( mWindow )->GetSDLWindow(), + SDL_SetWindowGrab( static_cast( mWindow )->getSDLWindow(), Grab ? SDL_TRUE : SDL_FALSE ); } void InputSDL::injectMousePos( const Uint16& x, const Uint16& y ) { - SDL_WarpMouseInWindow( reinterpret_cast( mWindow )->GetSDLWindow(), x, y ); + SDL_WarpMouseInWindow( reinterpret_cast( mWindow )->getSDLWindow(), x, y ); } Vector2i InputSDL::queryMousePos() { @@ -71,7 +71,7 @@ Vector2i InputSDL::queryMousePos() { Vector2i tempMouse; Vector2i tempWinPos; Rect bordersSize; - SDL_Window* sdlw = reinterpret_cast( mWindow )->GetSDLWindow(); + SDL_Window* sdlw = reinterpret_cast( mWindow )->getSDLWindow(); SDL_GetGlobalMouseState( &tempMouse.x, &tempMouse.y ); SDL_GetWindowPosition( sdlw, &tempWinPos.x, &tempWinPos.y ); // Since an unknown version the window position includes the margin from the border size. @@ -88,7 +88,7 @@ void InputSDL::captureMouse( const bool& capture ) { } bool InputSDL::isMouseCaptured() const { - return SDL_GetWindowFlags( reinterpret_cast( mWindow )->GetSDLWindow() ) & + return SDL_GetWindowFlags( reinterpret_cast( mWindow )->getSDLWindow() ) & SDL_WINDOW_MOUSE_CAPTURE; } diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 7a80efbe5..c57b94f24 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -861,7 +861,7 @@ bool WindowSDL::showMessageBox( const MessageBoxType& type, const std::string& t mSDLWindow ); } -SDL_Window* WindowSDL::GetSDLWindow() const { +SDL_Window* WindowSDL::getSDLWindow() const { return mSDLWindow; } diff --git a/src/eepp/window/backend/SDL2/windowsdl2.hpp b/src/eepp/window/backend/SDL2/windowsdl2.hpp index 5eaf034bc..be4b1e754 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.hpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.hpp @@ -86,7 +86,7 @@ class EE_API WindowSDL : public Window { virtual bool showMessageBox( const MessageBoxType& type, const std::string& title, const std::string& message ); - SDL_Window* GetSDLWindow() const; + SDL_Window* getSDLWindow() const; void startOnScreenKeyboard(); diff --git a/src/examples/7guis/cells/spreadsheet.cpp b/src/examples/7guis/cells/spreadsheet.cpp index b28224b12..692e3e32e 100644 --- a/src/examples/7guis/cells/spreadsheet.cpp +++ b/src/examples/7guis/cells/spreadsheet.cpp @@ -45,7 +45,7 @@ void Cell::setData( std::string&& data ) { calc(); bool circular = !subscribeToObservers(); if ( circular ) { - displayValue = "!CIRCULAR"; + displayValue = "#REF!"; formulaContainsErrors = true; } else { setChanged(); @@ -72,7 +72,7 @@ void Cell::calc() { auto oldDisplayValue = displayValue; if ( !hasFormula() && !value.empty() && value[0] == '=' ) { - displayValue = "!ERR"; + displayValue = "#ERR!"; formulaContainsErrors = true; return; } else if ( !hasFormula() ) { @@ -85,7 +85,7 @@ void Cell::calc() { if ( res ) displayValue = String::fromDouble( *res ); else - displayValue = "!ERR"; + displayValue = "#ERR!"; formulaContainsErrors = res ? false : true; diff --git a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp index 607b47b5e..0d22ead64 100644 --- a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp +++ b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp @@ -1385,7 +1385,7 @@ void TerminalDisplay::drawGrid( const Vector2f& pos ) { } void TerminalDisplay::draw( const Vector2f& pos ) { - if ( !mEmulator ) + if ( !mEmulator || !mTerminal ) return; mDrawing = true; diff --git a/src/tools/eterm/eterm.cpp b/src/tools/eterm/eterm.cpp index f36264ec8..29ed63186 100644 --- a/src/tools/eterm/eterm.cpp +++ b/src/tools/eterm/eterm.cpp @@ -98,30 +98,6 @@ void inputCallback( InputEvent* event ) { } } -void mainLoop() { - bool termNeedsUpdate = false; - win->getInput()->update(); - - if ( terminal ) - termNeedsUpdate = !terminal->update(); - - if ( terminal && ( benchmarkMode || terminal->isDirty() ) && - ( !termNeedsUpdate || lastRender.getElapsedTime() >= frameTime ) ) { - lastRender.restart(); - win->clear(); - terminal->draw(); - win->display(); - } else if ( !benchmarkMode && !termNeedsUpdate ) { - win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) ); - } - - if ( benchmarkMode && secondsCounter.getElapsedTime() >= Seconds( 1 ) ) { - win->setTitle( "eterm - " + windowStringData + " - " + String::toString( win->getFPS() ) + - " FPS" ); - secondsCounter.restart(); - } -} - EE_MAIN_FUNC int main( int argc, char* argv[] ) { #ifdef EE_DEBUG Log::instance()->setLogToStdOut( true ); @@ -263,42 +239,73 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { Float realMaxFPS = maxFPS.Get() ? maxFPS.Get() : currentDisplay->getRefreshRate(); frameTime = benchmarkMode ? Time::Zero : Milliseconds( 1000.f / realMaxFPS ); - if ( !terminal || terminal->hasTerminated() ) { - 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(), - shellArgs ? String::split( shellArgs.Get() ) : std::vector(), - file.getDirectoryPath(), historySize.Get(), nullptr, fb.Get(), - !( file.isRegularFile() && file.isExecutable() ) ); - terminal->getTerminal()->setAllowMemoryTrimnming( true ); - terminal->pushEventCallback( [&closeOnExit]( const TerminalDisplay::Event& event ) { - if ( event.type == TerminalDisplay::EventType::TITLE ) { - windowStringData = event.eventData; - win->setTitle( "eterm - " + windowStringData ); - } else if ( event.type == TerminalDisplay::EventType::PROCESS_EXIT && - closeOnExit.Get() ) { - win->close(); - } - } ); - if ( shell ) - terminal->setKeepAlive( false ); + 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(), + shellArgs ? String::split( shellArgs.Get() ) : std::vector(), + file.getDirectoryPath(), historySize.Get(), nullptr, fb.Get(), + !( file.isRegularFile() && file.isExecutable() ) ); - if ( colorScheme ) { - auto selColorScheme = terminalColorSchemes.find( colorScheme.Get() ); - if ( selColorScheme != terminalColorSchemes.end() ) - terminal->setColorScheme( selColorScheme->second ); - } - - if ( !executeInShell.Get().empty() ) - terminal->executeFile( executeInShell.Get() ); - - win->startTextInput(); + if ( terminal->getTerminal() == nullptr ) { + win->close(); + win->showMessageBox( EE::Window::Window::MessageBoxType::Error, "eterm", + "Operating System not supported." ); + terminal.reset(); + Engine::destroySingleton(); + MemoryManager::showResults(); + return EXIT_FAILURE; } + terminal->getTerminal()->setAllowMemoryTrimnming( true ); + terminal->pushEventCallback( [&closeOnExit]( const TerminalDisplay::Event& event ) { + if ( event.type == TerminalDisplay::EventType::TITLE ) { + windowStringData = event.eventData; + win->setTitle( "eterm - " + windowStringData ); + } else if ( event.type == TerminalDisplay::EventType::PROCESS_EXIT && + closeOnExit.Get() ) { + win->close(); + } + } ); + if ( shell ) + terminal->setKeepAlive( false ); + + if ( colorScheme ) { + auto selColorScheme = terminalColorSchemes.find( colorScheme.Get() ); + if ( selColorScheme != terminalColorSchemes.end() ) + terminal->setColorScheme( selColorScheme->second ); + } + + if ( !executeInShell.Get().empty() ) + terminal->executeFile( executeInShell.Get() ); + + win->startTextInput(); + win->getInput()->pushCallback( &inputCallback ); - win->runMainLoop( &mainLoop ); + win->runMainLoop( [] { + bool termNeedsUpdate = false; + win->getInput()->update(); + + if ( terminal ) + termNeedsUpdate = !terminal->update(); + + if ( terminal && ( benchmarkMode || terminal->isDirty() ) && + ( !termNeedsUpdate || lastRender.getElapsedTime() >= frameTime ) ) { + lastRender.restart(); + win->clear(); + terminal->draw(); + win->display(); + } else if ( !benchmarkMode && !termNeedsUpdate ) { + win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) ); + } + + if ( benchmarkMode && secondsCounter.getElapsedTime() >= Seconds( 1 ) ) { + win->setTitle( "eterm - " + windowStringData + " - " + + String::toString( win->getFPS() ) + " FPS" ); + secondsCounter.restart(); + } + } ); } terminal.reset();