private void AddDebugPage(CodeFileDocumentControl tp)
 {
     if (TabStack.Count > 0 && !TabStack.Contains(tp))
     {
         CodeFileDocumentControl cfdc = TabStack[TabStack.Count - 1];
         //TabStack.RemoveAt(TabStack.Count-1);
         RichTextBox tb = null;
         if (OutputTextBoxs.ContainsKey(cfdc))
         {
             tb = OutputTextBoxs[cfdc];
             RichTextBox new_tb = OutputTextBoxs[tp];
             new_tb.Text = tb.Text;
         }
         OutputWindow.OutputTextBoxScrolToEnd();
     }
     if (!TabStack.Contains(tp))
     {
         TabStack.Add(tp);
         OutputBoxStack.Add(OutputTextBoxs[tp]);
     }
     if (DebugTabs[tp] != null)
     {
         return;
     }
     DebugTabs[tp] = tp.TextEditor.ActiveTextAreaControl.TextArea;
     TextAreaHelper.TextAreas[tp.TextEditor.ActiveTextAreaControl.TextArea] = tp.FileName;
     tp.TextEditor.ActiveTextAreaControl.TextArea.ToolTipRequest           += WorkbenchServiceFactory.DebuggerManager.TextAreaToolTipRequest;
 }
Esempio n. 2
0
 public bool SaveAll(bool Question)
 {
     if (ProjectFactory.Instance.ProjectLoaded && Question)
     {
         return(SaveAllInProject() != 2);
     }
     SaveCanceled = false;
     CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
     OpenDocuments.Values.CopyTo(l, 0);
     foreach (CodeFileDocumentControl tp in l)
     {
         if (tp.DocumentChanged && !tp.FromMetadata)
         {
             if (Question)
             {
                 if (!QuestionAndSaveFile(tp))
                 {
                     SaveCanceled = true;
                     return(false);
                 }
             }
             else
             {
                 SaveSelFile(tp);
             }
         }
     }
     UpdateSaveButtonsEnabled();
     return(true);
 }
        private CodeFileDocumentControl AddNewProgramToTab(DockPanel tabControl, string FileName)
        {
            CodeFileDocumentControl edit = AddNewTab(tabControl);

            edit.FileName = FileName;
            SetTabPageText(edit);
            edit.SetHighlightingStrategyForFile(FileName);
            OpenDocuments.Add(Tools.FileNameToLower(FileName), edit);
            //this.codeCompletionParserController.SetAsChanged(FileName);
            //ivan
            AddBreakPointHandler(edit, FileName);
            var RunService = WorkbenchServiceFactory.RunService;

            if (!RunService.HasRunArgument(FileName.ToLower()))
            {
                RunService.AddRunArgument(FileName.ToLower(), "");
            }
            if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
            {
                AddEditorHandlers(edit);
            }
            CodeCompletionKeyHandler.Attach(edit.TextEditor);
            edit.TextEditor.ActiveTextAreaControl.TextArea.KeyEventHandler += TextArea_KeyEventHandler;

            //HostCallbackImplementation.Register(this);

            //\ivan
            return(edit);
        }
Esempio n. 4
0
        private void ExecuteSaveAs(CodeFileDocumentControl TbPage)
        {
            //if (TbPage.DesignerAndCodeTabs != null)
            //{
            //    TbPage.GenerateDesignerCode();
            //}
            CodeFileDocumentControl bakTab = CurrentCodeFileDocument;

            CurrentCodeFileDocument  = TbPage;
            saveFileDialog1.FileName = Path.GetFileName(CurrentSourceFileName);
            string id = Path.GetDirectoryName(CurrentSourceFileName);

            if (id == "")
            {
                if (WorkbenchStorage.WorkingDirectoryExsist)
                {
                    saveFileDialog1.InitialDirectory = WorkbenchStorage.WorkingDirectory;
                }
            }
            else
            {
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(CurrentSourceFileName);
            }
            DialogResult dr = saveFileDialog1.ShowDialog();

            CurrentCodeFileDocument = bakTab;
        }
Esempio n. 5
0
        private void AddBreakPointHandler(CodeFileDocumentControl tp, string FileName)
        {
            string name = tp.FileName;

            TextAreaHelper.TextAreas[tp.TextEditor.ActiveTextAreaControl.TextArea] = FileName;
            tp.TextEditor.ActiveTextAreaControl.TextArea.IconBarMargin.MouseDown  += BreakPointFactory.IconBarMouseDown;
        }
        public void OpenTabWithText(string tabName, string Text)
        {
            CodeFileDocumentControl edit = FindTab(tabName + ".pas");

            if (edit != null)
            {
                CurrentCodeFileDocument = edit;
                return;
            }
            edit = AddNewTab(MainDockPanel);
            edit.FromMetadata = true;
            OpenDocuments.Add(Tools.FileNameToLower(tabName + ".pas"), edit);
            CloseButtonsEnabled = OpenDocuments.Count > 1;
            edit.FileName       = tabName + ".pas";
            edit.Text           = tabName;
            edit.SetHighlightingStrategyForFile("prog.pas");
            edit.TextEditor.Document.Insert(0, Text);
            if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
            {
                AddEditorHandlers(edit);
            }
            WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(tabName + ".pas");
            //edit.FileName = FileName;
            //SetTabPageText(edit);
        }
