1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-11 04:52:21 +02:00
This commit is contained in:
Brian Fiete 2020-01-18 14:42:46 -08:00
parent e2799b8d6d
commit de2716bcd1
3 changed files with 57 additions and 65 deletions

View file

@ -44,9 +44,7 @@ namespace IDE.ui
} }
} }
public DarkDockingFrame mDockingFrame;
public ErrorsListView mErrorLV; public ErrorsListView mErrorLV;
public OutputWidget mOutputWidget;
public bool mNeedsResolveAll; public bool mNeedsResolveAll;
public bool mErrorsDirty; public bool mErrorsDirty;
@ -87,16 +85,7 @@ namespace IDE.ui
//let newItem = mErrorLV.GetRoot().CreateChildItem(); //let newItem = mErrorLV.GetRoot().CreateChildItem();
//newItem.Label = "Hey"; //newItem.Label = "Hey";
mOutputWidget = new .(); AddWidget(mErrorLV);
var errorDock = new DockingProxy(mErrorLV);
var detailsDock = new DockingProxy(mOutputWidget);
mDockingFrame = new DarkDockingFrame();
mDockingFrame.mDrawBkg = false;
mDockingFrame.AddDockedWidget(errorDock, null, .Top);
mDockingFrame.AddDockedWidget(detailsDock, errorDock, .Bottom);
AddWidget(mDockingFrame);
} }
public ~this() public ~this()
@ -114,7 +103,7 @@ namespace IDE.ui
public override void Resize(float x, float y, float width, float height) public override void Resize(float x, float y, float width, float height)
{ {
base.Resize(x, y, width, height); base.Resize(x, y, width, height);
mDockingFrame.Resize(0, 0, width, height); mErrorLV.Resize(0, 0, width, height);
} }
public enum ResolveKind public enum ResolveKind

View file

