diff --git a/src/tools/eterm/eterm.cpp b/src/tools/eterm/eterm.cpp index 019991497..e5de31834 100644 --- a/src/tools/eterm/eterm.cpp +++ b/src/tools/eterm/eterm.cpp @@ -9,38 +9,41 @@ void inputCallback( InputEvent* event ) { return; switch ( event->Type ) { + case InputEvent::MouseMotion: { + terminal->onMouseMotion( win->getInput()->getMousePos(), + win->getInput()->getPressTrigger() ); + break; + } + case InputEvent::MouseButtonDown: { + terminal->onMouseDown( win->getInput()->getMousePos(), + win->getInput()->getPressTrigger() ); + break; + } + case InputEvent::MouseButtonUp: { + terminal->onMouseUp( win->getInput()->getMousePos(), + win->getInput()->getReleaseTrigger() ); + break; + } case InputEvent::Window: { break; } - case InputEvent::KeyUp: - + case InputEvent::KeyUp: { break; - case InputEvent::KeyDown: + } + case InputEvent::KeyDown: { terminal->onKeyDown( event->key.keysym.sym, event->key.keysym.unicode, event->key.keysym.mod, event->key.keysym.scancode ); break; - case InputEvent::TextInput: - terminal->onTextInput( event->text.text ); - case InputEvent::SysWM: - case InputEvent::VideoResize: - case InputEvent::VideoExpose: { } - } -} - -void tryInitTerminal( Font* fontDefault ) { - if ( !terminal || terminal->HasTerminated() ) { - auto fontSize = 15; - auto charWidth = fontDefault->getGlyph( 'A', fontSize, false ).advance; - auto charHeight = terminal ? terminal->getFontSize() : fontSize; - Sizef contentRegion = win->getSize().asFloat(); - - auto columns = (int)std::floor( std::max( 1.0f, contentRegion.x / charWidth ) ); - auto rows = (int)std::floor( std::max( 1.0f, contentRegion.y / charHeight ) ); - - terminal = - ETerminalDisplay::Create( win, fontDefault, columns, rows, "/usr/bin/fish", {}, "", 0 ); - terminal->setFontSize( charHeight ); + case InputEvent::TextInput: { + terminal->onTextInput( event->text.text ); + break; + } + case InputEvent::VideoResize: { + terminal->setPosition( { 0, 0 } ); + terminal->setSize( win->getSize().asFloat() ); + break; + } } } @@ -52,7 +55,7 @@ void mainLoop() { if ( terminal ) { terminal->Update(); - terminal->Draw( Rectf( { 0, 0 }, win->getSize().asFloat() ) ); + terminal->Draw( win->hasFocus() ); } win->display(); @@ -67,12 +70,32 @@ EE_MAIN_FUNC int main( int, char*[] ) { ContextSettings( true ) ); if ( win->isOpen() ) { - win->setClearColor( RGB( 50, 50, 50 ) ); + win->setClearColor( RGB( 0, 0, 0 ) ); FontTrueType* fontMono = FontTrueType::New( "monospace" ); fontMono->loadFromFile( "assets/fonts/DejaVuSansMono.ttf" ); - tryInitTerminal( fontMono ); + if ( !terminal || terminal->HasTerminated() ) { + auto fontSize = 15; + auto charWidth = fontMono->getGlyph( 'A', fontSize, false ).advance; + auto charHeight = terminal ? terminal->getFontSize() : fontSize; + Sizef contentRegion = win->getSize().asFloat(); + + auto columns = (int)std::floor( std::max( 1.0f, contentRegion.x / charWidth ) ); + auto rows = (int)std::floor( std::max( 1.0f, contentRegion.y / charHeight ) ); + + std::string shell; + const char* shellenv = getenv( "SHELL" ); + if ( shellenv != nullptr ) { + shell = shellenv; + } else { + shell = "/bin/bash"; + } + + terminal = ETerminalDisplay::Create( win, fontMono, columns, rows, shell, {}, "", 0 ); + terminal->setFontSize( charHeight ); + terminal->setSize( win->getSize().asFloat() ); + } win->getInput()->pushCallback( &inputCallback ); diff --git a/src/tools/eterm/eterminaldisplay.cpp b/src/tools/eterm/eterminaldisplay.cpp index efa92f1a0..4685b7e6e 100644 --- a/src/tools/eterm/eterminaldisplay.cpp +++ b/src/tools/eterm/eterminaldisplay.cpp @@ -320,14 +320,14 @@ ETerminalDisplay::Create( EE::Window::Window* window, Font* font, return terminal; } -static Hexe::System::IProcessFactory* g_processFactory = new Hexe::System::ProcessFactory(); +static EE::System::IProcessFactory* g_processFactory = new EE::System::ProcessFactory(); std::shared_ptr ETerminalDisplay::Create( EE::Window::Window* window, Font* font, int columns, int rows, const std::string& program, const std::vector& args, const std::string& workingDir, uint32_t options, - Hexe::System::IProcessFactory* processFactory ) { - using namespace Hexe::System; + EE::System::IProcessFactory* processFactory ) { + using namespace EE::System; TerminalConfig config{}; config.options = options; @@ -440,6 +440,8 @@ void ETerminalDisplay::SetTitle( const char* ) {} void ETerminalDisplay::SetIconTitle( const char* ) {} void ETerminalDisplay::SetClipboard( const char* text ) { + if ( text == nullptr ) + return; mClipboard = text; mWindow->getClipboard()->setText( mClipboard ); } @@ -482,9 +484,7 @@ void ETerminalDisplay::DrawEnd() { m_dirty = true; } -void ETerminalDisplay::Draw( const Rectf& contentArea ) { - bool hasFocus = mWindow->hasFocus(); - +void ETerminalDisplay::Draw( bool hasFocus ) { bool modeFocus = mMode & MODE_FOCUSED; if ( hasFocus != modeFocus ) { if ( hasFocus ) { @@ -496,7 +496,35 @@ void ETerminalDisplay::Draw( const Rectf& contentArea ) { mMode ^= MODE_FOCUS; } - Draw( Vector2i( contentArea.Left, contentArea.Top ), contentArea.getSize().asInt(), hasFocus ); + Draw( mPosition ); +} + +void ETerminalDisplay::onMouseMotion( const Vector2i& pos, const Uint32& flags ) { + if ( ( flags & EE_BUTTON_LMASK ) && + ( m_terminal->getSelectionMode() == selection_mode::SEL_EMPTY || + m_terminal->getSelectionMode() == selection_mode::SEL_READY ) ) { + auto gridPos{ positionToGrid( pos ) }; + m_terminal->selextend( + gridPos.x, gridPos.y, + mWindow->getInput()->getModState() == KEYMOD_SHIFT ? SEL_RECTANGULAR : SEL_REGULAR, 0 ); + } +} + +void ETerminalDisplay::onMouseDown( const Vector2i& pos, const Uint32& flags ) { + if ( ( flags & EE_BUTTON_LMASK ) && + ( m_terminal->getSelectionMode() == selection_mode::SEL_IDLE ) ) { + auto gridPos{ positionToGrid( pos ) }; + m_terminal->selstart( gridPos.x, gridPos.y, 0 ); + } +} + +void ETerminalDisplay::onMouseUp( const Vector2i&, const Uint32& flags ) { + if ( ( flags & EE_BUTTON_LMASK ) ) { + auto selection = m_terminal->getsel(); + if ( selection ) + SetClipboard( selection ); + m_terminal->selclear(); + } } static inline Color GetCol( unsigned int terminalColor, @@ -515,7 +543,7 @@ static inline Color GetCol( unsigned int terminalColor, #define COL32_B_SHIFT 8 #define COL32_A_SHIFT 0 -void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFocus*/ ) { +void ETerminalDisplay::Draw( Vector2f pos ) { if ( mClock.getElapsedTime().asSeconds() > 0.7 ) { mMode ^= MODE_BLINK; mClock.restart(); @@ -527,26 +555,11 @@ void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFoc auto width = m_columns * spaceCharAdvanceX; auto height = m_rows * fontSize; - auto clipWidth = clip_rect.getWidth(); - auto clipHeight = clip_rect.getHeight(); - - auto clipColumns = (int)std::floor( std::max( 1.0f, clipWidth / spaceCharAdvanceX ) ); - auto clipRows = (int)std::floor( std::max( 1.0f, clipHeight / fontSize ) ); - - if ( width < clipWidth ) { - pos.x = std::floor( pos.x + ( ( clipWidth - width ) / 2.0f ) ); + if ( width < mSize.getWidth() ) { + pos.x = std::floor( pos.x + ( ( mSize.getWidth() - width ) / 2.0f ) ); } - if ( height < clipHeight ) { - pos.y = std::floor( pos.y + ( ( clipHeight - height ) / 2.0f ) ); - } - - Primitives p; - p.setForceDraw( false ); - p.setColor( mEmulator->GetDefaultBackground() ); - p.drawRectangle( Rectf( pos.asFloat(), clip_rect.asFloat() ) ); - - if ( clipColumns != m_terminal->GetNumColumns() || clipRows != m_terminal->GetNumRows() ) { - m_terminal->Resize( clipColumns, clipRows ); + if ( height < mSize.getHeight() ) { + pos.y = std::floor( pos.y + ( ( mSize.getHeight() - height ) / 2.0f ) ); } float x = 0.0f; @@ -555,10 +568,15 @@ void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFoc auto defaultFg = GetCol( mEmulator->GetDefaultForeground(), m_colors ); auto defaultBg = GetCol( mEmulator->GetDefaultBackground(), m_colors ); + Primitives p; + p.setForceDraw( false ); + p.setColor( defaultBg ); + p.drawRectangle( Rectf( mPosition.asFloat(), mSize.asFloat() ) ); + for ( int j = 0; j < m_rows; j++ ) { x = std::floor( pos.x ); - if ( pos.y + line_height * j > clip_rect.getWidth() ) + if ( pos.y + line_height * j > mSize.getWidth() ) break; for ( int i = 0; i < m_columns; i++ ) { @@ -619,15 +637,12 @@ void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFoc y += line_height; } - p.setForceDraw( true ); - p.drawBatch(); - y = std::floor( pos.y ); for ( int j = 0; j < m_rows; j++ ) { x = std::floor( pos.x ); - if ( pos.y + line_height * j > clip_rect.getWidth() ) + if ( pos.y + line_height * j > mSize.getWidth() ) break; for ( int i = 0; i < m_columns; i++ ) { @@ -688,21 +703,20 @@ void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFoc auto advanceX = spaceCharAdvanceX * ( isWide ? 2.0f : 1.0f ); - if ( glyph.mode & ATTR_WDUMMY ) { + if ( glyph.mode & ATTR_WDUMMY ) continue; - } auto* gd = mFont->getGlyphDrawable( glyph.u, mFontSize, glyph.mode & ATTR_BOLD ); gd->setColor( fg ); gd->setDrawMode( GlyphDrawable::DrawMode::Text ); gd->draw( { x, y } ); - /*if ( glyph.mode & ATTR_BOXDRAW && m_useBoxDrawing ) { - auto bd = TerminalEmulator::boxdrawindex( &glyph ); - drawbox( x, y, advanceX, line_height, fg, bg, bd, vtx_write ); + if ( glyph.mode & ATTR_BOXDRAW && m_useBoxDrawing ) { + // auto bd = TerminalEmulator::boxdrawindex( &glyph ); + // drawbox( x, y, advanceX, line_height, fg, bg, bd, vtx_write ); } - if ( glyph.mode & ATTR_STRUCK ) { + /*if ( glyph.mode & ATTR_STRUCK ) { ImVec2 a( x, y + 2 * ascent / 3 ); ImVec2 c( x + advanceX, a.y + 1 ); ImVec2 b( c.x, a.y ), d( a.x, c.y ), uv( drawList->_Data->TexUvWhitePixel ); @@ -820,6 +834,40 @@ void ETerminalDisplay::Draw( Vector2i pos, const Sizei& clip_rect, bool /*hasFoc }*/ } +Vector2i ETerminalDisplay::positionToGrid( const Vector2i& pos ) { + Vector2f relPos = { pos.x - mPosition.x, pos.y - mPosition.y }; + int mouseX = 0; + int mouseY = 0; + + auto fontSize = (Float)mFont->getFontHeight( mFontSize ); + auto spaceCharAdvanceX = mFont->getGlyph( 'A', mFontSize, false ).advance; + + auto clipColumns = (int)std::floor( std::max( 1.0f, mSize.getWidth() / spaceCharAdvanceX ) ); + auto clipRows = (int)std::floor( std::max( 1.0f, mSize.getHeight() / fontSize ) ); + + if ( pos.x <= 0.0f || pos.y <= 0.0f ) { + mouseX = 0; + mouseY = 0; + } else if ( relPos.x >= 0.0f && relPos.y >= 0.0f ) { + mouseX = eeclamp( (int)std::floor( relPos.x / spaceCharAdvanceX ), 0, clipColumns ); + mouseY = eeclamp( (int)std::floor( relPos.y / fontSize ), 0, clipRows ); + } + + return { mouseX, mouseY }; +} + +void ETerminalDisplay::onSizeChange() { + auto fontSize = (Float)mFont->getFontHeight( mFontSize ); + auto spaceCharAdvanceX = mFont->getGlyph( 'A', mFontSize, false ).advance; + + auto clipColumns = (int)std::floor( std::max( 1.0f, mSize.getWidth() / spaceCharAdvanceX ) ); + auto clipRows = (int)std::floor( std::max( 1.0f, mSize.getHeight() / fontSize ) ); + + if ( clipColumns != m_terminal->GetNumColumns() || clipRows != m_terminal->GetNumRows() ) { + m_terminal->Resize( clipColumns, clipRows ); + } +} + void ETerminalDisplay::onTextInput( const Uint32& chr ) { if ( !m_terminal ) return; @@ -905,3 +953,22 @@ Float ETerminalDisplay::getFontSize() const { void ETerminalDisplay::setFontSize( Float FontSize ) { mFontSize = FontSize; } + +const Vector2f& ETerminalDisplay::getPosition() const { + return mPosition; +} + +void ETerminalDisplay::setPosition( const Vector2f& position ) { + mPosition = position; +} + +const Sizef& ETerminalDisplay::getSize() const { + return mSize; +} + +void ETerminalDisplay::setSize( const Sizef& size ) { + if ( mSize != size ) { + mSize = size; + onSizeChange(); + } +} diff --git a/src/tools/eterm/eterminaldisplay.hpp b/src/tools/eterm/eterminaldisplay.hpp index 8913bb620..5f3c62eeb 100644 --- a/src/tools/eterm/eterminaldisplay.hpp +++ b/src/tools/eterm/eterminaldisplay.hpp @@ -15,7 +15,7 @@ #include #include -using namespace Hexe::Terminal; +using namespace EE::Terminal; using namespace EE; using namespace EE::Window; using namespace EE::System; @@ -118,7 +118,7 @@ class ETerminalDisplay : public TerminalDisplay { Create( EE::Window::Window* window, Font* font, int columns, int rows, const std::string& program, const std::vector& args, const std::string& workingDir, uint32_t options = 0, - Hexe::System::IProcessFactory* processFactory = nullptr ); + EE::System::IProcessFactory* processFactory = nullptr ); virtual void ResetColors(); virtual int ResetColor( int index, const char* name ); @@ -140,7 +140,13 @@ class ETerminalDisplay : public TerminalDisplay { bool HasTerminated() const; - void Draw( const Rectf& contentArea ); + void Draw( bool hasFocus ); + + virtual void onMouseMotion( const Vector2i& pos, const Uint32& flags ); + + virtual void onMouseDown( const Vector2i& pos, const Uint32& flags ); + + virtual void onMouseUp( const Vector2i& pos, const Uint32& flags ); virtual void onTextInput( const Uint32& chr ); @@ -151,6 +157,14 @@ class ETerminalDisplay : public TerminalDisplay { void setFontSize( Float FontSize ); + const Vector2f& getPosition() const; + + void setPosition( const Vector2f& position ); + + const Sizef& getSize() const; + + void setSize( const Sizef& size ); + protected: EE::Window::Window* mWindow; std::vector m_buffer; @@ -160,6 +174,8 @@ class ETerminalDisplay : public TerminalDisplay { Font* mFont; Float mFontSize{ 12 }; + Vector2f mPosition; + Sizef mSize; int m_columns{ 0 }; int m_rows{ 0 }; bool m_dirty; @@ -175,7 +191,11 @@ class ETerminalDisplay : public TerminalDisplay { ETerminalDisplay( EE::Window::Window* window, Font* font, int columns, int rows, TerminalConfig* config ); - void Draw( Vector2i pos, const Sizei& clip_rect, bool hasFocus ); + void Draw( Vector2f pos ); + + Vector2i positionToGrid( const Vector2i& pos ); + + void onSizeChange(); }; #endif // ETERMINALDISPLAY_HPP diff --git a/src/tools/eterm/system/autohandle.cpp b/src/tools/eterm/system/autohandle.cpp index 515b3b019..d23efedb7 100644 --- a/src/tools/eterm/system/autohandle.cpp +++ b/src/tools/eterm/system/autohandle.cpp @@ -27,15 +27,15 @@ #include #endif -Hexe::AutoHandle::AutoHandle() : m_hHandle( invalid_value() ) {} -Hexe::AutoHandle::AutoHandle( AutoHandle&& other ) : m_hHandle( other.m_hHandle ) { +EE::AutoHandle::AutoHandle() : m_hHandle( invalid_value() ) {} +EE::AutoHandle::AutoHandle( AutoHandle&& other ) : m_hHandle( other.m_hHandle ) { other.m_hHandle = invalid_value(); } -Hexe::AutoHandle::~AutoHandle() { +EE::AutoHandle::~AutoHandle() { Release(); } -Hexe::AutoHandle& Hexe::AutoHandle::operator=( AutoHandle&& other ) { +EE::AutoHandle& EE::AutoHandle::operator=( AutoHandle&& other ) { if ( m_hHandle == other.m_hHandle ) return *this; Release(); @@ -45,49 +45,49 @@ Hexe::AutoHandle& Hexe::AutoHandle::operator=( AutoHandle&& other ) { } #ifdef _WIN32 -Hexe::AutoHandle::AutoHandle( HANDLE handle ) : m_hHandle( handle ) {} +EE::AutoHandle::AutoHandle( HANDLE handle ) : m_hHandle( handle ) {} -void Hexe::AutoHandle::Release() const { +void EE::AutoHandle::Release() const { if ( m_hHandle != INVALID_HANDLE_VALUE ) { CloseHandle( m_hHandle ); m_hHandle = INVALID_HANDLE_VALUE; } } #else -Hexe::AutoHandle::AutoHandle( int fd ) : m_hHandle( fd ) {} +EE::AutoHandle::AutoHandle( int fd ) : m_hHandle( fd ) {} -void Hexe::AutoHandle::Release() const { +void EE::AutoHandle::Release() const { if ( m_hHandle != -1 ) { close( m_hHandle ); } } #endif -Hexe::AutoHandle::operator bool() const noexcept { +EE::AutoHandle::operator bool() const noexcept { return m_hHandle != invalid_value(); } -Hexe::AutoHandle::type* Hexe::AutoHandle::Get() { +EE::AutoHandle::type* EE::AutoHandle::Get() { return &m_hHandle; } -const Hexe::AutoHandle::type* Hexe::AutoHandle::Get() const { +const EE::AutoHandle::type* EE::AutoHandle::Get() const { return &m_hHandle; } -Hexe::AutoHandle::operator Hexe::AutoHandle::type() const noexcept { +EE::AutoHandle::operator EE::AutoHandle::type() const noexcept { return m_hHandle; } #ifdef _WIN32 // On Windows we deal with the Windows API, which means HANDLE is used as the handle to files // and pipes -constexpr Hexe::AutoHandle::type Hexe::AutoHandle::invalid_value() { +constexpr EE::AutoHandle::type EE::AutoHandle::invalid_value() { return static_cast( 0 ); } #else // On non-Windows OS'es we deal with file descriptors -constexpr Hexe::AutoHandle::type Hexe::AutoHandle::invalid_value() { +constexpr EE::AutoHandle::type EE::AutoHandle::invalid_value() { return -1; } #endif diff --git a/src/tools/eterm/system/autohandle.hpp b/src/tools/eterm/system/autohandle.hpp index 6769f1796..dd353503d 100644 --- a/src/tools/eterm/system/autohandle.hpp +++ b/src/tools/eterm/system/autohandle.hpp @@ -21,7 +21,7 @@ // DEALINGS IN THE SOFTWARE. #pragma once -namespace Hexe { +namespace EE { // This class is designed to automatically free a resource handle when destructed class AutoHandle final { @@ -58,4 +58,4 @@ class AutoHandle final { void Release() const; }; -} // namespace Hexe +} // namespace EE diff --git a/src/tools/eterm/system/ipipe.hpp b/src/tools/eterm/system/ipipe.hpp index 18352e5ed..861ef96e9 100644 --- a/src/tools/eterm/system/ipipe.hpp +++ b/src/tools/eterm/system/ipipe.hpp @@ -24,7 +24,7 @@ #include #include -namespace Hexe { namespace System { +namespace EE { namespace System { class IPipe { public: @@ -47,4 +47,4 @@ class IPipe { virtual int Read( char* buf, size_t n, bool block = false ) = 0; }; -}} // namespace Hexe::System +}} // namespace EE::System diff --git a/src/tools/eterm/system/iprocess.hpp b/src/tools/eterm/system/iprocess.hpp index 854738acf..618abbbe5 100644 --- a/src/tools/eterm/system/iprocess.hpp +++ b/src/tools/eterm/system/iprocess.hpp @@ -21,7 +21,7 @@ // DEALINGS IN THE SOFTWARE. #pragma once -namespace Hexe { namespace System { +namespace EE { namespace System { enum class ProcessStatus { RUNNING = 0, EXITED }; @@ -50,4 +50,4 @@ class IProcess { virtual void WaitForExit() = 0; }; -}} // namespace Hexe::System +}} // namespace EE::System diff --git a/src/tools/eterm/system/iprocessfactory.hpp b/src/tools/eterm/system/iprocessfactory.hpp index 8fb1a9dbb..fdf80f5a6 100644 --- a/src/tools/eterm/system/iprocessfactory.hpp +++ b/src/tools/eterm/system/iprocessfactory.hpp @@ -28,9 +28,9 @@ #include #include -using namespace Hexe::Terminal; +using namespace EE::Terminal; -namespace Hexe { namespace System { +namespace EE { namespace System { class IProcessFactory { public: @@ -58,4 +58,4 @@ class IProcessFactory { std::unique_ptr& outPseudoTerminal ) = 0; }; -}} // namespace Hexe::System +}} // namespace EE::System diff --git a/src/tools/eterm/system/pipe.hpp b/src/tools/eterm/system/pipe.hpp index 75572b8fb..48bc3ccad 100644 --- a/src/tools/eterm/system/pipe.hpp +++ b/src/tools/eterm/system/pipe.hpp @@ -25,8 +25,10 @@ #include "autohandle.hpp" #include -namespace Hexe { namespace System { +namespace EE { namespace System { + class Process; + class Pipe : public IPipe { private: friend class Process; @@ -59,4 +61,5 @@ class Pipe : public IPipe { static bool CreatePipePair( std::unique_ptr& outPipeA, std::unique_ptr& outPipeB ); }; -}} // namespace Hexe::System + +}} // namespace EE::System diff --git a/src/tools/eterm/system/pipe.win32.cpp b/src/tools/eterm/system/pipe.win32.cpp index aed06b163..a2d526056 100644 --- a/src/tools/eterm/system/pipe.win32.cpp +++ b/src/tools/eterm/system/pipe.win32.cpp @@ -3,7 +3,7 @@ #include "../terminal/windowserrors.hpp" #include -using namespace Hexe::System; +using namespace EE::System; Pipe::Pipe( AutoHandle&& readHandle, AutoHandle&& writeHandle ) : m_hInput( std::move( readHandle ) ), m_hOutput( std::move( writeHandle ) ) {} diff --git a/src/tools/eterm/system/process.cpp b/src/tools/eterm/system/process.cpp index a476c3baf..ddb90c97c 100644 --- a/src/tools/eterm/system/process.cpp +++ b/src/tools/eterm/system/process.cpp @@ -41,7 +41,7 @@ #include #endif -using namespace Hexe::System; +using namespace EE::System; Process::~Process() { if ( m_pid != -1 ) { @@ -91,7 +91,7 @@ void Process::WaitForExit() { } bool Process::HasExited() const { - return m_status == Hexe::System::ProcessStatus::EXITED; + return m_status == EE::System::ProcessStatus::EXITED; } int Process::GetExitCode() const { @@ -196,8 +196,8 @@ Process::CreateWithPseudoTerminal( const std::string& program, const std::vector #include #include -using namespace Hexe::System; -using namespace Hexe; +using namespace EE::System; +using namespace EE; static std::wstring stringToWideString( const std::string& str ) { if ( str.empty() ) diff --git a/src/tools/eterm/system/process.hpp b/src/tools/eterm/system/process.hpp index b7e10e24d..bbb33489d 100644 --- a/src/tools/eterm/system/process.hpp +++ b/src/tools/eterm/system/process.hpp @@ -36,7 +36,7 @@ #include #endif -namespace Hexe { namespace System { +namespace EE { namespace System { class Process final : public IProcess { private: @@ -80,4 +80,4 @@ class Process final : public IProcess { Terminal::PseudoTerminal& pseudoTerminal ); }; -}} // namespace Hexe::System +}} // namespace EE::System diff --git a/src/tools/eterm/system/processfactory.cpp b/src/tools/eterm/system/processfactory.cpp index d344c3059..9194d9580 100644 --- a/src/tools/eterm/system/processfactory.cpp +++ b/src/tools/eterm/system/processfactory.cpp @@ -2,7 +2,7 @@ #include "../system/process.hpp" #include "../terminal/pseudoterminal.hpp" -using namespace Hexe::System; +using namespace EE::System; std::unique_ptr ProcessFactory::CreateWithStdioPipe( const std::string& program, const std::vector& args, diff --git a/src/tools/eterm/system/processfactory.hpp b/src/tools/eterm/system/processfactory.hpp index 9d2b93dbf..05be377dc 100644 --- a/src/tools/eterm/system/processfactory.hpp +++ b/src/tools/eterm/system/processfactory.hpp @@ -23,9 +23,9 @@ #include "iprocessfactory.hpp" -using namespace Hexe::Terminal; +using namespace EE::Terminal; -namespace Hexe { namespace System { +namespace EE { namespace System { class ProcessFactory : public IProcessFactory { public: @@ -53,4 +53,4 @@ class ProcessFactory : public IProcessFactory { std::unique_ptr& outPseudoTerminal ) override; }; -}} // namespace Hexe::System +}} // namespace EE::System diff --git a/src/tools/eterm/terminal/ipseudoterminal.hpp b/src/tools/eterm/terminal/ipseudoterminal.hpp index 0cb2d99fa..4d12eb0ac 100644 --- a/src/tools/eterm/terminal/ipseudoterminal.hpp +++ b/src/tools/eterm/terminal/ipseudoterminal.hpp @@ -24,9 +24,9 @@ #include "../system/ipipe.hpp" #include -namespace Hexe { namespace Terminal { +namespace EE { namespace Terminal { -class IPseudoTerminal : public Hexe::System::IPipe { +class IPseudoTerminal : public EE::System::IPipe { public: IPseudoTerminal() = default; @@ -47,4 +47,4 @@ class IPseudoTerminal : public Hexe::System::IPipe { virtual bool Resize( int columns, int rows ) = 0; }; -}} // namespace Hexe::Terminal +}} // namespace EE::Terminal diff --git a/src/tools/eterm/terminal/pseudoterminal.cpp b/src/tools/eterm/terminal/pseudoterminal.cpp index 95b310f2a..43eb1404b 100644 --- a/src/tools/eterm/terminal/pseudoterminal.cpp +++ b/src/tools/eterm/terminal/pseudoterminal.cpp @@ -31,7 +31,7 @@ #include #include -using namespace Hexe::Terminal; +using namespace EE::Terminal; PseudoTerminal::~PseudoTerminal() {} @@ -129,7 +129,7 @@ std::unique_ptr PseudoTerminal::Create( int columns, int rows ) #define NTDDI_VERSION NTDDI_WIN10_RS5 #include -using namespace Hexe::Terminal; +using namespace EE::Terminal; PseudoTerminal::~PseudoTerminal() { ClosePseudoConsole( m_phPC ); diff --git a/src/tools/eterm/terminal/pseudoterminal.hpp b/src/tools/eterm/terminal/pseudoterminal.hpp index 31d25d77b..d0d10319f 100644 --- a/src/tools/eterm/terminal/pseudoterminal.hpp +++ b/src/tools/eterm/terminal/pseudoterminal.hpp @@ -28,14 +28,14 @@ using namespace EE::Math; -namespace Hexe { +namespace EE { namespace System { class Process; } namespace Terminal { class PseudoTerminal final : public IPseudoTerminal { private: - friend class ::Hexe::System::Process; + friend class ::EE::System::Process; #ifdef _WIN32 Vector2i m_size; @@ -75,4 +75,4 @@ class PseudoTerminal final : public IPseudoTerminal { static std::unique_ptr Create( int columns, int rows ); }; } // namespace Terminal -} // namespace Hexe +} // namespace EE diff --git a/src/tools/eterm/terminal/terminaldisplay.cpp b/src/tools/eterm/terminal/terminaldisplay.cpp index 4efcf9d5c..46170a58d 100644 --- a/src/tools/eterm/terminal/terminaldisplay.cpp +++ b/src/tools/eterm/terminal/terminaldisplay.cpp @@ -25,7 +25,7 @@ #define MODBIT( x, set, bit ) ( ( set ) ? ( ( x ) |= ( bit ) ) : ( ( x ) &= ~( bit ) ) ) -using namespace Hexe::Terminal; +using namespace EE::Terminal; TerminalDisplay::TerminalDisplay() : mMode( MODE_VISIBLE ), mCursorMode( SteadyBar ), mEmulator( nullptr ) {} diff --git a/src/tools/eterm/terminal/terminaldisplay.hpp b/src/tools/eterm/terminal/terminaldisplay.hpp index a24bef464..bc7ed96c3 100644 --- a/src/tools/eterm/terminal/terminaldisplay.hpp +++ b/src/tools/eterm/terminal/terminaldisplay.hpp @@ -23,7 +23,7 @@ #include "types.hpp" -namespace Hexe { namespace Terminal { +namespace EE { namespace Terminal { class TerminalEmulator; class TerminalDisplay { @@ -66,4 +66,4 @@ class TerminalDisplay { virtual void DrawEnd() = 0; }; -}} // namespace Hexe::Terminal +}} // namespace EE::Terminal diff --git a/src/tools/eterm/terminal/terminalemulator.cpp b/src/tools/eterm/terminal/terminalemulator.cpp index 368d09f85..220787bed 100644 --- a/src/tools/eterm/terminal/terminalemulator.cpp +++ b/src/tools/eterm/terminal/terminalemulator.cpp @@ -74,7 +74,7 @@ const static unsigned int worddelimiters[] = { ' ', 0 }; * * stty tabs */ -static const unsigned int tabspaces = 8; +static const unsigned int tabspaces = 4; #ifdef WIN32 #include @@ -105,7 +105,7 @@ static const unsigned int tabspaces = 8; #define ISCONTROL( c ) ( ISCONTROLC0( c ) || ISCONTROLC1( c ) ) #define ISDELIM( u ) ( u && _wcschr( worddelimiters, u ) ) -using namespace Hexe::Terminal; +using namespace EE::Terminal; static inline bool is_emoji( int32_t code ) { const int32_t rangeMin = 127744; @@ -306,6 +306,10 @@ int TerminalEmulator::tlinelen( int y ) { return i; } +selection_mode TerminalEmulator::getSelectionMode() const { + return (selection_mode)sel.mode; +} + void TerminalEmulator::selstart( int col, int row, int snap ) { selclear(); sel.mode = SEL_EMPTY; diff --git a/src/tools/eterm/terminal/terminalemulator.hpp b/src/tools/eterm/terminal/terminalemulator.hpp index ba697e110..9390992ea 100644 --- a/src/tools/eterm/terminal/terminalemulator.hpp +++ b/src/tools/eterm/terminal/terminalemulator.hpp @@ -43,7 +43,7 @@ #include #include -namespace Hexe { namespace Terminal { +namespace EE { namespace Terminal { constexpr int ESC_BUF_SIZ = 512; constexpr int ESC_ARG_SIZ = 16; constexpr int STR_BUF_SIZ = ESC_BUF_SIZ; @@ -98,7 +98,7 @@ class TerminalEmulator final { using PtyPtr = std::unique_ptr; using ProcPtr = std::unique_ptr; - static ushort boxdrawindex( const TerminalGlyph* g ) ; + static ushort boxdrawindex( const TerminalGlyph* g ); private: DpyPtr m_dpy; @@ -258,6 +258,8 @@ class TerminalEmulator final { void printsel( const Arg* ); void sendbreak( const Arg* ); void toggleprinter( const Arg* ); + + selection_mode getSelectionMode() const; }; -}} // namespace Hexe::Terminal +}} // namespace EE::Terminal diff --git a/src/tools/eterm/terminal/types.hpp b/src/tools/eterm/terminal/types.hpp index 68109ced0..3234e4b74 100644 --- a/src/tools/eterm/terminal/types.hpp +++ b/src/tools/eterm/terminal/types.hpp @@ -24,7 +24,7 @@ #include #include -namespace Hexe { namespace Terminal { +namespace EE { namespace Terminal { enum cursor_mode { BlinkingBlock = 0, @@ -166,4 +166,4 @@ typedef struct { int alt; } Selection; -}} // namespace Hexe::Terminal +}} // namespace EE::Terminal