Esempio n. 7
0
        public bool CloseProject()
        {
            if (SaveAllInProject() == 2)
            {
                return(false);
            }
            BottomTabsVisible = true;
            ProjectUserOptionsManager.SaveOptions(ProjectFactory.Instance.CurrentProject.Path);
            CloseProjectFiles();
            ProjectFactory.Instance.CloseProject();
            ProjectExplorerWindow.Clear();
            HideContent(ProjectExplorerWindow);
            HideContent(PropertiesWindow);
            if (ToolBoxWindow != null)
            {
                HideContent(ToolBoxWindow);
            }
            this.miProjectExplorer.Visible = false;
            CodeFileDocumentControl tmp = CurrentCodeFileDocument;

            //CloseAllButThis(CurrentCodeFileDocument);
            RestoreFiles();
            RestoreWatch();
            //CloseFile(tmp, false);
            WorkbenchServiceFactory.BuildService.CompilerOptions.ProjectCompiled = false;
            mrDesigner.Visible     = false;
            miCloseProject.Visible = false;
            this.mRPROJECTToolStripMenuItem.Visible = false;
            CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = null;
            return(true);
        }
Esempio n. 8
0
        public void RenameFile(string OldFileName, string NewFileName)
        {
            CodeFileDocumentControl cfdc = FindTab(OldFileName);

            if (cfdc == null)
            {
                try
                {
                    File.Copy(OldFileName, NewFileName);
                    File.Delete(OldFileName);
                }
                catch
                {
                }
                return;
            }
            SaveFileAs(cfdc, NewFileName);
            try
            {
                File.Delete(OldFileName);
            }
            catch
            {
            }
        }
Esempio n. 9
0
        public void SetFileAsChanged(string FileName)
        {
            CodeFileDocumentControl tab = FindTab(FileName);

            if (tab != null)
            {
                tab.DocumentChanged = true;
                SetTabPageText(tab);
            }
        }
Esempio n. 10
0
        public void ReloadFile(string FileName)
        {
            CodeFileDocumentControl tab = FindTab(FileName);

            if (tab != null)
            {
                tab.LoadFromFile(FileName);
                tab.DocumentChanged = false;
                SetTabPageText(tab);
            }
        }
Esempio n. 11
0
 private void SaveSelFileAs(CodeFileDocumentControl TbPage, string FileName)
 {
     if (!TbPage.DocumentSavedToDisk)
     {
         ExecuteSaveAs(TbPage);
     }
     else
     {
         SaveFileAs(TbPage, FileName);
     }
 }
Esempio n. 12
0
        public CodeFileDocumentControl FindTab(string FileName)
        {
            if (FileName == null)
            {
                return(null);
            }
            CodeFileDocumentControl tp = null;

            OpenDocuments.TryGetValue(Tools.FileNameToLower(FileName), out tp);
            return(tp);
        }
Esempio n. 13
0
 private void RemoveEditorHandlers(CodeFileDocumentControl tp)
 {
     tp.TextEditor.RemoveToolTipRequestHandler(TooltipServiceManager.ToolTipService_TextAreaToolTipRequest);
     tp.TextEditor.RemoveMouseMoveHandler(TooltipServiceManager.ToolTipService_TextAreaMouseMove);
     tp.TextEditor.RemoveKeyDownHandler(TooltipServiceManager.ToolTipService_TextAreaKeyDown);
     tp.TextEditor.RemoveMouseWheelHandler(TooltipServiceManager.ToolTipService_TextAreaMouseEvent_HideToolTip);
     tp.TextEditor.RemoveMouseDownHandler(TooltipServiceManager.ToolTipService_TextAreaMouseEvent_HideToolTip);
     tp.TextEditor.RemoveMouseMoveHandler(DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseMove);
     tp.TextEditor.ActiveTextAreaControl.TextArea.Click -= DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseDown;
     //tp.TextEditor.RemoveMouseMoveHandler(DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseDown);
 }
Esempio n. 14
0
        public static void Rename(TextArea textArea)
        {
            if (CodeCompletion.CodeCompletionController.CurrentParser == null)
            {
                return;
            }
            IDocument doc         = textArea.Document;
            string    textContent = doc.TextContent;

            ccp = new CodeCompletionProvider();
            string name                       = null;
            string expressionResult           = FindOnlyIdent(textContent, textArea, ref name).Trim(' ', '\n', '\t', '\r');
            string new_val                    = null;
            List <SymbolsViewerSymbol> refers = ccp.Rename(expressionResult, name, textArea.MotherTextEditorControl.FileName, textArea.Caret.Line, textArea.Caret.Column, ref new_val);

            if (refers == null || new_val == null)
            {
                return;
            }
            int addit = 0;

            PascalABCCompiler.SourceLocation tmp = new PascalABCCompiler.SourceLocation(null, 0, 0, 0, 0);
            string file_name = null;

            foreach (SymbolsViewerSymbol svs in refers)
            {
                if (svs.SourceLocation.BeginPosition.Line != tmp.BeginPosition.Line)
                {
                    addit = 0;
                }
                else if (svs.SourceLocation.BeginPosition.Column < tmp.BeginPosition.Column)
                {
                    addit = 0;
                }
                if (svs.SourceLocation.FileName != file_name)
                {
                    CodeFileDocumentControl cfdoc = VisualPABCSingleton.MainForm.FindTab(svs.SourceLocation.FileName);
                    if (cfdoc == null)
                    {
                        continue;
                    }
                    doc       = cfdoc.TextEditor.ActiveTextAreaControl.TextArea.Document;
                    file_name = svs.SourceLocation.FileName;
                }
                tmp = svs.SourceLocation;
                TextLocation tl_beg = new TextLocation(svs.SourceLocation.BeginPosition.Column - 1 + addit, svs.SourceLocation.BeginPosition.Line - 1);
                //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column);
                int offset = doc.PositionToOffset(tl_beg);
                addit += new_val.Length - name.Length;
                doc.Replace(offset, name.Length, new_val);
                doc.CommitUpdate();
            }
        }
