예제 #1
0
        public void ScrollTo( VPos vp )
        {
            // 横フォーカス
            int dx=0;
            if( vp.vx < hScrollBar.Value ){
                dx = vp.vx - hScrollBar.Value;
            }
            else{
                int W = cvs_.getPainter().W();
                if (hScrollBar.Value + (hScrollBar.nPage - W) <= vp.vx)
                    dx = vp.vx - (hScrollBar.Value + hScrollBar.nPage) + W;
            }

            // 縦フォーカス
            int dy=0;
            if (vp.vl < vScrollBar.Value)
                dy = vp.vl - vScrollBar.Value;
            else if (vScrollBar.Value + (vScrollBar.nPage - 1) <= vp.vl)
                dy = vp.vl - (vScrollBar.Value + vScrollBar.nPage) + 2;

            // スクロール
            if( dy!=0 )
                //UpDown( dy, dx==0 ); //TODO scroll
                UpDown(dy, false);
            if( dx!=0 )	ScrollView( dx, 0, true );
        }
예제 #2
0
        //
        internal void ConvDPosToVPos(DPos dp, ref VPos vp, ref VPos basevp)
        {
            // 補正
            dp.tl = Math.Min(dp.tl, doc_.tln() - 1);
            dp.ad = Math.Min(dp.ad, doc_.len(dp.tl));

            VPos topPos = new VPos();
            //if (basevp == null) {
            if (basevp.ad <0) {
                basevp = topPos;
            }

            // とりあえずbase行頭の値を入れておく
            int vl = basevp.vl - basevp.rl;
            int rl = 0;
            int vx;

            // 違う行だった場合
            // vlを合わせる
            int tl = basevp.tl;
            if (tl > dp.tl) {      // 目的地が基準より上にある場合
                do {
                    vl -= rln(--tl);
                } while (tl > dp.tl);
            }
            else if (tl < dp.tl) { // 目的地が基準より下にある場合
                do {
                    vl += rln(tl++);// wrapList[tl++].wrap.Count;
                } while (tl < dp.tl);
            }

            // rlを合わせる
            int stt = 0;
            //while (wrapList[tl].wrap[rl] < dp.ad)
            //    stt = wrapList[tl].wrap[rl++];
            while (wrap_[tl][rl + 1] < dp.ad)
                stt = wrap_[tl][++rl];
            vl += rl;

            // x座標計算
            ///vx = CalcStringWidth(doc.LineList[tl].Text, stt, dp.ad - stt);

            //vx = fnt().CalcStringWidth(doc_.tl(tl), stt, (dp.ad - stt));
            vx = stt==(dp.ad - stt)?0:fnt().CalcStringWidth(doc_.tl(tl).Substring(stt, (dp.ad - stt)).ToString()); //TODO
            //vx = CalcLineWidth(doc_.tl(tl), stt, dp.ad - stt);

            vp.tl = dp.tl;
            vp.ad = dp.ad;
            vp.vl = vl;
            vp.rl = rl;
            vp.rx = vp.vx = vx;
        }
예제 #3
0
        public void Ud(int dy, Boolean select)
        {
            // はみ出す場合は、先頭行/終端行で止まるように制限
            VPos np = new VPos(cur_);
            //int viewvln = vlNum_;
            if (np.vl + dy < 0)
                dy = -np.vl;
            else if (np.vl + dy >= view_.vln())
                dy = view_.vln() - np.vl - 1;

            np.vl += dy;
            np.rl += dy;

            if (dy < 0) { // 上へ戻る場合
                // ジャンプ先論理行の行頭へDash!
                while (np.rl < 0)
                    np.rl += view_.rln(--np.tl);

            } else if (dy > 0) {  // 下へ進む場合
                // ジャンプ先論理行の行頭へDash!
                while (np.rl > 0)
                    np.rl -= view_.rln(np.tl++);
                if (np.rl < 0)
                    np.rl += view_.rln(--np.tl); //行き過ぎ修正
            }

            // x座標決定にかかる
            IText str = doc_.tl(np.tl);

            // 右寄せになってる。不自然?
            np.ad = (np.rl == 0 ? 0 : view_.rlend(np.tl, np.rl - 1) + 1);

            np.vx = (np.rl == 0 ? 0 : view_.fnt().CalcStringWidth(str.Substring(np.ad - 1, 1).ToString())); //TODO

            //int wrapindex = wrapList[np.tl].wrap[np.rl];

            while (np.vx < np.rx && np.ad < view_.rlend(np.tl, np.rl)) {
                //int newvx = np.vx + view_.CalcStringWidth(doc.LineList[np.tl].Text, np.ad, 1);
                //if (newvx > np.rx)
                //    break;
                //np.vx = newvx;
                //++np.ad;

                // 左寄せにしてみた。
                int newvx;
                //if( str[np.ad] == '\t')
                //    newvx = view_.fnt().nextTab(np.vx);
                //else
                //    newvx = np.vx + view_.fnt().W(&str[np.ad]);
                if (str[np.ad] == '\t')
                    newvx = view_.fnt().nextTab(np.vx);
                else
                    newvx = np.vx + view_.fnt().CalcStringWidth(str.Substring(np.ad, 1).ToString());

                // newvx = np.vx + view_.fnt().CalcStringWidth(str.Substring(np.ad, 1).ToString());//TODO
                if(newvx > np.rx)
                    break;
                np.vx = newvx;
                ++np.ad;
            }

            MoveTo(np, select);
        }
