Skip to content

Commit

Permalink
Fixes in Git plugin staging.
Browse files Browse the repository at this point in the history
Added a value viewer window in debugger.
  • Loading branch information
SpartanJ committed Jan 25, 2025
1 parent 4bbcfdd commit c339914
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 85 deletions.
4 changes: 4 additions & 0 deletions src/eepp/ui/uiwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ std::string UIWindow::getWindowFlagsString() const {
flags.push_back( "framebuffer" );
if ( getWinFlags() & UI_WIN_COLOR_BUFFER )
flags.push_back( "colorbuffer" );
if ( getWinFlags() & UI_WIN_EPHEMERAL )
flags.push_back( "ephemeral" );
return String::join( flags, '|' );
}

Expand Down Expand Up @@ -1719,6 +1721,8 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
winflags |= UI_WIN_FRAME_BUFFER;
else if ( "colorbuffer" == cur )
winflags |= UI_WIN_COLOR_BUFFER;
else if ( "ephemeral" == cur )
winflags |= UI_WIN_EPHEMERAL;
}

/// TODO: WinFlags should replace old winFlags
Expand Down
104 changes: 50 additions & 54 deletions src/tools/ecode/ecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,71 +1782,67 @@ std::map<KeyBindings::Shortcut, std::string> App::getDefaultKeybindings() {
std::map<KeyBindings::Shortcut, std::string> App::getLocalKeybindings() {
return {
{ { KEY_RETURN, KEYMOD_LALT | KEYMOD_LCTRL }, "fullscreen-toggle" },
{ { KEY_F3, KEYMOD_NONE }, "repeat-find" }, { { KEY_F3, KEYMOD_SHIFT }, "find-prev" },
{ { KEY_F12, KEYMOD_NONE }, "console-toggle" },
{ { KEY_F, KeyMod::getDefaultModifier() }, "find-replace" },
{ { KEY_Q, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "close-app" },
{ { KEY_O, KeyMod::getDefaultModifier() }, "open-file" },
{ { KEY_W, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "download-file-web" },
{ { KEY_O, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-folder" },
{ { KEY_F11, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "debug-widget-tree-view" },
{ { KEY_K, KeyMod::getDefaultModifier() }, "open-locatebar" },
{ { KEY_P, KeyMod::getDefaultModifier() }, "open-command-palette" },
{ { KEY_F, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-global-search" },
{ { KEY_L, KeyMod::getDefaultModifier() }, "go-to-line" },
{ { KEY_F3, KEYMOD_NONE }, "repeat-find" },
{ { KEY_F3, KEYMOD_SHIFT }, "find-prev" },
{ { KEY_F12, KEYMOD_NONE }, "console-toggle" },
{ { KEY_F, KeyMod::getDefaultModifier() }, "find-replace" },
{ { KEY_Q, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "close-app" },
{ { KEY_O, KeyMod::getDefaultModifier() }, "open-file" },
{ { KEY_W, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "download-file-web" },
{ { KEY_O, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-folder" },
{ { KEY_F11, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "debug-widget-tree-view" },
{ { KEY_K, KeyMod::getDefaultModifier() }, "open-locatebar" },
{ { KEY_P, KeyMod::getDefaultModifier() }, "open-command-palette" },
{ { KEY_F, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-global-search" },
{ { KEY_L, KeyMod::getDefaultModifier() }, "go-to-line" },
#if EE_PLATFORM == EE_PLATFORM_MACOS
{ { KEY_M, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "menu-toggle" },
{ { KEY_M, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "menu-toggle" },
#else
{ { KEY_M, KeyMod::getDefaultModifier() }, "menu-toggle" },
{ { KEY_M, KeyMod::getDefaultModifier() }, "menu-toggle" },
#endif
{ { KEY_S, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "save-all" },
{ { KEY_F9, KEYMOD_LALT }, "switch-side-panel" },
{ { KEY_J, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-left" },
{ { KEY_L, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-right" },
{ { KEY_I, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-top" },
{ { KEY_K, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-bottom" },
{ { KEY_S, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-swap" },
{ { KEY_T, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"reopen-closed-tab" },
{ { KEY_1, KEYMOD_LALT }, "toggle-status-locate-bar" },
{ { KEY_2, KEYMOD_LALT }, "toggle-status-global-search-bar" },
{ { KEY_3, KEYMOD_LALT }, "toggle-status-terminal" },
{ { KEY_4, KEYMOD_LALT }, "toggle-status-build-output" },
{ { KEY_5, KEYMOD_LALT }, "toggle-status-app-output" },
{ { KEY_B, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-start" },
{ { KEY_C, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-cancel" },
{ { KEY_R, KeyMod::getDefaultModifier() }, "project-build-and-run" },
{ { KEY_O, KEYMOD_LALT | KEYMOD_SHIFT }, "show-open-documents" },
{ { KEY_K, KeyMod::getDefaultModifier() | KEYMOD_SHIFT },
"open-workspace-symbol-search" },
{ { KEY_P, KeyMod::getDefaultModifier() | KEYMOD_SHIFT },
"open-document-symbol-search" },
{ { KEY_N, KEYMOD_SHIFT | KEYMOD_LALT }, "create-new-window" },
{ { KEY_S, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "save-all" },
{ { KEY_F9, KEYMOD_LALT }, "switch-side-panel" },
{ { KEY_J, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-left" },
{ { KEY_L, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-right" },
{ { KEY_I, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-top" },
{ { KEY_K, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-bottom" },
{ { KEY_S, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"terminal-split-swap" },
{ { KEY_T, KeyMod::getDefaultModifier() | KEYMOD_LALT | KEYMOD_SHIFT },
"reopen-closed-tab" },
{ { KEY_1, KEYMOD_LALT }, "toggle-status-locate-bar" },
{ { KEY_2, KEYMOD_LALT }, "toggle-status-global-search-bar" },
{ { KEY_3, KEYMOD_LALT }, "toggle-status-terminal" },
{ { KEY_4, KEYMOD_LALT }, "toggle-status-build-output" },
{ { KEY_5, KEYMOD_LALT }, "toggle-status-app-output" },
{ { KEY_B, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-start" },
{ { KEY_C, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "project-build-cancel" },
{ { KEY_R, KeyMod::getDefaultModifier() }, "project-build-and-run" },
{ { KEY_O, KEYMOD_LALT | KEYMOD_SHIFT }, "show-open-documents" },
{ { KEY_K, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-workspace-symbol-search" },
{ { KEY_P, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-document-symbol-search" },
{ { KEY_N, KEYMOD_SHIFT | KEYMOD_LALT }, "create-new-window" },
};
}

// Old keybindings will be rebinded to the new keybindings when they are still set to the old
// keybindind
std::map<std::string, std::string> App::getMigrateKeybindings() {
return {
{ "fullscreen-toggle", "alt+return" }, { "switch-to-tab-1", "alt+1" },
{ "switch-to-tab-2", "alt+2" }, { "switch-to-tab-3", "alt+3" },
{ "switch-to-tab-4", "alt+4" }, { "switch-to-tab-5", "alt+5" },
{ "switch-to-tab-6", "alt+6" }, { "switch-to-tab-7", "alt+7" },
{ "switch-to-tab-8", "alt+8" }, { "switch-to-tab-9", "alt+9" },
{ "switch-to-last-tab", "alt+0" },
return { { "fullscreen-toggle", "alt+return" }, { "switch-to-tab-1", "alt+1" },
{ "switch-to-tab-2", "alt+2" }, { "switch-to-tab-3", "alt+3" },
{ "switch-to-tab-4", "alt+4" }, { "switch-to-tab-5", "alt+5" },
{ "switch-to-tab-6", "alt+6" }, { "switch-to-tab-7", "alt+7" },
{ "switch-to-tab-8", "alt+8" }, { "switch-to-tab-9", "alt+9" },
{ "switch-to-last-tab", "alt+0" },
#if EE_PLATFORM == EE_PLATFORM_MACOS
{ "menu-toggle", "mod+shift+m" },
{ "menu-toggle", "mod+shift+m" },
#endif
{ "lock-toggle", "mod+shift+l" }, { "debug-widget-tree-view", "f11" }, {
"project-build-and-run", "f5"
}
};
{ "lock-toggle", "mod+shift+l" }, { "debug-widget-tree-view", "f11" },
{ "project-build-and-run", "f5" } };
}

std::vector<std::string> App::getUnlockedCommands() {
Expand Down
16 changes: 11 additions & 5 deletions src/tools/ecode/iconmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ void IconManager::init( UISceneNode* sceneNode, FontTrueType* iconFont, FontTrue
{ "debug-step-out", 0xead5 },
{ "debug-step-over", 0xead6 },
{ "debug-stop", 0xead7 },
{ "chrome-close", 0xeab8 } };
{ "chrome-close", 0xeab8 },
{ "diff-added", 0xeadc },
{ "diff-removed", 0xeadf },
{ "eye", 0xea70 },
{ "eye-closed", 0xeae7 } };

for ( const auto& icon : codIcons )
iconTheme->add( UIGlyphIcon::New( icon.first, codIconFont, icon.second ) );
Expand All @@ -282,12 +286,14 @@ void IconManager::init( UISceneNode* sceneNode, FontTrueType* iconFont, FontTrue
"4.0363-3.8406'/></g></svg>" ) );

iconTheme->add( UISVGIcon::New(
"debug-stackframe", "<svg fill='#fff' viewBox='0 0 16 16'><path d='M14.5 7.15l-4.26-4.74L9.31 2H4.25L3 "
"3.25v9.48l1.25 1.25h5.06l.93-.42 4.26-4.74V7.15zm-5.19 "
"5.58H4.25V3.25h5.06l4.26 4.73-4.26 4.75z' /></svg>" ) );
"debug-stackframe",
"<svg fill='#fff' viewBox='0 0 16 16'><path d='M14.5 7.15l-4.26-4.74L9.31 2H4.25L3 "
"3.25v9.48l1.25 1.25h5.06l.93-.42 4.26-4.74V7.15zm-5.19 "
"5.58H4.25V3.25h5.06l4.26 4.73-4.26 4.75z' /></svg>" ) );

iconTheme->add( UISVGIcon::New(
"circle-perfect", "<svg fill='#fff' viewBox='0 0 16 16'><circle cx='8' cy='8' r='7' /></svg>" ) );
"circle-perfect",
"<svg fill='#fff' viewBox='0 0 16 16'><circle cx='8' cy='8' r='7' /></svg>" ) );

sceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme );
}
Expand Down
35 changes: 29 additions & 6 deletions src/tools/ecode/plugins/debugger/debuggerclientlistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#include "../../notificationcenter.hpp"
#include "../../statusappoutputcontroller.hpp"
#include "debuggerplugin.hpp"
#include "eepp/window/clipboard.hpp"
#include "models/stackmodel.hpp"
#include "models/threadsmodel.hpp"
#include "models/variablesmodel.hpp"
#include <eepp/system/filesystem.hpp>
#include <eepp/ui/uipopupmenu.hpp>
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uitooltip.hpp>
#include <eepp/window/clipboard.hpp>
#include <eepp/window/input.hpp>

namespace ecode {
Expand Down Expand Up @@ -135,6 +137,10 @@ void DebuggerClientListener::initUI() {
->setId( "debugger_copy_variable_memory_reference" );
}

menu->add( context->i18n( "debugger_value_viewer", "Value Viewer" ),
context->findIcon( "eye" ) )
->setId( "debugger_value_viewer" );

menu->on( Event::OnItemClicked, [this, var = std::move( var )]( const Event* event ) {
UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
std::string id( item->getId() );
Expand All @@ -150,14 +156,26 @@ void DebuggerClientListener::initUI() {
} else if ( id == "debugger_copy_variable_memory_reference" ) {
mPlugin->getUISceneNode()->getWindow()->getClipboard()->setText(
*var.memoryReference );
} else if ( id == "debugger_value_viewer" ) {
static constexpr auto VALUE_VIEWER_LAYOUT = R"html(
<window id="process_picker" lw="250dp" lh="250dp" padding="4dp" window-flags="default|ephemeral">
<vbox lw="mp" lh="mp">
<TextEdit id="value_input" lw="mp" lh="0dp" lw8="1" wordwrap="true" />
</vbox>
</window>
)html";
UIWindow* win = mPlugin->getUISceneNode()
->loadLayoutFromString( VALUE_VIEWER_LAYOUT )
->asType<UIWindow>();
win->setTitle( String::format( "%s:", var.name ) );
UITextEdit* input = win->find( "value_input" )->asType<UITextEdit>();
input->setText( var.value );
win->center();
win->showWhenReady();
}
} );

Vector2f pos( context->getWindow()->getInput()->getMousePos().asFloat() );
menu->nodeToWorldTranslation( pos );
UIMenu::findBestMenuPos( pos, menu );
menu->setPixelsPosition( pos );
menu->show();
menu->showOverMouseCursor();
}
} );

Expand Down Expand Up @@ -223,6 +241,11 @@ void DebuggerClientListener::debuggeeExited( int /*exitCode*/ ) {
void DebuggerClientListener::debuggeeStopped( const StoppedEvent& event ) {
Log::debug( "DebuggerClientListener::debuggeeStopped: reason %s", event.reason );

for ( auto& [editor, _] : mPlugin->mEditors ) {
if ( editor->getTooltip() )
editor->getTooltip()->hide();
}

if ( "exception" == event.reason ) {
if ( event.description ) {
mPlugin->getPluginContext()->getNotificationCenter()->addNotification(
Expand Down
8 changes: 6 additions & 2 deletions src/tools/ecode/plugins/debugger/debuggerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,11 @@ void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) {
if ( getStatusDebuggerController() )
getStatusDebuggerController()->toggle();
} );

doc->setCommand( "show-debugger-tab", [this]() {
if ( mTab )
mTab->setTabSelected();
} );
}

void DebuggerPlugin::onRegisterEditor( UICodeEditor* editor ) {
Expand Down Expand Up @@ -2136,8 +2141,7 @@ void DebuggerPlugin::displayTooltip( UICodeEditor* editor, const std::string& ex
mHoverTooltip->showWhenReady();
}

bool DebuggerPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& position,
const Uint32& flags ) {
bool DebuggerPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& position, const Uint32& ) {

if ( !mDebugger || !mListener || !mDebugger->isServerConnected() ||
mDebuggingState != StatusDebuggerController::State::Paused ) {
Expand Down
1 change: 1 addition & 0 deletions src/tools/ecode/plugins/debugger/debuggerplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class DebuggerPlugin : public PluginBase {
UIWindow* processPicker();

bool resume( int threadId, bool singleThread = false );

};

} // namespace ecode
36 changes: 19 additions & 17 deletions src/tools/ecode/plugins/git/gitplugin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "gitbranchmodel.hpp"
#include "gitplugin.hpp"
#include "gitbranchmodel.hpp"
#include "gitstatusmodel.hpp"
#include <eepp/graphics/primitives.hpp>
#include <eepp/scene/scenemanager.hpp>
Expand Down Expand Up @@ -1609,37 +1609,39 @@ void GitPlugin::buildSidePanelTab() {
switch ( modelEvent->getModelEventType() ) {
case ModelEventType::OpenMenu: {
const auto* status = model->statusType( modelEvent->getModelIndex() );
if ( status->type == Git::GitStatusType::Staged ||
status->type == Git::GitStatusType::Untracked ||
status->type == Git::GitStatusType::Changed ) {
auto type = status->type;
if ( type == Git::GitStatusType::Staged ||
type == Git::GitStatusType::Untracked ||
type == Git::GitStatusType::Changed ) {
std::string repoPath;
if ( !status->files.empty() )
repoPath = mGit->repoPath( status->files.front().file );

UIPopUpMenu* menu = UIPopUpMenu::New();
menu->setId( "git_status_type_menu" );

if ( status->type == Git::GitStatusType::Staged ) {
if ( type == Git::GitStatusType::Staged ) {
menuAdd( menu, "git-commit", i18n( "git_commit", "Commit" ),
"git-commit" );
menuAdd( menu, "git-diff-staged",
i18n( "git_diff_staged", "Diff Staged" ), "diff-multiple" );
menuAdd( menu, "git-unstage-all",
i18n( "git_unstage_all", "Unstage All" ) );
i18n( "git_unstage_all", "Unstage All" ), "diff-removed" );
}

if ( status->type == Git::GitStatusType::Untracked ||
status->type == Git::GitStatusType::Changed )
menuAdd( menu, "git-stage-all", i18n( "git_stage_all", "Stage All" ) );
if ( type == Git::GitStatusType::Untracked ||
type == Git::GitStatusType::Changed )
menuAdd( menu, "git-stage-all", i18n( "git_stage_all", "Stage All" ),
"diff-added" );

if ( status->type == Git::GitStatusType::Changed ) {
if ( type == Git::GitStatusType::Changed ) {
menu->addSeparator();
menuAdd( menu, "git-discard-all",
i18n( "git_discard_all", "Discard All" ) );
}

menu->on( Event::OnItemClicked, [this, model,
repoPath]( const Event* event ) {
menu->on( Event::OnItemClicked, [this, model, repoPath,
type]( const Event* event ) {
if ( !mGit )
return;
UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
Expand All @@ -1648,8 +1650,7 @@ void GitPlugin::buildSidePanelTab() {
commit( repoPath );
} else if ( id == "git-stage-all" ) {
stage( model->getFiles( repoFullName( repoPath ),
(Uint32)Git::GitStatusType::Untracked |
(Uint32)Git::GitStatusType::Changed ) );
static_cast<Uint32>( type ) ) );
} else if ( id == "git-unstage-all" ) {
unstage( model->getFiles( repoFullName( repoPath ),
(Uint32)Git::GitStatusType::Staged ) );
Expand Down Expand Up @@ -1693,7 +1694,8 @@ void GitPlugin::buildSidePanelTab() {
}

if ( repo->hasStatusType( Git::GitStatusType::Untracked ) ) {
menuAdd( menu, "git-stage-all", i18n( "git_stage_all", "Stage All" ) );
menuAdd( menu, "git-stage-all", i18n( "git_stage_all", "Stage All" ),
"diff-added" );
}

menuAdd( menu, "git-fetch", i18n( "git_fetch", "Fetch" ), "repo-fetch" );
Expand Down Expand Up @@ -1836,9 +1838,9 @@ void GitPlugin::openFileStatusMenu( const Git::DiffFile& file ) {
menuAdd( menu, "git-diff", i18n( "git_open_diff", "Open Diff" ), "diff-single" );

if ( file.report.type != Git::GitStatusType::Staged ) {
menuAdd( menu, "git-stage", i18n( "git_stage", "Stage" ) );
menuAdd( menu, "git-stage", i18n( "git_stage", "Stage" ), "diff-added" );
} else {
menuAdd( menu, "git-unstage", i18n( "git_unstage", "Unstage" ) );
menuAdd( menu, "git-unstage", i18n( "git_unstage", "Unstage" ), "diff-removed" );
}

menu->addSeparator();
Expand Down
1 change: 0 additions & 1 deletion src/tools/ecode/plugins/git/gitstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ std::vector<std::string> GitStatusModel::getFiles( const std::string& repo,
if ( static_cast<uint32_t>( type.type ) & statusType ) {
for ( const auto& file : type.files )
files.push_back( file.file );
break;
}
}
break;
Expand Down

0 comments on commit c339914

Please sign in to comment.