mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +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;
|
SourceViewPanel mSourceViewPanel;
|
||||||
int mCursorPos;
|
int mCursorPos;
|
||||||
double mVertPos;
|
double mVertPos;
|
||||||
|
bool mIsValid = true;
|
||||||
|
EditWidget mEditWidget;
|
||||||
|
|
||||||
public this(String title = null, String text = null, Image icon = null) :
|
public this(String title = null, String text = null, Image icon = null) :
|
||||||
base(title, text, icon)
|
base(title, text, icon)
|
||||||
|
@ -35,14 +37,16 @@ namespace IDE.ui
|
||||||
|
|
||||||
mDefaultButton = AddButton("OK", new (evt) => GotoLineSubmit(true));
|
mDefaultButton = AddButton("OK", new (evt) => GotoLineSubmit(true));
|
||||||
mEscButton = AddButton("Cancel", new (evt) => Cancel());
|
mEscButton = AddButton("Cancel", new (evt) => Cancel());
|
||||||
var editWidget = AddEdit(StackStringFormat!("{0}", line + 1));
|
mEditWidget = AddEdit(StackStringFormat!("{0}", line + 1));
|
||||||
editWidget.mOnContentChanged.Add(new (evt) => GotoLineSubmit(false));
|
mEditWidget.mOnContentChanged.Add(new (evt) => GotoLineSubmit(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GotoLineSubmit(bool isFinal)
|
void GotoLineSubmit(bool isFinal)
|
||||||
{
|
{
|
||||||
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
||||||
|
|
||||||
|
mIsValid = false;
|
||||||
|
|
||||||
var text = scope String();
|
var text = scope String();
|
||||||
mDialogEditWidget.GetText(text);
|
mDialogEditWidget.GetText(text);
|
||||||
var lineResult = int32.Parse(text);
|
var lineResult = int32.Parse(text);
|
||||||
|
@ -52,10 +56,12 @@ namespace IDE.ui
|
||||||
line--;
|
line--;
|
||||||
if ((line < 0) || (line >= editWidgetContent.Content.GetLineCount()))
|
if ((line < 0) || (line >= editWidgetContent.Content.GetLineCount()))
|
||||||
{
|
{
|
||||||
IDEApp.Beep(IDEApp.MessageBeepType.Error);
|
if (isFinal)
|
||||||
|
IDEApp.Beep(IDEApp.MessageBeepType.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mIsValid = true;
|
||||||
int column = ((SourceEditWidgetContent)editWidgetContent.Content).GetLineEndColumn(line, false, true, true);
|
int column = ((SourceEditWidgetContent)editWidgetContent.Content).GetLineEndColumn(line, false, true, true);
|
||||||
editWidgetContent.Content.CursorLineAndColumn = EditWidgetContent.LineAndColumn(line, column);
|
editWidgetContent.Content.CursorLineAndColumn = EditWidgetContent.LineAndColumn(line, column);
|
||||||
editWidgetContent.Content.CursorMoved();
|
editWidgetContent.Content.CursorMoved();
|
||||||
|
@ -74,8 +80,23 @@ namespace IDE.ui
|
||||||
editWidgetContent.Content.mSelection = EditSelection(lineStart, lineEnd + 1);
|
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()
|
void Cancel()
|
||||||
{
|
{
|
||||||
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
var editWidgetContent = mSourceViewPanel.mEditWidget;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue