mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
UIDiffView: Added Reduced / Complete toggle. Added LCS support. A lot of extra improvements.
This commit is contained in:
@@ -12,6 +12,7 @@ class UIDiffEditorPlugin;
|
||||
class EE_API UIDiffView : public UIWidget {
|
||||
public:
|
||||
enum class ViewMode { Unified, SideBySide };
|
||||
enum class SubLineDiffAlgorithm { LCS, SES };
|
||||
|
||||
static UIDiffView* New();
|
||||
|
||||
@@ -20,7 +21,7 @@ class EE_API UIDiffView : public UIWidget {
|
||||
virtual Uint32 getType() const override;
|
||||
virtual bool isType( const Uint32& type ) const override;
|
||||
|
||||
void loadFromPatch( const std::string& patchText );
|
||||
void loadFromPatch( const std::string& patchText, const std::string& originalFilePath = "" );
|
||||
void loadFromStrings( const std::string& oldText, const std::string& newText );
|
||||
void loadFromFile( const std::string& oldFilePath, const std::string& newFilePath );
|
||||
|
||||
@@ -38,6 +39,7 @@ class EE_API UIDiffView : public UIWidget {
|
||||
};
|
||||
|
||||
const std::vector<DiffLine>& getDiffLines() const { return mLines; }
|
||||
const std::vector<size_t>& getViewLines() const { return mViewLines; }
|
||||
|
||||
void setViewMode( ViewMode mode );
|
||||
ViewMode getViewMode() const { return mViewMode; }
|
||||
@@ -45,17 +47,32 @@ class EE_API UIDiffView : public UIWidget {
|
||||
void setViewModeToggleVisible( bool visible );
|
||||
bool isViewModeToggleVisible() const { return mViewModeToggleVisible; }
|
||||
|
||||
void setCompleteView( bool complete );
|
||||
bool isCompleteView() const { return mShowCompleteView; }
|
||||
|
||||
void setCompleteViewToggleVisible( bool visible );
|
||||
bool isCompleteViewToggleVisible() const { return mCompleteViewToggleVisible; }
|
||||
|
||||
void setSubLineDiffAlgorithm( SubLineDiffAlgorithm algo );
|
||||
SubLineDiffAlgorithm getSubLineDiffAlgorithm() const { return mSubLineDiffAlgorithm; }
|
||||
|
||||
protected:
|
||||
UICodeEditor* mEditor{ nullptr };
|
||||
UICodeEditor* mLeftEditor{ nullptr };
|
||||
UICodeEditor* mRightEditor{ nullptr };
|
||||
UIPushButton* mModeToggle{ nullptr };
|
||||
UIPushButton* mCompleteViewToggle{ nullptr };
|
||||
std::unique_ptr<UIDiffEditorPlugin> mPlugin;
|
||||
std::unique_ptr<UIDiffEditorPlugin> mLeftPlugin;
|
||||
std::unique_ptr<UIDiffEditorPlugin> mRightPlugin;
|
||||
std::vector<DiffLine> mLines;
|
||||
std::vector<size_t> mViewLines;
|
||||
ViewMode mViewMode{ ViewMode::Unified };
|
||||
SubLineDiffAlgorithm mSubLineDiffAlgorithm{ SubLineDiffAlgorithm::LCS };
|
||||
bool mViewModeToggleVisible{ true };
|
||||
bool mShowCompleteView{ false };
|
||||
bool mCompleteViewToggleVisible{ true };
|
||||
std::shared_ptr<SyntaxDefinition> mSyntaxDef;
|
||||
|
||||
UIDiffView();
|
||||
|
||||
@@ -65,6 +82,8 @@ class EE_API UIDiffView : public UIWidget {
|
||||
void syncScroll( UICodeEditor* source, UICodeEditor* target, bool emitEvent = false );
|
||||
void updateModeButton();
|
||||
void computeSubLineDiff( DiffLine& oldLine, DiffLine& newLine );
|
||||
void updateEditorsText();
|
||||
void updateButtonsText();
|
||||
};
|
||||
|
||||
}}} // namespace EE::UI::Tools
|
||||
|
||||
Reference in New Issue
Block a user