Esempio n. 15
0
        internal void CloseProjectFiles()
        {
            CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
            OpenDocuments.Values.CopyTo(l, 0);

            foreach (CodeFileDocumentControl tp in l)
            {
                if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(tp.FileName))
                {
                    CloseFile(tp, false);
                }
            }
        }
Esempio n. 16
0
        public void CloseFile(string FileName)
        {
            CodeFileDocumentControl tp = FindTab(FileName);

            if (tp != null)
            {
                CloseFile(tp);
                if (OpenDocuments.Count == 0)
                {
                    OpenFile(null, null);
                }
            }
        }
Esempio n. 17
0
        void CloseAllButThis(CodeFileDocumentControl nonCloseTab)
        {
            SaveCanceled = false;
            CodeFileDocumentControl bakTab = CurrentCodeFileDocument;

            /*foreach (TabPage tbPage in tabControl1.TabPages)
             *  if (tbPage != tabControl1.SelectedTab)
             *      CloseFile(tbPage);*/
            List <CodeFileDocumentControl> to_close = new List <CodeFileDocumentControl>();

            foreach (CodeFileDocumentControl tbPage in OpenDocuments.Values)
            {
                if (SaveCanceled)
                {
                    break;
                }
                if (tbPage != nonCloseTab)
                {
                    if (tbPage == bakTab)
                    {
                        bakTab = null;
                    }
                    to_close.Add(tbPage);
                }
            }
            if (!SaveCanceled)
            {
                foreach (CodeFileDocumentControl tbPage in to_close)
                {
                    tbPage.Close();
                }
            }
            if (bakTab != null)
            {
                if (bakTab != CurrentCodeFileDocument)
                {
                    CurrentCodeFileDocument = bakTab;
                }
            }
            List <WebBrowserControl> todelete = new List <WebBrowserControl>();

            foreach (WebBrowserControl browserTab in OpenBrowserDocuments.Values)
            {
                todelete.Add(browserTab);
            }
            foreach (WebBrowserControl browserTab in todelete)
            {
                browserTab.Close();
            }
            //OpenBrowserDocuments.Clear();
        }
Esempio n. 18
0
        public void CloseFile(CodeFileDocumentControl tp, bool ask_for_save = true)
        {
            string FileName = tp.FileName.ToLower();
            string exeName  = tp.EXEFileName;

            if (WorkbenchServiceFactory.RunService.IsRun(exeName))
            {
                WorkbenchServiceFactory.RunService.Stop(exeName);
            }
            if (ask_for_save)
            {
                if (tp.DocumentChanged && !tp.FromMetadata)
                {
                    if (!QuestionAndSaveFile(tp))
                    {
                        SaveCanceled = true;
                        return;
                    }
                }
            }
            if (tp.DocumentSavedToDisk)
            {
                AddLastFile(CurrentSourceFileName);
            }
            if (LastSelectedTab != null && !LastSelectedTab.IsDisposed)
            {
                CurrentCodeFileDocument = LastSelectedTab;
            }
            if (tp == ActiveCodeFileDocument)
            {
                ActiveCodeFileDocument = null;
            }
            OutputTextBoxs.Remove(tp);
            OpenDocuments.Remove(Tools.FileNameToLower(tp.FileName));
            //RunArgumentsTable.Remove(tp);
            tp.Dispose();
            CheckErrorListAndClear(FileName);
            WatcherService.RemoveWatcher(FileName);
            if (OpenDocuments.Count == 1)
            {
                CloseButtonsEnabled = false;
            }
            SaveAllButtonsEnabled = !AllSaved();
            WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(FileName);
            WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated -= tp.TextEditor.UpdateFolding;
            CodeCompletionKeyHandler.Detach(tp.TextEditor);
            tp.TextEditor.Document.DocumentChanged -= tp.Document_DocumentChanged;
            tp.TextEditor.Document.TextContent      = "";
            tp.TextEditor.Document.DocumentChanged += tp.Document_DocumentChanged;
            GC.Collect();
        }
Esempio n. 19
0
        public CodeFileDocumentControl OpenFileAndNoSelection(string FileName)
        {
            CodeFileDocumentControl tp = FindTab(FileName);

            if (tp != null)
            {
                return(tp);
            }
            tp = AddNewProgramToTab(MainDockPanel, FileName);
            AddLastFile(FileName);
            tp.LoadFromFile(FileName);
            tp.DocumentSavedToDisk = true;
            ShowAddedBreakpoints(tp);
            return(tp);
        }
        public object SourceFilesProvider(string FileName, PascalABCCompiler.SourceFileOperation FileOperation)
        {
            CodeFileDocumentControl tp = null;

            ICSharpCode.TextEditor.TextEditorControl ed = null;
            if (OpenDocuments.TryGetValue(Tools.FileNameToLower(FileName), out tp))
            {
                ed = tp.TextEditor;
            }


            switch (FileOperation)
            {
            case PascalABCCompiler.SourceFileOperation.GetText:
                if (tp != null)
                {
                    return(ed.Document.TextContent);
                }
                if (!File.Exists(FileName))
                {
                    return(null);
                }

                /*TextReader tr = new StreamReader(FileName, System.Text.Encoding.GetEncoding(1251));
                 * string Text = tr.ReadToEnd();
                 * tr.Close();*/
                string Text = PascalABCCompiler.FileReader.ReadFileContent(FileName, null);
                return(Text);

            case PascalABCCompiler.SourceFileOperation.Exists:
                if (tp != null)
                {
                    return(true);
                }
                return(File.Exists(FileName));

            case PascalABCCompiler.SourceFileOperation.GetLastWriteTime:
                if (tp != null)
                {
                    return(tp.ModifyDateTime);
                }
                return(File.GetLastWriteTime(FileName));

            case PascalABCCompiler.SourceFileOperation.FileEncoding:
                return(DefaultFileEncoding);
            }
            return(null);
        }
