コード例 #1
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
        public ICommand Execute(Document doc)
        {
            //DocImpl & di = d.impl();

            //// 削除
            //unicode* buf;
            //ulong siz;
            //DPos s = stt_, e = end_;
            //bool aa = di.DeletingOperation(s, e, buf, siz);

            //// イベント発火
            //di.Fire_TEXTUPDATE(s, e, s, aa, true);

            //// 逆操作オブジェクトを返す
            //return new Insert(s, buf, siz, true);

            string buf;
            DPos s = new DPos(stt_);
            DPos e = new DPos(end_);
            bool aa = doc.DeletingOperation(ref s, ref e, out buf);
            //TextUpdate(s, e, s, aa, true);
            doc.Fire_TEXTUPDATE(s, e, s, aa, true);

            return new Insert(s, buf);
        }
コード例 #2
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
        public bool FindNextImpl()
        {
            // カーソル位置取得
            //VPos stt, end;
            //view.cursor.getCurPos( out stt, out end );
            DPos stt, end;
            view.GetSelction(out stt, out end);

            // 選択範囲ありなら、選択範囲先頭の1文字先から検索
            // そうでなければカーソル位置から検索
            DPos s = new DPos(stt.tl, stt.ad);
            if( stt != end )
                //if (stt.ad == view.Document.len(stt.tl))
                if (stt.ad == document.GetLength(stt.tl))
                    s = new DPos( stt.tl+1, 0 );
                else
                    s = new DPos( stt.tl, stt.ad+1 );

            // 検索
            DPos b = new DPos();
            DPos e = new DPos();
            if( FindNextFromImpl( s, ref b, ref e ) ){
                // 見つかったら選択
                //view.cursor.MoveCur(b, false);
                //view.cursor.MoveCur(e, true);
                view.SetSelction(b, e);
                return true;
            }

            // 見つからなかった場合
            return false;
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
        public ICommand Execute(Document doc)
        {
            // 挿入
            DPos s = new DPos(stt_); //, e;
            DPos e = new DPos();
            bool aa = doc.InsertingOperation(ref s, buf_, ref e);

            // イベント発火
            //doc.Fire_TEXTUPDATE(s, s, e, aa, true);
            doc.Fire_TEXTUPDATE(s, s, e, aa, true);

            // 逆操作オブジェクトを返す
            return new Delete(s, e);
        }
コード例 #4
0
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
 public void MoveCursor(DPos dp)
 {
     cur_.MoveCur(dp, false);
 }
コード例 #5
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
        public bool FindPrevImpl()
        {
            // カーソル位置取得
            //VPos stt = new VPos();
            //VPos end = new VPos();
            //view.cursor.getCurPos( out stt, out end );
            DPos stt, end;
            view.GetSelction(out stt, out end);

            if( stt.ad!=0 || stt.tl!=0 ){
                // 選択範囲先頭の1文字前から検索
                DPos s;
                if( stt.ad == 0 )
                    //s = new DPos( stt.tl-1, view.Document.len(stt.tl-1) );
                    s = new DPos( stt.tl-1, view.Document.GetLength(stt.tl-1) );
                else
                    s = new DPos( stt.tl, stt.ad-1 );

                // 検索
                DPos b = new DPos(); DPos e = new DPos();
                if( FindPrevFromImpl( s, ref b, ref e ) ){
                    // 見つかったら選択
                    //view.cursor.MoveCur( b, false );
                    //view.cursor.MoveCur( e, true );
                    view.SetSelction(b, e);

                    return true;
                }
            }

            // 見つからなかった場合
            return false;
        }
コード例 #6
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
        private bool FindPrevFromImpl( DPos s, ref DPos beg, ref DPos end )
        {
            Searcher.SearchWord = this.SearchWord;

            // 1行ずつサーチ
            //Document d = view.Document();
            //IDocument d = view.Document;
            //for( int mbg=0,med=0; ; s.ad=d.len(--s.tl) ){
            for (int mbg = 0, med = 0; ; s.ad = document.GetLength(--s.tl)) {
                if( Searcher.Search(
                    //d.tl(s.tl).ToString(), d.len(s.tl), s.ad, ref mbg, ref med ) ){
                    document.GetText(s.tl), document.GetLength(s.tl), s.ad, ref mbg, ref med)) {
                    beg.tl = end.tl = s.tl;
                    beg.ad = mbg;
                    end.ad = med;
                    return true; // 発見
                }
                if( s.tl==0 )
                    break;
            }
            return false;
        }
コード例 #7
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
        public void ReplaceImpl()
        {
            // カーソル位置取得
            //VPos stt = new VPos();
            //VPos end = new VPos();
            //view.cursor.getCurPos( out stt, out end );
            DPos stt, end;
            view.GetSelction(out stt, out end);

            // 選択範囲先頭から検索
            DPos b = new DPos();
            DPos e = new DPos();
            if( FindNextFromImpl( stt, ref b, ref e ) )
                if( e == (DPos)end ){
                    //string str = replStr_.ConvToWChar();
                    //int len = replstr.Length;

                    // 置換
                    //edit.getDoc().Execute( doc::Replace(
                    //    b, e, ustr, ulen
                    //) );

                    //view.Document.Execute(new Replace(b, e, ReplaceWord));
                    document.Replace(b, e, ReplaceWord);

                    if (FindNextFromImpl(new DPos(b.tl, b.ad + ReplaceWord.Length), ref b, ref e))
                    {
                        // 次を選択
                        //view.cursor.MoveCur( b, false );
                        //view.cursor.MoveCur( e, true );
                        view.SetSelction(b, e);
                        return;
                    }
                }
                else
                {
                    // そうでなければとりあえず選択
                    //view.cursor.MoveCur( b, false );
                    //view.cursor.MoveCur( e, true );
                    view.SetSelction(b, e);
                    return;
                }

            // 見つからなかった場合
            //NotFound();
        }
コード例 #8
0
        //
        void InvalidateView( DPos dp, bool afterall )
        {
            int H = cvs_.getPainter().H();

            // 表示域より上での更新
            if( dp.tl < udScr_tl_ ){
                if( afterall )
                    //::InvalidateRect( hwnd_, NULL, FALSE );
                    this.Invalidate(false);
                return;
            }

            // 開始y座標計算
            int r=0, yb=-udScr_vrl_;
            for( int t=udScr_tl_, ybe=cy()/H; t<dp.tl; yb+=rln(t++) )
                if( yb >= ybe )
                    return;
            for( ; dp.ad>rlend(dp.tl,r); ++r,++yb );
            yb = H * Math.Max( yb, -100 ); // 上にはみ出し過ぎないよう調整
            if( yb >= cy() )
                return;

            // 1行目を再描画
            int rb = (r==0 ? 0 : rlend(dp.tl,r-1));
            string text = doc_.tl(dp.tl).Substring(rb).ToString();
            //int xb = left() + Math.Max( 0,
            //    //CalcLineWidth(doc_.tl(dp.tl)+rb, dp.ad-rb) -rlScr_.nPos );
            //    CalcLineWidth(text, dp.ad - rb) - hScrollBar.Value);
            int xb = left();
            if( xb < right() ){
                Rectangle rc = new Rectangle(xb, yb, right(), H);
                this.Invalidate(rc, false);
                //this.Invalidate(false);
            }

            // 残り
            int ye;
            yb += H;
            if( afterall ){
                xb=0;
                ye=cy();
            }else{
                xb=left();
                ye=Math.Min(cy(),yb+(int)(H*(rln(dp.tl)-r-1)));
            }
            if( yb < ye ){
                Rectangle rc = new Rectangle( xb, yb, right(), ye );
                //::InvalidateRect( hwnd_, &rc, FALSE );
                this.Invalidate(rc, false);
            }
        }
コード例 #9
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
 public VPos(DPos dp)
 {
     tl = dp.tl; ad = dp.ad;
     vl = 0; rl = 0; vx = 0; rx = 0;
 }
コード例 #10
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
 public DPos(DPos dp)
 {
     this.tl = dp.tl;
     this.ad = dp.ad;
 }
コード例 #11
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
        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
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
        //
        //-------------------------------------------------------------------------
        // 再描画したい範囲を Invalidate する。
        //-------------------------------------------------------------------------
        private void ReDraw( ReDrawType r, DPos s )
        {
            // まずスクロールバーを更新
            //UpdateScrollBar();

            switch( r ){
                case ReDrawType.ALL: // 全画面
                    //::InvalidateRect( hwnd_, NULL, FALSE );
                    this.Invalidate(false);
                break;

                case ReDrawType.LNAREA: // 行番号表示域のみ
                    if( lna() > 0 )
                    {
                        Rectangle rc = new Rectangle(0, 0, lna(), bottom());
                        //::InvalidateRect( hwnd_, &rc, FALSE );
                        this.Invalidate(rc, false);
                    }
                break;

                case ReDrawType.LINE: // 指定した行の後半
                case ReDrawType.AFTER: // 指定した行以下全部
                    DPos st = ( s.ad==0 ? s : doc_.leftOf(s,true) );
                    InvalidateView(st, r == ReDrawType.AFTER);
                break;
            }
        }
コード例 #13
0
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
        //
        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;
        }
