Index: sakura_core/COpe.h =================================================================== --- sakura_core/COpe.h (リビジョン 50499) +++ sakura_core/COpe.h (リビジョン 50507) @@ -11,12 +11,12 @@ 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 +#include "basis/SakuraBasis.h" // CLogicRange // アンドゥバッファ用 操作コード @@ -25,6 +25,7 @@ OPE_INSERT = 1, OPE_DELETE = 2, OPE_MOVECARET = 3, + OPE_SELECT }; @@ -86,7 +87,24 @@ } }; +/** 選択範囲/矩形選択範囲とキャレット位置 + Insert/Deleteの直前のものを保存し、アンドゥ・リドゥのときに復元できるようにする。 + 選択範囲の*変化*ではない。主役は挿入や削除という操作で、その前後の付加情報として存在する。 + キャレットが選択範囲の端点にいないことが全選択で起こる。 +*/ +class CSelectOpe +: public COpe +{ +public: + CSelectOpe(const CLogicRange& selectRange, bool boxSelecting, const CLogicPoint& caretPos) + : COpe(OPE_SELECT), selectRange(selectRange), boxSelecting(boxSelecting) + { + this->m_ptCaretPos_PHY_After = this->m_ptCaretPos_PHY_Before = caretPos; + } + CLogicRange selectRange; // fromと toの関係。fromは選択始点。toは fromより前にも後ろにもなりうる。 + bool boxSelecting; +}; Index: sakura_core/view/CEditView_Command_New.cpp =================================================================== --- sakura_core/view/CEditView_Command_New.cpp (リビジョン 50499) +++ sakura_core/view/CEditView_Command_New.cpp (リビジョン 50507) @@ -436,13 +436,11 @@ if( GetSelectionInfo().IsTextSelected() ){ CWaitCursor cWaitCursor( this->GetHwnd() ); // 2002.02.05 hor if( !m_bDoing_UndoRedo ){ /* アンドゥ・リドゥの実行中か */ - /* 操作の追加 */ - m_pcOpeBlk->AppendOpe( - new CMoveCaretOpe( - GetCaret().GetCaretLogicPos(), // 操作前のキャレット位置 - GetCaret().GetCaretLogicPos() // 操作後のキャレット位置 - ) - ); + /* 操作の追加(選択範囲とキャレット位置の保存) */ + CLogicRange selectLogicRange; + CLayoutRange selectLayoutRange = this->GetSelectionInfo().m_sSelect.GetFrom() == this->GetSelectionInfo().m_sSelectBgn.GetFrom() ? this->GetSelectionInfo().m_sSelect : CLayoutRange(this->GetSelectionInfo().m_sSelect.GetTo(), this->GetSelectionInfo().m_sSelect.GetFrom()); + this->GetDocument()->m_cLayoutMgr.LayoutToLogic(selectLayoutRange, &selectLogicRange); + m_pcOpeBlk->AppendOpe(new CSelectOpe(selectLogicRange, this->GetSelectionInfo().IsBoxSelecting(), this->GetCaret().GetCaretLogicPos())); } /* 矩形範囲選択中か */ Index: sakura_core/CViewCommander_New.cpp =================================================================== --- sakura_core/CViewCommander_New.cpp (リビジョン 50499) +++ sakura_core/CViewCommander_New.cpp (リビジョン 50507) @@ -135,6 +135,20 @@ /* カーソルを移動 */ GetCaret().MoveCursor( ptCaretPos_After, false ); break; + case OPE_SELECT: /* OPE_INSERTや OPE_DELETE前後の選択範囲とキャレット位置を復元する。 */ + CSelectOpe* pSelectOpe = dynamic_cast(pcOpe); + + CLayoutRange selectRange; + this->GetDocument()->m_cLayoutMgr.LogicToLayout(pSelectOpe->selectRange, &selectRange); + + this->m_pCommanderView->GetSelectionInfo().DisableSelectArea(false); + this->m_pCommanderView->GetCaret().MoveCursor(selectRange.GetFrom(), false); + this->m_pCommanderView->GetSelectionInfo().BeginSelectArea(); + this->m_pCommanderView->GetSelectionInfo().SetBoxSelect(pSelectOpe->boxSelecting); + this->m_pCommanderView->GetCaret().MoveCursor(selectRange.GetTo(), false); + this->m_pCommanderView->GetSelectionInfo().ChangeSelectAreaByCurrentCursor(this->m_pCommanderView->GetCaret().GetCaretLayoutPos()); + // キャレット位置の復元は COpe共通のタスクらしいのでここではやらない。 + break; } GetDocument()->m_cLayoutMgr.LogicToLayout( @@ -292,6 +306,20 @@ break; case OPE_MOVECARET: break; + case OPE_SELECT: /* OPE_INSERTや OPE_DELETE前後の選択範囲とキャレット位置を復元する。 */ + CSelectOpe* pSelectOpe = dynamic_cast(pcOpe); + + CLayoutRange selectRange; + this->GetDocument()->m_cLayoutMgr.LogicToLayout(pSelectOpe->selectRange, &selectRange); + + this->m_pCommanderView->GetSelectionInfo().DisableSelectArea(false); + this->m_pCommanderView->GetCaret().MoveCursor(selectRange.GetFrom(), false); + this->m_pCommanderView->GetSelectionInfo().BeginSelectArea(); + this->m_pCommanderView->GetSelectionInfo().SetBoxSelect(pSelectOpe->boxSelecting); + this->m_pCommanderView->GetCaret().MoveCursor(selectRange.GetTo(), false); + this->m_pCommanderView->GetSelectionInfo().ChangeSelectAreaByCurrentCursor(this->m_pCommanderView->GetCaret().GetCaretLayoutPos()); + // キャレット位置の復元は COpe共通のタスクらしいのでここではやらない。 + break; } GetDocument()->m_cLayoutMgr.LogicToLayout( pcOpe->m_ptCaretPos_PHY_After,