Пример #1
0
 public EditorSegment(Tab tab, string name, int offset, int length)
 {
     Tab = tab;
     Name = name;
     Offset = offset;
     Length = length;
 }
Пример #2
0
 public EditorSegment(Tab tab)
 {
     Tab = tab;
     Name = tab.Language.Name;
     Offset = 0;
     Length = tab.Editor.Text.Length;
 }
Пример #3
0
        public ColorPreviewRenderer(Tab tab)
        {
            colors = new List<ColorMatches>();

            this.tab = tab;

            tab.Editor.TextArea.Caret.PositionChanged += CaretPositionChanged;
        }
Пример #4
0
        public ExtendedTabItem(Tab tab)
        {
            this.tab = tab;

            InitializeComponent();

            Tag = tab;
            Header = tab.TabHeader;
            Content = tab.Editor;
        }
Пример #5
0
        public BlockHighlighter(Tab tab)
        {
            editor = tab.Editor;

            blocks = new List<HighlightedBlocks>();

            tabsColor = new SolidColorBrush(Theme.Instance.ShowTabColor.ToColor());
            spacesColor = new SolidColorBrush(Theme.Instance.ShowSpaceColor.ToColor());

            if (Theme.Instance.HighlightLineOfCaret)
            {
                lineOfCaret = new SolidColorBrush(Theme.Instance.LineOfCaretColor.ToColor());
            }
        }
Пример #6
0
        public ExtendedTabHeader(Tab tab)
        {
            InitializeComponent();

            Tab = tab;
            TabCaption.Text = tab.Name;

            if (!tab.DocumentPath.IsBlank())
            {
                ToolTip = tab.DocumentPath;
            }

            ContextMenu = new ContextMenu();
            ContextMenu.Items.Add(ContextMenuHelper.CreateManuItem("Close Tab", "CTRL+F4", Tab.Close));
            ContextMenu.Items.Add(ContextMenuHelper.CreateManuItem("Rename File", "", () => Controller.Current.GetWidget<Features.Projects.Widget>().RenameFile(tab.DocumentPath)));
            ContextMenu.Items.Add(Tab.GetChangleLanguageContextMenuItem());

            Controller.Current.MainWindow.Tab.SelectionChanged += ActiveTabChanges; // un-listen when closed
            CloseBtn.Click += CloseBtnClicked;
            Container.MouseDown += MouseClick;
        }
Пример #7
0
 private void OnNewTab(Tab tab)
 {
     // always listen to caret move
     tab.Editor.TextArea.TextEntered += TextEntered;
     tab.Editor.TextArea.TextEntering += TextEntering;
 }
Пример #8
0
        private void NoResultsFound(SearchAction action, Tab tab, Regex regex)
        {
            if (SearchAreaCurrentDocument.IsSelected)
            {
                if (lastReachedOffset == 0)
                    Notifier.Growl("Search", "Zero matches", Query.Text);
                else
                {
                    lastReachedOffset = 0;
                    Notifier.Growl("Search", "Reached end of document", Query.Text);
                }
            }
            else if (SearchAreaOpenDocuments.IsSelected)
            {
                if (tab == Controller.Current.CurrentTabs.Last())
                {
                    Notifier.Growl("Search", "Reached end of document", Query.Text);

                    lastReachedOffset = 0;
                    lastReachedTab = null;
                }
                else
                {
                    lastReachedOffset = 0;
                    lastReachedTab = Controller.Current.CurrentTabs[tab.Index + 1];

                    DoSearch(action, lastReachedTab, regex);
                }
            }
        }
Пример #9
0
        private void DoSearch(SearchAction action, Tab tab, Regex regex)
        {
            // clear old blocks
            tab.BlockHighlighter.Clear("Search");

            // highlight matches
            if (action == SearchAction.Highlight)
            {
                lastReachedOffset = 0;

                foreach (Match match in regex.Matches(tab.Editor.Text))
                {
                    tab.BlockHighlighter.Add("Search", match.Index, match.Length, foundTextBackground);
                }
            }

            // matches
            else if (action == SearchAction.Jump)
            {
                // search
                var match = regex.Match(tab.Editor.Text, lastReachedOffset);

                // end of document?
                if (!match.Success)
                {
                    NoResultsFound(action, tab, regex);
                    return;
                }

                // update offset
                lastReachedOffset = match.Index + match.Length;

                // select
                tab.Editor.Select(match.Index, match.Length);

                // if not active, make it active
                tab.MakeActive(false);
                Query.Focus();
                DelayedAction.Invoke(250, () => Query.Focus());

                // scroll
                var position = tab.Editor.Document.GetLocation(match.Index);
                tab.Editor.ScrollTo(position.Line, position.Column);
            }

            // redraw
            tab.BlockHighlighter.Redraw();
        }
Пример #10
0
        private void DoSearch(SearchAction action)
        {
            var regex = GetRegexFromQuery();

            if (SearchAreaCurrentDocument.IsSelected)
            {
                DoSearch(action, Controller.Current.ActiveTab, regex);
            }
            else if (SearchAreaOpenDocuments.IsSelected)
            {
                if (action == SearchAction.Highlight)
                {
                    DoSearch(action, Controller.Current.ActiveTab, regex);
                    return;
                }

                if (lastReachedTab == null)
                {
                    lastReachedOffset = 0;
                    lastReachedTab = Controller.Current.CurrentTabs.First();
                }

                DoSearch(action, lastReachedTab, regex);

            }
        }
Пример #11
0
        private void DoReplace(Tab tab, Regex regex, string replacement)
        {
            var offset = 0;

            tab.Editor.Document.BeginUpdate();

            foreach(Match match in regex.Matches(tab.Editor.Text))
            {
                tab.Editor.Document.Replace(match.Index + offset, match.Length, replacement);
                offset += replacement.Length - match.Length;
            }

            tab.Editor.Document.EndUpdate();

            tab.TextChanged();
        }