コード例 #14
0
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
 internal void ConvDPosToVPos(DPos dp, ref VPos vp)
 {
     dummyVPos.ad = -1;
     ConvDPosToVPos(dp, ref vp, ref dummyVPos);
 }
コード例 #15
0
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
 public void SetSelction(DPos s, DPos e)
 {
     cur_.MoveCur(s, false);
     cur_.MoveCur(e, true);
 }
コード例 #16
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
        public ICommand Execute(Document doc)
        {
            //DocImpl & di = d.impl();

            //// 削除
            //unicode* buf;
            //ulong siz;
            //DPos s = stt_, e = end_;
            //bool aa = di.DeletingOperation(s, e, buf, siz);

            //// 挿入
            //DPos e2;
            //aa = (di.InsertingOperation(s, buf_, len_, e2) || aa);

            //// イベント発火
            //di.Fire_TEXTUPDATE(s, e, e2, aa, true);

            //// 逆操作オブジェクトを返す
            //return new Replace(s, e2, buf, siz, true);

            string buf;
            DPos s = new DPos(stt_);
            DPos e = new DPos(end_);
            bool aa = doc.DeletingOperation(ref s, ref e, out buf);

            DPos e2 = new DPos();
            aa = (doc.InsertingOperation(ref s, buf_, ref e2) || aa);

            doc.Fire_TEXTUPDATE(s, e, e2, aa, true);

            return new Replace(s, e2, buf);
        }
