Fix incorrectly adding watches of subfolders of currently loading directory.

WIP process id picker.
This commit is contained in:
Martín Lucas Golini
2025-01-19 01:34:15 -03:00
parent b0d6e6153d
commit 84f1740d2b
7 changed files with 158 additions and 21 deletions

View File

@@ -1094,6 +1094,9 @@ DebuggerPlugin::needsToResolveInputs( nlohmann::json& json ) {
auto it = mDapInputs.find( id );
if ( it != mDapInputs.end() )
inputs[it->first] = it->second;
} else if ( String::contains( val, "${pid}" ) ) {
DapConfigurationInput dci{ "pid", "Process ID", "pid", "", {} };
inputs["pid"] = dci;
}
}
};
@@ -1531,6 +1534,29 @@ void DebuggerPlugin::prepareAndRun( DapTool debugger, DapConfig config,
} );
}
UIWidget* DebuggerPlugin::processIdPicker() {
static constexpr auto PROCESS_PICKER_LAYOUT = R"html(
<window id="process_picker" lw="450dp" lh="450dp" padding="4dp" window-title="@string(list_of_processes, List of Processes)">
<vbox lw="mp" lh="mp">
<hbox lw="mp" lh="wc" margin-bottom="4dp">
<TextView text="@string(filter_semicolon, Filter:)" lh="mp" />
<TextInput lw="0dp" lw8="1" />
</hbox>
<TableView lw="mp" lh="0dp" lw8="1" />
<hbox class="buttons" lw="mp" lh="wc" margin-top="4dp">
<PushButton id="attach_to_process" text="@string(attach_to_process, Attach to Process)" />
<PushButton id="update_process_list" text="@string(update_list, Update List)" margin-left="4dp" />
<Widget lw="0dp" lw8="1" />
<PushButton id="cancel_pick" text="@string(cancel, Cancel)" />
</hbox>
</vbox>
</window>
)html";
UIWidget* widget = getUISceneNode()->loadLayoutFromString( PROCESS_PICKER_LAYOUT );
return widget;
}
std::optional<Command>
DebuggerPlugin::debuggerBinaryExists( const std::string& debugger,
std::optional<DapRunConfig> optRunConfig ) {

View File

@@ -236,6 +236,8 @@ class DebuggerPlugin : public PluginBase {
void prepareAndRun( DapTool debugger, DapConfig config,
std::unordered_map<std::string, std::string> solvedInputs );
UIWidget* processIdPicker();
};
} // namespace ecode

View File

@@ -0,0 +1,36 @@
#include "processesmodel.hpp"
#include <eepp/ui/uiscenenode.hpp>
namespace ecode {
ProcessesModel::ProcessesModel( std::vector<std::pair<Uint64, std::string>>&& processes,
UISceneNode* sceneNode ) :
mProcesses( std::move( processes ) ), mSceneNode( sceneNode ) {}
size_t ProcessesModel::rowCount( const ModelIndex& ) const {
return mProcesses.size();
}
size_t ProcessesModel::columnCount( const ModelIndex& ) const {
return 2;
}
std::string ProcessesModel::columnName( const size_t& colIdx ) const {
return colIdx == 0 ? mSceneNode->i18n( "process_id", "Process ID" )
: mSceneNode->i18n( "command_line", "Command Line" );
}
Variant ProcessesModel::data( const ModelIndex& modelIndex, ModelRole role ) const {
switch ( modelIndex.column() ) {
case Columns::Name:
return Variant( mProcesses[modelIndex.row()].second );
case Columns::ID:
default:
return role == ModelRole::Display
? Variant( String::toString( mProcesses[modelIndex.row()].first ) )
: Variant( mProcesses[modelIndex.row()].first );
}
return {};
}
} // namespace ecode

View File

@@ -0,0 +1,35 @@
#pragma once
#include <eepp/ui/models/model.hpp>
using namespace EE;
using namespace EE::UI;
using namespace EE::UI::Models;
namespace EE::UI {
class UISceneNode;
}
namespace ecode {
class ProcessesModel : public Model {
public:
enum Columns { ID, Name };
ProcessesModel( std::vector<std::pair<Uint64, std::string>>&& processes,
UISceneNode* sceneNode );
virtual size_t rowCount( const ModelIndex& ) const;
virtual size_t columnCount( const ModelIndex& ) const;
virtual std::string columnName( const size_t& colIdx ) const;
virtual Variant data( const ModelIndex& modelIndex, ModelRole role ) const;
protected:
std::vector<std::pair<Uint64, std::string>> mProcesses;
UISceneNode* mSceneNode{ nullptr };
};
} // namespace ecode