mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-13 05:44:11 +02:00
Default Rename in Files to current document. Added Undo Replace button
This commit is contained in:
parent
196b9604c1
commit
c337bee05c
4 changed files with 94 additions and 1 deletions
|
@ -44,7 +44,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
mLocationCombo = new PathComboBox();
|
mLocationCombo = new PathComboBox();
|
||||||
mLocationCombo.MakeEditable(new PathEditWidget());
|
mLocationCombo.MakeEditable(new PathEditWidget());
|
||||||
mLocationCombo.Label = FindResultsPanel.sEntireSolution;
|
mLocationCombo.Label = isReplace ? FindResultsPanel.sCurrentDocument : FindResultsPanel.sEntireSolution;
|
||||||
mLocationCombo.mPopulateMenuAction.Add(new => PopulateLocationMenu);
|
mLocationCombo.mPopulateMenuAction.Add(new => PopulateLocationMenu);
|
||||||
mLocationCombo.mEditWidget.mOnContentChanged.Add(new (evt) => { UpdateUI(); });
|
mLocationCombo.mEditWidget.mOnContentChanged.Add(new (evt) => { UpdateUI(); });
|
||||||
AddWidget(mLocationCombo);
|
AddWidget(mLocationCombo);
|
||||||
|
|
|
@ -730,12 +730,58 @@ namespace IDE.ui
|
||||||
line.AppendF(" {0}: Replaced {1} instance{2}\n", filePath, replaceInFileCount, (replaceInFileCount == 1) ? "" : "s");
|
line.AppendF(" {0}: Replaced {1} instance{2}\n", filePath, replaceInFileCount, (replaceInFileCount == 1) ? "" : "s");
|
||||||
Write(line);
|
Write(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (replaceCount > 0)
|
||||||
|
{
|
||||||
|
Write("\n");
|
||||||
|
base.Update();
|
||||||
|
var ewc = (OutputWidgetContent)EditWidget.mEditWidgetContent;
|
||||||
|
|
||||||
|
var actionButton = new UndoRenameActionButton();
|
||||||
|
actionButton.mPanel = this;
|
||||||
|
actionButton.mLine = ewc.GetLineCount() - 1;
|
||||||
|
actionButton.Label = "Undo Replace";
|
||||||
|
actionButton.mGlobalUndoData = globalUndoData;
|
||||||
|
ewc.AddWidget(actionButton);
|
||||||
|
ewc.mActionWidgets.Add(actionButton);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StopSearch();
|
StopSearch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UndoRenameActionButton : OutputActionButton
|
||||||
|
{
|
||||||
|
public GlobalUndoData mGlobalUndoData;
|
||||||
|
|
||||||
|
bool IsValid => ((!gApp.mGlobalUndoManager.mGlobalUndoDataList.IsEmpty) &&
|
||||||
|
(gApp.mGlobalUndoManager.mGlobalUndoDataList.Back == mGlobalUndoData) &&
|
||||||
|
(mGlobalUndoData.mUndoCount == 0));
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (!IsValid)
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
|
||||||
|
{
|
||||||
|
base.MouseClicked(x, y, origX, origY, btn);
|
||||||
|
if (!IsValid)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalUndoAction undoAction = scope .(null, mGlobalUndoData);
|
||||||
|
undoAction.Undo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Clear()
|
public override void Clear()
|
||||||
{
|
{
|
||||||
base.Clear();
|
base.Clear();
|
||||||
|
|
|
@ -45,6 +45,40 @@ namespace IDE.ui
|
||||||
public int32 mLineChar;
|
public int32 mLineChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OutputActionButton : DarkButton
|
||||||
|
{
|
||||||
|
public OutputPanel mPanel;
|
||||||
|
public int mLine;
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
RemoveSelf();
|
||||||
|
gApp.DeferDelete(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RemovedFromParent(Widget previousParent, WidgetWindow window)
|
||||||
|
{
|
||||||
|
base.RemovedFromParent(previousParent, window);
|
||||||
|
var ewc = (OutputWidgetContent)mPanel.EditWidget.mEditWidgetContent;
|
||||||
|
ewc.mActionWidgets.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
var ewc = (OutputWidgetContent)mPanel.EditWidget.mEditWidgetContent;
|
||||||
|
if (mLine >= ewc.GetLineCount())
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var font = DarkTheme.sDarkTheme.mSmallFont;
|
||||||
|
ewc.GetTextCoordAtLineChar(mLine, 0, var x, var y);
|
||||||
|
Resize(GS!(4), y, font.GetWidth(mLabel) + GS!(32), GS!(24));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public OutputWidget mOutputWidget;
|
public OutputWidget mOutputWidget;
|
||||||
String mQueuedText = new String() ~ delete _;
|
String mQueuedText = new String() ~ delete _;
|
||||||
List<QueuedDisplayChange> mQueuedDisplayChanges = new List<QueuedDisplayChange>() ~ delete _;
|
List<QueuedDisplayChange> mQueuedDisplayChanges = new List<QueuedDisplayChange>() ~ delete _;
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace IDE.ui
|
||||||
public class OutputWidgetContent : SourceEditWidgetContent
|
public class OutputWidgetContent : SourceEditWidgetContent
|
||||||
{
|
{
|
||||||
public bool mRemapToHighestCompileIdx;
|
public bool mRemapToHighestCompileIdx;
|
||||||
|
public List<Widget> mActionWidgets = new .() ~ delete _;
|
||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
|
@ -260,6 +261,18 @@ namespace IDE.ui
|
||||||
MouseClicked(x, y, x, y, 1);
|
MouseClicked(x, y, x, y, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void TextChanged()
|
||||||
|
{
|
||||||
|
base.TextChanged();
|
||||||
|
|
||||||
|
for (var widget in mActionWidgets)
|
||||||
|
{
|
||||||
|
widget.RemoveSelf();
|
||||||
|
delete widget;
|
||||||
|
}
|
||||||
|
mActionWidgets.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OutputWidget : SourceEditWidget
|
public class OutputWidget : SourceEditWidget
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue