Example #1
0
 public UndoItem(string text, MyEditor editor, TextPoint position, UndoType type)
 {
     this.text     = text;
     this.editor   = editor;
     this.position = position;
     this.type     = type;
 }
Example #2
0
 private static void AddEditorSignal(MyEditor editor)
 {
     /*updatedFiles.Remove(editor);
      * signalFiles.Remove(editor);
      * signalFiles.Add(editor);
      * SignalFile();*/
 }
Example #3
0
 public static void AddUnsureEditorSignal(MyEditor editor)
 {
     /*if (updatedFiles.Contains(editor) || signalFiles.Contains(editor))
      *  return;
      * signalFiles.Remove(editor);
      * signalFiles.Add(editor);
      * SignalFile();*/
 }
 public static void AddUnsureEditorSignal(MyEditor editor)
 {
     /*if (updatedFiles.Contains(editor) || signalFiles.Contains(editor))
         return;
     signalFiles.Remove(editor);
     signalFiles.Add(editor);
     SignalFile();*/
 }
Example #5
0
        public void TextAdded(string text, MyEditor editor, TextPoint position)
        {
            updatedFiles.Remove(editor);
            if (text.Contains(";") || text.Contains("}"))
            {
                AddEditorSignal(editor);
            }

            redoList.Clear();
            //If this and the two previous can be joined into 1 token, join them in 1 undo (if they follow eachother)
            UndoItem item = new UndoItem(text, editor, position, UndoType.TextAdded);

            if (undoList.Count > 0)
            {
                UndoItem lastItem = undoList[undoList.Count - 1];
                if (FollowEachother(lastItem, item))
                {
                    string       joined = lastItem.text + item.text;
                    Lexer        lexer  = new Lexer(new StringReader(joined));
                    List <Token> tokens = new List <Token>();
                    while (!(lexer.Peek() is EOF))
                    {
                        tokens.Add(lexer.Next());
                    }
                    if (tokens.Count == 1 || tokens.All(elm => elm is TWhiteSpace))
                    {
                        lastItem.text += item.text;
                        item           = lastItem;

                        if (undoList.Count > 1)
                        {
                            lastItem = undoList[undoList.Count - 2];
                            if (FollowEachother(lastItem, item))
                            {
                                joined = lastItem.text + item.text;
                                lexer  = new Lexer(new StringReader(joined));
                                tokens = new List <Token>();
                                while (!(lexer.Peek() is EOF))
                                {
                                    tokens.Add(lexer.Next());
                                }
                                if (tokens.Count == 1 || tokens.All(elm => elm is TWhiteSpace))
                                {
                                    lastItem.text += item.text;
                                    undoList.RemoveAt(undoList.Count - 1);
                                }
                            }
                        }
                        return;
                    }
                }
            }
            undoList.Add(item);
        }