Esempio n. 21
0
        private void GenerateMainProgramForDesigner(string MainFileName)
        {
            if (_currentCodeFileDocument.DesignerAndCodeTabs == null)
            {
                //string caption = PascalABCCompiler.StringResources.Get("VP_MF_FORM_DESIGNER");
                //string text = PascalABCCompiler.StringResources.Get("VP_MF_SHOULD_CREATE_FORM_FIRST");
                //MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            CodeFileDocumentControl DesignerDocument = _currentCodeFileDocument;

            WorkbenchServiceFactory.FileService.OpenFile(MainFileName, null);
            _currentCodeFileDocument.GenerateMainProgram(
                Path.GetFileNameWithoutExtension(DesignerDocument.FileName), DesignerDocument.FormName);
            CurrentCodeFileDocument = DesignerDocument;
        }
Esempio n. 22
0
        bool QuestionAndSaveFile(CodeFileDocumentControl tp)
        {
            CurrentCodeFileDocument = tp;
            DialogResult result = MessageBox.Show(string.Format(Form1StringResources.Get("SAVE_CHANGES_IN_FILE{0}"), Path.GetFileName(tp.FileName)), PascalABCCompiler.StringResources.Get("!CONFIRM"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                SaveSelFile(CurrentCodeFileDocument);
            }
            else
            if (result == DialogResult.Cancel)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 23
0
 internal void SaveFileAs(CodeFileDocumentControl TbPage, string FileName)
 {
     try
     {
         if (TbPage.DesignerAndCodeTabs != null)
         {
             TbPage.GenerateDesignerCode(null);
         }
         CodeFileDocumentControl dt = TbPage;
         WatcherService.DisableWatcher(FileName);
         //dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding;
         if (!dt.TextEditor.CanSaveWithCurrentEncoding())
         {
             dt.TextEditor.Encoding = Encoding.UTF8;
             dt.TextEditor.SaveFile(FileName);
             dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding;
         }
         else
         {
             dt.TextEditor.SaveFile(FileName);
         }
         WatcherService.EnableWatcher(FileName);
         OpenDocuments.Remove(Tools.FileNameToLower(dt.FileName));
         OpenDocuments.Add(Tools.FileNameToLower(FileName), TbPage);
         WorkbenchServiceFactory.CodeCompletionParserController.RenameFile(dt.FileName, FileName);
         TbPage.SaveFormFile(FileName);
         dt.DocumentChanged     = false;
         dt.FileName            = FileName;
         dt.DocumentSavedToDisk = true;
         dt.SetHighlightingStrategyForFile(FileName);
         SetTabPageText(TbPage);
         if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower()))
         {
             WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), "");
         }
         if (TbPage == CurrentCodeFileDocument)
         {
             UpdateSaveButtonsEnabled();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format(Form1StringResources.Get("SAVE_FILE_ERROR_TEXT{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 24
0
        private CodeFileDocumentControl AddNewTab(DockPanel tabControl, DockStyle dockStyle = DockStyle.Fill)
        {
            CodeFileDocumentControl tp = new CodeFileDocumentControl(this);
            //tp.BorderStyle=BorderStyle.Fixed3D;
            //tp.Font = new Font("MS Sans Serif", tp.Font.Size);
            RichTextBox tb = OutputWindow.outputTextBox;

            if (OpenDocuments.Count > 0)
            {
                tb = CopyTextBox(OutputWindow.outputTextBox);
            }
            AddWindowToDockPanel(tp, tabControl, tp.Dock != dockStyle?dockStyle:tp.Dock, DockState.Document, tp.IsFloat, null, 0);
            OutputTextBoxs.Add(tp, tb);

            WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated += tp.TextEditor.UpdateFolding;
            return(tp);
            //tabControl.SelectedTab = tp;
        }
Esempio n. 25
0
        public void SynEdit_ChangeText(object sender, CodeFileDocumentControl cfdc)
        {
            CodeFileDocumentControl d = cfdc;

            if (!d.DocumentChanged && !visualStates.FileOpened)//!((Data)tabControl1.SelectedTab.Tag).FileOpened)
            {
                d.DocumentChanged = true;
                SetTabPageText(CurrentCodeFileDocument);
                if (!d.FromMetadata)
                {
                    SaveAllButtonsEnabled = SaveButtonsEnabled = true;
                }
            }

            NavigationLocationChanged();
            UpdateUndoRedoEnabled();
            WorkbenchServiceFactory.CodeCompletionParserController.SetAsChanged(cfdc.FileName);
        }
Esempio n. 26
0
        internal int SaveAllInProject()
        {
            SaveCanceled = false;
            CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
            OpenDocuments.Values.CopyTo(l, 0);
            bool changed = false;

            foreach (CodeFileDocumentControl tp in l)
            {
                if (tp.DocumentChanged && !tp.FromMetadata && ProjectFactory.Instance.CurrentProject.ContainsSourceFile(tp.FileName))
                {
                    changed = true;
                    break;
                }
            }
            if (!changed)
            {
                return(1);
            }
            int result = QuestionAndSaveProject();

            if (result == 2)
            {
                return(result);
            }
            if (result == 0)
            {
                foreach (CodeFileDocumentControl tp in l)
                {
                    if (tp.DocumentChanged && !tp.FromMetadata)
                    {
                        SaveSelFile(tp);
                    }
                }
            }
            UpdateSaveButtonsEnabled();
            return(result);
        }
        public void UpdateUndoRedoEnabled()                      //roman// public
        {
            CodeFileDocumentControl d = CurrentCodeFileDocument; //roman//

            if (d.DesignerAndCodeTabs != null)
            {
                if (d.DesignerPage != null && d.Designer != null && d.DesignerAndCodeTabs.SelectedTab == d.DesignerPage)
                {
                    UndoButtonsEnabled = d.Designer.EnableUndo;
                    RedoButtonsEnabled = d.Designer.EnableRedo;
                }
                else
                {
                    UndoButtonsEnabled = d.CanUndo;
                    RedoButtonsEnabled = d.CanRedo;
                }
            }
            else
            {
                UndoButtonsEnabled = d.CanUndo;
                RedoButtonsEnabled = d.CanRedo;
            }
        }
Esempio n. 28
0
        private CodeFileDocumentControl AddNewTab(DockPanel tabControl)
        {
            CodeFileDocumentControl tp = new CodeFileDocumentControl(this);
            //tp.BorderStyle=BorderStyle.Fixed3D;
            //tp.Font = new Font("MS Sans Serif", tp.Font.Size);
            RichTextBox tb = OutputWindow.outputTextBox;
            if (OpenDocuments.Count > 0)
                tb = CopyTextBox(OutputWindow.outputTextBox);
            AddWindowToDockPanel(tp, tabControl, tp.Dock, DockState.Document, tp.IsFloat, null, 0);
            OutputTextBoxs.Add(tp, tb);

            WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated += tp.TextEditor.UpdateFolding;
            return tp;
            //tabControl.SelectedTab = tp;
        }
Esempio n. 29
0
 public void SetAsPossibleDebugPage(CodeFileDocumentControl ctrl)
 {
 	if (IsRunning && tab_changed && ctrl != this.curPage)
 	{
 		curPage = ctrl;
 	}
 	tab_changed = false;
 }
Esempio n. 30
0
 private void RemoveEditorHandlers(CodeFileDocumentControl tp)
 {
     tp.TextEditor.RemoveToolTipRequestHandler(TooltipServiceManager.ToolTipService_TextAreaToolTipRequest);
     tp.TextEditor.RemoveMouseMoveHandler(TooltipServiceManager.ToolTipService_TextAreaMouseMove);
     tp.TextEditor.RemoveKeyDownHandler(TooltipServiceManager.ToolTipService_TextAreaKeyDown);
     tp.TextEditor.RemoveMouseWheelHandler(TooltipServiceManager.ToolTipService_TextAreaMouseEvent_HideToolTip);
     tp.TextEditor.RemoveMouseDownHandler(TooltipServiceManager.ToolTipService_TextAreaMouseEvent_HideToolTip);
     tp.TextEditor.RemoveMouseMoveHandler(DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseMove);
     tp.TextEditor.ActiveTextAreaControl.TextArea.Click -= DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseDown;
     //tp.TextEditor.RemoveMouseMoveHandler(DefinitionByMouseClickManager.DefinitionByMouseClickManager_TextAreaMouseDown);
 }
Esempio n. 31
0
        public void SynEdit_ChangeText(object sender, CodeFileDocumentControl cfdc)
        {
            CodeFileDocumentControl d = cfdc;
            if (!d.DocumentChanged && !visualStates.FileOpened)//!((Data)tabControl1.SelectedTab.Tag).FileOpened) 
            {
                d.DocumentChanged = true;
                SetTabPageText(CurrentCodeFileDocument);
                if (!d.FromMetadata)
                    SaveAllButtonsEnabled = SaveButtonsEnabled = true;

            }
            
            NavigationLocationChanged();
            UpdateUndoRedoEnabled();
            WorkbenchServiceFactory.CodeCompletionParserController.SetAsChanged(cfdc.FileName);
        }
Esempio n. 32
0
 private void ShowAddedBreakpoints(CodeFileDocumentControl tp)
 {
     string name = tp.FileName;
     BreakPointFactory.AddBreakpoints(name, tp.TextEditor.ActiveTextAreaControl.TextArea);
 }
Esempio n. 33
0
        internal void SaveFileAs(CodeFileDocumentControl TbPage, string FileName)
        {
            try
            {
                if (TbPage.DesignerAndCodeTabs != null)
                {
                    TbPage.GenerateDesignerCode(null);
                }
                CodeFileDocumentControl dt = TbPage;
                WatcherService.DisableWatcher(FileName);
                //dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding;
                if (!dt.TextEditor.CanSaveWithCurrentEncoding())
                {
                    dt.TextEditor.Encoding = Encoding.UTF8;
                    dt.TextEditor.SaveFile(FileName);
                    dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding;
                }
                else
                    dt.TextEditor.SaveFile(FileName);
                WatcherService.EnableWatcher(FileName);
                OpenDocuments.Remove(Tools.FileNameToLower(dt.FileName));
                OpenDocuments.Add(Tools.FileNameToLower(FileName), TbPage);
                WorkbenchServiceFactory.CodeCompletionParserController.RenameFile(dt.FileName, FileName);
                TbPage.SaveFormFile(FileName);
                dt.DocumentChanged = false;
                dt.FileName = FileName;
                dt.DocumentSavedToDisk = true;
                dt.SetHighlightingStrategyForFile(FileName);
                SetTabPageText(TbPage);
                if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower()))
                    WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), "");
                if (TbPage == CurrentCodeFileDocument)
                    UpdateSaveButtonsEnabled();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Form1StringResources.Get("SAVE_FILE_ERROR_TEXT{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }
Esempio n. 34
0
        public void ChangedSelectedTab()
        {
            if (BrowserTabSelected)
            {
                BottomTabsVisible        = true;
                BrowserTabSelected       = false;
                CurrentWebBrowserControl = null;
                SetFocusToEditor();
            }
            if (BakSelectedTab == CurrentCodeFileDocument)
            {
                return;
            }
            LastSelectedTab = BakSelectedTab;
            BakSelectedTab  = CurrentCodeFileDocument;

            if (LastSelectedTab != null && LastSelectedTab.DesignerAndCodeTabs != null)
            {
                //LastSelectedTab.Designer.host.HideCombo();
            }

            if (CurrentCodeFileDocument != null && CurrentCodeFileDocument.DesignerAndCodeTabs != null)
            {
                // CurrentCodeFileDocument.Designer.host.ShowCombo();
            }

            if (OutputTextBoxs[CurrentCodeFileDocument] != OutputWindow.outputTextBox)
            {
                OutputTextBoxs[CurrentCodeFileDocument].Visible = true;
                OutputWindow.outputTextBox.Visible = false;
                OutputWindow.outputTextBox         = OutputTextBoxs[CurrentCodeFileDocument];
            }
            CodeCompletion.CodeCompletionController.SetParser(Path.GetExtension(CurrentCodeFileDocument.FileName));
            SetFocusToEditor();
            bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName);

            WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument);
            bool debug = WorkbenchServiceFactory.DebuggerManager.IsRunAndInThisTabPage(CurrentEXEFileName, CurrentCodeFileDocument);

            if (!debug)
            {
                SetStopEnabled(run);
            }
            else
            {
                SetStopEnabled(debug);
            }
            //if (debug) SetStopEnabled(debug);
            if (VisualEnvironmentCompiler != null)
            {
                if (!debug)
                {
                    SetCompilingButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
                    SetDebugButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
                }
                else
                {
                    SetCompilingButtonsEnabled(!debug);
                    SetDebugButtonsAsByDebug();
                }
            }
            else
            {
                SetCompilingButtonsEnabled(false);
            }
            SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged;
            UpdateUndoRedoEnabled();
            UpdateCutCopyButtonsEnabled();
            UpdateLineColPosition();
            WorkbenchServiceFactory.RunService.UpdateReadRequest(true);
            UpdateDesignerIsActive();
        }
Esempio n. 35
0
        public static void RenameUnit(string FileName, string new_val)
        {
            if (CodeCompletion.CodeCompletionController.CurrentParser == null)
            {
                return;
            }
            ccp = new CodeCompletionProvider();
            IDocument doc = null;

            CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
            string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string;

            PascalABCCompiler.SyntaxTree.compilation_unit cu       = controller.ParseOnlySyntaxTree(FileName, text);
            PascalABCCompiler.SyntaxTree.ident            unitName = null;
            if (cu is PascalABCCompiler.SyntaxTree.unit_module)
            {
                unitName = (cu as PascalABCCompiler.SyntaxTree.unit_module).unit_name.idunit_name;
            }
            else if (cu is PascalABCCompiler.SyntaxTree.program_module)
            {
                if ((cu as PascalABCCompiler.SyntaxTree.program_module).program_name == null)
                {
                    return;
                }
                unitName = (cu as PascalABCCompiler.SyntaxTree.program_module).program_name.prog_name;
            }

            List <SymbolsViewerSymbol> refers = ccp.Rename(unitName.name, unitName.name, FileName, unitName.source_context.begin_position.line_num, unitName.source_context.begin_position.column_num);

            if (refers == null || new_val == null)
            {
                return;
            }
            int addit = 0;

            PascalABCCompiler.SourceLocation tmp = new PascalABCCompiler.SourceLocation(null, 0, 0, 0, 0);
            string file_name = null;

            VisualPABCSingleton.MainForm.StopTimer();
            WorkbenchServiceFactory.CodeCompletionParserController.StopParseThread();
            foreach (IFileInfo fi in ProjectFactory.Instance.CurrentProject.SourceFiles)
            {
                WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(fi.Path);
            }
            WorkbenchServiceFactory.CodeCompletionParserController.ParseInThread();
            foreach (SymbolsViewerSymbol svs in refers)
            {
                if (svs.SourceLocation.BeginPosition.Line != tmp.BeginPosition.Line)
                {
                    addit = 0;
                }
                else if (svs.SourceLocation.BeginPosition.Column < tmp.BeginPosition.Column)
                {
                    addit = 0;
                }
                if (svs.SourceLocation.FileName != file_name)
                {
                    CodeFileDocumentControl cfdoc = VisualPABCSingleton.MainForm.FindTab(svs.SourceLocation.FileName);
                    if (cfdoc == null)
                    {
                        continue;
                    }
                    doc       = cfdoc.TextEditor.ActiveTextAreaControl.TextArea.Document;
                    file_name = svs.SourceLocation.FileName;
                }
                tmp = svs.SourceLocation;
                TextLocation tl_beg = new TextLocation(svs.SourceLocation.BeginPosition.Column - 1, svs.SourceLocation.BeginPosition.Line - 1);
                //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column);
                int offset = doc.PositionToOffset(tl_beg);
                //addit += new_val.Length - unitName.name.Length;
                doc.Replace(offset, unitName.name.Length, new_val);
                doc.CommitUpdate();
            }
            WorkbenchServiceFactory.CodeCompletionParserController.RunParseThread();
            VisualPABCSingleton.MainForm.StartTimer();
        }
Esempio n. 36
0
        private void AddDebugPage(CodeFileDocumentControl tp)
        {
            if (TabStack.Count > 0 && !TabStack.Contains(tp))
            {
                CodeFileDocumentControl cfdc = TabStack[TabStack.Count - 1];
                //TabStack.RemoveAt(TabStack.Count-1);
                RichTextBox tb = null;
                if (OutputTextBoxs.ContainsKey(cfdc))
                {
                    tb = OutputTextBoxs[cfdc];
                    RichTextBox new_tb = OutputTextBoxs[tp];
                    new_tb.Text = tb.Text;
                }
                OutputWindow.OutputTextBoxScrolToEnd();
            }
            if (!TabStack.Contains(tp))
            {
                TabStack.Add(tp);
                OutputBoxStack.Add(OutputTextBoxs[tp]);
            }
            if (DebugTabs[tp] != null) return;
            DebugTabs[tp] = tp.TextEditor.ActiveTextAreaControl.TextArea;
            TextAreaHelper.TextAreas[tp.TextEditor.ActiveTextAreaControl.TextArea] = tp.FileName;
            tp.TextEditor.ActiveTextAreaControl.TextArea.ToolTipRequest += WorkbenchServiceFactory.DebuggerManager.TextAreaToolTipRequest;

        }
Esempio n. 37
0
        public void ChangedSelectedTab()
        {
            if (BrowserTabSelected)
            {
                BottomTabsVisible = true;
                BrowserTabSelected = false;
                CurrentWebBrowserControl = null;
                SetFocusToEditor();
            }
            if (BakSelectedTab == CurrentCodeFileDocument)
                return;
            LastSelectedTab = BakSelectedTab;
            BakSelectedTab = CurrentCodeFileDocument;

            if (LastSelectedTab != null && LastSelectedTab.DesignerAndCodeTabs != null)
            {
                //LastSelectedTab.Designer.host.HideCombo();
            }

            if (CurrentCodeFileDocument != null && CurrentCodeFileDocument.DesignerAndCodeTabs != null)
            {
                // CurrentCodeFileDocument.Designer.host.ShowCombo();
            }

            if (OutputTextBoxs[CurrentCodeFileDocument] != OutputWindow.outputTextBox)
            {
                OutputTextBoxs[CurrentCodeFileDocument].Visible = true;
                OutputWindow.outputTextBox.Visible = false;
                OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument];
            }
            CodeCompletion.CodeCompletionController.SetParser(Path.GetExtension(CurrentCodeFileDocument.FileName));
            SetFocusToEditor();
            bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName);
            WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument);
            bool debug = WorkbenchServiceFactory.DebuggerManager.IsRunAndInThisTabPage(CurrentEXEFileName, CurrentCodeFileDocument);
            if (!debug)
            {
                SetStopEnabled(run);
            }
            else SetStopEnabled(debug);
            //if (debug) SetStopEnabled(debug);
            if (VisualEnvironmentCompiler != null)
                if (!debug)
                {
                    SetCompilingButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
                    SetDebugButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
                }
                else
                {
                    SetCompilingButtonsEnabled(!debug);
                    SetDebugButtonsAsByDebug();
                }
            else
                SetCompilingButtonsEnabled(false);
            SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged;
            UpdateUndoRedoEnabled();
            UpdateCutCopyButtonsEnabled();
            UpdateLineColPosition();
            WorkbenchServiceFactory.RunService.UpdateReadRequest(true);
            UpdateDesignerIsActive();
        }
