1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 07:44:09 +02:00

Fixit improvements, remove namespace

This commit is contained in:
Brian Fiete 2020-02-07 08:44:06 -08:00
parent 7a5dd90cff
commit 61bd31836d
10 changed files with 304 additions and 157 deletions

View file

@ -215,7 +215,6 @@ namespace IDE
Add("New File", new => gApp.Cmd_NewFile);
Add("New Project", new => gApp.Cmd_NewProject);
Add("New Workspace", new => gApp.Cmd_NewWorkspace);
Add("New View Into File", new => gApp.Cmd_NewFileView);
Add("Next Document Panel", new => gApp.[Friend]DoShowNextDocumentPanel);
Add("Open Corresponding", new => gApp.[Friend]OpenCorresponding);
Add("Open Crash Dump", new => gApp.OpenCrashDump);
@ -264,7 +263,6 @@ namespace IDE
Add("Show Threads", new => gApp.ShowThreads);
Add("Show Watches", new => gApp.ShowWatches);
Add("Show Workspace Explorer", new => gApp.ShowWorkspacePanel);
Add("Split View", new => gApp.[Friend]SplitView);
Add("Start Debugging", new => gApp.[Friend]RunWithCompiling);
Add("Start Without Debugging", new => gApp.[Friend]RunWithoutCompiling);
Add("Step Into", new => gApp.[Friend]StepInto);
@ -275,6 +273,8 @@ namespace IDE
Add("Tab Last", new => gApp.[Friend]TabLast);
Add("Tab Next", new => gApp.[Friend]TabNext);
Add("Tab Prev", new => gApp.[Friend]TabPrev);
Add("View New", new => gApp.Cmd_ViewNew);
Add("View Split", new => gApp.[Friend]ViewSplit);
Add("View White Space", new => gApp.Cmd_ViewWhiteSpace);
Add("Zoom In", new => gApp.Cmd_ZoomIn);
Add("Zoom Out", new => gApp.Cmd_ZoomOut);

View file