Example #6
0
        public void TextReplaced(string oldText, string newText, MyEditor editor, TextPoint position)
        {
            AddEditorSignal(editor);
            if (oldText == newText)
            {
                return;
            }
            UndoItem item = new UndoItem(oldText, editor, position, UndoType.TextReplaced);

            item.replaceNewText = newText;
            undoList.Add(item);
        }
 private void currentEditor_OnScrolled(MyEditor sender)
 {
     //Reposition
     Reposition();
 }
        public void TextRemoved(string text, MyEditor editor, TextPoint position)
        {
            AddEditorSignal(editor);

            redoList.Clear();
            //If this and the two previous can be joined into 1 token, join them in 1 undo (if they follow eachother)
            UndoItem item = new UndoItem(text, editor, position, UndoType.TextRemoved);
            if (undoList.Count > 0)
            {
                UndoItem lastItem = undoList[undoList.Count - 1];
                if (FollowEachother(item, lastItem))
                {
                    string joined = item.text + lastItem.text;
                    Lexer lexer = new Lexer(new StringReader(joined));
                    List<Token> tokens = new List<Token>();
                    while (!(lexer.Peek() is EOF))
                    {
                        tokens.Add(lexer.Next());
                    }
                    if (tokens.Count == 1 || tokens.All(elm => elm is TWhiteSpace))
                    {
                        lastItem.text = joined;
                        lastItem.position = item.position;
                        item = lastItem;

                        if (undoList.Count > 1)
                        {
                            lastItem = undoList[undoList.Count - 2];
                            if (FollowEachother(item, lastItem))
                            {
                                joined = item.text + lastItem.text;
                                lexer = new Lexer(new StringReader(joined));
                                tokens = new List<Token>();
                                while (!(lexer.Peek() is EOF))
                                {
                                    tokens.Add(lexer.Next());
                                }
                                if (tokens.Count == 1 || tokens.All(elm => elm is TWhiteSpace))
                                {
                                    lastItem.text = joined;
                                    lastItem.position = item.position;
                                    undoList.RemoveAt(undoList.Count - 1);
                                }
                            }
                        }
                        return;
                    }
                }
            }
            undoList.Add(item);
        }
        public void AddDialogFile(DialogItem item, MyEditor text = null)
        {
            ProjectProperties.CurrentProjectPropperties.CompileStatus = ProjectProperties.ECompileStatus.Changed;
            //Check if it already exists
            foreach (SourceFileContents sourceFile in ParsedSourceFiles)
            {
                if (sourceFile.Item == item)
                    return;
            }
            SourceFileContents contents = new SourceFileContents();
            contents.Item = item;
            contents.GetSource = new ExtractDialogItemCode(item, false).Extract;
            ParsedSourceFiles.Add(contents);
            liteCompileQueue.Add(new KeyValuePair<SourceFileContents, MyEditor>(contents, text));
            SourceFileContentsChanged(contents);

            contents = new SourceFileContents();
            contents.Item = item;
            contents.IsDialogDesigner = true;
            contents.GetSource = new ExtractDialogItemCode(item, true).Extract;
            ParsedSourceFiles.Add(contents);
            liteCompileQueue.Add(new KeyValuePair<SourceFileContents, MyEditor>(contents, text));
            SourceFileContentsChanged(contents);
            SignalLiteCompiler();
        }
 /*public void SourceFileMoved(FileInfo oldFile, FileInfo newFile)
 {
     foreach (SourceFileContents t in ParsedSourceFiles)
     {
         if (t.File == oldFile)
         {
             t.File = newFile;
         }
     }
 }*/
 public void SourceFileChanged(FileItem file, MyEditor contents)
 {
     ProjectProperties.CurrentProjectPropperties.CompileStatus = ProjectProperties.ECompileStatus.Changed;
     //If its already in the compile queue, update the text
     for (int i = 0; i < liteCompileQueue.Count; i++)
     {
         if (liteCompileQueue[i].Key.Item == file)
         {
             liteCompileQueue[i] = new KeyValuePair<SourceFileContents, MyEditor>(liteCompileQueue[i].Key, contents);
             SignalLiteCompiler();
             return;
         }
     }
     //Otherwise, add it
     foreach (SourceFileContents t in ParsedSourceFiles)
     {
         if (t.Item == file)
         {
             liteCompileQueue.Add(new KeyValuePair<SourceFileContents, MyEditor>(t, contents));
         }
     }
     SignalLiteCompiler();
 }
 public void AddSourceFile(FileItem file, MyEditor text = null)
 {
     ProjectProperties.CurrentProjectPropperties.CompileStatus = ProjectProperties.ECompileStatus.Changed;
     //Check if it already exists
     foreach (SourceFileContents sourceFile in ParsedSourceFiles)
     {
         if (sourceFile.Item == file)
             return;
     }
     SourceFileContents contents = new SourceFileContents();
     contents.Item = file;
     contents.GetSource = new ExtractSourceFileCode(file).Extract;
     ParsedSourceFiles.Add(contents);
     liteCompileQueue.Add(new KeyValuePair<SourceFileContents, MyEditor>(contents, text));
     SourceFileContentsChanged(contents);
     SignalLiteCompiler();
 }
 public UndoItem(string text, MyEditor editor, TextPoint position, UndoType type)
 {
     this.text = text;
     this.editor = editor;
     this.position = position;
     this.type = type;
 }
 private static void AddEditorSignal(MyEditor editor)
 {
     /*updatedFiles.Remove(editor);
     signalFiles.Remove(editor);
     signalFiles.Add(editor);
     SignalFile();*/
 }
 public void TextReplaced(string oldText, string newText, MyEditor editor, TextPoint position)
 {
     AddEditorSignal(editor);
     if (oldText == newText) return;
     UndoItem item = new UndoItem(oldText, editor, position, UndoType.TextReplaced);
     item.replaceNewText = newText;
     undoList.Add(item);
 }
 public Caret(MyEditor owner)
 {
     this.owner = owner;
 }
 private void currentEditor_OnCaretChanged(MyEditor sender)
 {
     //Display method arg help if in a method invocation arg
     int commaCount;
     TextPoint parenPos;
     bool isAsyncInvoke;
     List<AMethodDecl> matchingMethods = GetMatchingCurrentMethod(out commaCount, out parenPos, out isAsyncInvoke);
     methodParamTooltip.Items.Clear();
     foreach (AMethodDecl method in matchingMethods)
     {
         var item = new MyToolboxControl.Item();
         string prefix = "", bold = "", postfix = "";
         prefix = "(";
         for (int i = 0; i < method.GetFormals().Count; i++)
         {
             AALocalDecl formal = (AALocalDecl) method.GetFormals()[i];
             string text = Util.TypeToString(formal.GetType()) + " " + formal.GetName().Text;
             if (i < commaCount && i < method.GetFormals().Count - 1)
                 text += ", ";
             if (i > commaCount)
                 text = ", " + text;
             if (i < commaCount)
                 prefix += text;
             else if (i == commaCount)
                 bold += text;
             else
                 postfix += text;
         }
         postfix += ") : " + (isAsyncInvoke ? "void" : Util.TypeToString(method.GetReturnType()));
         if (bold == "")
         {
             item.Sections.Add(new MyToolboxControl.Item.Section(prefix + postfix));
         }
         else
         {
             item.Sections.Add(new MyToolboxControl.Item.Section(prefix));
             item.Sections.Add(new MyToolboxControl.Item.Section(bold, FontStyle.Bold));
             item.Sections.Add(new MyToolboxControl.Item.Section(postfix));
         }
         methodParamTooltip.Items.Add(item);
     }
     if (methodParamTooltip.Items.Count == 0)
     {
         methodParamTooltip.Visible = false;
         return;
     }
     Point pos = CurrentEditor.GetPixelAtTextpoint(parenPos);
     pos = CurrentEditor.PointToScreen(pos);
     Size size = methodParamTooltip.TooltipControl.GetRequiredSize(Screen.PrimaryScreen.Bounds.Width - pos.X);
     pos.Y -= size.Height;
     methodParamTooltip.Show(pos, size);
     methodParamTooltip.Redraw();
 }