예제 #4
0
 public void Right( bool wide, bool select )
 {
     VPos np = new VPos();
     if( cur_!=sel_ && !select ){
         //np = Max(cur_, sel_);
         //np = cur_ < sel_ ? sel_ : cur_;
         np.Copy(Util.Max(cur_, sel_));
         np.rx = np.vx;
     }else{
         //np = new VPos();
         view_.ConvDPosToVPos( doc_.rightOf(cur_,wide), ref np, ref cur_ );
     }
     MoveTo( np, select );
 }
예제 #5
0
        public void MoveText(VPos to, DPos s, DPos e)
        {
            DPos s1, e1;
            if (s < e) {
                s1 = s; e1 = e;
            } else {
                s1 = e; e1 = s;
            }
            var text = doc_.GetText(s1, e1);
            var cmds = new List<ICommand>();
            if (to < s1) {
                cmds.Add(new Delete(s1, e1));
                cmds.Add(new Insert(to, text));
                doc_.Execute(cmds);
            } else if (to > e1) {
                cmds.Add(new Insert(to, text));
                cmds.Add(new Delete(s1, e1));
                doc_.Execute(cmds);
                if (s1.tl == e1.tl) {
                    to.ad += text.Length;
                }
                else {

                }
                Cur.Copy(to);
                Sel.Copy(Cur);
                UpdateCaretPos();
            }
        }
예제 #6
0
 public void Left( bool wide, bool select )
 {
     VPos np = new VPos();
     if( cur_!=sel_ && !select ){
         //np = Math.Min(cur_, sel_);
         //np = cur_ > sel_ ? sel_ : cur_;
         np.Copy(Util.Min(cur_, sel_));
         np.rx = np.vx;
     }else{
         view_.ConvDPosToVPos( doc_.leftOf(cur_,wide), ref np, ref cur_ );
     }
     MoveTo( np, select );
 }
예제 #7
0
        public bool getCurPos( out VPos start, out VPos end)
        {
            //*start = *end = &cur_;
            start = new VPos();
            end = new VPos();
            start.Copy(cur_);
            end.Copy(cur_);

            if (cur_ == sel_)//|| !caret_->isAlive() )
                return false;
            if (cur_ < sel_) {
                //*end = &sel_;
                end.Copy(sel_);
            } else {
                //*start = &sel_;
                start.Copy(sel_);
            }
            return true;
        }
예제 #8
0
 public void DragOver(DragEventArgs e)
 {
     switch (State) {
         case StateType.None:
             break;
         case StateType.TextSelect:
             break;
         case StateType.TextGrab:
             break;
         case StateType.TextMove:
             Point p = view_.PointToClient(new Point(e.X, e.Y));
             var vp = new VPos();
             view_.GetVPos(p.X, p.Y, ref vp, false);
             SetPos(vp);
             break;
         default:
             break;
     }
 }