コード例 #17
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
 public Delete(DPos s, DPos e)
 {
     stt_ = new DPos(s);
     end_ = new DPos(e);
 }
コード例 #18
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
 public static Tuple<DPos, DPos> Sort(DPos x, DPos y)
 {
     Tuple<DPos, DPos> res = new Tuple<DPos, DPos>();
     if (x < y) {
         res.t1 = x;
         res.t2 = y;
     } else {
         res.t1 = y;
         res.t2 = x;
     }
     return res;
 }
コード例 #19
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
 public Insert(DPos s, string str)
 {
     stt_ = new DPos(s);
     buf_ = str;
 }
コード例 #20
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
 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;
 }
コード例 #21
0
        internal ReDrawType TextUpdate_ScrollBar( DPos s, DPos e, DPos e2 )
        {
            int prevUdMax = vScrollBar.Maximum;
            bool rlScrolled = ReSetScrollInfo();
            int vl_dif = (vScrollBar.Maximum - prevUdMax);
            ReDrawType ans =
                (vl_dif != 0 || s.tl != e2.tl ? ReDrawType.AFTER : ReDrawType.LINE);

            if( udScr_tl_ < s.tl ){
                // パターン1:現在の画面上端より下で更新された場合
                // スクロールしない
            }
            else if( udScr_tl_ == s.tl ){
                // パターン2:現在の画面上端と同じ行で更新された場合
                // 出来るだけ同じ位置を表示し続けようと試みる。

                if( vScrollBar.Value >= vln() ){
                    // パターン2-1:しかしそこはすでにEOFよりも下だ!
                    // しゃーないので一番下の行を表示
                    vScrollBar.Value = vln() - 1;
                    udScr_tl_   = doc_.tln()-1;
                    udScr_vrl_  = rln(udScr_tl_)-1;
                    ans = ReDrawType.ALL;
                }
                else{
                    // パターン2-2:
                    // スクロール無し
                    while( udScr_vrl_ >= rln(udScr_tl_) ){
                        udScr_vrl_ -= rln(udScr_tl_);
                        udScr_tl_++;
                    }
                }
            }
            else{
                // パターン3:現在の画面上端より上で更新された場合
                // 表示内容を変えないように頑張る

                if( e.tl < udScr_tl_ ){
                    // パターン3-1:変更範囲の終端も、現在行より上の場合
                    // 行番号は変わるが表示内容は変わらないで済む
                    vScrollBar.Value += vl_dif;
                    udScr_tl_   += (e2.tl - e.tl);
                    ans = ReDrawType.LNAREA;
                }
                else{
                    // パターン3-2:
                    // どうしよーもないので適当な位置にスクロール
                    ForceScrollTo( e2.tl );
                    ans = ReDrawType.ALL;
                }
            }

            // どんな再描画をすればよいか返す
            return (rlScrolled ? ReDrawType.ALL : ans);
        }
