Пример #1
0
        public void DrawLineForeground(Graphics g, int lineIndex, Rectangle backgroundArea)
        {
            TextEditorBox textEditorBox            = this.Callback.TextEditorBox;
            TextLine <TextEditorBox.LineInfo> line = textEditorBox.TextProvider[lineIndex];

            foreach (var block in
                     !textEditorBox.UIExtensions.EditingSnippet
                    ? line.Blocks
                    : textEditorBox.UIExtensions.CurrentAffectedSegments
                     .Select(s =>
            {
                TextPosition start = textEditorBox.UIExtensions.GetSegmentStart(s);
                string text = textEditorBox.UIExtensions.GetSegmentText(s);
                TextPosition end = new TextPosition(start.row, start.col + text.Length);
                return(Tuple.Create(start, end));
            })
                     .Where(t => t.Item1.row == lineIndex)
                     .Select(t => Tuple.Create(t.Item1.col, t.Item2.col))
                     .Concat(line.Blocks)
                     )
            {
                Point     p1    = textEditorBox.TextPositionToViewPoint(new TextPosition(lineIndex, block.Item1));
                Point     p2    = textEditorBox.TextPositionToViewPoint(new TextPosition(lineIndex, block.Item2));
                Rectangle r     = new Rectangle(p1.X, p1.Y - textEditorBox.TextTopOffset, p2.X - p1.X, textEditorBox.LineHeight);
                Color     color = textEditorBox.Colorizer.ColorItems[this.Provider.BlockColorId].Text;
                using (Pen pen = new Pen(color))
                {
                    g.DrawRectangle(pen, r);
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                TextEditorBox.Clear();
            }
            name = openFileDialog1.FileName;
            TextEditorBox.Text = File.ReadAllText(openFileDialog1.FileName);
        }
Пример #3
0
        private bool EnterLimitedMode(TextEditorBox editor, KeyEventArgs e)
        {
            TextPosition start = editor.SelectionStart;
            TextPosition end   = editor.SelectionEnd;

            if (start.row == end.row)
            {
                editor.Controller.EnterLimitedMode(start.row, start.col, end.col);
            }
            return(true);
        }
Пример #4
0
        private bool RemoveBlock(TextEditorBox editor, KeyEventArgs e)
        {
            TextPosition start = editor.SelectionStart;
            TextPosition end   = editor.SelectionEnd;

            if (start.row == end.row)
            {
                editor.RemoveBlock(start.row, start.col, end.col);
            }
            return(true);
        }
Пример #5
0
        public bool NeedColorLineForDisplay(int lineIndex)
        {
            TextEditorBox textEditorBox = this.Callback.TextEditorBox;

            if (textEditorBox.Controller.LimitedMode)
            {
                if (textEditorBox.Controller.LimitedStart.row == lineIndex)
                {
                    return(true);
                }
            }
            TextLine <TextEditorBox.LineInfo> line = this.Callback.TextEditorBox.TextProvider[lineIndex];

            return(line.BlockCount > 0);
        }
Пример #6
0
        public void DrawLineBackground(Graphics g, int lineIndex, Rectangle backgroundArea)
        {
            TextEditorBox textEditorBox = this.Callback.TextEditorBox;

            if (textEditorBox.Controller.LimitedMode && textEditorBox.Controller.LimitedStart.row == lineIndex)
            {
                Point     p1    = textEditorBox.TextPositionToViewPoint(textEditorBox.Controller.LimitedStart);
                Point     p2    = textEditorBox.TextPositionToViewPoint(textEditorBox.Controller.LimitedEnd);
                Rectangle r     = new Rectangle(p1.X, p1.Y - textEditorBox.TextTopOffset, p2.X - p1.X, textEditorBox.LineHeight);
                Color     color = this.Provider.SnippetBackColor;
                using (SolidBrush brush = new SolidBrush(color))
                {
                    g.FillRectangle(brush, r);
                }
            }
        }
Пример #7
0
        public void ColorLineForDisplay(int lineIndex, int[] colors)
        {
            TextEditorBox textEditorBox            = this.Callback.TextEditorBox;
            TextLine <TextEditorBox.LineInfo> line = textEditorBox.TextProvider[lineIndex];

            foreach (var block in line.Blocks)
            {
                for (int i = block.Item1; i < block.Item2; i++)
                {
                    colors[i] = this.Provider.BlockColorId;
                }
            }
            if (textEditorBox.Controller.LimitedMode && textEditorBox.Controller.LimitedStart.row == lineIndex)
            {
                int start = Math.Min(line.CharCount, textEditorBox.Controller.LimitedStart.col);
                int end   = Math.Min(line.CharCount, textEditorBox.Controller.LimitedEnd.col);
                for (int i = start; i < end; i++)
                {
                    colors[i] = this.Provider.SnippetColorId;
                }
            }
        }
Пример #8
0
 private bool LeaveLimitedMode(TextEditorBox editor, KeyEventArgs e)
 {
     editor.Controller.LeaveLimitedMode();
     return(true);
 }