Example #17
0
        private void MyEditor_TextEdited(MyEditor sender)
        {
            if (sender.Tag is OpenFileData)
            {
                OpenFileData openFile = (OpenFileData) sender.Tag;
                if (openFile.File.IsDecendantOf(openProjectSrcDir))
                {
                    compiler.SourceFileChanged(openFile.File, sender);
                    UploadedChangesToMap = false;
                }
                //Add * to indicate changes
                if (!openFile.Changed)
                {
                    openFile.Changed = true;
                    openFile.TabPage.Title += "*";
                }
                //Enable/disable undo/redo buttons
                TBUndo.Enabled = openFile.Editor.UndoSys.CanUndo;
                TBRedo.Enabled = openFile.Editor.UndoSys.CanRedo;
            }
            else if (sender.Tag is DialogData)
            {
                DialogData openFile = (DialogData)sender.Tag;
                compiler.DialogItemChanged(openFile.DialogItem, sender);

                //Add * to indicate changes
                if (!openFile.CodeChanged)
                {
                    openFile.CodeChanged = true;
                    //openFile.CodeTabPage.Title += "*";
                }
                //Enable/disable undo/redo buttons
                TBUndo.Enabled = openFile.CodeEditor.UndoSys.CanUndo;
                TBRedo.Enabled = openFile.CodeEditor.UndoSys.CanRedo;
            }
        }
 public void SetCurrentEditor(MyEditor editor)
 {
     myListbox1.CurrentEditor = editor;
 }