mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-26 19:48:01 +02:00
Added View Whitespace for string viewer
This commit is contained in:
parent
e508b8ded7
commit
76cb117e1f
7 changed files with 109 additions and 15 deletions
|
@ -300,6 +300,17 @@ namespace Beefy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BFWindow FocusedWindow
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var window in mWindows)
|
||||||
|
if (window.mHasFocus)
|
||||||
|
return window;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Startup(String[] args, Action startupCallback)
|
public static void Startup(String[] args, Action startupCallback)
|
||||||
{
|
{
|
||||||
/*string[] newArgs = new string[args.Length + 1];
|
/*string[] newArgs = new string[args.Length + 1];
|
||||||
|
|
|
@ -462,6 +462,18 @@ namespace Beefy
|
||||||
BFWindow_SetNonExclusiveMouseCapture(mNativeWindow);
|
BFWindow_SetNonExclusiveMouseCapture(mNativeWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasParent(BFWindow widgetWindow)
|
||||||
|
{
|
||||||
|
var checkParent = mParent;
|
||||||
|
while (checkParent != null)
|
||||||
|
{
|
||||||
|
if (checkParent == widgetWindow)
|
||||||
|
return true;
|
||||||
|
checkParent = checkParent.mParent;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Closed()
|
public virtual void Closed()
|
||||||
{
|
{
|
||||||
if (mHasClosed)
|
if (mHasClosed)
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace Beefy.theme.dark
|
||||||
{
|
{
|
||||||
float spaceWidth = mFont.GetWidth((char32)' ');
|
float spaceWidth = mFont.GetWidth((char32)' ');
|
||||||
if (mTabSize == 0)
|
if (mTabSize == 0)
|
||||||
return startX + spaceWidth;
|
return startX + spaceWidth*4;
|
||||||
return (float)Math.Truncate((startX + spaceWidth) / mTabSize + 0.999f) * mTabSize;
|
return (float)Math.Truncate((startX + spaceWidth) / mTabSize + 0.999f) * mTabSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,15 +299,17 @@ namespace Beefy.theme.dark
|
||||||
mFont = font;
|
mFont = font;
|
||||||
if (isMonospace)
|
if (isMonospace)
|
||||||
{
|
{
|
||||||
mCharWidth = mFont.GetWidth((char32)' ');
|
mCharWidth = mFont.GetWidth(' ');
|
||||||
//Debug.Assert(mFont.GetWidth((char32)'W') == mCharWidth);
|
|
||||||
if (mTabSize == 0)
|
if (mTabSize == 0)
|
||||||
mTabSize = mTabLength * mCharWidth;
|
mTabSize = mTabLength * mCharWidth;
|
||||||
else
|
else
|
||||||
mTabSize = (float)Math.Round(mTabSize / mCharWidth) * mCharWidth;
|
mTabSize = (float)Math.Round(mTabSize / mCharWidth) * mCharWidth;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
mCharWidth = -1;
|
mCharWidth = -1;
|
||||||
|
mTabSize = mTabLength * mFont.GetWidth('W');
|
||||||
|
}
|
||||||
if (virtualCursor)
|
if (virtualCursor)
|
||||||
Debug.Assert(isMonospace);
|
Debug.Assert(isMonospace);
|
||||||
mAllowVirtualCursor = virtualCursor;
|
mAllowVirtualCursor = virtualCursor;
|
||||||
|
|
|
@ -38,6 +38,18 @@ namespace Beefy.theme.dark
|
||||||
if (tabButton.mCloseClickedEvent.HasListeners)
|
if (tabButton.mCloseClickedEvent.HasListeners)
|
||||||
tabButton.mCloseClickedEvent();
|
tabButton.mCloseClickedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void MouseMove(float x, float y)
|
||||||
|
{
|
||||||
|
base.MouseMove(x, y);
|
||||||
|
MarkDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseLeave()
|
||||||
|
{
|
||||||
|
base.MouseLeave();
|
||||||
|
MarkDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DarkTabButton : TabbedView.TabButton
|
public class DarkTabButton : TabbedView.TabButton
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace Beefy.theme.dark
|
||||||
public Insets mRelWidgetMouseInsets ~ delete _;
|
public Insets mRelWidgetMouseInsets ~ delete _;
|
||||||
public bool mAllowMouseInsideSelf;
|
public bool mAllowMouseInsideSelf;
|
||||||
public bool mAllowMouseOutside;
|
public bool mAllowMouseOutside;
|
||||||
|
public int mAutoCloseDelay;
|
||||||
|
|
||||||
public const float cShadowSize = 8;
|
public const float cShadowSize = 8;
|
||||||
|
|
||||||
|
@ -199,7 +200,8 @@ namespace Beefy.theme.dark
|
||||||
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
|
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
|
||||||
if (widgetWindow == mWidgetWindow)
|
if (widgetWindow == mWidgetWindow)
|
||||||
return;
|
return;
|
||||||
|
if (widgetWindow.HasParent(mWidgetWindow))
|
||||||
|
return;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +210,8 @@ namespace Beefy.theme.dark
|
||||||
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
|
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
|
||||||
if (widgetWindow == mWidgetWindow)
|
if (widgetWindow == mWidgetWindow)
|
||||||
return;
|
return;
|
||||||
|
if (widgetWindow.HasParent(mWidgetWindow))
|
||||||
|
return;
|
||||||
//if ((!(widgetWindow.mRootWidget is HoverWatch)) && (!(widgetWindow.mRootWidget is MenuWidget)))
|
//if ((!(widgetWindow.mRootWidget is HoverWatch)) && (!(widgetWindow.mRootWidget is MenuWidget)))
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -221,6 +225,12 @@ namespace Beefy.theme.dark
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
if (mAutoCloseDelay > 0)
|
||||||
|
{
|
||||||
|
mAutoCloseDelay--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mWidgetWindow == null)
|
if (mWidgetWindow == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -243,7 +253,16 @@ namespace Beefy.theme.dark
|
||||||
if ((mWidgetWindow.mHasMouseInside) && (mAllowMouseInsideSelf))
|
if ((mWidgetWindow.mHasMouseInside) && (mAllowMouseInsideSelf))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var checkWindow = BFApp.sApp.FocusedWindow;
|
||||||
|
if ((checkWindow != null) && (checkWindow.HasParent(mWidgetWindow)))
|
||||||
|
return;
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExpandAllowedRegion()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RemovedFromWindow()
|
protected override void RemovedFromWindow()
|
||||||
|
|
|
@ -83,10 +83,13 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (var editWidget = gApp.GetActiveWindow().mFocusWidget as EditWidget)
|
if (var editWidget = gApp.GetActiveWindow().mFocusWidget as EditWidget)
|
||||||
{
|
{
|
||||||
|
bool isMultiline = false;
|
||||||
|
|
||||||
var content = editWidget.mEditWidgetContent;
|
var content = editWidget.mEditWidgetContent;
|
||||||
|
if (content.mSelection.HasValue)
|
||||||
|
{
|
||||||
int selStart = content.mSelection.Value.MinPos;
|
int selStart = content.mSelection.Value.MinPos;
|
||||||
int selEnd = content.mSelection.Value.MaxPos;
|
int selEnd = content.mSelection.Value.MaxPos;
|
||||||
bool isMultiline = false;
|
|
||||||
for (int i = selStart; i < selEnd; i++)
|
for (int i = selStart; i < selEnd; i++)
|
||||||
{
|
{
|
||||||
if (content.mData.mText[i].mChar == '\n')
|
if (content.mData.mText[i].mChar == '\n')
|
||||||
|
@ -95,6 +98,7 @@ namespace IDE.ui
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isMultiline)
|
if (!isMultiline)
|
||||||
{
|
{
|
||||||
|
|
|
@ -572,6 +572,8 @@ namespace IDE.ui
|
||||||
public int mMaxShowSize = cMoreBlockSize;
|
public int mMaxShowSize = cMoreBlockSize;
|
||||||
public DarkButton mMoreButton;
|
public DarkButton mMoreButton;
|
||||||
public QuickFind mQuickFind;
|
public QuickFind mQuickFind;
|
||||||
|
public DarkTabbedView.DarkTabMenuButton mMenuButton;
|
||||||
|
public bool mViewWhiteSpace;
|
||||||
|
|
||||||
public this(String text, String evalStr)
|
public this(String text, String evalStr)
|
||||||
{
|
{
|
||||||
|
@ -614,6 +616,36 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (evalStr != null)
|
if (evalStr != null)
|
||||||
mEvalString.Set(evalStr);
|
mEvalString.Set(evalStr);
|
||||||
|
|
||||||
|
mMenuButton = new DarkTabbedView.DarkTabMenuButton();
|
||||||
|
AddWidget(mMenuButton);
|
||||||
|
|
||||||
|
mMenuButton.mOnMouseDown.Add(new (evt) =>
|
||||||
|
{
|
||||||
|
float x = mMenuButton.mX + GS!(14);
|
||||||
|
float y = mMenuButton.mY + GS!(6);
|
||||||
|
|
||||||
|
Menu menu = new Menu();
|
||||||
|
var menuItem = menu.AddItem("Show Whitespace");
|
||||||
|
if (mViewWhiteSpace)
|
||||||
|
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
|
||||||
|
menuItem.mOnMenuItemSelected.Add(new (menu) =>
|
||||||
|
{
|
||||||
|
mViewWhiteSpace = !mViewWhiteSpace;
|
||||||
|
var darkEditWidgetContent = (DarkEditWidgetContent)mEditWidget.Content;
|
||||||
|
darkEditWidgetContent.mViewWhiteSpaceColor = mViewWhiteSpace ? SourceEditWidgetContent.sTextColors[(int)SourceElementType.VisibleWhiteSpace] : 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu);
|
||||||
|
menuWidget.Init(this, x, y, true);
|
||||||
|
|
||||||
|
menu.mOnMenuClosed.Add(new (menu, itemSelected) =>
|
||||||
|
{
|
||||||
|
if (DarkTooltipManager.sTooltip != null)
|
||||||
|
DarkTooltipManager.sTooltip.mAutoCloseDelay = 90;
|
||||||
|
});
|
||||||
|
//menuWidget.mWidgetWindow.mOnWindowClosed.Add(new => MenuClosed);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowQuickFind(bool isReplace)
|
public void ShowQuickFind(bool isReplace)
|
||||||
|
@ -750,8 +782,8 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis);
|
g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis);
|
||||||
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(120), textY);
|
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(130), textY);
|
||||||
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(60), textY);
|
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(70), textY);
|
||||||
|
|
||||||
//using (g.PushColor(0xD0FFFFFF))
|
//using (g.PushColor(0xD0FFFFFF))
|
||||||
base.DrawAll(g);
|
base.DrawAll(g);
|
||||||
|
@ -764,6 +796,8 @@ namespace IDE.ui
|
||||||
mEditWidget.Resize(0, 0, width, height - GS!(16));
|
mEditWidget.Resize(0, 0, width, height - GS!(16));
|
||||||
if (mQuickFind != null)
|
if (mQuickFind != null)
|
||||||
mQuickFind.ResizeSelf();
|
mQuickFind.ResizeSelf();
|
||||||
|
|
||||||
|
mMenuButton.Resize(width - GS!(26), height - GS!(12), GS!(16), GS!(16));
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetWantHeight(float wantWidth)
|
public float GetWantHeight(float wantWidth)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue