Пример #1
0
        //public Tuple<DPos, DPos> GetSelect() {
        //    if (cur_.Cur > cur_.Sel) {
        //        DPos s = new DPos(cur_.Sel);
        //        DPos e = new DPos(cur_.Cur);
        //        return new Tuple<DPos, DPos> { t1 = s, t2 = e };
        //    }
        //    else {
        //        DPos s = new DPos(cur_.Cur);
        //        DPos e = new DPos(cur_.Sel);
        //        return new Tuple<DPos, DPos> { t1 = s, t2 = e };
        //    }
        //}

        public GCsTextEdit()
        {
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            //this.SetStyle(ControlStyles.DoubleBuffer, true);
            //this.SetStyle(ControlStyles.UserPaint, true);
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            vScrollBar         = new VGcsScrollBar();
            vScrollBar.Scroll += new ScrollEventHandler(ScrollBar_Scroll);
            this.Controls.Add(vScrollBar);

            hScrollBar         = new HGcsScrollBar();
            hScrollBar.Scroll += new ScrollEventHandler(ScrollBar_Scroll);
            this.Controls.Add(hScrollBar);

            this.ImeMode   = ImeMode.Off;
            imeComposition = new Ime(this);
            //imeComposition.ImeCompositedHira += new Ime.ImeEventHandler(imeComposition_ImeCompositedHira);
            //imeComposition.ImeCompositedKata += new Ime.ImeEventHandler(imeComposition_ImeCompositedKata);

            //this.HandleDestroyed += new EventHandler(AsTextEdit_HandleDestroyed);
            this.LostFocus += (sender, e) => {
                cur_.on_killfocus();
            };
            this.GotFocus += (sender, e) => {
                cur_.on_setfocus();
            };

            KeyMap = new KeyMap();
            MouseNormalSelectKey = Keys.Shift;
            MouseRectSelectKey   = Keys.Alt;

            doc_ = new Document();
            //doc_.setHighlight(new Highlight(this.ForeColor));
            //doc_.SetPartition(new Partition(new Highlight(this.ForeColor)));
            //doc_.SetPartition(new DefaultPartition(new DefaultHighlight(this.ForeColor)));
            //doc_.AddHighlight(Document.DEFAULT_ID, new DefaultHighlight(this.ForeColor));
            //doc_.SetPartition(Document.DEFAULT_ID);
            doc_.Parser = new PlaneParser();
            doc_.Parser.SetHighlight(new DefaultHighlight(this.ForeColor));
            //doc_.DocumentChanged += (sender, e) => {
            //    if (e.type == DocumentEventType.Clear) {
            //        this.MoveCursor(new DPos(0, 0));
            //    }
            //};
            doc_.TextUpdateEvent += (s, e, e2, reparsed, nmlcmd) => {
                on_text_update(s, e, e2, reparsed, nmlcmd);
            };
            doc_.ParserChangeEvent += (sender) => {
                this.Invalidate(false);
            };
            //
            cvs_ = new Canvas(this, this.Font, ShowLineNumber);
            fnt().LineNumberForeColor  = this.ForeColor;
            fnt().LineNumberBackColor  = this.BackColor;
            fnt().LineNumberLineColor  = this.ForeColor;
            fnt().SpecialCharForeColor = Color.Gray;

            fnt().canvas = cvs_;

            cur_ = new Cursor(this, new Caret(this.Handle));

            Initialize();
        }
Пример #2
0
        //public Tuple<DPos, DPos> GetSelect() {
        //    if (cur_.Cur > cur_.Sel) {
        //        DPos s = new DPos(cur_.Sel);
        //        DPos e = new DPos(cur_.Cur);
        //        return new Tuple<DPos, DPos> { t1 = s, t2 = e };
        //    }
        //    else {
        //        DPos s = new DPos(cur_.Cur);
        //        DPos e = new DPos(cur_.Sel);
        //        return new Tuple<DPos, DPos> { t1 = s, t2 = e };
        //    }
        //}
        public GCsTextEdit()
        {
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            //this.SetStyle(ControlStyles.DoubleBuffer, true);
            //this.SetStyle(ControlStyles.UserPaint, true);
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            vScrollBar = new VGcsScrollBar();
            vScrollBar.Scroll += new ScrollEventHandler(ScrollBar_Scroll);
            this.Controls.Add(vScrollBar);

            hScrollBar = new HGcsScrollBar();
            hScrollBar.Scroll += new ScrollEventHandler(ScrollBar_Scroll);
            this.Controls.Add(hScrollBar);

            this.ImeMode = ImeMode.Off;
            imeComposition = new Ime(this);
            //imeComposition.ImeCompositedHira += new Ime.ImeEventHandler(imeComposition_ImeCompositedHira);
            //imeComposition.ImeCompositedKata += new Ime.ImeEventHandler(imeComposition_ImeCompositedKata);

            //this.HandleDestroyed += new EventHandler(AsTextEdit_HandleDestroyed);
            this.LostFocus += (sender, e) => {
                cur_.on_killfocus();
            };
            this.GotFocus += (sender, e) => {
                cur_.on_setfocus();
            };

            KeyMap = new KeyMap();
            MouseNormalSelectKey = Keys.Shift;
            MouseRectSelectKey = Keys.Alt;

            doc_ = new Document();
            //doc_.setHighlight(new Highlight(this.ForeColor));
            //doc_.SetPartition(new Partition(new Highlight(this.ForeColor)));
            //doc_.SetPartition(new DefaultPartition(new DefaultHighlight(this.ForeColor)));
            //doc_.AddHighlight(Document.DEFAULT_ID, new DefaultHighlight(this.ForeColor));
            //doc_.SetPartition(Document.DEFAULT_ID);
            doc_.Parser = new PlaneParser();
            doc_.Parser.SetHighlight(new DefaultHighlight(this.ForeColor));
            //doc_.DocumentChanged += (sender, e) => {
            //    if (e.type == DocumentEventType.Clear) {
            //        this.MoveCursor(new DPos(0, 0));
            //    }
            //};
            doc_.TextUpdateEvent += (s, e, e2, reparsed, nmlcmd) => {
                on_text_update(s, e, e2, reparsed, nmlcmd);
            };
            doc_.ParserChangeEvent += (sender) => {
                this.Invalidate(false);
            };
            //
            cvs_ = new Canvas(this, this.Font, ShowLineNumber);
            fnt().LineNumberForeColor = this.ForeColor;
            fnt().LineNumberBackColor = this.BackColor;
            fnt().LineNumberLineColor = this.ForeColor;
            fnt().SpecialCharForeColor = Color.Gray;

            fnt().canvas = cvs_;

            cur_ = new Cursor(this, new Caret(this.Handle));

            Initialize();
        }