mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
ecode: Added font and font size terminal config. Added many i18n translate calls. Improved keybindings and commands when using terminal. Some minor bug fixing. Added terminal splitting keybindings.
This commit is contained in:
@@ -59,6 +59,10 @@ class EE_API KeyBindings {
|
||||
|
||||
bool existsKeybind( const Shortcut& keys );
|
||||
|
||||
void removeCommandKeybind( const std::string& command );
|
||||
|
||||
void removeCommandsKeybind( const std::vector<std::string>& command );
|
||||
|
||||
std::string getCommandFromKeyBind( const Shortcut& keys );
|
||||
|
||||
std::string getCommandKeybindString( const std::string& command ) const;
|
||||
|
||||
@@ -117,6 +117,8 @@ class EE_API UICodeEditorSplitter {
|
||||
|
||||
void forEachWidgetStoppable( std::function<bool( UIWidget* )> run ) const;
|
||||
|
||||
void forEachWidget( std::function<void( UIWidget* )> run ) const;
|
||||
|
||||
void forEachEditor( std::function<void( UICodeEditor* )> run ) const;
|
||||
|
||||
void forEachDoc( std::function<void( TextDocument& doc )> run ) const;
|
||||
@@ -171,6 +173,8 @@ class EE_API UICodeEditorSplitter {
|
||||
|
||||
bool curWidgetExists() const;
|
||||
|
||||
UICodeEditor* getSomeEditor();
|
||||
|
||||
protected:
|
||||
UISceneNode* mUISceneNode{ nullptr };
|
||||
UICodeEditor* mCurEditor{ nullptr };
|
||||
|
||||
@@ -96,7 +96,7 @@ KeyBindings::Shortcut KeyBindings::getShortcutFromString( const std::string& key
|
||||
}
|
||||
|
||||
void KeyBindings::removeKeybind( const KeyBindings::Shortcut& keys ) {
|
||||
auto it = mShortcuts.find( keys.key );
|
||||
auto it = mShortcuts.find( keys.toUint64() );
|
||||
if ( it != mShortcuts.end() ) {
|
||||
mShortcuts.erase( it );
|
||||
}
|
||||
@@ -106,6 +106,19 @@ bool KeyBindings::existsKeybind( const KeyBindings::Shortcut& keys ) {
|
||||
return mShortcuts.find( keys.toUint64() ) != mShortcuts.end();
|
||||
}
|
||||
|
||||
void KeyBindings::removeCommandKeybind( const std::string& command ) {
|
||||
auto kbIt = mKeybindingsInvert.find( command );
|
||||
if ( kbIt != mKeybindingsInvert.end() ) {
|
||||
removeKeybind( kbIt->second );
|
||||
mKeybindingsInvert.erase( command );
|
||||
}
|
||||
}
|
||||
|
||||
void KeyBindings::removeCommandsKeybind( const std::vector<std::string>& commands ) {
|
||||
for ( auto& cmd : commands )
|
||||
removeCommandKeybind( cmd );
|
||||
}
|
||||
|
||||
std::string KeyBindings::getCommandFromKeyBind( const KeyBindings::Shortcut& keys ) {
|
||||
auto it = mShortcuts.find( sanitizeShortcut( keys ) );
|
||||
if ( it != mShortcuts.end() ) {
|
||||
|
||||
@@ -630,6 +630,15 @@ void UICodeEditorSplitter::forEachWidgetStoppable( std::function<bool( UIWidget*
|
||||
}
|
||||
}
|
||||
|
||||
void UICodeEditorSplitter::forEachWidget( std::function<void( UIWidget* )> run ) const {
|
||||
for ( auto tabWidget : mTabWidgets ) {
|
||||
for ( size_t i = 0; i < tabWidget->getTabCount(); i++ ) {
|
||||
if ( tabWidget->getTab( i )->getOwnedWidget()->isWidget() )
|
||||
run( tabWidget->getTab( i )->getOwnedWidget()->asType<UIWidget>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UICodeEditorSplitter::forEachDocStoppable( std::function<bool( TextDocument& )> run ) const {
|
||||
for ( auto tabWidget : mTabWidgets ) {
|
||||
for ( size_t i = 0; i < tabWidget->getTabCount(); i++ ) {
|
||||
@@ -966,6 +975,15 @@ bool UICodeEditorSplitter::curWidgetExists() const {
|
||||
return found || mCurWidget == nullptr;
|
||||
}
|
||||
|
||||
UICodeEditor* UICodeEditorSplitter::getSomeEditor() {
|
||||
UICodeEditor* ed = nullptr;
|
||||
forEachEditorStoppable( [&]( UICodeEditor* editor ) {
|
||||
ed = editor;
|
||||
return true;
|
||||
} );
|
||||
return ed;
|
||||
}
|
||||
|
||||
UICodeEditor* UICodeEditorSplitter::getCurEditor() const {
|
||||
eeASSERT( curEditorExists() );
|
||||
return mCurEditor;
|
||||
|
||||
@@ -189,7 +189,11 @@ class TerminalDisplay : public ITerminalDisplay {
|
||||
virtual void onKeyDown( const Keycode& keyCode, const Uint32& chr, const Uint32& mod,
|
||||
const Scancode& scancode );
|
||||
|
||||
Float getFontSize() const;
|
||||
Font* getFont() const;
|
||||
|
||||
void setFont( Font* font );
|
||||
|
||||
const Float& getFontSize() const;
|
||||
|
||||
void setFontSize( const Float& FontSize );
|
||||
|
||||
|
||||
@@ -43,6 +43,14 @@ class UITerminal : public UIWidget {
|
||||
|
||||
KeyBindings& getKeyBindings();
|
||||
|
||||
Float getFontSize() const;
|
||||
|
||||
void setFontSize( Float fontSize );
|
||||
|
||||
Font* getFont() const;
|
||||
|
||||
void setFont( Font* font );
|
||||
|
||||
void setKeyBindings( const KeyBindings& keyBindings );
|
||||
|
||||
void addKeyBindingString( const std::string& shortcut, const std::string& command );
|
||||
@@ -65,7 +73,9 @@ class UITerminal : public UIWidget {
|
||||
|
||||
bool hasCommand( const std::string& command );
|
||||
|
||||
static std::string getExclusiveModeToggleCommandName() { return "toggle-exclusive-mode"; }
|
||||
static std::string getExclusiveModeToggleCommandName() {
|
||||
return "terminal-toggle-exclusive-mode";
|
||||
}
|
||||
|
||||
bool getExclusiveMode() const;
|
||||
|
||||
|
||||
@@ -1383,7 +1383,18 @@ void TerminalDisplay::onKeyDown( const Keycode& keyCode, const Uint32& /*chr*/,
|
||||
}
|
||||
}
|
||||
|
||||
Float TerminalDisplay::getFontSize() const {
|
||||
Font* TerminalDisplay::getFont() const {
|
||||
return mFont;
|
||||
}
|
||||
|
||||
void TerminalDisplay::setFont( Font* font ) {
|
||||
if ( mFont != font ) {
|
||||
mFont = font;
|
||||
onSizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
const Float& TerminalDisplay::getFontSize() const {
|
||||
return mFontSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,8 @@ void UITerminal::scheduledUpdate( const Time& ) {
|
||||
mVScroll->setVisible( !mTerm->getTerminal()->tisaltscr() )
|
||||
->setEnabled( !mTerm->getTerminal()->tisaltscr() );
|
||||
} else if ( ScrollBarMode::Auto == mVScrollMode ) {
|
||||
if ( mViewType == Inclusive && mMouseClock.getElapsedTime() > Seconds( 1 ) )
|
||||
if ( mViewType == Inclusive && mMouseClock.getElapsedTime() > Seconds( 1 ) &&
|
||||
!mVScroll->isDragging() )
|
||||
mVScroll->setVisible( false )->setEnabled( false );
|
||||
}
|
||||
}
|
||||
@@ -303,6 +304,22 @@ KeyBindings& UITerminal::getKeyBindings() {
|
||||
return mKeyBindings;
|
||||
}
|
||||
|
||||
Float UITerminal::getFontSize() const {
|
||||
return mTerm->getFontSize();
|
||||
}
|
||||
|
||||
void UITerminal::setFontSize( Float fontSize ) {
|
||||
mTerm->setFontSize( fontSize );
|
||||
}
|
||||
|
||||
Font* UITerminal::getFont() const {
|
||||
return mTerm->getFont();
|
||||
}
|
||||
|
||||
void UITerminal::setFont( Font* font ) {
|
||||
mTerm->setFont( font );
|
||||
}
|
||||
|
||||
void UITerminal::setKeyBindings( const KeyBindings& keyBindings ) {
|
||||
mKeyBindings = keyBindings;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
|
||||
ui.panelPosition = panelPositionFromString( ini.getValue( "ui", "panel_position", "left" ) );
|
||||
ui.serifFont = ini.getValue( "ui", "serif_font", "fonts/NotoSans-Regular.ttf" );
|
||||
ui.monospaceFont = ini.getValue( "ui", "monospace_font", "fonts/DejaVuSansMono.ttf" );
|
||||
ui.terminalFont =
|
||||
ini.getValue( "ui", "terminal_font", "fonts/DejaVuSansMonoNerdFontComplete.ttf" );
|
||||
ui.colorScheme = ini.getValue( "ui", "ui_color_scheme", "dark" ) == "light"
|
||||
? ColorSchemePreference::Light
|
||||
: ColorSchemePreference::Dark;
|
||||
@@ -115,6 +117,8 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
|
||||
globalSearchBarConfig.escapeSequence =
|
||||
ini.getValueB( "global_search_bar", "escape_sequence", false );
|
||||
|
||||
term.fontSize = ini.getValue( "terminal", "font_size", "11dp" );
|
||||
|
||||
iniInfo = FileInfo( ini.path() );
|
||||
}
|
||||
|
||||
@@ -163,6 +167,7 @@ void AppConfig::save( const std::vector<std::string>& recentFiles,
|
||||
ini.setValue( "ui", "panel_position", panelPositionToString( ui.panelPosition ) );
|
||||
ini.setValue( "ui", "serif_font", ui.serifFont );
|
||||
ini.setValue( "ui", "monospace_font", ui.monospaceFont );
|
||||
ini.setValue( "ui", "terminal_font", ui.terminalFont );
|
||||
ini.setValue( "ui", "ui_color_scheme",
|
||||
ui.colorScheme == ColorSchemePreference::Light ? "light" : "dark" );
|
||||
ini.setValueB( "document", "trim_trailing_whitespaces", doc.trimTrailingWhitespaces );
|
||||
@@ -198,6 +203,8 @@ 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", "font_size", term.fontSize.toString() );
|
||||
|
||||
ini.writeFile();
|
||||
iniState.writeFile();
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ class App;
|
||||
enum class PanelPosition { Left, Right };
|
||||
|
||||
struct UIConfig {
|
||||
StyleSheetLength fontSize{ 12, StyleSheetLength::Dp };
|
||||
StyleSheetLength fontSize{ 11, StyleSheetLength::Dp };
|
||||
bool showSidePanel{ true };
|
||||
PanelPosition panelPosition{ PanelPosition::Left };
|
||||
std::string serifFont;
|
||||
std::string monospaceFont;
|
||||
std::string terminalFont;
|
||||
ColorSchemePreference colorScheme{ ColorSchemePreference::Dark };
|
||||
};
|
||||
|
||||
@@ -43,7 +44,7 @@ struct WindowConfig {
|
||||
|
||||
struct CodeEditorConfig {
|
||||
std::string colorScheme{ "lite" };
|
||||
StyleSheetLength fontSize{ 12, StyleSheetLength::Dp };
|
||||
StyleSheetLength fontSize{ 11, StyleSheetLength::Dp };
|
||||
bool showLineNumbers{ true };
|
||||
bool showWhiteSpaces{ true };
|
||||
bool highlightMatchingBracket{ true };
|
||||
@@ -98,10 +99,15 @@ struct ProjectDocumentConfig {
|
||||
ProjectDocumentConfig( const DocumentConfig& doc ) { this->doc = doc; }
|
||||
};
|
||||
|
||||
struct TerminalConfig {
|
||||
StyleSheetLength fontSize{ 11, StyleSheetLength::Dp };
|
||||
};
|
||||
|
||||
struct AppConfig {
|
||||
WindowConfig window;
|
||||
CodeEditorConfig editor;
|
||||
DocumentConfig doc;
|
||||
TerminalConfig term;
|
||||
UIConfig ui;
|
||||
IniFile ini;
|
||||
IniFile iniState;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,6 +60,8 @@ class App : public UICodeEditorSplitter::Client {
|
||||
|
||||
std::vector<std::string> getUnlockedCommands();
|
||||
|
||||
bool isUnlockedCommand( const std::string& command );
|
||||
|
||||
void saveAll();
|
||||
|
||||
ProjectDirectoryTree* getDirTree() const;
|
||||
@@ -83,10 +85,12 @@ class App : public UICodeEditorSplitter::Client {
|
||||
|
||||
void createNewTerminal( const std::string& title = "", UITabWidget* inTabWidget = nullptr );
|
||||
|
||||
std::map<KeyBindings::Shortcut, std::string> getAppKeybindings();
|
||||
std::map<KeyBindings::Shortcut, std::string> getTerminalKeybindings();
|
||||
|
||||
void fullscreenToggle();
|
||||
|
||||
void downloadFileWebDialog();
|
||||
|
||||
protected:
|
||||
EE::Window::Window* mWindow{ nullptr };
|
||||
UISceneNode* mUISceneNode{ nullptr };
|
||||
@@ -114,7 +118,7 @@ class App : public UICodeEditorSplitter::Client {
|
||||
UIPopUpMenu* mProjectMenu{ nullptr };
|
||||
UISplitter* mProjectSplitter{ nullptr };
|
||||
UITabWidget* mSidePanel{ nullptr };
|
||||
UICodeEditorSplitter* mEditorSplitter{ nullptr };
|
||||
UICodeEditorSplitter* mSplitter{ nullptr };
|
||||
std::string mInitColorScheme;
|
||||
std::unordered_map<std::string, std::string> mKeybindings;
|
||||
std::unordered_map<std::string, std::string> mKeybindingsInvert;
|
||||
@@ -281,6 +285,12 @@ class App : public UICodeEditorSplitter::Client {
|
||||
void createProjectTreeMenu( const FileInfo& file );
|
||||
|
||||
void setUIColorScheme( const ColorSchemePreference& colorScheme );
|
||||
|
||||
UIMessageBox* errorMsgBox( const String& msg );
|
||||
|
||||
UIMessageBox* fileAlreadyExistsMsgBox();
|
||||
|
||||
void renameFile( const FileInfo& file );
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
Reference in New Issue
Block a user