public int UnComment(TextDocument textDocument, ISegment segment, int caret = -1, bool format = true)
 {
     throw new NotImplementedException();
 }
        public CSharpDataAssociation(TextDocument textDocument)
        {
            BackgroundRenderers = new List<IBackgroundRenderer>();
            DocumentLineTransformers = new List<IDocumentLineTransformer>();

            TextColorizer = new TextColoringTransformer(textDocument);
            TextMarkerService = new TextMarkerService(textDocument);

            BackgroundRenderers.Add(new BracketMatchingBackgroundRenderer());
            BackgroundRenderers.Add(TextMarkerService);

            DocumentLineTransformers.Add(TextColorizer);
        }
        public void RegisterSourceFile(IIntellisenseControl intellisenseControl, ICompletionAssistant completionAssistant, TextEditor editor, ISourceFile file, TextDocument textDocument)
        {
            CSharpDataAssociation association = null;

            if (dataAssociations.TryGetValue(file, out association))
            {
                throw new Exception("Source file already registered with language service.");
            }

            association = new CSharpDataAssociation(textDocument);
            association.Solution = file.Project.Solution as OmniSharpSolution; // CanHandle has checked this.

            dataAssociations.Add(file, association);

            association.KeyUpHandler = (sender, e) =>
            {
                if (editor.TextDocument == textDocument)
                {
                    switch (e.Key)
                    {
                        case Key.Return:
                            {
                                if (editor.CaretIndex >= 0 && editor.CaretIndex < editor.TextDocument.TextLength)
                                {
                                    if (editor.TextDocument.GetCharAt(editor.CaretIndex) == '}')
                                    {
                                        editor.TextDocument.Insert(editor.CaretIndex, Environment.NewLine);
                                        editor.CaretIndex--;

                                        var currentLine = editor.TextDocument.GetLineByOffset(editor.CaretIndex);

                                        editor.CaretIndex = IndentationStrategy.IndentLine(editor.TextDocument, currentLine, editor.CaretIndex);
                                        editor.CaretIndex = IndentationStrategy.IndentLine(editor.TextDocument, currentLine.NextLine.NextLine,
                                            editor.CaretIndex);
                                        editor.CaretIndex = IndentationStrategy.IndentLine(editor.TextDocument, currentLine.NextLine, editor.CaretIndex);
                                    }

                                    var newCaret = IndentationStrategy.IndentLine(editor.TextDocument,
                                        editor.TextDocument.GetLineByOffset(editor.CaretIndex), editor.CaretIndex);

                                    editor.CaretIndex = newCaret;
                                }
                            }
                            break;
                    }
                }
            };

            editor.AddHandler(InputElement.KeyUpEvent, association.KeyUpHandler, RoutingStrategies.Tunnel);
        }
 public int Format(TextDocument textDocument, uint offset, uint length, int cursor)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 private void New_Document_Click(object sender, RoutedEventArgs e)
 {
     this.Document     = new TextDocument();
     this.Display.Text = this.Document.Content;
 }
Esempio n. 6
0
        private void OpenFunction()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect     = false;
            openFileDialog.Filter          = FILE_FILTER;
            openFileDialog.AddExtension    = true;
            openFileDialog.CheckFileExists = true;
            openFileDialog.CheckPathExists = true;
            openFileDialog.Title           = OPEN_ACTION_NAME;
            textDocument = new TextDocument(textBox);

            if (!string.IsNullOrWhiteSpace(textDocument.TextInput.Text) && backupTextDocument == null)
            {
                SaveWarning();
                openFileDialog.ShowDialog();
                if (!string.IsNullOrEmpty(openFileDialog.FileName))
                {
                    textDocument = new TextDocument(openFileDialog.FileName, textBox);
                    textDocument.OpenText();
                    backupTextDocument = new TextDocument(openFileDialog.FileName, textBox.Text);
                    backupTextDocument.ReadText();
                    ChangeApplicationTitle(Path.GetFileNameWithoutExtension(textDocument.PathName));
                    return;
                }
                else
                {
                    return;
                }
            }
            if (backupTextDocument == null)
            {
                openFileDialog.ShowDialog();
                if (!string.IsNullOrEmpty(openFileDialog.FileName))
                {
                    textDocument       = new TextDocument(openFileDialog.FileName, textBox);
                    backupTextDocument = new TextDocument(openFileDialog.FileName, textBox.Text);
                    textDocument.OpenText();
                    backupTextDocument.ReadText();
                    ChangeApplicationTitle(Path.GetFileNameWithoutExtension(textDocument.PathName));
                    return;
                }
                else
                {
                    return;
                }
            }
            if (System.String.Compare(textDocument.TextInput.Text, backupTextDocument.CurrentText) != 0 && !string.IsNullOrEmpty(textDocument.TextInput.Text))
            {
                SaveWarning();
                openFileDialog.ShowDialog();
                if (!string.IsNullOrEmpty(openFileDialog.FileName))
                {
                    textDocument       = new TextDocument(openFileDialog.FileName, textBox);
                    backupTextDocument = new TextDocument(openFileDialog.FileName, textBox.Text);
                    textDocument.OpenText();
                    backupTextDocument.ReadText();
                    ChangeApplicationTitle(Path.GetFileNameWithoutExtension(textDocument.PathName));
                    return;
                }
                else
                {
                    return;
                }
            }
            openFileDialog.ShowDialog();
            if (!string.IsNullOrEmpty(openFileDialog.FileName))
            {
                textDocument       = new TextDocument(openFileDialog.FileName, textBox);
                backupTextDocument = new TextDocument(openFileDialog.FileName, textBox.Text);
                textDocument.OpenText();
                backupTextDocument.ReadText();
                ChangeApplicationTitle(Path.GetFileNameWithoutExtension(textDocument.PathName));
                return;
            }
            else
            {
                return;
            }
        }
 /// <summary>
 /// Create <see cref="NewFolding"/>s for the specified document.
 /// </summary>
 public IEnumerable <NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
 {
     firstErrorOffset = -1;
     return(CreateNewFoldings(document));
 }