@ -751,7 +751,7 @@ namespace IDE
base.Run();
}
public void Cmd_NewFileView()
public void Cmd_ViewNew()
{
var sourceViewPanel = GetActiveSourceViewPanel();
if (sourceViewPanel != null)
@ -4824,7 +4824,6 @@ namespace IDE
AddMenuItem(subMenu, "&Save File","Save File");
AddMenuItem(subMenu, "Save &As...", "Save As");
AddMenuItem(subMenu, "Save A&ll", "Save All");
AddMenuItem(subMenu, "N&ew View into File", "New View Into File");
let prefMenu = subMenu.AddMenuItem("&Preferences");
//prefMenu.AddMenuItem("&Keyboard Shortcuts", null, new (evt) => { ShowKeyboardShortcuts(); });
AddMenuItem(prefMenu, "&Settings", "Settings");
@ -5028,7 +5027,8 @@ namespace IDE
mWindowMenu = root.AddMenuItem("&Window");
AddMenuItem(mWindowMenu, "&Close", "Close Window");
AddMenuItem(mWindowMenu, "&Close All", "Close All Windows");
AddMenuItem(mWindowMenu, "&Split View", "Split View");
AddMenuItem(mWindowMenu, "&New View into File", "View New");
AddMenuItem(mWindowMenu, "&Split View", "View Split");
subMenu = root.AddMenuItem("&Help");
AddMenuItem(subMenu, "&About", "About");
@ -6155,7 +6155,7 @@ namespace IDE
DocumentCloseClicked(docPanel);
}
void SplitView()
void ViewSplit()
{
var sourceViewPanel = GetActiveSourceViewPanel();
if (sourceViewPanel != null)

View file

@ -2126,35 +2126,47 @@ namespace IDE.ui
return mInsertStartIdx == mInsertEndIdx;
}
/*void ApplyFixit(String fixitType, String fileName, String fixitParam)
{
var projectSource = IDEApp.sApp.FindProjectSourceItem(fileName);
var editData = IDEApp.sApp.GetEditData(projectSource);
var sourceEditWidgetContent = (SourceEditWidgetContent)editData.mEditWidget.Content;
//cursorPositions.Add(sourceEditWidgetContent.CursorTextPos);
var bfSystem = IDEApp.sApp.mBfResolveSystem;
var parser = bfSystem.CreateEmptyParser(null);
defer:: delete parser;
var text = scope String();
editData.mEditWidget.GetText(text);
parser.SetSource(text, fileName);
var passInstance = bfSystem.CreatePassInstance();
defer:: delete passInstance;
parser.Parse(passInstance, false);
parser.Reduce(passInstance);
parser.Ref
}*/
void ApplyFixit(String data)
{
var parts = String.StackSplit!(data, '|');
//String fixitType = parts[0];
String fixitFileName = parts[1];
int32 fixitIdx = int32.Parse(parts[2]).GetValueOrDefault();
UndoBatchStart undoBatchStart = null;
var parts = String.StackSplit!(data, '|');
String fixitFileName = parts[1];
SourceViewPanel sourceViewPanel = IDEApp.sApp.ShowSourceFile(fixitFileName);
var targetSourceEditWidgetContent = mTargetEditWidget.Content as SourceEditWidgetContent;
var historyEntry = targetSourceEditWidgetContent.RecordHistoryLocation();
historyEntry.mNoMerge = true;
var sourceEditWidgetContent = targetSourceEditWidgetContent;
if (sourceEditWidgetContent.mSourceViewPanel != sourceViewPanel)
{
sourceEditWidgetContent = (SourceEditWidgetContent)sourceViewPanel.GetActivePanel().EditWidget.mEditWidgetContent;
undoBatchStart = new UndoBatchStart("autocomplete");
sourceEditWidgetContent.mData.mUndoManager.Add(undoBatchStart);
}
int32 fixitIdx = 0;
int32 fixitLen = 0;
StringView fixitLocStr = parts[2];
int dashPos = fixitLocStr.IndexOf('-');
if (dashPos != -1)
{
fixitLen = int32.Parse(fixitLocStr.Substring(dashPos + 1));
fixitLocStr.RemoveToEnd(dashPos);
}
if (fixitLocStr.Contains(':'))
{
var splitItr = fixitLocStr.Split(':');
int32 line = int32.Parse(splitItr.GetNext().Value).Value;
int32 col = int32.Parse(splitItr.GetNext().Value).Value;
fixitIdx = (.)sourceEditWidgetContent.GetTextIdx(line, col);
}
else
fixitIdx = int32.Parse(fixitLocStr).GetValueOrDefault();
int insertCount = 0;
int dataIdx = 3;
while (dataIdx < parts.Count)
@ -2178,7 +2190,6 @@ namespace IDE.ui
#unwarn
bool hasMore = dataIdx < parts.Count;
SourceViewPanel sourceViewPanel = IDEApp.sApp.ShowSourceFile(fixitFileName);
if (sourceViewPanel != null)
{
if (sourceViewPanel.IsReadOnly)
@ -2186,50 +2197,48 @@ namespace IDE.ui
gApp.Fail(scope String()..AppendF("The selected fixit cannot be applied to locked file '{}'", sourceViewPanel.mFilePath));
return;
}
var targetSourceEditWidgetContent = mTargetEditWidget.Content as SourceEditWidgetContent;
var history = targetSourceEditWidgetContent.RecordHistoryLocation();
history.mNoMerge = true;
var editWidgetContent = (SourceEditWidgetContent)sourceViewPanel.mEditWidget.mEditWidgetContent;
editWidgetContent.CursorTextPos = fixitIdx;
editWidgetContent.EnsureCursorVisible(true, true);
sourceEditWidgetContent.CursorTextPos = fixitIdx;
sourceEditWidgetContent.EnsureCursorVisible(true, true);
if (fixitLen > 0)
{
sourceEditWidgetContent.mSelection = EditSelection(fixitIdx, fixitIdx + fixitLen);
sourceEditWidgetContent.DeleteSelection();
fixitLen = 0;
}
if (fixitInsert.StartsWith('\n'))
editWidgetContent.PasteText(fixitInsert, fixitInsert.StartsWith("\n"));
sourceEditWidgetContent.PasteText(fixitInsert, fixitInsert.StartsWith("\n"));
else
InsertImplText(fixitInsert);
InsertImplText(sourceEditWidgetContent, fixitInsert);
fixitIdx = (.)editWidgetContent.CursorTextPos;
fixitIdx = (.)sourceEditWidgetContent.CursorTextPos;
insertCount++;
}
}
/*switch (parts[0])
if (historyEntry != null)
{
case "using":
//ApplyFixit(parts[0], parts[1], parts[2]);
break;
case "addMethod":
break;
}*/
// Make sure when we go back that we'll go back to the insert position
int idx = gApp.mHistoryManager.mHistoryList.LastIndexOf(historyEntry);
if (idx != -1)
gApp.mHistoryManager.mHistoryIdx = (.)idx;
}
if (undoBatchStart != null)
sourceEditWidgetContent.mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
}
void InsertImplText(String implText)
void InsertImplText(SourceEditWidgetContent sourceEditWidgetContent, String implText)
{
var sourceEditWidgetContent = mTargetEditWidget.Content as SourceEditWidgetContent;
/*sourceEditWidgetContent.ClearLine();
sourceEditWidgetContent.InsertAtCursor("ABC\nDEF\nGHI");
return;*/
String implSect = scope .();
int startIdx = 0;
for (int i < implText.Length)
{
char8 c = implText[i];
if ((c == '\t') || (c == '\b') || (c == '\r') || (c == '\f'))
if ((c == '\a') || (c == '\t') || (c == '\b') || (c == '\r') || (c == '\f'))
{
implSect.Clear();
implSect.Append(implText, startIdx, i - startIdx);
@ -2238,7 +2247,30 @@ namespace IDE.ui
sourceEditWidgetContent.InsertAtCursor(implSect);
}
if (c == '\f')
if (c == '\a') // Ensure we have spacing or an open brace on the previous line
{
int lineNum = sourceEditWidgetContent.CursorLineAndColumn.mLine;
if (lineNum > 0)
{
sourceEditWidgetContent.GetLinePosition(lineNum - 1, var lineStart, var lineEnd);
for (int idx = lineEnd; idx >= lineStart; idx--)
{
let charData = sourceEditWidgetContent.mData.mText[idx];
if (charData.mDisplayTypeId == (.)SourceElementType.Comment)
continue;
if (charData.mChar.IsWhiteSpace)
continue;
if (charData.mChar == '{')
break;
// Add new line
sourceEditWidgetContent.InsertAtCursor("\n");
sourceEditWidgetContent.CursorToLineEnd();
break;
}
}
}
else if (c == '\f') // Make sure we're on an empty line
{
if (!sourceEditWidgetContent.IsLineWhiteSpace(sourceEditWidgetContent.CursorLineAndColumn.mLine))
{
@ -2251,29 +2283,19 @@ namespace IDE.ui
sourceEditWidgetContent.CursorTextPos = prevPos;
}
sourceEditWidgetContent.CursorToLineEnd();
/*if (!sourceEditWidgetContent.IsLineWhiteSpace(sourceEditWidgetContent.CursorLineAndColumn.mLine))
{
sourceEditWidgetContent.InsertText(sourceEditWidgetContent.CursorTextPos + 1, "\n");
sourceEditWidgetContent.ContentChanged();
}*/
//return;
//sourceEditWidgetContent.GetLineText(sourceEditWidgetContent.CursorLineAndColumn.mLine, )
//sourceEditWidgetContent.InsertAtCursor("ABC\n");
}
else if (c == '\t')
else if (c == '\t') // Open block
{
sourceEditWidgetContent.InsertAtCursor("\n");
sourceEditWidgetContent.CursorToLineEnd();
sourceEditWidgetContent.OpenCodeBlock();
}
else if (c == '\r')
else if (c == '\r') // Newline
{
sourceEditWidgetContent.InsertAtCursor("\n");
sourceEditWidgetContent.CursorToLineEnd();
}
else if (c == '\b')
else if (c == '\b') // Close block
{
int cursorPos = sourceEditWidgetContent.CursorTextPos;
while (cursorPos < sourceEditWidgetContent.mData.mTextLength)
@ -2406,7 +2428,7 @@ namespace IDE.ui
UpdateAsyncInfo();*/
if (implText != null)
InsertImplText(implText);
InsertImplText(sourceEditWidgetContent, implText);
if (persistentInvokeSrcPositons != null)
{

View file

@ -1489,7 +1489,7 @@ namespace IDE.ui
base.InsertAtCursor(theString, insertFlags);
mInsertDisplayFlags = 0;
if ((!mIgnoreSetHistory) && (!insertFlags.HasFlag(.NoMoveCursor)))
if ((!mIgnoreSetHistory) && (!insertFlags.HasFlag(.NoMoveCursor)) && (!insertFlags.HasFlag(.NoRecordHistory)))
RecordHistoryLocation();
}

View file

@ -236,22 +236,12 @@ namespace IDE.ui
if (activeDocument is SourceViewPanel)
{
var sourceViewPanel = (SourceViewPanel)activeDocument;
sourceViewPanel = sourceViewPanel.GetActivePanel();
int32 line;
int32 column;
sourceViewPanel.GetCursorPosition(out line, out column);
/*var ewc = sourceViewPanel.mEditWidget.Content;
int cursorPos = ewc.CursorTextPos;
if (cursorPos < ewc.mData.mTextLength)
{
ewc.mData.mTextIdData.Prepare();
g.DrawString(StackStringFormat!("Id {0}", ewc.mData.mTextIdData.GetIdAtIndex(cursorPos)), mWidth - GS!(310), 0);
}*/
/*line = 8'888'888;
column = 8'888'888;*/
if (gApp.mSettings.mEnableDevMode)
g.DrawString(StackStringFormat!("Idx {0}", sourceViewPanel.mEditWidget.Content.CursorTextPos), mWidth - GS!(240), 0);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(150), 0);