예제 #9
0
        private List<Tuple<DPos, DPos>> getRectangleDpos(VPos s, VPos e)
        {
            List<Tuple<DPos, DPos>> list = new List<Tuple<DPos, DPos>>();

            int sxb = view_.VRect.SXB;
            int sxe = view_.VRect.SXE;
            int syb = view_.VRect.SYB;

            int H = view_.fnt().H();
            int y = syb+H/2;

            Action<int> action = (rl) => {
                VPos vpb = new VPos();
                VPos vpe = new VPos();

                view_.GetVPos(sxb, y , ref vpb, false);
                view_.GetVPos(sxe, y , ref vpe, false);
                y += H;

                if (rl > 0 && sxb == view_.VRect.XBASE)
                    vpb.ad--;

                list.Add(new Tuple<DPos, DPos>(vpb, vpe));
            };

            if (s.tl == e.tl) {
                for (int i = s.rl; i <= e.rl; i++) {
                    action(i);
                }
            }
            else {

                for (int i = s.rl; i < view_.rln(s.tl); i++) {
                    action(i);
                }

                for (int i = s.tl + 1; i < e.tl; i++) {
                    for (int j = 0; j < view_.rln(i); j++) {
                        action(j);
                    }
                }

                for (int i = 0; i <= e.rl; i++) {
                    action(i);
                }
            }
            return list;
        }
예제 #10
0
        private List<Tuple<DPos, int>> getRectangleDpos(VPos s, VPos e, int etl, int erl)
        {
            List<Tuple<DPos, int>> list = new List<Tuple<DPos,int>>();

            int H = view_.fnt().H();

            int sxb = s.vx+view_.lna();
            int syb = 0;
            if (s == e) {
                //syb = caret_.GetPos().Y;// + H;
                int dummyx = 0;
                view_.GetOrigin(ref dummyx, ref syb);
                syb += s.vl * view_.fnt().H();
            } else {
                syb = view_.VRect.SYB;
            }

            int y = syb + H / 2;

            int wsw= view_.fnt().W(' ');

            Func<int, VPos> func = (rl) => {
                VPos vpb = new VPos();
                view_.GetVPos(sxb, y, ref vpb, false);
                y += H;

                if (vpb.ad > 0 && rl > 0 && sxb == view_.VRect.XBASE)
                    vpb.ad--;

                return vpb;
            };
            int wcnt = 0;
            if (s.tl == etl) {
                wcnt=0;
                for (int i = s.rl; i < erl; i++) {
                    VPos vp = func(i);

                    //if (i == erl-1) {
                    if (i == view_.rln(s.tl)- 1) {
                        if (s.vx > vp.vx) {
                            wcnt = (s.vx - vp.vx) / wsw;
                        }
                    }
                    list.Add(new Tuple<DPos, int>(vp, wcnt));
                }
            } else {
                wcnt = 0;
                for (int i = s.rl; i < view_.rln(s.tl); i++) {
                    VPos vp = func(i);

                    if (i == view_.rln(s.tl)- 1) {
                        if (s.vx > vp.vx) {
                            wcnt = (s.vx - vp.vx) / wsw;
                        }
                    }
                    list.Add(new Tuple<DPos, int>(vp, wcnt));
                }

                for (int i = s.tl + 1; i < etl; i++) {
                    wcnt = 0;
                    for (int j = 0; j < view_.rln(i); j++) {
                        VPos vp = func(j);
                        //if (i == erl-1) {
                        if (j == view_.rln(i) - 1) {
                            if (s.vx > vp.vx) {
                                wcnt = (s.vx - vp.vx) / wsw;
                            }
                        }
                        list.Add(new Tuple<DPos, int>(vp, wcnt));
                    }
                }

                wcnt = 0;
                for (int i = 0; i < erl; i++) {
                    VPos vp = func(etl);
                    //if (i == erl-1) {
                    if (i == view_.rln(etl) - 1) {
                        if (s.vx > vp.vx) {
                            wcnt = (s.vx - vp.vx) / wsw;
                        }
                    }
                    list.Add(new Tuple<DPos, int>(vp, wcnt));
                }
            }
            return list;
        }