Esempio n. 38
0
 void CloseAllButThis(CodeFileDocumentControl nonCloseTab)
 {
     SaveCanceled = false;
     CodeFileDocumentControl bakTab = CurrentCodeFileDocument;
     /*foreach (TabPage tbPage in tabControl1.TabPages)
         if (tbPage != tabControl1.SelectedTab)
             CloseFile(tbPage);*/
     List<CodeFileDocumentControl> to_close = new List<CodeFileDocumentControl>();
     foreach (CodeFileDocumentControl tbPage in OpenDocuments.Values)
     {
         if (SaveCanceled) break;
         if (tbPage != nonCloseTab)
         {
             if (tbPage == bakTab)
                 bakTab = null;
             to_close.Add(tbPage);
         }
     }
     if (!SaveCanceled)
         foreach (CodeFileDocumentControl tbPage in to_close)
         {
             tbPage.Close();
         }
     if (bakTab != null)
         if (bakTab != CurrentCodeFileDocument)
             CurrentCodeFileDocument = bakTab;
     List<WebBrowserControl> todelete = new List<WebBrowserControl>();
     foreach (WebBrowserControl browserTab in OpenBrowserDocuments.Values)
         todelete.Add(browserTab);
     foreach (WebBrowserControl browserTab in todelete)
         browserTab.Close();
     //OpenBrowserDocuments.Clear();
 }
