Exemplo n.º 1
0
 public OrangeIDE()
 {
     InitializeComponent();
     richCode.AllowDrop = true;
     stopwatch          = new Stopwatch();
     document           = new Document(this, richCode)
     {
         OpenFileDialog = dialogOpen,
         SaveFileDialog = dialogSave
     };
     locked          = false;
     manual          = false;
     verbose         = false;
     fileCache       = new InteractiveFileCache();
     textFile        = @"C:\Enterprise\Orange\Orange.txt"; //OrangeSettings.SettingsFolder + "Orange.txt";
     backupTexts     = new Stack <BackupText>();
     fancy           = false;
     breakpointSaves = new Hash <int, BreakpointSave>();
     //breakHighlight = null;
     matcher   = new Matcher();
     modifying = false;
 }
Exemplo n.º 2
0
        void Playground_Load(object sender, EventArgs e)
        {
            results  = new AutoHash <int, string>(k => "");
            settings = getSettings();

            errorConsole = new TextBoxConsole(this, textErrors, settings.ErrorFont, settings.ErrorFontSize, Cathode);
            errorWriter  = errorConsole.Writer();
            try
            {
                try
                {
                    tabStops = array(32, 64, 96, 128);
                    textEditor.SelectionTabs = tabStops;
                }
                catch (Exception exception)
                {
                    displayException(exception);
                }

                outputConsole = new TextBoxConsole(this, textConsole, settings.ConsoleFont, settings.ConsoleFontSize, Quick);
                consoleWriter = outputConsole.Writer();
                textReader    = outputConsole.Reader();

                document = new Document(this, textEditor, ".orange", "Orange", settings.EditorFont, settings.EditorFontSize);
                document.StandardMenus();
                menus = document.Menus;
                menus.Menu(MENU_FILE, "Set Current Folder", (s, evt) => setCurrentFolder());

                menus.Menu(MENU_EDIT, "Duplicate", (s, evt) => duplicate(), "^D");
                menus.Menu(MENU_EDIT, "Indent", (s, evt) => indent(), "^I");
                menus.Menu(MENU_EDIT, "Unindent", (s, evt) => unindent(), "^%I");

                menus.Menu($"&{MENU_BUILD}");
                menus.Menu(MENU_BUILD, "Run", (s, evt) => run(), "F5");
                menus.Menu(MENU_BUILD, "Manual", (s, evt) =>
                {
                    manual = !manual;
                    ((ToolStripMenuItem)s).Checked = manual;
                }, "^F5");

                menus.Menu($"&{MENU_TEXT}");
                menus.Menu(MENU_TEXT, "Clipboard -> Text", (s, evt) =>
                {
                    var text = ClipboardText();
                    if (text.IsSome)
                    {
                        var windowsText = GetWindowsText(text.Value);
                        if (textText.SelectionLength == 0)
                        {
                            textText.Text = windowsText;
                        }
                        else
                        {
                            textText.SelectedText = windowsText;
                        }
                        tabs.SelectedTab = tabText;
                    }
                }, "^|V");
                menus.Menu(MENU_TEXT, "Clipboard -> Append to Text", (s, evt) =>
                {
                    var text = ClipboardText();
                    if (text.IsSome)
                    {
                        var windowsText = GetWindowsText(text.Value);
                        textText.AppendText(windowsText);
                        tabs.SelectedTab = tabText;
                    }
                });
                menus.Menu(MENU_TEXT, "Clipboard -> Text & Run", (s, evt) =>
                {
                    var text = ClipboardText();
                    if (text.IsSome)
                    {
                        textText.Text = GetWindowsText(text.Value);
                    }
                    DoEvents();
                    run();
                    var selectedText = textConsole.SelectionLength == 0 ? textConsole.Text : textConsole.SelectedText;
                    selectedText     = GetWindowsText(selectedText);
                    SetText(selectedText);
                }, "F6");
                menus.Menu(MENU_TEXT, "Text -> Clipboard", (s, evt) =>
                {
                    var text = textConsole.SelectionLength == 0 ? textConsole.Text : textConsole.SelectedText;
                    text     = GetWindowsText(text);
                    SetText(text);
                }, "^|C");
                menus.Menu(MENU_TEXT, "Save text to file", (s, evt) =>
                {
                    var text = textConsole.SelectionLength == 0 ? textConsole.Text : textConsole.SelectedText;
                    text     = GetWindowsText(text);
                    if (dialogSave.ShowDialog() == DialogResult.OK)
                    {
                        FileName file = dialogSave.FileName;
                        try
                        {
                            file.Text = text;
                        }
                        catch (Exception exception)
                        {
                            displayException(exception);
                        }
                    }
                });

                menus.Menu($"&{MENU_INSERT}");
                menus.Menu(MENU_INSERT, "println", (s, evt) => insertText("println ", 0, 0), "^P");
                menus.Menu(MENU_INSERT, "println interpolated", (s, evt) => insertText("println $\"\"", -1, 0), "^%P");
                menus.Menu(MENU_INSERT, "print", (s, evt) => insertText("print ", 0, 0));
                menus.Menu(MENU_INSERT, "manifln", (s, evt) => insertText("manifln ", 0, 0), "^M");
                menus.Menu(MENU_INSERT, "manif", (s, evt) => insertText("manif", 0, 0));
                menus.Menu(MENU_INSERT, "put", (s, evt) => insertText("put ", 0, 0));
                menus.Menu(MENU_INSERT, "peek", (s, evt) => surround("peek(", ")"), "^K");
                menus.MenuSeparator(MENU_INSERT);
                menus.Menu(MENU_INSERT, "if template", (s, evt) => insertTemplate("if true", "true"), "^|I");
                menus.Menu(MENU_INSERT, "while template", (s, evt) => insertTemplate("while true", "true"), "^|W");
                menus.Menu(MENU_INSERT, "for template", (s, evt) => insertTemplate("for i in ^0", "^0"), "^|F");
                menus.Menu(MENU_INSERT, "func template", (s, evt) => insertTemplate("func proc()", "proc"), "^|P");
                menus.Menu(MENU_INSERT, "func template", (s, evt) => insertTemplate("func proc()", "proc"), "^|P");

                menus.CreateMainMenu(this);

                menus.StandardContextEdit(document);

                textEditor.ReassignHandle();

                locked    = false;
                manual    = false;
                stopwatch = new Stopwatch();
                fileCache = new InteractiveFileCache();

                textEditor.Paint += (s, evt) => paintResults(evt);

                setManual(settings.Manual);
                if (settings.DefaultFolder != null)
                {
                    FolderName.Current = settings.DefaultFolder;
                }
                textText.Text = settings.Text.FromBase64(Encoding.UTF8) ?? "";
                if (PassedFileName.IsSome)
                {
                    document.Open(PassedFileName.Value);
                }
                else if (settings.LastFile != null && ((FileName)settings.LastFile).Exists())
                {
                    document.Open(settings.LastFile);
                }
            }
            catch (Exception exception)
            {
                displayException(exception);
            }
        }