예제 #11
0
        internal void RectangleInsert(VPos s, VPos e, List<string> texts)
        {
            Func<int, int, int, Tuple<int, int, int>> func = (stl, srl, cnt) => {
                if (cnt - (view_.rln(stl) - srl) > 0) {
                    cnt -= (view_.rln(stl) - srl);
                    stl++;
                }
                else {
                    srl = srl + cnt;
                }

                while (cnt > 0 && stl < doc_.tln()) {
                    if (cnt > view_.rln(stl)) {
                        cnt -= view_.rln(stl);
                    }
                    else if (cnt == view_.rln(stl)) {
                        cnt -= view_.rln(stl);
                        srl = view_.rln(stl);
                        break;
                    }
                    else {
                        cnt = 0;
                        srl = view_.rln(stl) + (cnt - view_.rln(stl));
                        break;
                    }
                    if (stl + 1 >= doc_.tln()) {
                        break;
                    }
                    stl++;
                }

                return new Tuple<int, int, int>(stl, srl, cnt);
            };

            if (s == e) {

                var cmds = new List<ICommand>();

                int cnt = texts.Count;
                var etlerl = func(s.tl, s.rl, cnt);
                int etl = etlerl.t1;
                int erl = etlerl.t2;
                int rescnt = etlerl.t3;
                var list = getRectangleDpos(s, e, etl, erl);

                //add
                if (rescnt > 0) {

                    int wsw = view_.fnt().W(' ');
                    int wscnt = s.vx / wsw;
                    string ws = string.Empty;
                    for (int j = 0; j < wscnt; j++) {
                        ws += " ";
                    }

                    for (int i = 0; i < rescnt; i++) {
                        DPos dp = new DPos(doc_.tln() - 1, doc_.tl(doc_.tln() - 1).Length);

                        //doc_.Execute(new Insert(dp, "\r\n" + ws + texts[rescnt - i]));
                        cmds.Add(new Insert(dp, "\r\n" + ws + texts[rescnt - i]));
                    }
                    texts.RemoveRange(texts.Count-rescnt, rescnt);
                }

                for (int i = list.Count-1; i >= 0; i--)
                {
                    DPos dp = list[i].t1;
                    String ws= string.Empty;
                    for (int j = 0; j < list[i].t2; j++) {
                        ws += " ";
                    }
                    if (ws.Length > 0) {
                        //doc_.Execute(new Insert(dp, ws));
                        cmds.Add(new Insert(dp, ws));
                    }
                    dp.ad += ws.Length;
                    //doc_.Execute(new Insert(dp, texts[i]));
                    cmds.Add(new Insert(dp, texts[i]));
                }
                doc_.Execute(cmds);

            } else {
                if (Selection == SelectionType.Rectangle) {

                    var cmds = new List<ICommand>();

                    var dposlist = getRectangleDpos(s, e);
                    if (dposlist.Count >= texts.Count) {
                        int c = dposlist.Count - texts.Count;
                        for (int i = 0; i < c; i++) {
                            texts.Add("");
                        }
                    }
                    else {
                        int cnt = texts.Count;// -dposlist.Count;

                        var etlerl = func(s.tl, s.rl, cnt);
                        int etl = etlerl.t1;
                        int erl = etlerl.t2;
                        int rescnt = etlerl.t3;
                        var list = getRectangleDpos(s, e, etl, erl);

                        //add
                        if (rescnt > 0) {

                            int wsw = view_.fnt().W(' ');
                            int wscnt = s.vx / wsw;
                            string ws = string.Empty;
                            for (int j = 0; j < wscnt; j++) {
                                ws += " ";
                            }

                            for (int i = 0; i < rescnt; i++) {
                                DPos dp = new DPos(doc_.tln() - 1, doc_.tl(doc_.tln() - 1).Length);

                                //doc_.Execute(new Insert(dp, "\r\n" + ws + texts[rescnt - i]));
                                cmds.Add(new Insert(dp, "\r\n" + ws + texts[rescnt - i]));
                            }
                            texts.RemoveRange(texts.Count - rescnt, rescnt);
                        }

                        for (int i = list.Count - 1 ; i >= dposlist.Count; i--) {
                            DPos dp = list[i].t1;
                            String ws = string.Empty;
                            for (int j = 0; j < list[i].t2; j++) {
                                ws += " ";
                            }
                            if (ws.Length > 0) {
                                //doc_.Execute(new Insert(dp, ws));
                                cmds.Add(new Insert(dp, ws));
                            }
                            dp.ad += ws.Length;
                            //doc_.Execute(new Insert(dp, texts[i]));
                            cmds.Add(new Insert(dp, texts[i]));
                        }
                    }

                    for (int i = dposlist.Count - 1; i >= 0; i--) {
                        string text = texts[i];
                        DPos dps = dposlist[i].t1;
                        DPos dpe = dposlist[i].t2;
                        //doc_.Execute(new Replace(dps, dpe, text));
                        cmds.Add(new Replace(dps, dpe, text));
                    }

                    doc_.Execute(cmds);
                }
                else {
                }
            }
        }
