Ejemplo n.º 1
0
        /// <summary>
        /// Sets status bar text along the current cursor position in the parsed text box.
        /// Finds the selected capture, determines its filter tree path and constructs from them status text.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="length"></param>
        void set_status_by_position(int start, int length)
        {
            if (CaptureLabels == null)
                return;

            if (current_capture_label_index < 0 || current_capture_label_index >= CaptureLabels.Count)
            {
                SetStatus("");
                return;
            }

            int end = start + length;
            CaptureLabel owner_cl = null;
            for (CaptureLabel c = CaptureLabels[current_capture_label_index]; c != null; c = c.parent)
            {
                if (!c.visible)
                    continue;
                if (start >= c.start3 && end <= c.end && (owner_cl == null || c.level > owner_cl.level))
                    owner_cl = c;
            }
            if (owner_cl == null)
            {
                SetStatus("");
                return;
            }

            string path = null;
            for (CaptureLabel l = owner_cl; l != null; l = l.parent)
            {
                string name;
                int r;
                if (int.TryParse(l.group_name, out r))
                    name = "$" + l.group_name;
                else
                    name = l.group_name;
                path = "/" + name + "[" + l.match_id.ToString() + "]" + path;
            }

            string text = Document.Text.Substring(owner_cl.start, owner_cl.end - owner_cl.start);

            if (tr != null)
                tr.Abort();
            tr = new ThreadRunner(10000, this, "Stripping text of the selected capture is not completed still. Break it?");
            text = (string)tr.Run(this, "set_status_by_position_2", text);

            SetStatus(path.Substring(1) + " - \"" + text + "\"");
        }
        /// <summary>
        /// Sets status bar text along the current cursor position in the parsed text box.
        /// Finds the selected capture, determines its filter tree path and constructs from them status text.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="length"></param>
        void set_status_by_position(int start, int length)
        {
            if (CaptureLabels == null)
            {
                return;
            }

            if (current_capture_label_index < 0 || current_capture_label_index >= CaptureLabels.Count)
            {
                SetStatus("");
                return;
            }

            int          end      = start + length;
            CaptureLabel owner_cl = null;

            for (CaptureLabel c = CaptureLabels[current_capture_label_index]; c != null; c = c.parent)
            {
                if (!c.visible)
                {
                    continue;
                }
                if (start >= c.start3 && end <= c.end && (owner_cl == null || c.level > owner_cl.level))
                {
                    owner_cl = c;
                }
            }
            if (owner_cl == null)
            {
                SetStatus("");
                return;
            }

            string path = null;

            for (CaptureLabel l = owner_cl; l != null; l = l.parent)
            {
                string name;
                int    r;
                if (int.TryParse(l.group_name, out r))
                {
                    name = "$" + l.group_name;
                }
                else
                {
                    name = l.group_name;
                }
                path = "/" + name + "[" + l.match_id.ToString() + "]" + path;
            }

            string text = Document.Text.Substring(owner_cl.start, owner_cl.end - owner_cl.start);

            if (tr != null)
            {
                tr.Abort();
            }
            tr   = new ThreadRunner(10000, this, "Stripping text of the selected capture is not completed still. Break it?");
            text = (string)tr.Run(this, "set_status_by_position_2", text);

            SetStatus(path.Substring(1) + " - \"" + text + "\"");
        }