Ejemplo n.º 1
0
        private TabPage CreateTab(string name = "", RichTextBoxWPath richTextBoxParam = null)
        {
            TabPage          tabPage = new TabPage();
            RichTextBoxWPath richTextBox;

            if (richTextBoxParam == null)
            {
                richTextBox = new RichTextBoxWPath();
            }
            else
            {
                richTextBox = richTextBoxParam;
            }
            tabPage.Controls.Add(richTextBox);
            if (name == "")
            {
                tabPage.Text = "Page: " + (textEditor.TabCount + 1);
                tabPage.Tag  = "Page: " + (textEditor.TabCount + 1);
            }
            else
            {
                tabPage.Text = name.Substring(name.LastIndexOf("\\") + 1);
                tabPage.Tag  = name;
            }
            richTextBox.Dock = DockStyle.Fill;
            return(tabPage);
        }
Ejemplo n.º 2
0
        private RichTextBoxWPath GetRichTextBoxFromSelectedTab()
        {
            RichTextBoxWPath richTextBox = new RichTextBoxWPath();

            richTextBox = (RichTextBoxWPath)textEditor.SelectedTab.Controls[0];
            return(richTextBox);
        }
Ejemplo n.º 3
0
        private void AddTabPage(TabPage tabPage)
        {
            textEditor.TabPages.Add(tabPage);
            textEditor.SelectedTab = tabPage;
            RichTextBoxWPath richTextBox = (RichTextBoxWPath)tabPage.Controls[0];

            richTextBox.Path = tabPage.Name;
        }
Ejemplo n.º 4
0
 void Open()
 {
     if (openFile.ShowDialog() == DialogResult.OK)
     {
         RichTextBoxWPath richTextBox = new RichTextBoxWPath();
         string           name;
         richTextBox.LoadFile(name = openFile.FileName, RichTextBoxStreamType.PlainText);
         TabPage tabPage = CreateTab(name, richTextBox);
         tabPage.Controls.Add(richTextBox);
         AddTabPage(tabPage);
         richTextBox.Path = name;
     }
 }
Ejemplo n.º 5
0
        private void RunProgram_Click(object sender, EventArgs e)
        {
            output.Clear();
            RichTextBoxWPath richTextBox = new RichTextBoxWPath();

            richTextBox = (RichTextBoxWPath)textEditor.SelectedTab.Controls[0];
            string    sourceCode = richTextBox.Text;
            InputData inputData  = new InputData();

            inputData.callInputBox = RunInputBox;
            string result = Interpreter.RunInterpreter(sourceCode, inputData);

            output.Text = result;
        }
Ejemplo n.º 6
0
        private void Debugger(bool ended)
        {
            if (!ended)
            {
                for (int ind = 0; ind < DebugCells.RowCount; ind++)
                {
                    DebugCells.Rows[ind].Cells[1].Value = BfInterpreter.buf[ind];
                }
                RichTextBoxWPath richTextBox = GetRichTextBoxFromSelectedTab();
                if (debugResult.commands == "")
                {
                    debugResult.commands = richTextBox.Text;
                }
                if (debugResult.commands.Length == 0)
                {
                    return;
                }
                int right = richTextBox.TextLength;
                while ((debugResult.i < right) && (bfCommands.IndexOf(debugResult.commands[debugResult.i]) == -1))
                {
                    debugResult.i++;
                }

                if (debugResult.i < right)
                {
                    SelectCharacter(richTextBox, debugResult.i);

                    InputData inputData = new InputData();
                    inputData.callInputBox = RunInputBox;

                    debugResult = BfInterpreter.DebugProgram(debugResult, inputData);
                    debugResult.i++;
                }
                else
                {
                    return;
                }
                output.Text = debugResult.resultStr.ToString();
            }
            if (ended)
            {
                output.Clear();
                debugResult.ClearResult();
                BfInterpreter.Reset();
            }
        }
Ejemplo n.º 7
0
 private void Save()
 {
     if (saveFile.ShowDialog() == DialogResult.OK)
     {
         try
         {
             RichTextBoxWPath richTextBox = GetRichTextBoxFromSelectedTab();
             string           name;
             richTextBox.SaveFile(name = saveFile.FileName, RichTextBoxStreamType.PlainText);
             richTextBox.Path          = name;
             name = name.Substring(name.LastIndexOf("\\") + 1);
             textEditor.SelectedTab.Text = name;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Ejemplo n.º 8
0
 private void Compile_Click(object sender, EventArgs e)
 {
     try
     {
         RichTextBoxWPath richTextBox = new RichTextBoxWPath();
         richTextBox = (RichTextBoxWPath)textEditor.SelectedTab.Controls[0];
         if (richTextBox.Path != "")
         {
             Compiler.StartCompiler(richTextBox.Path);
         }
         else
         {
             MessageBox.Show("Please, Save first, then repeat attempt");
             return;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Please, Save first, then repeat attempt");
         return;
     }
 }
Ejemplo n.º 9
0
 private void SelectCharacter(RichTextBoxWPath rtb, int index)
 {
     rtb.SelectionStart  = index;
     rtb.SelectionLength = 1;
     rtb.Select();
 }