コード例 #22
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
        public void Copy()
        {
            if( cur_==sel_ )
                return;

            if(Selection == SelectionType.Rectangle){
                string lines =string.Empty;
                if (cur_ > sel_) {
                    lines = getRangesText(sel_, cur_);
                }
                else {
                    lines = getRangesText(cur_, sel_);
                }
                //Clipboard.SetData("Rectangle", data);
                DataObject data = new DataObject();
                data.SetData(lines);
                data.SetData(SelectionType.Rectangle);
                Clipboard.SetDataObject(data, true);
            }else{

                DPos dm = new DPos(cur_.tl, cur_.ad);
                DPos dM = new DPos(sel_.tl, sel_.ad);
                if (cur_ > sel_) {
                    Clipboard.SetText(doc_.GetText(dM, dm));
                }
                else {
                    Clipboard.SetText(doc_.GetText(dm, dM));
                }
            }
        }
コード例 #23
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
        public void ReplaceAllImpl()
        {
            // まず、実行する置換を全てここに登録する
            //doc::MacroCommand mcr;

            // 置換後文字列
            //const wchar_t* ustr = replStr_.ConvToWChar();
            //const ulong ulen = my_lstrlenW( ustr );

            List<ICommand> mcr = new List<ICommand>();

            // 文書の頭から検索
            int dif=0;
            DPos s = new DPos(0, 0);//s(0,0)
            DPos b = new DPos();
            DPos e = new DPos();
            while( FindNextFromImpl(new DPos(s), ref b, ref e ) ){
                if( s.tl != b.tl ) dif = 0;
                //s = e;
                s.tl = e.tl;
                s.ad = e.ad;

                // 置換コマンドを登録
                b.ad += dif; e.ad += dif;

                mcr.Add(new Replace(b, e, ReplaceWord));

                dif -= e.ad - b.ad - ReplaceWord.Length;

                int f = dif;
            }

            //if( mcr.size() > 0 ){
            //    // ここで連続置換
            //    edit.getDoc().Execute( mcr );
            //    // カーソル移動
            //    e.ad = b.ad + ulen;
            //    edit.cursor.MoveCur( e, false );
            //    // 閉じる?
            //    //End( IDOK );
            //}
            if (mcr.Count > 0) {
                // ここで連続置換
                foreach (var cmd in mcr) {
                    //view.GetDocument().Execute(cmd);
                    document.Execute(cmd);
                }
                // カーソル移動
                e.ad = b.ad + ReplaceWord.Length;
                //view.cursor.MoveCur(e, false);
                view.MoveCursor(e);
            }
        }
コード例 #24
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
 public void MoveCur(DPos dp, bool select)
 {
     VPos vp = new VPos();
     view_.ConvDPosToVPos(dp, ref vp);
     MoveTo(vp, select);
 }
コード例 #25
0
ファイル: Search.cs プロジェクト: mohammadul/addondev
 private bool FindNextFromImpl(DPos s, ref DPos beg, ref DPos end)
 {
     Searcher.SearchWord = this.SearchWord;
     // 1行ずつサーチ
     //Document d = view.GetDocument();
     //for( int mbg=0,med=0,e=d.tln(); s.tl<e; ++s.tl, s.ad=0 )
     for (int mbg = 0, med = 0, e = document.tln(); s.tl < e; ++s.tl, s.ad = 0)
         //if (Searcher.Search(d.tl(s.tl).ToString(), d.GetLength(s.tl), s.ad, ref mbg, ref med)) {
         if (Searcher.Search(document.GetText(s.tl), document.GetLength(s.tl), s.ad, ref mbg, ref med)) {
             beg.tl = end.tl = s.tl;
             beg.ad = mbg;
             end.ad = med;
             return true; // 発見
         }
     return false;
 }
コード例 #26
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
        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();
            }
        }
コード例 #27
0
ファイル: Cursor.cs プロジェクト: mohammadul/addondev
        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();
        }
コード例 #28
0
ファイル: Command.cs プロジェクト: mohammadul/addondev
 public Replace(DPos s, DPos e, string str)
 {
     stt_ = new DPos(s);
     end_ = new DPos(e);
     buf_ = str;
 }
コード例 #29
0
 public void Cancel()
 {
     pos = null;
 }
コード例 #30
0
ファイル: gcsTextEdit.cs プロジェクト: mohammadul/addondev
        public Tuple<DPos, DPos> GetSelction()
        {
            DPos s, e;
            if (cur_.Cur <= cur_.Sel) {
                s = new DPos(cur_.Cur.tl, cur_.Cur.ad);
                e = new DPos(cur_.Sel.tl, cur_.Sel.ad);

            }
            else {
                s = new DPos(cur_.Sel.tl, cur_.Sel.ad);
                e = new DPos(cur_.Cur.tl, cur_.Cur.ad);
            }
            return new Tuple<DPos, DPos>(s, e);
        }