mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-14 05:06:54 +03:00
ecode: Added an option to configure the default shell used by ecode terminal.
Closes SpartanJ/ecode#70.
This commit is contained in:
@@ -27,6 +27,8 @@ class EE_API UIComboBox : public UIWidget {
|
||||
|
||||
const String& getText();
|
||||
|
||||
void setText( const String& text );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
|
||||
|
||||
@@ -27,7 +27,7 @@ class EE_API UIListBox : public UITouchDraggableWidget {
|
||||
|
||||
void clear();
|
||||
|
||||
void addListBoxItems( std::vector<String> Texts );
|
||||
void addListBoxItems( std::vector<String> texts );
|
||||
|
||||
Uint32 addListBoxItem( const String& Text );
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define EEPP_MAJOR_VERSION 2
|
||||
#define EEPP_MINOR_VERSION 5
|
||||
#define EEPP_PATCH_LEVEL 8
|
||||
#define EEPP_PATCH_LEVEL 9
|
||||
#define EEPP_CODENAME "Bindu"
|
||||
|
||||
/** The compiled version of the library */
|
||||
|
||||
@@ -67,6 +67,10 @@ const String& UIComboBox::getText() {
|
||||
return mDropDownList->getText();
|
||||
}
|
||||
|
||||
void UIComboBox::setText( const String& text ) {
|
||||
mDropDownList->setText( text );
|
||||
}
|
||||
|
||||
void UIComboBox::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginAttributesTransaction();
|
||||
|
||||
|
||||
@@ -122,12 +122,12 @@ UIScrollBar* UIListBox::getHorizontalScrollBar() const {
|
||||
return mHScrollBar;
|
||||
}
|
||||
|
||||
void UIListBox::addListBoxItems( std::vector<String> Texts ) {
|
||||
mItems.reserve( mItems.size() + Texts.size() );
|
||||
mTexts.reserve( mTexts.size() + Texts.size() );
|
||||
void UIListBox::addListBoxItems( std::vector<String> texts ) {
|
||||
mItems.reserve( mItems.size() + texts.size() );
|
||||
mTexts.reserve( mTexts.size() + texts.size() );
|
||||
|
||||
for ( Uint32 i = 0; i < Texts.size(); i++ ) {
|
||||
mTexts.push_back( Texts[i] );
|
||||
for ( Uint32 i = 0; i < texts.size(); i++ ) {
|
||||
mTexts.push_back( std::move( texts[i] ) );
|
||||
mItems.push_back( NULL );
|
||||
}
|
||||
|
||||
|
||||
@@ -507,8 +507,7 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )
|
||||
->getTranslatorString( attribute.asString() ) );
|
||||
setText( getUISceneNode()->getTranslatorString( attribute.asString() ) );
|
||||
break;
|
||||
case PropertyId::Icon: {
|
||||
std::string val = attribute.asString();
|
||||
|
||||
@@ -1643,7 +1643,7 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setSize( getSize().getWidth(), attribute.asDpDimension( this ) );
|
||||
break;
|
||||
case PropertyId::WindowTitle:
|
||||
setTitle( attribute.asString() );
|
||||
setTitle( getUISceneNode()->getTranslatorString( attribute.asString() ) );
|
||||
break;
|
||||
case PropertyId::WindowOpacity:
|
||||
setWindowOpacity( (Uint8)eemin<Uint32>( (Uint32)attribute.asFloat() * 255.f, 255u ) );
|
||||
|
||||
@@ -393,7 +393,7 @@ TerminalDisplay::create( EE::Window::Window* window, Font* font, const Float& fo
|
||||
if ( program.empty() ) {
|
||||
const char* shellenv = getenv( "SHELL" );
|
||||
#ifdef _WIN32
|
||||
program = shellenv != nullptr ? shellenv : "cmd.exe";
|
||||
program = shellenv != nullptr ? shellenv : "powershell.exe";
|
||||
#else
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID
|
||||
program = shellenv != nullptr ? shellenv : "/bin/sh";
|
||||
|
||||
@@ -142,6 +142,7 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
|
||||
globalSearchBarConfig.escapeSequence =
|
||||
ini.getValueB( "global_search_bar", "escape_sequence", false );
|
||||
|
||||
term.shell = ini.getValue( "terminal", "shell" );
|
||||
term.fontSize = ini.getValue( "terminal", "font_size", "11dp" );
|
||||
term.colorScheme = ini.getValue( "terminal", "colorscheme", "eterm" );
|
||||
|
||||
@@ -246,6 +247,7 @@ void AppConfig::save( const std::vector<std::string>& recentFiles,
|
||||
ini.setValueB( "global_search_bar", "whole_word", globalSearchBarConfig.wholeWord );
|
||||
ini.setValueB( "global_search_bar", "escape_sequence", globalSearchBarConfig.escapeSequence );
|
||||
|
||||
ini.setValue( "terminal", "shell", term.shell );
|
||||
ini.setValue( "terminal", "font_size", term.fontSize.toString() );
|
||||
ini.setValue( "terminal", "colorscheme", term.colorScheme );
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ struct ProjectDocumentConfig {
|
||||
};
|
||||
|
||||
struct TerminalConfig {
|
||||
std::string shell;
|
||||
std::string colorScheme{ "eterm" };
|
||||
StyleSheetLength fontSize{ 11, StyleSheetLength::Dp };
|
||||
};
|
||||
|
||||
@@ -1034,7 +1034,8 @@ std::string App::getCurrentWorkingDir() const {
|
||||
if ( !mCurrentProject.empty() )
|
||||
return mCurrentProject;
|
||||
|
||||
if ( mSplitter && mSplitter->curEditorIsNotNull() && mSplitter->getCurEditor()->hasDocument() &&
|
||||
if ( mSplitter && mSplitter->curEditorIsNotNull() && mSplitter->curEditorExists() &&
|
||||
mSplitter->getCurEditor()->hasDocument() &&
|
||||
mSplitter->getCurEditor()->getDocument().hasFilepath() ) {
|
||||
return mSplitter->getCurEditor()->getDocument().getFileInfo().getDirectoryPath();
|
||||
}
|
||||
@@ -3084,7 +3085,7 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
|
||||
{ "cursor-pointer", 0xec09 },
|
||||
{ "drive", 0xedf8 },
|
||||
{ "refresh", 0xf064 },
|
||||
};
|
||||
{ "hearth-pulse", 0xee10 } };
|
||||
for ( const auto& icon : icons )
|
||||
iconTheme->add( UIGlyphIcon::New( icon.first, iconFont, icon.second ) );
|
||||
|
||||
|
||||
@@ -238,6 +238,10 @@ class App : public UICodeEditorSplitter::Client {
|
||||
t.setCommand( "fallback-font", [&] { openFontDialog( mConfig.ui.fallbackFont, false ); } );
|
||||
t.setCommand( "tree-view-configure-ignore-files", [&] { treeViewConfigureIgnoreFiles(); } );
|
||||
t.setCommand( "check-languages-health", [&] { checkLanguagesHealth(); } );
|
||||
t.setCommand( "configure-terminal-shell", [&] {
|
||||
if ( mTerminalManager )
|
||||
mTerminalManager->configureTerminalShell();
|
||||
} );
|
||||
mSplitter->registerSplitterCommands( t );
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class AutoCompletePlugin : public UICodeEditorPlugin {
|
||||
"Auto complete shows the completion popup as you type, so you can fill "
|
||||
"in long words by typing only a few characters.",
|
||||
AutoCompletePlugin::New,
|
||||
{ 0, 1, 0 } };
|
||||
{ 0, 2, 0 } };
|
||||
}
|
||||
|
||||
static UICodeEditorPlugin* New( PluginManager* pluginManager );
|
||||
|
||||
@@ -33,7 +33,7 @@ class FormatterPlugin : public UICodeEditorPlugin {
|
||||
static PluginDefinition Definition() {
|
||||
return {
|
||||
"autoformatter", "Auto Formatter", "Enables the code formatter/prettifier plugin.",
|
||||
FormatterPlugin::New, { 0, 1, 0 }, FormatterPlugin::NewSync };
|
||||
FormatterPlugin::New, { 0, 2, 0 }, FormatterPlugin::NewSync };
|
||||
}
|
||||
|
||||
static UICodeEditorPlugin* New( PluginManager* pluginManager );
|
||||
|
||||
@@ -55,7 +55,7 @@ class LinterPlugin : public UICodeEditorPlugin {
|
||||
"Use static code analysis tool used to flag programming errors, bugs, "
|
||||
"stylistic errors, and suspicious constructs.",
|
||||
LinterPlugin::New,
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 2, 0 },
|
||||
LinterPlugin::NewSync };
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class LSPClientPlugin : public UICodeEditorPlugin {
|
||||
public:
|
||||
static PluginDefinition Definition() {
|
||||
return { "lspclient", "LSP Client", "Language Server Protocol Client.",
|
||||
LSPClientPlugin::New, { 0, 0, 2 }, LSPClientPlugin::NewSync };
|
||||
LSPClientPlugin::New, { 0, 2, 0 }, LSPClientPlugin::NewSync };
|
||||
}
|
||||
|
||||
static UICodeEditorPlugin* New( PluginManager* pluginManager );
|
||||
|
||||
@@ -728,6 +728,13 @@ UIMenu* SettingsMenu::createTerminalMenu() {
|
||||
getKeybind( "terminal-rename" ) )
|
||||
->setId( "terminal-rename" );
|
||||
|
||||
mTerminalMenu->addSeparator();
|
||||
|
||||
mTerminalMenu
|
||||
->add( i18n( "configure_terminal_shell", "Configure Terminal Shell" ),
|
||||
findIcon( "terminal" ), getKeybind( "configure-terminal-shell" ) )
|
||||
->setId( "configure-terminal-shell" );
|
||||
|
||||
mTerminalMenu->addEventListener( Event::OnItemClicked, [&]( const Event* event ) {
|
||||
const std::string& id( event->getNode()->getId() );
|
||||
if ( mSplitter->getCurWidget() && mSplitter->getCurWidget()->isType( UI_TYPE_TERMINAL ) ) {
|
||||
@@ -1222,12 +1229,19 @@ UIPopUpMenu* SettingsMenu::createToolsMenu() {
|
||||
mToolsMenu->addSeparator();
|
||||
|
||||
mToolsMenu
|
||||
->add( i18n( "check_languages_health", "Check Languages Health" ), nullptr,
|
||||
getKeybind( "check-languages-health" ) )
|
||||
->add( i18n( "check_languages_health", "Check Languages Health" ),
|
||||
findIcon( "hearth-pulse" ), getKeybind( "check-languages-health" ) )
|
||||
->setId( "check-languages-health" );
|
||||
|
||||
mToolsMenu->addSeparator();
|
||||
|
||||
mToolsMenu
|
||||
->add( i18n( "configure_terminal_shell", "Configure Terminal Shell" ),
|
||||
findIcon( "terminal" ), getKeybind( "configure-terminal-shell" ) )
|
||||
->setId( "configure-terminal-shell" );
|
||||
|
||||
mToolsMenu->addSeparator();
|
||||
|
||||
mToolsMenu
|
||||
->add( i18n( "load_cur_dir_as_folder", "Load current document directory as folder" ),
|
||||
findIcon( "folder" ), getKeybind( "load-current-dir" ) )
|
||||
|
||||
@@ -89,6 +89,72 @@ void TerminalManager::setUseFrameBuffer( bool useFrameBuffer ) {
|
||||
mUseFrameBuffer = useFrameBuffer;
|
||||
}
|
||||
|
||||
void TerminalManager::configureTerminalShell() {
|
||||
const std::string layout( R"xml(
|
||||
<window layout_width="300dp" layout_height="150dp" window-flags="default|shadow" window-title='@string(shell_configuration, "Shell Configuration")'>
|
||||
<vbox lw="mp" lh="mp" padding="4dp">
|
||||
<vbox lw="mp" lh="0" lw8="1">
|
||||
<textview text='@string(configure_default_shell, "Configure default shell")' font-size="14dp" margin-bottom="8dp" />
|
||||
<ComboBox id="shell_combo" layout_width="match_parent" layout_height="wrap_content" selectedIndex="0" popup-to-root="true"></ComboBox>
|
||||
</vbox>
|
||||
<hbox layout_gravity="right">
|
||||
<pushbutton id="ok" text="@string(msg_box_ok, Ok)" icon="ok" />
|
||||
<pushbutton id="cancel" text="@string(msg_box_cancel, Cancel)" margin-left="8dp" icon="cancel" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
</window>
|
||||
)xml" );
|
||||
UIWindow* window = mApp->getUISceneNode()->loadLayoutFromString( layout )->asType<UIWindow>();
|
||||
UIComboBox* shellCombo = window->find<UIComboBox>( "shell_combo" );
|
||||
UIPushButton* ok = window->find<UIPushButton>( "ok" );
|
||||
UIPushButton* cancel = window->find<UIPushButton>( "cancel" );
|
||||
const std::vector<std::string> list{
|
||||
"bash", "sh", "zsh", "fish", "nu", "csh", "tcsh", "ksh", "dash", "cmd", "powershell",
|
||||
};
|
||||
std::vector<String> found;
|
||||
for ( const auto& i : list ) {
|
||||
std::string f( Sys::which( i ) );
|
||||
if ( !f.empty() )
|
||||
found.emplace_back( std::move( f ) );
|
||||
}
|
||||
shellCombo->getListBox()->addListBoxItems( found );
|
||||
const char* shellEnv = std::getenv( "SHELL" );
|
||||
if ( !mApp->termConfig().shell.empty() ) {
|
||||
shellCombo->getListBox()->setSelected( mApp->termConfig().shell );
|
||||
shellCombo->setText( mApp->termConfig().shell );
|
||||
} else if ( shellEnv ) {
|
||||
std::string shellEnvStr( FileSystem::fileExists( shellEnv ) ? shellEnv
|
||||
: Sys::which( shellEnv ) );
|
||||
if ( !shellEnvStr.empty() )
|
||||
shellCombo->getListBox()->setSelected( shellEnvStr );
|
||||
}
|
||||
auto setShellFn = []( App* app, UIWindow* window, UIComboBox* shellCombo ) {
|
||||
std::string shell( shellCombo->getText().toUtf8() );
|
||||
if ( !Sys::which( shell ).empty() || FileSystem::fileExists( shell ) ) {
|
||||
app->getConfig().term.shell = shell;
|
||||
window->closeWindow();
|
||||
} else {
|
||||
app->errorMsgBox( app->i18n(
|
||||
"shell_not_found", "The shell selected was not found in the file system.\nMake "
|
||||
"sure that the shell is visible in your PATH" ) );
|
||||
}
|
||||
};
|
||||
ok->setFocus();
|
||||
ok->addMouseClickListener(
|
||||
[&, window, shellCombo]( const MouseEvent* ) { setShellFn( mApp, window, shellCombo ); },
|
||||
MouseButton::EE_BUTTON_LEFT );
|
||||
cancel->addMouseClickListener( [window]( const MouseEvent* ) { window->closeWindow(); },
|
||||
EE_BUTTON_LEFT );
|
||||
window->on( Event::KeyDown, [window]( const Event* event ) {
|
||||
if ( event->asKeyEvent()->getKeyCode() == KEY_ESCAPE )
|
||||
window->closeWindow();
|
||||
} );
|
||||
window->center();
|
||||
window->on( Event::OnWindowReady, [ok] ( const Event* ) {
|
||||
ok->setFocus();
|
||||
} );
|
||||
}
|
||||
|
||||
UIMenu* TerminalManager::createColorSchemeMenu() {
|
||||
mColorSchemeMenuesCreatedWithHeight = mApp->uiSceneNode()->getPixelsSize().getHeight();
|
||||
size_t maxItems = 19;
|
||||
@@ -140,8 +206,7 @@ void TerminalManager::updateMenuColorScheme( UIMenuSubMenu* colorSchemeMenu ) {
|
||||
}
|
||||
|
||||
UITerminal* TerminalManager::createNewTerminal( const std::string& title, UITabWidget* inTabWidget,
|
||||
const std::string& workingDir,
|
||||
const std::string& program,
|
||||
const std::string& workingDir, std::string program,
|
||||
const std::vector<std::string>& args ) {
|
||||
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
UIMessageBox* msgBox = UIMessageBox::New(
|
||||
@@ -179,6 +244,9 @@ UITerminal* TerminalManager::createNewTerminal( const std::string& title, UITabW
|
||||
}
|
||||
}
|
||||
|
||||
if ( program.empty() && !mApp->termConfig().shell.empty() )
|
||||
program = mApp->termConfig().shell;
|
||||
|
||||
UITerminal* term = UITerminal::New(
|
||||
mApp->getTerminalFont() ? mApp->getTerminalFont() : mApp->getFontMono(),
|
||||
mApp->termConfig().fontSize.asPixels( 0, Sizef(), mApp->getDisplayDPI() ), initialSize,
|
||||
|
||||
@@ -17,8 +17,7 @@ class TerminalManager {
|
||||
|
||||
UITerminal* createNewTerminal( const std::string& title = "",
|
||||
UITabWidget* inTabWidget = nullptr,
|
||||
const std::string& workingDir = "",
|
||||
const std::string& program = "",
|
||||
const std::string& workingDir = "", std::string program = "",
|
||||
const std::vector<std::string>& args = {} );
|
||||
|
||||
void applyTerminalColorScheme( const TerminalColorScheme& colorScheme );
|
||||
@@ -47,6 +46,8 @@ class TerminalManager {
|
||||
|
||||
void setUseFrameBuffer( bool useFrameBuffer );
|
||||
|
||||
void configureTerminalShell();
|
||||
|
||||
protected:
|
||||
App* mApp;
|
||||
std::string mTerminalColorSchemesPath;
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace EE;
|
||||
|
||||
#define ECODE_MAJOR_VERSION 0
|
||||
#define ECODE_MINOR_VERSION 4
|
||||
#define ECODE_PATCH_LEVEL 6
|
||||
#define ECODE_PATCH_LEVEL 7
|
||||
#define ECODE_CODENAME "Vajra"
|
||||
|
||||
/** The compiled version of the library */
|
||||
|
||||
Reference in New Issue
Block a user