예제 #12
0
 internal void on_mouse_db_click(int x, int y)
 {
     // 行番号ゾーンの場合は特に何もしない
     if (view_.lna() - view_.fnt().F() < x) {
         // 行末の場合も特に何もしない
         if (cur_.ad != doc_.len(cur_.tl)) {
             VPos np = new VPos();
             view_.ConvDPosToVPos(doc_.wordStartOf(cur_), ref np, ref cur_);
             MoveTo(np, false);
             Right(true, true);
         }
     }
 }
예제 #13
0
        internal void MoveByMouse2(int x, int y)
        {
            dragX_ = x;
            dragY_ = y;

            VPos vp = new VPos();
            view_.GetVPos(x, y, ref vp, lineSelectMode_);
            MoveTo2(vp, true, new Point(x, y));
        }
예제 #14
0
        //TODO Rectangle
        internal string getRangesText(VPos s, VPos e)
        {
            List<string> texts = new List<string>();
            var list = getRectangleDpos(s, e);
            foreach (var item in list) {
                IText text = doc_.tl(item.t1.tl).Substring(item.t1.ad, item.t2.ad - item.t1.ad);
                //buff.Append(text.ToString());
                texts.Add(text.ToString());
            }

            //return buff.ToString();
            return String.Join("\r\n", texts.ToArray<string>());
        }
예제 #15
0
 private string getLinkFromPositon(int x, int y)
 {
     string link = null;
     VPos vp = new VPos();
     GetVPos(x, y, ref vp, false);
     var rules = doc_.Rules(vp.tl);
     foreach (var rule in rules) {
         if (((rule.attr.type & AttrType.Link) == AttrType.Link)
             && (vp.ad >= rule.ad && vp.ad <= (rule.ad + rule.len))) {
             link = doc_.tl(vp.tl).Substring(rule.ad, rule.len).ToString();
             break;
         }
     }
     return link;
 }
예제 #16
0
        public void DelRectangle(VPos cur, VPos sel)
        {
            DPos dp = (cur == sel ? doc_.rightOf(cur, false) : (DPos)sel);
            if (cur != dp) {
                List<Tuple<DPos, DPos>> list = null;
                if (cur < sel) {
                    list = getRectangleDpos(cur, sel);
                } else {
                    list = getRectangleDpos(sel, cur);
                }
                list.Sort((x, y) => {
                    if (x.t1.ad == y.t1.ad) return 0;
                    return x.t1.ad < y.t1.ad ? 1 : -1;
                });

                var cmds = new List<ICommand>();
                foreach (var item in list) {
                    cmds.Add(new Delete(item.t1, item.t2));
                }
                doc_.Execute(cmds);
            }
        }
예제 #17
0
        public void DragDrop(DragEventArgs e)
        {
            switch (State) {
                case StateType.None:
                    break;
                case StateType.TextSelect:
                    break;
                case StateType.TextGrab:
                    break;
                case StateType.TextMove:
                    Point p = view_.PointToClient(new Point(e.X, e.Y));
                    if (ContainSelect(p.X, p.Y, Cur, Sel)) {
                        on_lbutton_down(p.X, p.Y, false);
                        return;
                    }
                    if (Selection == SelectionType.Normal) {
                        var vp = new VPos();
                        view_.GetVPos(p.X, p.Y, ref vp, false);
                        //cur_.Cur.Copy(vp);
                        MoveText(vp, Cur, Sel);

                        //cur_.on_lbutton_down(p.X, p.Y, false);
                        //cur_.on_button_up(); //State = CursorState.None;

                    } else if (Selection == SelectionType.Rectangle) {
                        //var vp1 = new VPos();
                        ///GetVPos(p.X, p.Y, ref vp1, false);
                        //cur_.Cur.Copy(vp1);

                        //VPos vp = new VPos(cur_.Cur);
                        string text = e.Data.GetData(DataFormats.Text) as string;
                        //var text = getRangesText(Cur, Sel);
                        DelRectangle(Cur, Sel);
                        List<string> lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList<string>();

                        var vp = new VPos();
                        view_.GetVPos(p.X, p.Y, ref vp, false);
                        Cur.Copy(vp);
                        RectangleInsert(Cur, Cur, lines);
                    }
                    Selection = SelectionType.Normal;
                    State = StateType.None;
                    view_.AllowDrop = AllowDropbk;
                    break;
                default:
                    break;
            }
        }
