Ejemplo n.º 1
0
        public void SetText(string text, bool isDiff = false)
        {
            _lineNumbersControl.Clear(isDiff);

            if (isDiff)
            {
                TextEditor.ShowLineNumbers = false;
                _lineNumbersControl.SetVisibility(true);
                var index = TextEditor.ActiveTextAreaControl.TextArea.LeftMargins.IndexOf(_lineNumbersControl);
                if (index == -1)
                {
                    TextEditor.ActiveTextAreaControl.TextArea.InsertLeftMargin(0, _lineNumbersControl);
                }

                _diffHighlightService = DiffHighlightService.IsCombinedDiff(text)
                    ? CombinedDiffHighlightService.Instance
                    : DiffHighlightService.Instance;
            }
            else
            {
                TextEditor.ShowLineNumbers = true;
                _lineNumbersControl.SetVisibility(false);
            }

            TextEditor.Text         = text;
            _isGotoLineUIApplicable = !isDiff;

            if (isDiff)
            {
                _lineNumbersControl.DisplayLineNumFor(text);
            }
            TextEditor.Refresh();
        }
Ejemplo n.º 2
0
        private static bool IsDiffLine(string wholeText, string lineContent)
        {
            var isCombinedDiff = DiffHighlightService.IsCombinedDiff(wholeText);

            return(lineContent.StartsWithAny(isCombinedDiff ? new[] { "+", "-", " +", " -" }
                : new[] { "+", "-" }));
        }
Ejemplo n.º 3
0
        private string RemovePrefix(string line)
        {
            var isCombinedDiff = DiffHighlightService.IsCombinedDiff(_internalFileViewer.GetText());
            var specials       = isCombinedDiff ? new[] { "  ", "++", "+ ", " +", "--", "- ", " -" }
                : new[] { " ", "-", "+" };

            if (string.IsNullOrWhiteSpace(line))
            {
                return(line);
            }
            foreach (var special in specials.Where(line.StartsWith))
            {
                return(line.Substring(special.Length));
            }
            return(line);
        }
Ejemplo n.º 4
0
        public void SetText(string text, bool isDiff = false)
        {
            _diffHighlightService = DiffHighlightService.IsCombinedDiff(text) ? CombinedDiffHighlightService.Instance : DiffHighlightService.Instance;

            _lineNumbersControl.Clear();

            TextEditor.Text = text;
            TextEditor.Refresh();

            if (isDiff)
            {
                _diffLineNumAnalyzer.StartAsync(text, () =>
                {
                    if (TextEditor != null && !TextEditor.Disposing && TextEditor.Visible)
                    {
                        TextEditor.ActiveTextAreaControl.TextArea.Refresh();
                    }
                });
            }
        }
Ejemplo n.º 5
0
        public void SetText(string text, bool isDiff = false)
        {
            _lineNumbersControl.Clear();

            if (isDiff)
            {
                TextEditor.ShowLineNumbers = false;
                _lineNumbersControl.SetVisibility(true);
                var index = TextEditor.ActiveTextAreaControl.TextArea.LeftMargins.IndexOf(_lineNumbersControl);
                if (index == -1)
                {
                    TextEditor.ActiveTextAreaControl.TextArea.InsertLeftMargin(0, _lineNumbersControl);
                }

                _diffHighlightService = DiffHighlightService.IsCombinedDiff(text)
                    ? CombinedDiffHighlightService.Instance
                    : DiffHighlightService.Instance;
            }
            else
            {
                TextEditor.ShowLineNumbers = true;
                _lineNumbersControl.SetVisibility(false);
            }

            TextEditor.Text         = text;
            _isGotoLineUIApplicable = !isDiff;

            if (isDiff)
            {
                _diffLineNumAnalyzer.StartAsync(text, () =>
                {
                    if (TextEditor != null && !TextEditor.Disposing && TextEditor.Visible)
                    {
                        TextEditor.ActiveTextAreaControl.TextArea.Refresh();
                    }
                });
            }

            TextEditor.Refresh();
        }