/*! 選択範囲のテキストを頁名称にする @return HRESULT 終了状態コード */ HRESULT DocSelText2PageName( VOID ) { INT cbSize; LPVOID pString = NULL; LPTSTR ptText; UINT_PTR cchSize, d; if( !( IsSelecting( NULL ) ) ) return E_ABORT; // 選択してないなら何もしない cbSize = DocSelectTextGetAlloc( D_UNI, &pString, NULL ); // 選択範囲をいただく TRACE( TEXT("BYTE:%d"), cbSize ); ptText = (LPTSTR)pString; StringCchLength( ptText, STRSAFE_MAX_CCH, &cchSize ); for( d = 0; cchSize > d; d++ ) // 改行カット { if( 0x0D == ptText[d] ) { ptText[d] = NULL; break; } } PageListNameRewrite( ptText ); FREE( pString ); return S_OK; }
/** * CFootyDoc::InsertChar * @brief ワイド文字一つを挿入します * @param wChar 挿入する文字 * @return 描画範囲 */ CFootyDoc::RedrawType CFootyDoc::InsertChar(wchar_t wChar) { // 宣言 LinePt pLine; size_t nPos; CUndoBuffer cUndo; CEditPosition cEditPosition = m_cCaretPos; RedrawType nRetRedraw = REDRAW_LINE; if ( IsReadOnly() ) return REDRAW_FAILED; // 選択文字列を削除、アンドゥ情報を格納 if ( IsSelecting() ) { DeleteSelected(&cUndo); cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE; nRetRedraw = REDRAW_ALL; } else if (m_bInsertMode || m_cCaretPos.GetPosition() == m_cCaretPos.GetLinePointer()->GetLineLength()) { cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT; } else { // 上書きされるときは、アンドゥ情報を書き換える必要がある cUndo.m_cBeforeStart = cEditPosition; cEditPosition.MoveColumnForward(&m_lsLines,1); cUndo.m_cBeforeEnd = cEditPosition; cUndo.m_strBefore += m_cCaretPos.GetLinePointer()->GetLineData() [m_cCaretPos.GetPosition()]; cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE; } cUndo.m_strAfter += wChar; // 文字を入れる pLine = m_cCaretPos.GetLinePointer(); nPos = m_cCaretPos.GetPosition(); if (m_bInsertMode || nPos == pLine->GetLineLength()) pLine->m_strLineData.insert(nPos,1,wChar); else pLine->m_strLineData[nPos] = wChar; // 倫理行何行になるかチェック size_t nBeforeEthic = pLine->GetEthicLine(); if (SetLineInfo(pLine, false/*改行を含むか by Tetr@pod*/)) nRetRedraw = REDRAW_ALL; if (nBeforeEthic != pLine->GetEthicLine()) nRetRedraw = REDRAW_ALL; // 桁を増加させる cUndo.m_cAfterStart = m_cCaretPos; m_cCaretPos.MoveColumnForward(&m_lsLines,1); cUndo.m_cAfterEnd = m_cCaretPos; // アンドゥ情報を挿入 PushBackUndo(&cUndo); SendMoveCaretCallBack(); return nRetRedraw; }
void CFrameEditorModel::ContinueFrameSelection(int frame) { if (IsSelecting()) { CSongView *pSongView = view_->GetSongView(); selStart_.m_iChannel = 0; selEnd_ = {frame, (int)pSongView->GetChannelOrder().GetChannelCount()}; Select(CFrameSelection::Including(selStart_, selEnd_)); } }
/*! クリップボードの文字列を挿入する・いわゆる貼り付け @param[in,out] pNowDot 今のキャレットのドット位置 @param[in,out] pdLine 対象の行番号・絶対0インデックスか @param[in,out] pdMozi 今のキャレットの文字数 @param[in] bSqMode 非0強制矩形貼付・内容増やすならFlagに注意 @return 0壱行ですんだ 非0複数行に渡った */ INT DocInputFromClipboard( PINT pNowDot, PINT pdLine, PINT pdMozi, UINT bSqMode ) { LPTSTR ptString = NULL; UINT cchSize, dStyle = 0, i, j; INT dCrLf, dTop, dBtm; BOOLEAN bSelect; UINT dSqSel, iLines; // クリップボードからデータを頂く ptString = DocClipboardDataGet( &dStyle ); if( !(ptString) ) { NotifyBalloonExist( TEXT("テキストじゃないみたい。\t\n貼り付けられないよ。"), TEXT("お燐からのお知らせ"), NIIF_INFO ); return 0; } StringCchLength( ptString, STRSAFE_MAX_CCH, &cchSize ); // タブをヌく for( i = 0; cchSize > i; ) { if( CC_TAB == ptString[i] ) { for( j = i; cchSize > j; j++ ) { ptString[j] = ptString[j+1]; } cchSize--; continue; } i++; } bSelect = IsSelecting( &dSqSel ); // 選択状態であるか if( bSelect ) { DocSelRangeGet( &dTop, &dBtm ); dCrLf = DocSelectedDelete( pNowDot, pdLine, dSqSel, TRUE ); if( dCrLf ) // 処理した行以降全取っ替え { iLines = DocPageParamGet( NULL, NULL ); // 再計算も要るかも・・・ for( i = *pdLine; iLines >= i; i++ ){ ViewRedrawSetLine( i ); } } else{ ViewRedrawSetLine( *pdLine ); } } if( bSqMode ) dStyle |= D_SQUARE; // 矩形挿入として扱うか dCrLf = DocInsertString( pNowDot, pdLine, pdMozi, ptString, dStyle, TRUE ); FREE( ptString ); DocPageInfoRenew( -1, 1 ); return dCrLf; }
/** * CFootyDoc::OnDelete * @brief Deleteキーが押されたときの処理を行います。 * @return どのように再描画するのか */ CFootyDoc::RedrawType CFootyDoc::OnDelete() { // 宣言 CUndoBuffer cUndo; RedrawType nType; if ( IsReadOnly() ) return REDRAW_FAILED; // 選択しているかどうかで場合分け if (IsSelecting()){ nType = DeleteSelected(&cUndo); PushBackUndo(&cUndo); return nType; } else{ // 前に一つ移動してからBackSpaceという形にする CEditPosition cBackUp = m_cCaretPos; m_cCaretPos.MoveColumnForward(&m_lsLines,1); if (cBackUp != m_cCaretPos) // 違う return OnBackSpace(); else // 末尾 return REDRAW_NONE; } }
/** * CFootyDoc::OnBackSpace * @brief BackSpaceキーが押されたときの処理を行います。 * @return どのように再描画するのか * @note 適切な位置へキャレットが移動します。 */ CFootyDoc::RedrawType CFootyDoc::OnBackSpace() { // 宣言 LinePt pLine = m_cCaretPos.GetLinePointer(); size_t nPos = m_cCaretPos.GetPosition(); CUndoBuffer cUndo; RedrawType nType; if ( IsReadOnly() ) return REDRAW_FAILED; // 場合分け if (IsSelecting()) { nType = DeleteSelected(&cUndo); PushBackUndo(&cUndo); return nType; } else // 選択していないとき { if (nPos != 0) // 文字を削除 { bool bIsSurrogatePair = CFootyLine::IsSurrogateTail(pLine->GetLineData()[nPos-1]); RedrawType nNeedRedraw = REDRAW_LINE; // アンドゥ情報を代入する cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE; if (bIsSurrogatePair) cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-2,2); else cUndo.m_strBefore = pLine->m_strLineData.substr(nPos-1,1); cUndo.m_cBeforeEnd = m_cCaretPos; // 文字列を削除する if (bIsSurrogatePair) pLine->m_strLineData.erase(nPos-2,2); else pLine->m_strLineData.erase(nPos-1,1); size_t nBeforeEthic = pLine->GetEthicLine(); if (SetLineInfo(pLine, false/*改行を含むか by Tetr@pod*/)) nNeedRedraw = REDRAW_ALL; if (nBeforeEthic != pLine->GetEthicLine()) nNeedRedraw = REDRAW_ALL; // ポジションを移動して if (bIsSurrogatePair) m_cCaretPos.MoveColumnBackward(&m_lsLines,2); else m_cCaretPos.MoveColumnBackward(&m_lsLines,1); // アンドゥ情報を格納する cUndo.m_cBeforeStart = m_cCaretPos; PushBackUndo(&cUndo); SendMoveCaretCallBack(); return nNeedRedraw; } else // 改行を削除 { if (pLine != m_lsLines.begin()) { // 次の行ポインタ取得 LinePt pPrevLine = pLine; pPrevLine--; // アンドゥ情報を代入しつつキャレット位置を移動する cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_DELETE; cUndo.m_strBefore = L"\r\n"; cUndo.m_cBeforeEnd = m_cCaretPos; m_cCaretPos.MoveColumnBackward(&m_lsLines,1); cUndo.m_cBeforeStart = m_cCaretPos; PushBackUndo(&cUndo); // 行の結合 pPrevLine->m_strLineData += pLine->GetLineData(); // 現在の位置を削除する DeleteLine(pLine); // 情報を更新する LinePt pNextLine = pPrevLine; pNextLine++; SetLineInfo(pPrevLine,pNextLine, false); SendMoveCaretCallBack(); return REDRAW_ALL; } else return REDRAW_NONE; } } }
/** * @brief 現在のキャレット位置で改行処理を行います。 * @param bIndentMode [in] オートインデントを行うかどうか */ CFootyDoc::RedrawType CFootyDoc::InsertReturn( bool bIndentMode ) { // 宣言 CUndoBuffer cUndo; CFootyLine cNewLine; LinePt pLine, pInsertPos; size_t nPos; if ( IsReadOnly() ) return REDRAW_FAILED; // 選択位置を削除します if (IsSelecting()) { DeleteSelected(&cUndo); cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE; } else { cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT; } cUndo.m_cAfterStart = m_cCaretPos; // 改行を挿入する位置を取得します pLine = m_cCaretPos.GetLinePointer(); nPos = m_cCaretPos.GetPosition(); // オートインデントとして挿入できる文字数をカウントします size_t nIndentChars = 0; if ( bIndentMode ) { nIndentChars = pLine->CalcAutoIndentPos( nPos ); } // 挿入後、となるテキストを作成します cUndo.m_strAfter = L"\r\n"; if ( nIndentChars != 0 ) { cUndo.m_strAfter.append( pLine->GetLineData(), nIndentChars ); } // 行末で改行してないときは次の行に回します if (pLine->GetLineLength() != nPos) { if ( nIndentChars == 0 ) { cNewLine.m_strLineData = &pLine->GetLineData()[nPos]; } else { cNewLine.m_strLineData.append( pLine->GetLineData(), nIndentChars ); cNewLine.m_strLineData += &pLine->GetLineData()[nPos]; } pLine->m_strLineData.erase(nPos); } else if ( nIndentChars != 0 ) { cNewLine.m_strLineData.append( pLine->GetLineData(), nIndentChars ); } // 次の行をリストに追加 pInsertPos = pLine; pInsertPos++; pInsertPos = m_lsLines.insert( pInsertPos, cNewLine ); SetLineInfo( pLine, pInsertPos, false/*改行を含むか by Tetr@pod*/ ); // キャレット位置を移動させる m_cCaretPos.SetPosition( pInsertPos, nIndentChars ); // 再度更新 SetLineInfo( pLine, pInsertPos, false/*改行を含むか by Tetr@pod*/ ); // アンドゥー情報を格納 cUndo.m_cAfterEnd = m_cCaretPos; PushBackUndo(&cUndo); SendMoveCaretCallBack(); return REDRAW_ALL; }
/** * CFootyDoc::InsertString * @brief 現在のキャレット位置に文字を挿入します。 * @param pString 挿入する文字列(NULL終端) * @param bRecUndo trueのときアンドゥを記録する * @param bOverwritable INSERTキーによる上書きチェックを有効にする * @param bMemLineMode 改行コードをこの文章のコードとして保存する */ CFootyDoc::RedrawType CFootyDoc::InsertString (const wchar_t *pString,bool bRecUndo,bool bOverwritable,bool bMemLineMode) { FOOTY2_PRINTF( L"InsertString開始\n"); // 宣言 const wchar_t *pWork; //!< 改行位置検索用 std::wstring strRestLine; //!< 挿入位置以降のデータ LinePt pLine,pBeginLine; size_t nNumLines = 0; size_t nPos; CUndoBuffer cUndo; // エラーチェック if ( !pString )return REDRAW_FAILED; if ( IsReadOnly() ) return REDRAW_FAILED; // 上書きの場合は if (bOverwritable && !m_bInsertMode && !IsSelecting()) { // 長さを計測する size_t nStrLen = wcslen(pString); size_t nLineLeft = m_cCaretPos.GetLinePointer()->GetLineLength() - m_cCaretPos.GetPosition(); // 選択処理 SetSelectStart(); m_cCaretPos.MoveColumnForward(&m_lsLines,min(nLineLeft,nStrLen)); SetSelectEndNormal(); // そして、再帰 return InsertString(pString); } // 選択位置情報を削除してアンドゥ情報を代入 if (bRecUndo) { if (IsSelecting()) { DeleteSelected(&cUndo); cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_REPLACE; } else cUndo.m_nUndoType = CUndoBuffer::UNDOTYPE_INSERT; cUndo.m_cAfterStart = m_cCaretPos; cUndo.m_strAfter = pString; } else DeleteSelected(NULL); // キャレットの位置を取得する pLine = m_cCaretPos.GetLinePointer(); pBeginLine = pLine; nPos = m_cCaretPos.GetPosition(); // 文字を走査していく for (pWork=pString;;pWork++) { if (*pWork == L'\r') { if (*(pWork+1) == L'\n') // CRLF { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,2,nNumLines==0); nNumLines++; pWork++; if (bMemLineMode)m_nLineMode = LM_CRLF; FOOTY2_PRINTF( L"InsertString CRLF発見\n"); } else // キャリッジリターンのみ { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,1,nNumLines==0); nNumLines++; if (bMemLineMode)m_nLineMode = LM_CR; FOOTY2_PRINTF( L"InsertString CR発見\n"); } } else if (*pWork == L'\n') // ラインフィード { ReturnLine(&pLine,&pString,pWork, nPos,&strRestLine,1,nNumLines==0); nNumLines++; if (bMemLineMode)m_nLineMode = LM_LF; FOOTY2_PRINTF( L"InsertString LF発見\n"); } else if (*pWork == L'\0') // 終端文字 { FOOTY2_PRINTF( L"InsertString走査終了\n"); if (!nNumLines) // 今までに改行が無かったとき { FOOTY2_PRINTF( L"InsertString改行なし\n"); // その位置に全ての文字列を挿入する pLine->m_strLineData.insert(nPos,pString); FOOTY2_PRINTF( L"InsertString変更確定しそう\n"); SetLineInfo(pBeginLine, false/*改行を含むか by Tetr@pod*/); FOOTY2_PRINTF( L"InsertString変更確定\n"); // キャレット位置を移動させる m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString)); } else // 改行があったとき { FOOTY2_PRINTF( L"InsertString改行あり\n"); // バックアップ文字列を代入する pLine->m_strLineData = pString + strRestLine; // 変更を確定する FOOTY2_PRINTF( L"InsertString変更確定しそう\n"); SetLineInfo(pBeginLine,pLine, true/*改行を含むか by Tetr@pod*/); FOOTY2_PRINTF( L"InsertString変更確定\n"); // キャレット位置を移動させる m_cCaretPos.MoveRealNext(&m_lsLines,nNumLines); m_cCaretPos.MoveColumnForward(&m_lsLines,(size_t)(pWork-pString)); } FOOTY2_PRINTF( L"InsertStringアンドゥ情報追加\n"); // アンドゥ情報を挿入する if (bRecUndo) { cUndo.m_cAfterEnd = m_cCaretPos; PushBackUndo(&cUndo); } break; } } FOOTY2_PRINTF( L"InsertString終了間際\n"); SendMoveCaretCallBack(); FOOTY2_PRINTF( L"InsertString終了\n"); return REDRAW_ALL; }
CFrameSelection CFrameEditorModel::GetActiveSelection() const { return IsSelecting() ? m_selection : MakeFrameSelection(GetCurrentFrame()); }
bool CFrameEditorModel::IsChannelSelected(int channel) const { return IsSelecting() && m_selection.IncludesChannel(channel); }
bool CFrameEditorModel::IsFrameSelected(int frame) const { return IsSelecting() && m_selection.IncludesFrame(frame); }
void CFrameEditorModel::ContinueSelection(const CFrameCursorPos &pos) { if (IsSelecting()) { selEnd_ = pos; Select(CFrameSelection::Including(selStart_, selEnd_)); } }