mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-26 08:08:28 +03:00
Added an option to "Use status bar terminal" in the Run configuration.
This commit is contained in:
@@ -278,6 +278,8 @@ class TerminalDisplay : public ITerminalDisplay {
|
||||
|
||||
bool isAppCapturingMouse() const;
|
||||
|
||||
std::size_t getHistorySize() const { return mHistorySize; }
|
||||
|
||||
protected:
|
||||
EE::Window::Window* mWindow;
|
||||
std::vector<TerminalGlyph> mBuffer;
|
||||
@@ -321,6 +323,7 @@ class TerminalDisplay : public ITerminalDisplay {
|
||||
Primitives mPrimitives;
|
||||
Vector2u mCurGridPos;
|
||||
Clock mLastAutoScroll;
|
||||
std::size_t mHistorySize{ 0 };
|
||||
|
||||
std::string mProgram;
|
||||
std::vector<std::string> mArgs;
|
||||
|
||||
@@ -453,6 +453,7 @@ std::shared_ptr<TerminalDisplay> TerminalDisplay::create(
|
||||
terminal->mEnv = env;
|
||||
terminal->mWorkingDir = workingDir;
|
||||
terminal->mKeepAlive = keepAlive;
|
||||
terminal->mHistorySize = historySize;
|
||||
|
||||
if ( freeProcessFactory )
|
||||
eeSAFE_DELETE( processFactory );
|
||||
|
||||
@@ -617,10 +617,10 @@ bool UITerminal::onCreateContextMenu( const Vector2i& position, const Uint32& fl
|
||||
|
||||
void UITerminal::restart() {
|
||||
auto win = SceneManager::instance()->getUISceneNode()->getWindow();
|
||||
mTerm = TerminalDisplay::create(
|
||||
win, mTerm->getFont(), mTerm->getFontSize(), mTerm->getSize(), mTerm->getProgram(),
|
||||
mTerm->getArgs(), mTerm->getWorkingDir(), mTerm->getTerminal()->getHistorySize(), nullptr,
|
||||
mTerm->useFrameBuffer(), mTerm->getKeepAlive(), mTerm->getEnv() );
|
||||
mTerm = TerminalDisplay::create( win, mTerm->getFont(), mTerm->getFontSize(), mTerm->getSize(),
|
||||
mTerm->getProgram(), mTerm->getArgs(), mTerm->getWorkingDir(),
|
||||
mTerm->getHistorySize(), nullptr, mTerm->useFrameBuffer(),
|
||||
mTerm->getKeepAlive(), mTerm->getEnv() );
|
||||
}
|
||||
|
||||
}} // namespace eterm::UI
|
||||
|
||||
@@ -111,6 +111,8 @@ json ProjectBuild::serialize( const ProjectBuild::Map& builds ) {
|
||||
step["run_in_terminal"] = run->runInTerminal;
|
||||
if ( run->reusePreviousTerminal )
|
||||
step["reuse_previous_terminal"] = run->reusePreviousTerminal;
|
||||
if ( run->useStatusBarTerminal )
|
||||
step["use_statusbar_terminal"] = run->useStatusBarTerminal;
|
||||
jrun.push_back( step );
|
||||
}
|
||||
}
|
||||
@@ -560,6 +562,7 @@ ProjectBuild::Map ProjectBuild::deserialize( const json& j, const std::string& p
|
||||
rstep->enabled = step.value( "enabled", true );
|
||||
rstep->runInTerminal = step.value( "run_in_terminal", false );
|
||||
rstep->reusePreviousTerminal = step.value( "reuse_previous_terminal", false );
|
||||
rstep->useStatusBarTerminal = step.value( "use_statusbar_terminal", false );
|
||||
b.mRun.emplace_back( std::move( rstep ) );
|
||||
}
|
||||
}
|
||||
@@ -848,27 +851,37 @@ void ProjectBuildManager::runConfig( StatusAppOutputController* saoc ) {
|
||||
|
||||
auto cmd = finalBuild.cmd + ( !finalBuild.args.empty() ? ( " " + finalBuild.args ) : "" );
|
||||
if ( finalBuild.runInTerminal ) {
|
||||
bool mustReuseLastUsedTerm = finalBuild.reusePreviousTerminal && mLastUsedTerm &&
|
||||
mApp->getSplitter()->ownedWidgetExists( mLastUsedTerm );
|
||||
|
||||
UITerminal* term = mustReuseLastUsedTerm
|
||||
? mLastUsedTerm
|
||||
: mApp->getTerminalManager()->createTerminalInSplitter(
|
||||
finalBuild.workingDir, "", {}, {}, false );
|
||||
|
||||
Log::info( "Running \"%s\" in terminal", cmd );
|
||||
if ( term == nullptr || term->getTerm() == nullptr ) {
|
||||
mApp->getTerminalManager()->openInExternalTerminal( cmd, finalBuild.workingDir );
|
||||
} else {
|
||||
if ( mustReuseLastUsedTerm ) {
|
||||
term->restart();
|
||||
} else {
|
||||
mLastUsedTermCloseCbId =
|
||||
term->on( Event::OnClose, [this]( auto ) { mLastUsedTerm = nullptr; } );
|
||||
}
|
||||
if ( finalBuild.useStatusBarTerminal && mApp->getStatusTerminalController() ) {
|
||||
mApp->getStatusTerminalController()->show();
|
||||
auto term = mApp->getStatusTerminalController()->getUITerminal();
|
||||
term->restart();
|
||||
term->executeFile( cmd );
|
||||
mLastUsedTerm = term;
|
||||
} else {
|
||||
bool mustReuseLastUsedTerm =
|
||||
finalBuild.reusePreviousTerminal && mLastUsedTerm &&
|
||||
mApp->getSplitter()->ownedWidgetExists( mLastUsedTerm );
|
||||
|
||||
UITerminal* term = mustReuseLastUsedTerm
|
||||
? mLastUsedTerm
|
||||
: mApp->getTerminalManager()->createTerminalInSplitter(
|
||||
finalBuild.workingDir, "", {}, {}, false );
|
||||
|
||||
Log::info( "Running \"%s\" in terminal", cmd );
|
||||
if ( term == nullptr || term->getTerm() == nullptr ) {
|
||||
mApp->getTerminalManager()->openInExternalTerminal( cmd,
|
||||
finalBuild.workingDir );
|
||||
} else {
|
||||
if ( mustReuseLastUsedTerm ) {
|
||||
term->restart();
|
||||
} else {
|
||||
mLastUsedTermCloseCbId =
|
||||
term->on( Event::OnClose, [this]( auto ) { mLastUsedTerm = nullptr; } );
|
||||
}
|
||||
term->executeFile( cmd );
|
||||
mLastUsedTerm = term;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Log::info( "Running \"%s\" in app", cmd );
|
||||
finalBuild.config = build->getConfig();
|
||||
|
||||
@@ -106,6 +106,7 @@ struct ProjectBuildStep {
|
||||
bool enabled{ true };
|
||||
bool runInTerminal{ false };
|
||||
bool reusePreviousTerminal{ false };
|
||||
bool useStatusBarTerminal{ false };
|
||||
};
|
||||
|
||||
using ProjectBuildSteps = std::vector<std::unique_ptr<ProjectBuildStep>>;
|
||||
|
||||
@@ -240,6 +240,8 @@ class UIBuildStep : public UILinearLayout {
|
||||
UIDataBindBool::New( &mStep->runInTerminal, findByClass( "run_in_terminal" ) );
|
||||
mDataBindHolder += UIDataBindBool::New( &mStep->reusePreviousTerminal,
|
||||
findByClass( "reuse_previous_terminal" ) );
|
||||
mDataBindHolder += UIDataBindBool::New( &mStep->useStatusBarTerminal,
|
||||
findByClass( "use_statusbar_terminal" ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -279,6 +281,7 @@ class UIBuildStep : public UILinearLayout {
|
||||
<hbox lw="mp">
|
||||
<CheckBox class="run_in_terminal" text="@string(run_in_terminal, Run in terminal)" visible="false" />
|
||||
<CheckBox margin-left="8dp" class="reuse_previous_terminal" text="@string(reuse_previous_terminal, Reuse previous terminal)" visible="false" />
|
||||
<CheckBox margin-left="8dp" class="use_statusbar_terminal" text="@string(use_statusbar_terminal, Use status bar terminal)" visible="false" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
)xml";
|
||||
@@ -292,16 +295,37 @@ class UIBuildStep : public UILinearLayout {
|
||||
auto reusePreviousTerminal =
|
||||
findByClass( "reuse_previous_terminal" )->asType<UICheckBox>();
|
||||
|
||||
auto useStatusBarTerminal =
|
||||
findByClass( "use_statusbar_terminal" )->asType<UICheckBox>();
|
||||
|
||||
runInTerminal->setVisible( true );
|
||||
runInTerminal->setChecked( buildStep->runInTerminal );
|
||||
runInTerminal->on( Event::OnValueChange,
|
||||
[reusePreviousTerminal, runInTerminal]( auto ) {
|
||||
reusePreviousTerminal->setEnabled( runInTerminal->isChecked() );
|
||||
} );
|
||||
runInTerminal->on( Event::OnValueChange, [reusePreviousTerminal, runInTerminal,
|
||||
useStatusBarTerminal]( auto ) {
|
||||
reusePreviousTerminal->setEnabled( runInTerminal->isChecked() );
|
||||
useStatusBarTerminal->setEnabled( runInTerminal->isChecked() );
|
||||
if ( !runInTerminal->isChecked() ) {
|
||||
reusePreviousTerminal->setChecked( false );
|
||||
useStatusBarTerminal->setChecked( false );
|
||||
}
|
||||
} );
|
||||
|
||||
useStatusBarTerminal->on( Event::OnValueChange, [runInTerminal, reusePreviousTerminal,
|
||||
useStatusBarTerminal]( auto ) {
|
||||
if ( useStatusBarTerminal->isChecked() ) {
|
||||
reusePreviousTerminal->setChecked( true )->setEnabled( false );
|
||||
} else if ( runInTerminal->isChecked() ) {
|
||||
reusePreviousTerminal->setEnabled( true );
|
||||
}
|
||||
} );
|
||||
|
||||
reusePreviousTerminal->setVisible( true );
|
||||
reusePreviousTerminal->setEnabled( buildStep->runInTerminal );
|
||||
reusePreviousTerminal->setChecked( buildStep->reusePreviousTerminal );
|
||||
|
||||
useStatusBarTerminal->setVisible( true );
|
||||
useStatusBarTerminal->setEnabled( buildStep->runInTerminal );
|
||||
useStatusBarTerminal->setChecked( buildStep->useStatusBarTerminal );
|
||||
}
|
||||
|
||||
findByClass( "details_but" )->onClick( [this]( const MouseEvent* event ) {
|
||||
|
||||
Reference in New Issue
Block a user