Esempio n. 39
0
 private void AddBreakPointHandler(CodeFileDocumentControl tp, string FileName)
 {
     string name = tp.FileName;
     TextAreaHelper.TextAreas[tp.TextEditor.ActiveTextAreaControl.TextArea] = FileName;
     tp.TextEditor.ActiveTextAreaControl.TextArea.IconBarMargin.MouseDown += BreakPointFactory.IconBarMouseDown;
 }
Esempio n. 40
0
        private void ExecuteSaveAs(CodeFileDocumentControl TbPage)
        {
            //if (TbPage.DesignerAndCodeTabs != null)
            //{
            //    TbPage.GenerateDesignerCode();
            //}
            CodeFileDocumentControl bakTab = CurrentCodeFileDocument;
            CurrentCodeFileDocument = TbPage;
            saveFileDialog1.FileName = Path.GetFileName(CurrentSourceFileName);
            string id = Path.GetDirectoryName(CurrentSourceFileName);
            if (id == "")
            {
                if (WorkbenchStorage.WorkingDirectoryExsist)
                    saveFileDialog1.InitialDirectory = WorkbenchStorage.WorkingDirectory;
            }
            else
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(CurrentSourceFileName);
            DialogResult dr = saveFileDialog1.ShowDialog();
            CurrentCodeFileDocument = bakTab;

        }
