Index: sakura_core/COpe.h =================================================================== --- sakura_core/COpe.h (リビジョン 50499) +++ sakura_core/COpe.h (リビジョン 50500) @@ -11,12 +11,13 @@ Please contact the copyright holder to use this code for other purpose. */ -class COpe; - #ifndef _COPE_H_ #define _COPE_H_ +class COpe; class CMemory;// 2002/2/10 aroka +class CViewSelect; +#include "basis/SakuraBasis.h" // CLogicRange // アンドゥバッファ用 操作コード @@ -25,6 +26,7 @@ OPE_INSERT = 1, OPE_DELETE = 2, OPE_MOVECARET = 3, + OPE_SELECT }; @@ -86,7 +88,19 @@ } }; +/** 選択範囲/矩形選択範囲 + Insert/Deleteの直前のものを保存し、アンドゥ・リドゥのときに復元できるようにする。 + 選択範囲の*変化*ではない。主役は挿入や削除という操作で、その前後の付加情報として存在する。 +*/ +class CSelectOpe +: public COpe +{ +public: + CSelectOpe(const CViewSelect& vs); + CLogicRange select; // fromと toの関係。fromは選択始点。toは fromより前にも後ろにもなりうる。 + bool boxSelecting; +}; Index: sakura_core/COpe.cpp =================================================================== --- sakura_core/COpe.cpp (リビジョン 50499) +++ sakura_core/COpe.cpp (リビジョン 50500) @@ -15,6 +15,8 @@ #include "COpe.h" #include "debug/Debug.h" #include "mem/CMemory.h"// 2002/2/10 aroka +#include "view/CViewSelect.h" +#include "view/CEditView.h" // 座標変換 // COpeクラス構築 @@ -50,3 +52,10 @@ +CSelectOpe::CSelectOpe(const CViewSelect& vs) +: COpe(OPE_SELECT), boxSelecting(vs.IsBoxSelecting()) +{ + CLayoutRange select = vs.m_sSelect.GetFrom() == vs.m_sSelectBgn.GetFrom() ? vs.m_sSelect : CLayoutRange(vs.m_sSelect.GetTo(), vs.m_sSelect.GetFrom()); + vs.GetEditView()->GetDocument()->m_cLayoutMgr.LayoutToLogic(select, &(this->select)); + this->m_ptCaretPos_PHY_After = this->m_ptCaretPos_PHY_Before = this->select.GetTo(); +} Index: sakura_core/view/CEditView_Command_New.cpp =================================================================== --- sakura_core/view/CEditView_Command_New.cpp (リビジョン 50499) +++ sakura_core/view/CEditView_Command_New.cpp (リビジョン 50500) @@ -443,6 +443,8 @@ GetCaret().GetCaretLogicPos() // 操作後のキャレット位置 ) ); + // CSelectOpeがあれば CMoveCaretOpeはいらないかもね。 + m_pcOpeBlk->AppendOpe(new CSelectOpe(this->GetSelectionInfo())); } /* 矩形範囲選択中か */ Index: sakura_core/CViewCommander_New.cpp =================================================================== --- sakura_core/CViewCommander_New.cpp (リビジョン 50499) +++ sakura_core/CViewCommander_New.cpp (リビジョン 50500) @@ -135,6 +135,17 @@ /* カーソルを移動 */ GetCaret().MoveCursor( ptCaretPos_After, false ); break; + case OPE_SELECT: /* OPE_INSERTや OPE_DELETE前後の選択範囲を復元する。 */ + CSelectOpe* pSelectOpe = dynamic_cast(pcOpe); + CLayoutRange select; + this->GetDocument()->m_cLayoutMgr.LogicToLayout(pSelectOpe->select, &select); + this->m_pCommanderView->GetSelectionInfo().DisableSelectArea(false); + this->m_pCommanderView->GetCaret().MoveCursor(select.GetFrom(), false); + this->m_pCommanderView->GetSelectionInfo().BeginSelectArea(); + this->m_pCommanderView->GetSelectionInfo().SetBoxSelect(pSelectOpe->boxSelecting); + this->m_pCommanderView->GetCaret().MoveCursor(select.GetTo(), false); + this->m_pCommanderView->GetSelectionInfo().ChangeSelectAreaByCurrentCursor(this->m_pCommanderView->GetCaret().GetCaretLayoutPos()); + break; } GetDocument()->m_cLayoutMgr.LogicToLayout( @@ -292,6 +303,17 @@ break; case OPE_MOVECARET: break; + case OPE_SELECT: /* OPE_INSERTや OPE_DELETE前後の選択範囲を復元する。 */ + CSelectOpe* pSelectOpe = dynamic_cast(pcOpe); + CLayoutRange select; + this->GetDocument()->m_cLayoutMgr.LogicToLayout(pSelectOpe->select, &select); + this->m_pCommanderView->GetSelectionInfo().DisableSelectArea(false); + this->m_pCommanderView->GetCaret().MoveCursor(select.GetFrom(), false); + this->m_pCommanderView->GetSelectionInfo().BeginSelectArea(); + this->m_pCommanderView->GetSelectionInfo().SetBoxSelect(pSelectOpe->boxSelecting); + this->m_pCommanderView->GetCaret().MoveCursor(select.GetTo(), false); + this->m_pCommanderView->GetSelectionInfo().ChangeSelectAreaByCurrentCursor(this->m_pCommanderView->GetCaret().GetCaretLayoutPos()); + break; } GetDocument()->m_cLayoutMgr.LogicToLayout( pcOpe->m_ptCaretPos_PHY_After,