예제 #18
0
        private void MoveTo2(VPos vp, bool sel, Point p)
        {
            if (sel) {
                // 選択状態が変わる範囲を再描画
                Redraw(vp, cur_);
            }
            else {
                // 選択解除される範囲を再描画
                if (cur_ != sel_)
                    Redraw(cur_, sel_);
                sel_.Copy(vp);
            }

            cur_.Copy(vp);
            UpdateCaretPos(p);
            view_.ScrollTo(cur_);
        }
예제 #19
0
        public void End(bool wide, bool select)
        {
            VPos np = new VPos();
            if (wide) { // 文書の末尾へ
                np.tl = doc_.tln() - 1;
                np.vl = view_.vln() - 1;
            } else { // 行の末尾へ

                // 1.07.4 --> 1.08 :: Virtual End
                // np.tl = cur_.tl;
                // np.vl = cur_.vl + view_.rln(np.tl) - 1 - cur_.rl;

                view_.ConvDPosToVPos(new DPos(cur_.tl, view_.rlend(cur_.tl, cur_.rl)), ref np, ref cur_);
                MoveTo(np, select);
                return;
            }
            np.ad = doc_.len(np.tl);
            np.rl = view_.rln(np.tl) - 1;
            np.rx = np.vx = view_.GetLastWidth(np.tl);

            MoveTo(np, select);
        }
예제 #20
0
        private void Redraw(VPos s, VPos e )
        {
            int x=0, y=0; // 原点
            view_.GetOrigin( ref x, ref y );

            Point sp = new Point(x + s.vx, y + s.vl * view_.fnt().H());
            Point ep = new Point(x + e.vx, y + e.vl * view_.fnt().H());
            if( s > e ){ // Swap
                //sp.X^=ep.X; ep.X^=sp.X; sp.X^=ep.X;
                //sp.X^=ep.Y; ep.Y^=sp.Y; sp.Y^=ep.Y;

                int tmp = ep.X;
                ep.X = sp.X;
                sp.X = tmp;

                tmp = ep.Y;
                ep.Y = sp.Y;
                sp.Y = tmp;
            }
            ep.X+=2;

            //// 手抜き16bitチェック入り…
            int LFT = view_.left();
            int RHT = view_.right();
            int TOP = 0;
            int BTM = view_.bottom();

            if( sp.Y == ep.Y )
            {
                if (Selection == SelectionType.Rectangle) {

                    var v = view_.VRect;
                    var pos = view_.PointToClient(System.Windows.Forms.Cursor.Position);
                    Rectangle rc = new Rectangle(LFT, Math.Max(TOP, 0), pos.X, ep.Y + view_.fnt().H());
                    view_.Invalidate( false);
                }
                else {
                    //Rectangle rc = new Rectangle(Math.Max(LFT,sp.X), sp.Y, Math.Min(RHT,ep.X), sp.Y+view_.fnt().H());

                    //Rectangle rc = new Rectangle(Math.Max(LFT, sp.X), sp.Y, Math.Min(RHT, ep.X - sp.X), view_.fnt().H());
                    Rectangle rc = new Rectangle(Math.Max(LFT, sp.X), sp.Y, RHT, view_.fnt().H()); //TODO
                    view_.Invalidate(rc, false);
                    //::InvalidateRect( caret_->hwnd(), &rc, FALSE );
                    //Console.WriteLine("Rectangle sp.Y == ep.Y");
                }
            }
            else
            {
                //TODO Rectangle
                if (Selection == SelectionType.Rectangle) {
                    //Rectangle rc = new Rectangle(LFT, Math.Max(TOP, sp.Y), ep.X, ep.Y + view_.fnt().H());
                    //Rectangle rc = new Rectangle(LFT, Math.Max(TOP, sp.Y), ep.X, ep.Y + view_.fnt().H());
                    Rectangle rc = new Rectangle(LFT, Math.Min(TOP, sp.Y), RHT, (ep.Y - sp.Y) * view_.fnt().H());
                    view_.Invalidate(rc, false);
                } else {
                    //RECT rc = { Max(LFT,sp.x), Max(TOP,sp.y), RHT, Min<int>(BTM,sp.y+view_.fnt().H()) };
                    //::InvalidateRect( caret_->hwnd(), &rc, FALSE );
                    //RECT re = { LFT, Max(TOP,ep.y), Min(RHT,ep.x), Min<int>(BTM,ep.y+view_.fnt().H()) };
                    //::InvalidateRect( caret_->hwnd(), &re, FALSE );
                    //RECT rd = { LFT, Max(TOP,rc.bottom), RHT, Min<int>((long)BTM,re.top) };
                    //::InvalidateRect( caret_->hwnd(), &rd, FALSE );

                    //Rectangle rc = new Rectangle(LFT, Math.Max(TOP, sp.Y), RHT, Math.Min(BTM, sp.Y + view_.fnt().H()));
                    //view_.Invalidate(rc, false);
                    //Rectangle re = new Rectangle(LFT, Math.Max(TOP, ep.Y), Math.Min(RHT, ep.X), Math.Min(BTM, ep.Y + view_.fnt().H()));
                    //view_.Invalidate(re, false);
                    //Rectangle rd = new Rectangle(LFT, Math.Max(TOP, rc.Bottom), RHT, Math.Min(BTM, re.Top));
                    //view_.Invalidate(rd, false);

                    Rectangle rc = new Rectangle(Math.Max(LFT, sp.X), Math.Max(TOP, sp.Y), RHT - Math.Max(LFT, sp.X), Math.Min(BTM, view_.fnt().H()));
                    view_.Invalidate(rc, false);

                    Rectangle re = new Rectangle(LFT, Math.Max(TOP, ep.Y), Math.Min(RHT, ep.X) - LFT, Math.Min(BTM, view_.fnt().H()));
                    view_.Invalidate(re, false);

                    Rectangle rd = new Rectangle(LFT, Math.Max(TOP, rc.Bottom), RHT - LFT, Math.Min(BTM, re.Top));
                    view_.Invalidate(rd, false);
                }
            }
        }
