1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-06 16:25:59 +02:00

Minor IDE changes

This commit is contained in:
Brian Fiete 2019-09-27 13:03:47 -07:00
parent be3c968e2b
commit 2ea5d31c37
15 changed files with 373 additions and 87 deletions

View file

@ -1919,6 +1919,37 @@ namespace Beefy.widgets
InsertAtCursor(text);
}
public void CutText()
{
if (!CheckReadOnly())
{
String selText = scope String();
GetSelectionText(selText);
if (!selText.IsWhiteSpace)
{
BFApp.sApp.SetClipboardText(selText);
DeleteSelection();
}
}
}
public void CopyText()
{
String selText = scope String();
GetSelectionText(selText);
if (!selText.IsWhiteSpace)
BFApp.sApp.SetClipboardText(selText);
}
public void PasteText()
{
String aText = scope String();
BFApp.sApp.GetClipboardText(aText);
aText.Replace("\r", "");
if ((aText != null) && (!CheckReadOnly()))
PasteText(aText);
}
public override void KeyDown(KeyCode keyCode, bool isRepeat)
{
base.KeyDown(keyCode, isRepeat);
@ -1944,38 +1975,16 @@ namespace Beefy.widgets
{
case (KeyCode)'A':
SelectAll();
break;
case (KeyCode)'C':
String selText = scope String();
GetSelectionText(selText);
if (!selText.IsWhiteSpace)
BFApp.sApp.SetClipboardText(selText);
break;
CopyText();
case (KeyCode)'X':
if (!CheckReadOnly())
{
String selText = scope String();
GetSelectionText(selText);
if (!selText.IsWhiteSpace)
{
BFApp.sApp.SetClipboardText(selText);
DeleteSelection();
}
}
break;
CutText();
case (KeyCode)'V':
String aText = scope String();
BFApp.sApp.GetClipboardText(aText);
aText.Replace("\r", "");
if ((aText != null) && (!CheckReadOnly()))
PasteText(aText);
break;
PasteText();
case (KeyCode)'Z':
Undo();
break;
case (KeyCode)'Y':
Redo();
break;
case .Return:
if (mIsMultiline)
mEditWidget.Submit();

View file

@ -54,9 +54,9 @@ namespace System.IO
}
public static void GetFileName(String inPath, String outFileName)
public static void GetFileName(StringView inPath, String outFileName)
{
if (inPath == null)
if (inPath.IsEmpty)
return;
CheckInvalidPathChars(inPath);
@ -236,7 +236,7 @@ namespace System.IO
outFileName.Append(inPath, lastSlash + 1);
}
public static Result<void> GetExtension(String inPath, String outExt)
public static Result<void> GetExtension(StringView inPath, String outExt)
{
int i;
if ((i = inPath.LastIndexOf('.')) != -1)

View file

@ -561,6 +561,17 @@ namespace System.IO
return .Ok;
}
public Result<char8> Read()
{
if (mStream == null)
return .Err;
if (mCharPos == mCharLen)
{
if (Try!(ReadBuffer()) == 0) return .Err;
}
return mCharBuffer[mCharPos++];
}
public struct LineReader : IEnumerator<Result<StringView>>
{
StreamReader mStreamReader;

View file

@ -1,3 +1,5 @@
using System.Globalization;
namespace System
{
struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
@ -120,17 +122,19 @@ namespace System
ToString(outString, minNumerals);
}
public static Result<int32, ParseError> Parse(StringView val)
public static Result<int32, ParseError> Parse(StringView val, NumberStyles style)
{
if (val.Length == 0)
if (val.IsEmpty)
return .Err(.NoValue);
bool isNeg = false;
int32 result = 0;
//TODO: Use Number.ParseNumber
int32 result = 0;
int32 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
for (int32 i = 0; i < val.Length; i++)
{
char8 c = val.Ptr[i];
char8 c = val[i];
if ((i == 0) && (c == '-'))
{
@ -140,13 +144,39 @@ namespace System
if ((c >= '0') && (c <= '9'))
{
result *= 10;
result *= radix;
result += (int32)(c - '0');
}
else if ((c >= 'a') && (c <= 'f'))
{
result *= radix;
result += c - 'a' + 10;
}
else if ((c >= 'A') && (c <= 'F'))
{
result *= radix;
result += c - 'A' + 10;
}
else if ((c == 'X') || (c == 'x'))
{
if (result != 0)
return .Err(.InvalidChar(result));
radix = 0x10;
}
else if (c == '\'')
{
// Ignore
}
else
return .Err(.InvalidChar(isNeg ? -result : result));
return .Err(.InvalidChar(result));
}
return .Ok(isNeg ? -result : result);
return isNeg ? -result : result;
}
public static Result<int32, ParseError> Parse(StringView val)
{
return Parse(val, .Any);
}
}
}