@ -117,7 +117,7 @@ namespace IDE.ui
{ {
if ((let editWidget = mWidgetWindow.mFocusWidget as EditWidget) && (let ewc = editWidget.mEditWidgetContent as SourceEditWidgetContent)) if ((let editWidget = mWidgetWindow.mFocusWidget as EditWidget) && (let ewc = editWidget.mEditWidgetContent as SourceEditWidgetContent))
{ {
if ((ewc.mAutoComplete != null) && (ewc.mAutoComplete.IsShowing())) if ((ewc.mAutoComplete != null) && (ewc.mAutoComplete.IsShowing()) && (dir == 1))
{ {
//ewc.KeyChar('\t'); //ewc.KeyChar('\t');
return false; return false;

View file

@ -2063,7 +2063,7 @@ namespace IDE.ui
mAutoComplete.CloseListWindow();*/ mAutoComplete.CloseListWindow();*/
} }
public override void KeyChar(char32 theChar) public override void KeyChar(char32 keyChar)
{ {
scope AutoBeefPerf("SEWC.KeyChar"); scope AutoBeefPerf("SEWC.KeyChar");
@ -2075,18 +2075,21 @@ namespace IDE.ui
if (mIsReadOnly) if (mIsReadOnly)
{ {
base.KeyChar(theChar); base.KeyChar(keyChar);
return; return;
} }
if ((keyChar == '\t') && (mWidgetWindow.IsKeyDown(.Shift)))
return;
if ((gApp.mSymbolReferenceHelper != null) && (gApp.mSymbolReferenceHelper.IsRenaming)) if ((gApp.mSymbolReferenceHelper != null) && (gApp.mSymbolReferenceHelper.IsRenaming))
{ {
if ((theChar == '\r') || (theChar == '\n')) if ((keyChar == '\r') || (keyChar == '\n'))
{ {
gApp.mSymbolReferenceHelper.Close(); gApp.mSymbolReferenceHelper.Close();
return; return;
} }
else if (theChar == '\t') else if (keyChar == '\t')
{ {
if (HasSelection()) if (HasSelection())
{ {
@ -2094,7 +2097,7 @@ namespace IDE.ui
return; return;
} }
} }
else if (theChar == '\b') else if (keyChar == '\b')
{ {
if (HasSelection()) if (HasSelection())
mSelection = null; mSelection = null;
@ -2103,20 +2106,20 @@ namespace IDE.ui
int32 startRevision = mData.mCurTextVersionId; int32 startRevision = mData.mCurTextVersionId;
bool doAutocomplete = (theChar == '\t'); bool doAutocomplete = (keyChar == '\t');
if ((mAutoComplete != null) && (theChar == '\r') && if ((mAutoComplete != null) && (keyChar == '\r') &&
((!mIsMultiline) || (mAutoComplete.mIsUserRequested))) ((!mIsMultiline) || (mAutoComplete.mIsUserRequested)))
doAutocomplete = true; doAutocomplete = true;
bool hasEmptyAutocompleteReplace = true; bool hasEmptyAutocompleteReplace = true;
if (mAutoComplete != null) if (mAutoComplete != null)
hasEmptyAutocompleteReplace = mAutoComplete.mInsertEndIdx == -1; hasEmptyAutocompleteReplace = mAutoComplete.mInsertEndIdx == -1;
bool isEndingChar = (theChar >= (char8)32) && !theChar.IsLetterOrDigit && (theChar != '_') && (theChar != '~') && (theChar != '=') && (theChar != '!') && (theChar != ':'); bool isEndingChar = (keyChar >= (char8)32) && !keyChar.IsLetterOrDigit && (keyChar != '_') && (keyChar != '~') && (keyChar != '=') && (keyChar != '!') && (keyChar != ':');
if (gApp.mSettings.mEditorSettings.mAutoCompleteRequireTab) if (gApp.mSettings.mEditorSettings.mAutoCompleteRequireTab)
{ {
doAutocomplete = theChar == '\t'; doAutocomplete = keyChar == '\t';
if (theChar == '\r') if (keyChar == '\r')
{ {
if (mAutoComplete != null) if (mAutoComplete != null)
mAutoComplete.Close(); mAutoComplete.Close();
@ -2156,29 +2159,29 @@ namespace IDE.ui
if ((mAutoComplete != null) && (mAutoComplete.mAutoCompleteListWidget != null)) if ((mAutoComplete != null) && (mAutoComplete.mAutoCompleteListWidget != null))
{ {
if ((mAutoComplete.mInsertEndIdx != -1) && (mAutoComplete.mInsertEndIdx != mCursorTextPos) && (theChar != '\t') && (theChar != '\r') && (theChar != '\n')) if ((mAutoComplete.mInsertEndIdx != -1) && (mAutoComplete.mInsertEndIdx != mCursorTextPos) && (keyChar != '\t') && (keyChar != '\r') && (keyChar != '\n'))
doAutocomplete = false; doAutocomplete = false;
if ((mAutoComplete.IsInsertEmpty()) && (!mAutoComplete.mIsFixit) && (theChar != '.') && (theChar != '\t')) if ((mAutoComplete.IsInsertEmpty()) && (!mAutoComplete.mIsFixit) && (keyChar != '.') && (keyChar != '\t'))
{ {
// Require a '.' or tab to insert autocomplete when we don't have any insert section (ie: after an 'enumVal = ') // Require a '.' or tab to insert autocomplete when we don't have any insert section (ie: after an 'enumVal = ')
doAutocomplete = false; doAutocomplete = false;
} }
if ((theChar == '[') && (mAutoComplete.mInsertStartIdx >= 0) && (mData.mText[mAutoComplete.mInsertStartIdx].mChar != '.')) if ((keyChar == '[') && (mAutoComplete.mInsertStartIdx >= 0) && (mData.mText[mAutoComplete.mInsertStartIdx].mChar != '.'))
{ {
// Don't autocomplete for ".[" (member access attributes) // Don't autocomplete for ".[" (member access attributes)
doAutocomplete = false; doAutocomplete = false;
} }
if (((theChar == '.') || (theChar == '*')) && if (((keyChar == '.') || (keyChar == '*')) &&
((mAutoComplete.mInsertEndIdx == -1) || (mAutoComplete.IsInsertEmpty()))) ((mAutoComplete.mInsertEndIdx == -1) || (mAutoComplete.IsInsertEmpty())))
{ {
// Don't autocomplete for object allocation when we haven't typed anything yet but then we press '.' (for 'inferred type') // Don't autocomplete for object allocation when we haven't typed anything yet but then we press '.' (for 'inferred type')
doAutocomplete = false; doAutocomplete = false;
} }
if ((mAutoComplete.mUncertain) && (theChar != '\t')) if ((mAutoComplete.mUncertain) && (keyChar != '\t'))
doAutocomplete = false; doAutocomplete = false;
if (doAutocomplete) if (doAutocomplete)
@ -2193,12 +2196,12 @@ namespace IDE.ui
mIsInKeyChar = true; mIsInKeyChar = true;
String insertType = scope String(); String insertType = scope String();
String insertStr = scope String(); String insertStr = scope String();
mAutoComplete.InsertSelection(theChar, insertType, insertStr); mAutoComplete.InsertSelection(keyChar, insertType, insertStr);
mIsInKeyChar = false; mIsInKeyChar = false;
if (insertType != null) if (insertType != null)
{ {
//mGenerateAutocompleteHandler(false, false); //mGenerateAutocompleteHandler(false, false);
if (((insertType == "method") && (theChar == '(')) || if (((insertType == "method") && (keyChar == '(')) ||
((insertType == "token") && (insertStr == "override"))) ((insertType == "token") && (insertStr == "override")))
{ {
if (IsCursorVisible(false)) if (IsCursorVisible(false))
@ -2213,7 +2216,7 @@ namespace IDE.ui
{ {
// Update invoke since the autocompletion may have selected a different overload // Update invoke since the autocompletion may have selected a different overload
if (IsCursorVisible(false)) if (IsCursorVisible(false))
mOnGenerateAutocomplete(theChar, .OnlyShowInvoke); mOnGenerateAutocomplete(keyChar, .OnlyShowInvoke);
} }
} }
@ -2222,7 +2225,7 @@ namespace IDE.ui
allowChar = false; allowChar = false;
} }
if ((insertType == "mixin") && (theChar == '!')) if ((insertType == "mixin") && (keyChar == '!'))
{ {
// It already ends with the char8 that we have // It already ends with the char8 that we have
allowChar = false; allowChar = false;
@ -2231,7 +2234,7 @@ namespace IDE.ui
else else
mAutoComplete.CloseListWindow(); mAutoComplete.CloseListWindow();
if ((theChar == '\t') || (theChar == '\r')) // Let other chars besides explicit-insert chrars pass through if ((keyChar == '\t') || (keyChar == '\r')) // Let other chars besides explicit-insert chrars pass through
{ {
allowChar = false; allowChar = false;
} }
@ -2251,7 +2254,7 @@ namespace IDE.ui
prevChar = mData.mText[cursorTextPos - 1].mChar; prevChar = mData.mText[cursorTextPos - 1].mChar;
} }
if (((theChar == '\n') || (theChar == '\r')) && (mIsMultiline) && (!CheckReadOnly())) if (((keyChar == '\n') || (keyChar == '\r')) && (mIsMultiline) && (!CheckReadOnly()))
{ {
UndoBatchStart undoBatchStart = new UndoBatchStart("newline"); UndoBatchStart undoBatchStart = new UndoBatchStart("newline");
mData.mUndoManager.Add(undoBatchStart); mData.mUndoManager.Add(undoBatchStart);
@ -2368,7 +2371,7 @@ namespace IDE.ui
return; return;
} }
if ((theChar == '/') && (ToggleComment())) if ((keyChar == '/') && (ToggleComment()))
{ {
return; return;
} }
@ -2378,7 +2381,7 @@ namespace IDE.ui
if ((cursorTextPos < mData.mTextLength - 1) && (mData.mText[cursorTextPos - 1].mChar == '\n')) if ((cursorTextPos < mData.mTextLength - 1) && (mData.mText[cursorTextPos - 1].mChar == '\n'))
prevElementType = (SourceElementType)mData.mText[cursorTextPos].mDisplayTypeId; prevElementType = (SourceElementType)mData.mText[cursorTextPos].mDisplayTypeId;
if (theChar == '*') if (keyChar == '*')
{ {
if (cursorTextPos >= 3) if (cursorTextPos >= 3)
{ {
@ -2414,13 +2417,13 @@ namespace IDE.ui
char8UnderCursor = (char8)mData.mText[cursorTextPos].mChar; char8UnderCursor = (char8)mData.mText[cursorTextPos].mChar;
cursorInOpenSpace = ((char8UnderCursor == ')') || (char8UnderCursor == ']') || (char8UnderCursor == (char8)0) || (char8UnderCursor.IsWhiteSpace)); cursorInOpenSpace = ((char8UnderCursor == ')') || (char8UnderCursor == ']') || (char8UnderCursor == (char8)0) || (char8UnderCursor.IsWhiteSpace));
if ((char8UnderCursor == theChar) && (!HasSelection())) if ((char8UnderCursor == keyChar) && (!HasSelection()))
{ {
var wantElementType = SourceElementType.Normal; var wantElementType = SourceElementType.Normal;
bool ignore = false; bool ignore = false;
int checkPos = cursorTextPos; int checkPos = cursorTextPos;
if ((theChar == '"') || (theChar == '\'')) if ((keyChar == '"') || (keyChar == '\''))
{ {
checkPos = Math.Max(cursorTextPos - 1, 0); checkPos = Math.Max(cursorTextPos - 1, 0);
wantElementType = .Literal; wantElementType = .Literal;
@ -2434,7 +2437,7 @@ namespace IDE.ui
if (!ignore) if (!ignore)
{ {
if ((mData.mText[checkPos].mDisplayTypeId == (int32)wantElementType) && if ((mData.mText[checkPos].mDisplayTypeId == (int32)wantElementType) &&
((theChar == '"') || (theChar == '\'') || (theChar == ')') || (theChar == ']') || (theChar == '>') || (theChar == '}'))) ((keyChar == '"') || (keyChar == '\'') || (keyChar == ')') || (keyChar == ']') || (keyChar == '>') || (keyChar == '}')))
{ {
mJustInsertedCharPair = false; mJustInsertedCharPair = false;
CursorTextPos++; CursorTextPos++;
@ -2442,12 +2445,12 @@ namespace IDE.ui
} }
else else
{ {
if ((theChar == '"') || (theChar == '\'')) if ((keyChar == '"') || (keyChar == '\''))
cursorInOpenSpace = true; cursorInOpenSpace = true;
} }
} }
} }
else if ((theChar == '}') && (!HasSelection())) // Jump down to block close, as long as it's just whitespace between us and there else if ((keyChar == '}') && (!HasSelection())) // Jump down to block close, as long as it's just whitespace between us and there
{ {
int checkPos = cursorTextPos; int checkPos = cursorTextPos;
while (checkPos < mData.mTextLength - 1) while (checkPos < mData.mTextLength - 1)
@ -2487,11 +2490,11 @@ namespace IDE.ui
if (HasSelection()) if (HasSelection())
{ {
if ((theChar == '{') && (OpenCodeBlock())) if ((keyChar == '{') && (OpenCodeBlock()))
{ {
// OpenCodeBlock handled this char // OpenCodeBlock handled this char
} }
else if ((theChar == '{') || (theChar == '(')) else if ((keyChar == '{') || (keyChar == '('))
{ {
UndoBatchStart undoBatchStart = new UndoBatchStart("blockSurround"); UndoBatchStart undoBatchStart = new UndoBatchStart("blockSurround");
mData.mUndoManager.Add(undoBatchStart); mData.mUndoManager.Add(undoBatchStart);
@ -2501,19 +2504,19 @@ namespace IDE.ui
mSelection = null; mSelection = null;
CursorTextPos = minPos; CursorTextPos = minPos;
String insertStr = scope String(); String insertStr = scope String();
insertStr.Append(theChar); insertStr.Append(keyChar);
InsertAtCursor(insertStr); InsertAtCursor(insertStr);
CursorTextPos = maxPos + 1; CursorTextPos = maxPos + 1;
insertStr.Clear(); insertStr.Clear();
if (theChar == '(') if (keyChar == '(')
insertStr.Append(')'); insertStr.Append(')');
else if (theChar == '{') else if (keyChar == '{')
insertStr.Append('}'); insertStr.Append('}');
InsertAtCursor(insertStr); InsertAtCursor(insertStr);
mData.mUndoManager.Add(undoBatchStart.mBatchEnd); mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
} }
else if ((theChar == '}') && (CloseCodeBlock())) else if ((keyChar == '}') && (CloseCodeBlock()))
{ {
// CloseCodeBlock handled this char // CloseCodeBlock handled this char
} }
@ -2522,7 +2525,7 @@ namespace IDE.ui
} }
else if (prevElementType == SourceElementType.Literal) else if (prevElementType == SourceElementType.Literal)
doChar = true; doChar = true;
else if (theChar == '#') else if (keyChar == '#')
{ {
int32 line = CursorLineAndColumn.mLine; int32 line = CursorLineAndColumn.mLine;
String lineText = scope String(); String lineText = scope String();
@ -2532,11 +2535,11 @@ namespace IDE.ui
CursorLineAndColumn = LineAndColumn(line, 0); CursorLineAndColumn = LineAndColumn(line, 0);
doChar = true; doChar = true;
} }
else if ((theChar == '{') && (OpenCodeBlock())) else if ((keyChar == '{') && (OpenCodeBlock()))
{ {
// OpenCodeBlock handled this char8 // OpenCodeBlock handled this char8
} }
else if (theChar == '}') else if (keyChar == '}')
{ {
int32 line = CursorLineAndColumn.mLine; int32 line = CursorLineAndColumn.mLine;
String lineText = scope String(); String lineText = scope String();
@ -2548,11 +2551,11 @@ namespace IDE.ui
CursorLineAndColumn = LineAndColumn(line, Math.Max(0, GetLineEndColumn(line, false, false) - 4)); CursorLineAndColumn = LineAndColumn(line, Math.Max(0, GetLineEndColumn(line, false, false) - 4));
CursorMoved(); CursorMoved();
} }
base.KeyChar(theChar); base.KeyChar(keyChar);
} }
else if ((theChar == '(') && (cursorInOpenSpace)) else if ((keyChar == '(') && (cursorInOpenSpace))
InsertCharPair("()"); InsertCharPair("()");
else if ((theChar == '{') && (cursorInOpenSpace)) else if ((keyChar == '{') && (cursorInOpenSpace))
{ {
/*int lineStart; /*int lineStart;
int lineEnd; int lineEnd;
@ -2569,11 +2572,11 @@ namespace IDE.ui
doChar = true;*/ doChar = true;*/
InsertCharPair("{}"); InsertCharPair("{}");
} }
else if ((theChar == '[') && (cursorInOpenSpace)) else if ((keyChar == '[') && (cursorInOpenSpace))
InsertCharPair("[]"); InsertCharPair("[]");
else if ((theChar == '\"') && (cursorInOpenSpace) && (!cursorAfterText)) else if ((keyChar == '\"') && (cursorInOpenSpace) && (!cursorAfterText))
InsertCharPair("\"\""); InsertCharPair("\"\"");
else if ((theChar == '\'') && (cursorInOpenSpace) && (!cursorAfterText)) else if ((keyChar == '\'') && (cursorInOpenSpace) && (!cursorAfterText))
InsertCharPair("\'\'"); InsertCharPair("\'\'");
else else
doChar = true; doChar = true;
@ -2582,16 +2585,16 @@ namespace IDE.ui
if (doChar) if (doChar)
{ {
mIsInKeyChar = true; mIsInKeyChar = true;
base.KeyChar(theChar); base.KeyChar(keyChar);
mIsInKeyChar = false; mIsInKeyChar = false;
} }
if ((theChar == '\b') || (theChar == '\r') || (theChar >= (char8)32)) if ((keyChar == '\b') || (keyChar == '\r') || (keyChar >= (char8)32))
{ {
bool isHighPri = (theChar == '(') || (theChar == '.'); bool isHighPri = (keyChar == '(') || (keyChar == '.');
bool needsFreshAutoComplete = ((isHighPri) /*|| (!mAsyncAutocomplete)*/ || (mAutoComplete == null) || (mAutoComplete.mAutoCompleteListWidget == null)); bool needsFreshAutoComplete = ((isHighPri) /*|| (!mAsyncAutocomplete)*/ || (mAutoComplete == null) || (mAutoComplete.mAutoCompleteListWidget == null));
if ((needsFreshAutoComplete) && (theChar == '\b')) if ((needsFreshAutoComplete) && (keyChar == '\b'))
{ {
if ((prevChar != 0) && (prevChar.IsWhiteSpace) && (prevElementType != .Comment)) if ((prevChar != 0) && (prevChar.IsWhiteSpace) && (prevElementType != .Comment))
{ {
@ -2619,7 +2622,7 @@ namespace IDE.ui
{ {
//Profiler.StartSampling(); //Profiler.StartSampling();
if (IsCursorVisible(false)) if (IsCursorVisible(false))
mOnGenerateAutocomplete(theChar, isHighPri ? .HighPriority : default); mOnGenerateAutocomplete(keyChar, isHighPri ? .HighPriority : default);
//Profiler.StopSampling(); //Profiler.StopSampling();
} }
} }
@ -2629,7 +2632,7 @@ namespace IDE.ui
mAutoComplete.CloseListWindow(); mAutoComplete.CloseListWindow();
} }
if ((theChar.IsLower) || (theChar == ' ') || (theChar == ':')) if ((keyChar.IsLower) || (keyChar == ' ') || (keyChar == ':'))
{ {
int cursorTextIdx = CursorTextPos; int cursorTextIdx = CursorTextPos;
int line; int line;
@ -2641,10 +2644,10 @@ namespace IDE.ui
String trimmedLineText = scope String(lineText); String trimmedLineText = scope String(lineText);
trimmedLineText.TrimStart(); trimmedLineText.TrimStart();
if ((theChar == ' ') || (theChar == ':')) if ((keyChar == ' ') || (keyChar == ':'))
{ {
bool isLabel = false; bool isLabel = false;
if (theChar == ':') if (keyChar == ':')
{ {
isLabel = trimmedLineText != "scope:"; isLabel = trimmedLineText != "scope:";
for (var c in trimmedLineText.RawChars) for (var c in trimmedLineText.RawChars)