예제 #21
0
        public void Home(bool wide, bool select)
        {
            VPos np = new VPos();
            np.ad = np.vx = np.rx = np.rl = 0;
            if( wide ) // 文書の頭へ
                np.tl = np.vl = 0;
            else // 行の頭へ
            {
                // 1.07.4 --> 1.08 :: Virtual Home
                // np.tl = cur_.tl, np.vl = cur_.vl-cur_.rl;

                if( cur_.rl == 0 ){
                    np.tl = cur_.tl;
                    np.vl = cur_.vl - cur_.rl;
                } else{
                    //view_.ConvDPosToVPos( doc_.rightOf(DPos(cur_.tl, view_.rlend(cur_.tl,cur_.rl-1))), &np, &cur_ );
                    view_.ConvDPosToVPos(doc_.rightOf(new DPos(cur_.tl, view_.rlend(cur_.tl, cur_.rl - 1)), false), ref np, ref cur_);
                }
            }
            MoveTo( np, select );
        }
예제 #22
0
        //public Cursor(GCsTextEdit view_, Document doc_, Caret caret_) {
        public Cursor(GCsTextEdit view_, Caret caret_)
        {
            this.view_ = view_;
            this.doc_ = view_.Document;
            this.caret_ = caret_;

            cur_ = new VPos();
            sel_ = new VPos();

            bIns_ = true;

            State = StateType.None;

            //TODO Rectangle
            Selection = SelectionType.Normal;

            //this.view_.MouseDown += (sender, e) => {
            //    state = State.MouseDown;
            //};
            //this.view_.MouseUp += (sender, e) => {
            //    state = State.None;
            //};
            //this.view_.MouseMove += (sender, e) => {
            //    if (State == CursorState.MouseDown) {
            //        //if (!PtInRect(&view_.zone(), pt)) {
            //        //if ( view_.zone().Contains(e.X, e.Y)){
            //            MoveByMouse(e.X, e.Y);
            //        //}
            //    }
            //};
            //this.view_.MouseDoubleClick += (sender, e) => {
            //    // 行番号ゾーンの場合は特に何もしない
            //    if (view_.lna() - view_.fnt().F() < e.X) {
            //        // 行末の場合も特に何もしない
            //        if (cur_.ad != doc_.len(cur_.tl)) {
            //            VPos np = new VPos();
            //            view_.ConvDPosToVPos(doc_.wordStartOf(cur_), ref np, ref cur_);
            //            MoveTo(np, false);
            //            Right(true, true);
            //        }
            //    }
            //};
        }
