private void insertByteArray(IIde ide) { string @default, selected = ide.GetSelectedText(); try { @default = ScliptingUtil.DecodeByteArray(selected).ToHex(); } catch { @default = ""; } var line = InputBox.GetLine("Type a byte array to insert (in hexdump format; two hexadecimal digits per byte):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) { try { ide.InsertText(ScliptingUtil.EncodeByteArray(line.FromHex())); } catch { DlgMessage.Show("The text you entered is not valid hexadecimal. Please ensure that you enter an even number of characters 0-9/a-f.", "Esoteric IDE", DlgType.Error, "&OK"); } } }
private void insertInteger(IIde ide) { string @default, selected = ide.GetSelectedText(); try { if (selected.Length == 1 && selected[0] >= 0xbc00 && selected[0] <= 0xd7a3) { @default = (0xbbff - selected[0]).ToString(); } else { @default = new BigInteger(new byte[] { 0 }.Concat(ScliptingUtil.DecodeByteArray(selected)).Reverse().ToArray()).ToString(); } } catch { @default = "0"; } var line = InputBox.GetLine("Type an integer to insert (must be greater than −7077):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) { BigInteger i; if (BigInteger.TryParse(line, out i) && (i >= -7076)) { if (i < 0) { ide.InsertText(((char)(0xbbff - i)).ToString()); } else { ide.InsertText(ScliptingUtil.EncodeByteArray(i.ToByteArray().Reverse().SkipWhile(b => b == 0).DefaultIfEmpty().ToArray())); } } else { DlgMessage.Show("The integer you typed is not a valid literal integer for Sclipting. Literal integers must be greater than −7077.", "Esoteric IDE", DlgType.Error, "&OK"); } } }
private void insertString(IIde ide) { string @default, selected = ide.GetSelectedText(); try { if (selected.Length == 1 && selected[0] >= 0xbc00 && selected[0] <= 0xd7a3) { @default = (0xbbff - selected[0]).ToString(); } else { @default = ScliptingUtil.DecodeByteArray(selected).FromUtf8().CLiteralEscape(); } } catch { @default = "\\n"; } var line = InputBox.GetLine("Type a string to insert (in C-escaped format; backslashes must be escaped):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) { try { ide.InsertText(ScliptingUtil.EncodeByteArray(line.CLiteralUnescape().ToUtf8())); } catch { DlgMessage.Show("The string you typed is not a valid C-escaped string. Please ensure that your backslashes are escaped.", "Esoteric IDE", DlgType.Error, "&OK"); } } }
private void insertString(IIde ide) { string @default, selected = ide.GetSelectedText(); try { if (selected.Length == 1 && selected[0] >= 0xbc00 && selected[0] <= 0xd7a3) @default = (0xbbff - selected[0]).ToString(); else @default = ScliptingUtil.DecodeByteArray(selected).FromUtf8().CLiteralEscape(); } catch { @default = "\\n"; } var line = InputBox.GetLine("Type a string to insert (in C-escaped format; backslashes must be escaped):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) try { ide.InsertText(ScliptingUtil.EncodeByteArray(line.CLiteralUnescape().ToUtf8())); } catch { DlgMessage.Show("The string you typed is not a valid C-escaped string. Please ensure that your backslashes are escaped.", "Esoteric IDE", DlgType.Error, "&OK"); } }
private void insertInteger(IIde ide) { string @default, selected = ide.GetSelectedText(); try { if (selected.Length == 1 && selected[0] >= 0xbc00 && selected[0] <= 0xd7a3) @default = (0xbbff - selected[0]).ToString(); else @default = new BigInteger(new byte[] { 0 }.Concat(ScliptingUtil.DecodeByteArray(selected)).Reverse().ToArray()).ToString(); } catch { @default = "0"; } var line = InputBox.GetLine("Type an integer to insert (must be greater than −7077):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) { BigInteger i; if (BigInteger.TryParse(line, out i) && (i >= -7076)) { if (i < 0) ide.InsertText(((char) (0xbbff - i)).ToString()); else ide.InsertText(ScliptingUtil.EncodeByteArray(i.ToByteArray().Reverse().SkipWhile(b => b == 0).DefaultIfEmpty().ToArray())); } else DlgMessage.Show("The integer you typed is not a valid literal integer for Sclipting. Literal integers must be greater than −7077.", "Esoteric IDE", DlgType.Error, "&OK"); } }
private void insertByteArray(IIde ide) { string @default, selected = ide.GetSelectedText(); try { @default = ScliptingUtil.DecodeByteArray(selected).ToHex(); } catch { @default = ""; } var line = InputBox.GetLine("Type a byte array to insert (in hexdump format; two hexadecimal digits per byte):", @default, "Esoteric IDE", "&OK", "&Cancel"); if (line != null) try { ide.InsertText(ScliptingUtil.EncodeByteArray(line.FromHex())); } catch { DlgMessage.Show("The text you entered is not valid hexadecimal. Please ensure that you enter an even number of characters 0-9/a-f.", "Esoteric IDE", DlgType.Error, "&OK"); } }