Example #1
0
        private void UpdateLines(RichText tas, Range range)
        {
            if (updating)
            {
                return;
            }
            updating = true;

            int start = range.Start.iLine;
            int end   = range.End.iLine;

            while (start <= end)
            {
                InputRecord old = Lines.Count > start ? Lines[start] : null;

                string text = tas[start++].Text;

                InputRecord input = new InputRecord(text);
                if (old != null)
                {
                    totalFrames -= old.Frames;

                    string line = input.ToString();
                    if (text != line)
                    {
                        if (old.Frames == 0 && old.ZeroPadding == input.ZeroPadding && old.Equals(input) && line.Length >= text.Length)
                        {
                            line = string.Empty;
                        }
                        Range oldRange = tas.Selection.Clone();
                        tas.Selection    = tas.GetLine(start - 1);
                        tas.SelectedText = line;

                        int actionPosition = input.ActionPosition();
                        if (!string.IsNullOrEmpty(line))
                        {
                            int index = oldRange.Start.iChar + line.Length - text.Length;
                            if (index < 0)
                            {
                                index = 0;
                            }
                            if (index > 4 && old.Angle == input.Angle)
                            {
                                index = 4;
                            }
                            if (old.Frames == input.Frames && old.ZeroPadding == input.ZeroPadding && old.Angle == input.Angle)
                            {
                                index = 4;
                            }

                            tas.Selection.Start = new Place(index, start - 1);
                        }

                        Text = titleBarText + " ***";
                    }
                    Lines[start - 1] = input;
                }

                totalFrames += input.Frames;
            }

            UpdateStatusBar();

            updating = false;
        }