예제 #23
0
 public void MoveCur(DPos dp, bool select)
 {
     VPos vp = new VPos();
     view_.ConvDPosToVPos(dp, ref vp);
     MoveTo(vp, select);
 }
예제 #24
0
 public VPos(VPos vp)
 {
     tl = vp.tl; ad = vp.ad;
     vl = vp.vl; rl = vp.rl; vx = vp.vx; rx = vp.rx;
 }
예제 #25
0
        public void on_text_update(DPos s, DPos e, DPos e2, bool mCur)
        {
            VPos search_base  = new VPos();
            search_base.ad = -1;

            if( mCur && s==cur_ && e==sel_ ){
                //search_base = new VPos(cur_);
                search_base = cur_;

            }
            else if( mCur && s==sel_ && e==cur_ ){
                //search_base =  new VPos(sel_);
                search_base = sel_;
            }
            else{
                Redraw( cur_, sel_ );
                if( mCur && caret_.isAlive() ){
                    if( cur_ <= s ){
                        //search_base = &cur_;
                        search_base.Copy(cur_);
                    }
                }
                else{
                    if( s < cur_ ){
                        if (cur_ <= e) {
                            //cur_ = e2 as VPos;
                            //VPos ve2 = e2 as VPos;
                            //cur_.Copy(ve2);
                            cur_.tl = e2.tl;
                            cur_.ad = e2.ad;
                        } else if (cur_.tl == e.tl) {
                            cur_.tl = e2.tl;
                            cur_.ad = e2.ad + cur_.ad - e.ad;
                        } else
                            cur_.tl = e2.tl - e.tl;
                        view_.ConvDPosToVPos( cur_, ref cur_ );
                    }
                    if (s < sel_)
                        //sel_ = cur_;
                        sel_.Copy(cur_);
                }
            }

            if( mCur ){
                view_.ConvDPosToVPos( e2, ref cur_, ref search_base );
                //sel_ = cur_;
                sel_.Copy(cur_);
                if( caret_.isAlive() )
                    view_.ScrollTo( cur_ );
            }
            UpdateCaretPos();
        }
예제 #26
0
 public void Copy(VPos src)
 {
     tl = src.tl;
     ad = src.ad;
     vl = src.vl;
     rl = src.rl;
     vx = src.vx;
     rx = src.rx;
 }
예제 #27
0
        public void SetPos(VPos vp)
        {
            int x = 0, y = 0;
            view_.GetOrigin(ref x, ref y);
            x += vp.vx;
            y += vp.vl * view_.fnt().H();

            // 行番号ゾーンにCaretがあっても困るので左に追いやる
            if (0 < x && x < view_.left())
                x = -view_.left();

            // セット
            caret_.SetPos(x, y);
        }
예제 #28
0
 //public bool ContainSelect(int x, int y) {
 //    if (view_.VRect.SXB < x && x < view_.VRect.SXE
 //        && view_.VRect.SYB < y && y < view_.VRect.SYE + view_.fnt().H()) {
 //        return true;
 //    }
 //    return false;
 //}
 public bool ContainSelect(int x, int y, VPos cur, VPos sel)
 {
     return this.ContainSelect(x, y, cur as DPos, sel as DPos);
 }
예제 #29
0
 public bool ContainSelect(int x, int y, DPos cur, DPos sel)
 {
     if (Selection == SelectionType.Rectangle) {
         //if (view_.VRect.SXB < x && x < view_.VRect.SXE
         //    && view_.VRect.SYB < y && y < view_.VRect.SYE + view_.fnt().H()) {
         if (view_.VRect.SXB < x && x < caret.GetPos().X
              && view_.VRect.SYB < y && y < caret.GetPos().Y + view_.fnt().H()) {
             return true;
         }
     } else {
         VPos vp = new VPos();
         view_.GetVPos(x, y, ref vp, false);
         DPos c = vp as DPos;
         var curs = Cursor.Sort(cur, sel);
         return (curs.t1 < c && c < curs.t2);
     }
     return false;
 }
예제 #30
0
 internal void ConvDPosToVPos(DPos dp, ref VPos vp)
 {
     dummyVPos.ad = -1;
     ConvDPosToVPos(dp, ref vp, ref dummyVPos);
 }