Esempio n. 41
0
        internal void CloseProjectFiles()
        {
            CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
            OpenDocuments.Values.CopyTo(l, 0);

            foreach (CodeFileDocumentControl tp in l)
                if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(tp.FileName))
                {
                    CloseFile(tp, false);
                }
        }
Esempio n. 42
0
 internal int SaveAllInProject()
 {
     SaveCanceled = false;
     CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
     OpenDocuments.Values.CopyTo(l, 0);
     bool changed = false;
     foreach (CodeFileDocumentControl tp in l)
         if (tp.DocumentChanged && !tp.FromMetadata && ProjectFactory.Instance.CurrentProject.ContainsSourceFile(tp.FileName))
         {
             changed = true;
             break;
         }
     if (!changed)
         return 1;
     int result = QuestionAndSaveProject();
     if (result == 2)
     {
         return result;
     }
     if (result == 0)
         foreach (CodeFileDocumentControl tp in l)
             if (tp.DocumentChanged && !tp.FromMetadata)
                 SaveSelFile(tp);
     UpdateSaveButtonsEnabled();
     return result;
 }
Esempio n. 43
0
 public void CloseFile(CodeFileDocumentControl tp, bool ask_for_save = true)
 {
     string FileName = tp.FileName.ToLower();
     string exeName = tp.EXEFileName;
     if (WorkbenchServiceFactory.RunService.IsRun(exeName))
         WorkbenchServiceFactory.RunService.Stop(exeName);
     if (ask_for_save)
         if (tp.DocumentChanged && !tp.FromMetadata)
             if (!QuestionAndSaveFile(tp))
             {
                 SaveCanceled = true;
                 return;
             }
     if (tp.DocumentSavedToDisk)
         AddLastFile(CurrentSourceFileName);
     if (LastSelectedTab != null && !LastSelectedTab.IsDisposed)
         CurrentCodeFileDocument = LastSelectedTab;
     if (tp == ActiveCodeFileDocument)
         ActiveCodeFileDocument = null;
     OutputTextBoxs.Remove(tp);
     OpenDocuments.Remove(Tools.FileNameToLower(tp.FileName));
     //RunArgumentsTable.Remove(tp);
     tp.Dispose();
     CheckErrorListAndClear(FileName);
     WatcherService.RemoveWatcher(FileName);
     if (OpenDocuments.Count == 1)
     {
         CloseButtonsEnabled = false;
     }
     SaveAllButtonsEnabled = !AllSaved();
     WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(FileName);
     WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated -= tp.TextEditor.UpdateFolding;
     CodeCompletionKeyHandler.Detach(tp.TextEditor);
     tp.TextEditor.Document.DocumentChanged -= tp.Document_DocumentChanged;
     tp.TextEditor.Document.TextContent = "";
     tp.TextEditor.Document.DocumentChanged += tp.Document_DocumentChanged;
     GC.Collect();
 }
