mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Improved errors
This commit is contained in:
parent
664078557f
commit
c62854d809
1 changed files with 25 additions and 4 deletions
|
@ -15,6 +15,8 @@ namespace IDE.ui
|
|||
SourceViewPanel mSourceViewPanel;
|
||||
int mCursorPos;
|
||||
double mVertPos;
|
||||
bool mIsValid = true;
|
||||
EditWidget mEditWidget;
|
||||
|
||||
public this(String title = null, String text = null, Image icon = null) :
|
||||
base(title, text, icon)
|
||||
|
@ -35,14 +37,16 @@ namespace IDE.ui
|
|||
|
||||
mDefaultButton = AddButton("OK", new (evt) => GotoLineSubmit(true));
|
||||
mEscButton = AddButton("Cancel", new (evt) => Cancel());
|
||||
var editWidget = AddEdit(StackStringFormat!("{0}", line + 1));
|
||||
editWidget.mOnContentChanged.Add(new (evt) => GotoLineSubmit(false));
|
||||
mEditWidget = AddEdit(StackStringFormat!("{0}", line + 1));
|
||||
mEditWidget.mOnContentChanged.Add(new (evt) => GotoLineSubmit(false));
|
||||
}
|
||||
|
||||
void GotoLineSubmit(bool isFinal)
|
||||
{
|
||||
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
||||
|
||||
mIsValid = false;
|
||||
|
||||
var text = scope String();
|
||||
mDialogEditWidget.GetText(text);
|
||||
var lineResult = int32.Parse(text);
|
||||
|
@ -52,10 +56,12 @@ namespace IDE.ui
|
|||
line--;
|
||||
if ((line < 0) || (line >= editWidgetContent.Content.GetLineCount()))
|
||||
{
|
||||
IDEApp.Beep(IDEApp.MessageBeepType.Error);
|
||||
if (isFinal)
|
||||
IDEApp.Beep(IDEApp.MessageBeepType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mIsValid = true;
|
||||
int column = ((SourceEditWidgetContent)editWidgetContent.Content).GetLineEndColumn(line, false, true, true);
|
||||
editWidgetContent.Content.CursorLineAndColumn = EditWidgetContent.LineAndColumn(line, column);
|
||||
editWidgetContent.Content.CursorMoved();
|
||||
|
@ -74,8 +80,23 @@ namespace IDE.ui
|
|||
editWidgetContent.Content.mSelection = EditSelection(lineStart, lineEnd + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isFinal)
|
||||
IDEApp.Beep(IDEApp.MessageBeepType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawAll(Graphics g)
|
||||
{
|
||||
base.DrawAll(g);
|
||||
if (!mIsValid)
|
||||
{
|
||||
using (g.PushColor(0xFFFF0000))
|
||||
g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Outline), mEditWidget.mX, mEditWidget.mY, mEditWidget.mWidth, mEditWidget.mHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel()
|
||||
{
|
||||
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue