Ejemplo n.º 1
0
void CDocLine::SetEol(const CEol& cEol, COpeBlk* pcOpeBlk)
{
	//改行コードを削除
	for(int i=0;i<(Int)m_cEol.GetLen();i++){
		m_cLine.Chop();
	}

	//改行コードを挿入
	m_cEol = cEol;
	m_cLine += cEol.GetValue2();
}
Ejemplo n.º 2
0
CLogicInt CViewCommander::ConvertEol(const wchar_t* pszText, CLogicInt nTextLen, wchar_t* pszConvertedText)
{
	// original by 2009.02.28 salarm
	CLogicInt nConvertedTextLen;
	CEol eol = GetDocument()->m_cDocEditor.GetNewLineCode();

	nConvertedTextLen = 0;
	bool bExtEol = GetDllShareData().m_Common.m_sEdit.m_bEnableExtEol;
	if( pszConvertedText == NULL ){
		for( int i = 0; i < nTextLen; i++ ){
			if( WCODE::IsLineDelimiter(pszText[i], bExtEol) ){
				if( pszText[i] == WCODE::CR ){
					if( i + 1 < nTextLen && pszText[i + 1] == WCODE::LF ){
						i++;
					}
				}
				nConvertedTextLen += eol.GetLen();
			} else {
				nConvertedTextLen++;
			}
		}
	}else{
		for( int i = 0; i < nTextLen; i++ ){
			if( WCODE::IsLineDelimiter(pszText[i], bExtEol) ){
				if( pszText[i] == WCODE::CR ){
					if( i + 1 < nTextLen && pszText[i + 1] == WCODE::LF ){
						i++;
					}
				}
				wmemcpy( &pszConvertedText[nConvertedTextLen], eol.GetValue2(), eol.GetLen() );
				nConvertedTextLen += eol.GetLen();
			} else {
				pszConvertedText[nConvertedTextLen++] = pszText[i];
			}
		}
	}
	return nConvertedTextLen;
}
Ejemplo n.º 3
0
/* Uudecode (デコード)*/
bool CDecode_UuDecode::DoDecode( const CNativeW& pcSrc, CMemory* pcDst )
{
	const WCHAR *psrc, *pline;
	int nsrclen;
	char *pw, *pw_base;
	int nlinelen, ncuridx;
	CEol ceol;
	bool bsuccess = false;

	pcDst->Clear();
	psrc = pcSrc.GetStringPtr();
	nsrclen = pcSrc.GetStringLength();

	if( nsrclen < 1 ){
		pcDst->_AppendSz("");
		return false;
	}
	pcDst->AllocBuffer( (nsrclen / 4) * 3 + 10 );
	pw_base = pw = static_cast<char *>( pcDst->GetRawPtr() );

	// 先頭の改行・空白文字をスキップ
	for( ncuridx = 0; ncuridx < nsrclen; ++ncuridx ){
		WCHAR c = psrc[ncuridx];
		if( !WCODE::IsLineDelimiterBasic(c) && c != L' ' && c != L'\t' ){
			break;
		}
	}

	// ヘッダーを解析
	pline = GetNextLineW( psrc, nsrclen, &nlinelen, &ncuridx, &ceol, false );
	if( !CheckUUHeader(pline, nlinelen, m_aFilename) ){
		pcDst->_AppendSz("");
		return false;
	}

	// ボディーを処理
	while( (pline = GetNextLineW(psrc, nsrclen, &nlinelen, &ncuridx, &ceol, false)) != NULL ){
		if( ceol.GetType() != EOL_CRLF ){
			pcDst->_AppendSz("");
			return false;
		}
		if( nlinelen < 1 ){
			pcDst->_AppendSz("");
			return false;
		}
		if( nlinelen == 1 ){
			// データの最後である場合
			if( pline[0] == L' ' || pline[0] == L'`' || pline[0] == L'~' ){
				bsuccess = true;
				break;
			}
		}
		pw += _DecodeUU_line( pline, nlinelen, pw );
	}
	if( bsuccess == false ){
		return false;
	}

	pline += 3;  // '`' 'CR' 'LF' の分をスキップ

	// フッターを解析
	if( !CheckUUFooter(pline, nsrclen-ncuridx) ){
		pcDst->_AppendSz("");
		return false;
	}

	pcDst->_SetRawLength( pw - pw_base );
	return true;
}
Ejemplo n.º 4
0
//2007.10.17 kobake 重複するコードを整理
void CCaret::ShowCaretPosInfo()
{
	//必要なインターフェース
	const CLayoutMgr* pLayoutMgr=&m_pEditDoc->m_cLayoutMgr;
	const STypeConfig* pTypes=&m_pEditDoc->m_cDocType.GetDocumentAttribute();


	if( !m_pEditView->GetDrawSwitch() ){
		return;
	}

	// ステータスバーハンドルを取得
	HWND hwndStatusBar = m_pEditDoc->m_pcEditWnd->m_cStatusBar.GetStatusHwnd();


	// カーソル位置の文字列を取得
	const CLayout*	pcLayout;
	CLogicInt		nLineLen;
	const wchar_t*	pLine = pLayoutMgr->GetLineStr( GetCaretLayoutPos().GetY2(), &nLineLen, &pcLayout );


	// -- -- -- -- 文字コード情報 -> pszCodeName -- -- -- -- //
	const TCHAR* pszCodeName;
	CNativeT cmemCodeName;
	if (hwndStatusBar) {
		TCHAR szCodeName[100];
		CCodePage::GetNameNormal(szCodeName, m_pEditDoc->GetDocumentEncoding());
		cmemCodeName.AppendString(szCodeName);
		if (m_pEditDoc->GetDocumentBomExist()) {
			cmemCodeName.AppendString( LS(STR_CARET_WITHBOM) );
		}
	}
	else {
		TCHAR szCodeName[100];
		CCodePage::GetNameShort(szCodeName, m_pEditDoc->GetDocumentEncoding());
		cmemCodeName.AppendString(szCodeName);
		if (m_pEditDoc->GetDocumentBomExist()) {
			cmemCodeName.AppendString( _T("#") );		// BOM付(メニューバーなので小さく)	// 2013/4/17 Uchi
		}
	}
	pszCodeName = cmemCodeName.GetStringPtr();


	// -- -- -- -- 改行モード -> szEolMode -- -- -- -- //
	//	May 12, 2000 genta
	//	改行コードの表示を追加
	CEol cNlType = m_pEditDoc->m_cDocEditor.GetNewLineCode();
	const TCHAR* szEolMode = cNlType.GetName();


	// -- -- -- -- キャレット位置 -> ptCaret -- -- -- -- //
	//
	bool bCaretHabaMode = GetDllShareData().m_Common.m_sStatusbar.m_bDispColByChar == 0;
	CMyPoint ptCaret;
	//行番号をロジック単位で表示
	if(pTypes->m_bLineNumIsCRLF){
		if( bCaretHabaMode ){
			ptCaret.y = GetCaretLogicPos().GetPOINT().y;
			if( pcLayout ){
				// 新レイアウト桁数を計算(1行のデータが長いと重い)
				int nPosX = 0;
				const CLayout* pcLayoutCalc = pcLayout;
				while( pcLayoutCalc->GetPrevLayout() ){
					if( pcLayoutCalc->GetLogicOffset() == 0 ){
						break; // 先頭行
					}
					pcLayoutCalc = pcLayoutCalc->GetPrevLayout();
					nPosX += Int((m_pEditView->LineIndexToColumn(pcLayoutCalc, pcLayoutCalc->GetLengthWithoutEOL()) - pcLayoutCalc->GetIndent()) / (Int)m_pEditView->GetTextMetrics().GetLayoutXDefault());
				}
				ptCaret.x = nPosX + (Int)(GetCaretLayoutPos().GetX() - pcLayout->GetIndent()) / (Int)m_pEditView->GetTextMetrics().GetLayoutXDefault();
			}else{
				ptCaret.x = 0;
			}
		}else{
			ptCaret = GetCaretLogicPos().GetPOINT();
		}
	}
	//行番号をレイアウト単位で表示
	else {
		if( bCaretHabaMode ){
			// ルーラー基準
			ptCaret.x = (Int)GetCaretLayoutPos().GetX() / (Int)m_pEditView->GetTextMetrics().GetLayoutXDefault();
		}else{
			// 文字単位
			if( pcLayout ){
				ptCaret.x = (Int)GetCaretLogicPos().GetX() - pcLayout->GetLogicOffset();
			}else{
				ptCaret.x = (Int)GetCaretLogicPos().GetX();
			}
		}
		ptCaret.y = (Int)GetCaretLayoutPos().GetY();
	}
	//表示値が1から始まるように補正
	ptCaret.x++;
	ptCaret.y++;


	// -- -- -- -- キャレット位置の文字情報 -> szCaretChar -- -- -- -- //
	//
	TCHAR szCaretChar[32]=_T("");
	if( pLine ){
		// 指定された桁に対応する行のデータ内の位置を調べる
		CLogicInt nIdx = GetCaretLogicPos().GetX2() - pcLayout->GetLogicOffset();
		if( nIdx < nLineLen ){
			if( nIdx < nLineLen - (pcLayout->GetLayoutEol().GetLen()?1:0) ){
				//auto_sprintf( szCaretChar, _T("%04x"), );
				//任意の文字コードからUnicodeへ変換する		2008/6/9 Uchi
				CCodeBase* pCode = CCodeFactory::CreateCodeBase(m_pEditDoc->GetDocumentEncoding(), false);
				CommonSetting_Statusbar* psStatusbar = &GetDllShareData().m_Common.m_sStatusbar;
				EConvertResult ret = pCode->UnicodeToHex(&pLine[nIdx], nLineLen - nIdx, szCaretChar, psStatusbar);
				delete pCode;
				if (ret != RESULT_COMPLETE) {
					// うまくコードが取れなかった(Unicodeで表示)
					pCode = CCodeFactory::CreateCodeBase(CODE_UNICODE, false);
					/* EConvertResult ret = */ pCode->UnicodeToHex(&pLine[nIdx], nLineLen - nIdx, szCaretChar, psStatusbar);
					delete pCode;
				}
			}
			else{
				_tcscpy_s(szCaretChar, _countof(szCaretChar), pcLayout->GetLayoutEol().GetName());
			}
		}
	}


	// -- -- -- --  ステータス情報を書き出す -- -- -- -- //
	//
	// ウィンドウ右上に書き出す
	if( !hwndStatusBar ){
		TCHAR	szText[64];
		TCHAR	szFormat[64];
		TCHAR	szLeft[64];
		TCHAR	szRight[64];
		int		nLen;
		{	// メッセージの左側文字列(「行:列」を除いた表示)
			nLen = _tcslen(pszCodeName) + _tcslen(szEolMode) + _tcslen(szCaretChar);
			// これは %s(%s)%6s%s%s 等になる。%6ts表記は使えないので注意
			auto_sprintf(
				szFormat,
				_T("%%s(%%s)%%%ds%%s%%s"),	// 「キャレット位置の文字情報」を右詰で配置(足りないときは左詰になって右に伸びる)
				(nLen < 15)? 15 - nLen: 1
			);
			auto_sprintf(
				szLeft,
				szFormat,
				pszCodeName,
				szEolMode,
				szCaretChar[0]? _T("["): _T(" "),	// 文字情報無しなら括弧も省略(EOFやフリーカーソル位置)
				szCaretChar,
				szCaretChar[0]? _T("]"): _T(" ")	// 文字情報無しなら括弧も省略(EOFやフリーカーソル位置)
			);
		}
		szRight[0] = _T('\0');
		nLen = MENUBAR_MESSAGE_MAX_LEN - _tcslen(szLeft);	// 右側に残っている文字長
		if( nLen > 0 ){	// メッセージの右側文字列(「行:列」表示)
			TCHAR szRowCol[32];
			auto_sprintf(
				szRowCol,
				_T("%d:%-4d"),	// 「列」は最小幅を指定して左寄せ(足りないときは右に伸びる)
				ptCaret.y,
				ptCaret.x
			);
			auto_sprintf(
				szFormat,
				_T("%%%ds"),	// 「行:列」を右詰で配置(足りないときは左詰になって右に伸びる)
				nLen
			);
			auto_sprintf(
				szRight,
				szFormat,
				szRowCol
			);
		}
		auto_sprintf(
			szText,
			_T("%s%s"),
			szLeft,
			szRight
		);
		m_pEditDoc->m_pcEditWnd->PrintMenubarMessage( szText );
	}
	// ステータスバーに状態を書き出す
	else{
		TCHAR	szText_1[64];
		auto_sprintf( szText_1, LS( STR_STATUS_ROW_COL ), ptCaret.y, ptCaret.x );	//Oct. 30, 2000 JEPRO 千万行も要らん

		TCHAR	szText_6[16];
		if( m_pEditView->IsInsMode() /* Oct. 2, 2005 genta */ ){
			_tcscpy( szText_6, LS( STR_INS_MODE_INS ) );	// "挿入"
		}else{
			_tcscpy( szText_6, LS( STR_INS_MODE_OVR ) );	// "上書"
		}

		auto& statusBar = m_pEditDoc->m_pcEditWnd->m_cStatusBar;

		if( m_bClearStatus ){
			statusBar.SetStatusText( 0, SBT_NOBORDERS, _T("") );
		}
		statusBar.SetStatusText( 1, 0,             szText_1 );
		//	May 12, 2000 genta
		//	改行コードの表示を追加.後ろの番号を1つずつずらす
		//	From Here
		statusBar.SetStatusText( 2, 0,             szEolMode );
		//	To Here
		statusBar.SetStatusText( 3, 0,             szCaretChar );
		statusBar.SetStatusText( 4, 0,             pszCodeName );
		statusBar.SetStatusText( 5, SBT_OWNERDRAW, _T("") );
		statusBar.SetStatusText( 6, 0,             szText_6 );
	}

}