Esempio n. 44
0
 private void SaveSelFile(CodeFileDocumentControl TbPage)
 {
     SaveSelFileAs(TbPage, TbPage.FileName);
 }
Esempio n. 45
0
 private void SaveSelFileAs(CodeFileDocumentControl TbPage, string FileName)
 {
     if (!TbPage.DocumentSavedToDisk)
         ExecuteSaveAs(TbPage);
     else
         SaveFileAs(TbPage, FileName);
 }
Esempio n. 46
0
 bool IsBlankNewProgram(CodeFileDocumentControl tp)
 {
     return(!tp.DocumentSavedToDisk && !tp.DocumentChanged);
 }
Esempio n. 47
0
 public bool SaveAll(bool Question)
 {
     if (ProjectFactory.Instance.ProjectLoaded && Question)
     {
         return SaveAllInProject() != 2;
     }
     SaveCanceled = false;
     CodeFileDocumentControl[] l = new CodeFileDocumentControl[OpenDocuments.Values.Count];
     OpenDocuments.Values.CopyTo(l, 0);
     foreach (CodeFileDocumentControl tp in l)
         if (tp.DocumentChanged && !tp.FromMetadata)
             if (Question)
             {
                 if (!QuestionAndSaveFile(tp))
                 {
                     SaveCanceled = true;
                     return false;
                 }
             }
             else
                 SaveSelFile(tp);
     UpdateSaveButtonsEnabled();
     return true;
 }
Esempio n. 48
0
 public void SaveAspPlugin(CodeFileDocumentControl dc)
 {
     SaveSelFile(dc);
 }
Esempio n. 49
0
 bool QuestionAndSaveFile(CodeFileDocumentControl tp)
 {
     CurrentCodeFileDocument = tp;
     DialogResult result = MessageBox.Show(string.Format(Form1StringResources.Get("SAVE_CHANGES_IN_FILE{0}"), Path.GetFileName(tp.FileName)), PascalABCCompiler.StringResources.Get("!CONFIRM"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
     if (result == DialogResult.Yes)
         SaveSelFile(CurrentCodeFileDocument);
     else
         if (result == DialogResult.Cancel)
             return false;
     return true;
 }
Esempio n. 50
0
 public void CloseAspPlugin(CodeFileDocumentControl dc)
 {
     CloseFile(dc);
 }
Esempio n. 51
0
 bool IsBlankNewProgram(CodeFileDocumentControl tp)
 {
     return (!tp.DocumentSavedToDisk && !tp.DocumentChanged);
 }
Esempio n. 52
0
 private void SetDebugTextOnPage(CodeFileDocumentControl tp)
 {
     SetTabPageText(tp);
 }