/*-----------------------------------------------------------------------------
[名称]	GeneralSetting.cpp
[概要]	設定情報クラスの実装
[備考]	なし
[履歴]	2002-12-26	NC		コメント付加(moralog)
		2003-12-22	b031228 (moralog) 等幅フォントの時はルーラを文字数に
		2003-12-26  b031228 (3330)PageUp,Downの挙動(dincom)
		2003-12-28  b040111 (3632)キャレット位置の強調(moralog)
		2004-02-24	b031228 (3367)Grep検索(dincom)
		2004-05-10	b031228 (3204)へぼぺとの連携(moralog)
-----------------------------------------------------------------------------*/

//-----------------------------------------------------------------------------
// インクルード
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "Shitarabian.h"
#include "GeneralSetting.h"
#include "Common.h"
#include "ExeCommon.h"
#include "EditDrawer.h"
#include "MainFrm.h"
#include "SettingPath.h"
#include "BackUp.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


//-----------------------------------------------------------------------------
// ファイル内関数
//-----------------------------------------------------------------------------



//-----------------------------------------------------------------------------
// クラス関数
//-----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
[名称]	コンストラクタ
[機能]	インスタンスの生成。
[戻値]	なし
[備考]	なし
-----------------------------------------------------------------------------*/
CGeneralSetting::CGeneralSetting()
:	m_bTabConvert( FALSE )
,	m_nTab( 4 )
,	m_strTabString( _T("　　") )
,	m_bVisibleRuler( TRUE )
,	m_uiRulerHeight( 10 )
,	m_fontRuler()
// ▼ (3181) BGN 2003.12.22 (moralog) 等幅フォントの時はルーラを文字数に
,	m_bRulerUnitPixel(TRUE )
// ▲ (3181) END
// ▼ (3632) BGN 2003.12.28 (moralog) キャレット位置の表示
,	m_bCaretMark( FALSE )
,	m_bCaretLine( FALSE )
// ▲ (3632) END
,	m_uiRowGap( 2 )
,	m_iLeftNumberMargin( 60 )
,	m_iLeftBlankMargin( 8 )
,	m_eHScrollUnit( Scroll1Char )
,	m_eVScrollUnit( Scroll1Row )
,	m_bVisibleNumber( TRUE )
,	m_bBlockAlignment( FALSE )
,	m_uiWheelMove( 3 )
,	m_strQuote( ">" )
,	m_bFreeCursor( FALSE )
// ▼ (3330) BGN 2003.12.26 (dincom) 
,	m_bRestrainedScroll( TRUE )
// ▲ (330) END
{
	// ルーラフォントの設定
	m_fontRuler.m_iPointSize = 8;

	// 空白文字の設定
	{
		CArray<TWhiteSpace, TWhiteSpace&>*	pCharz;
		pCharz = GetWhitespace()->GetCharz();

		TWhiteSpace	tWhitespace;

		// 全角空白
		tWhitespace.bEnable = TRUE;
		tWhitespace.strChar = g_cstrBigBlank;
		tWhitespace.bCanContinuation = TRUE;	// 連続許可
		tWhitespace.bCanHead = TRUE;			// 先頭許可
		tWhitespace.nCount = 0;					// 利用最大個数
		pCharz->Add( tWhitespace );

		// 半角空白
		tWhitespace.bEnable = TRUE;
		tWhitespace.strChar = g_cstrSmallBlank;
		tWhitespace.bCanContinuation = FALSE;	// 連続許可
		tWhitespace.bCanHead = FALSE;			// 先頭許可
		tWhitespace.nCount = 0;					// 利用最大個数
		pCharz->Add( tWhitespace );

		// &nbsp;
// ▼ (3421) BGN 2004.05.10 (moralog)
// ▽ original BGN
//		tWhitespace.bEnable = FALSE;
		tWhitespace.bEnable = TRUE;
// △ original END
// ▲ (3421) END
		tWhitespace.strChar = "&nbsp;";
		tWhitespace.bCanContinuation = TRUE;	// 連続許可
		tWhitespace.bCanHead = TRUE;			// 先頭許可
		tWhitespace.nCount = 0;					// 利用最大個数
		pCharz->Add( tWhitespace );

		// .
		tWhitespace.bEnable = FALSE;
		tWhitespace.strChar = _T(".");
		tWhitespace.bCanContinuation = TRUE;	// 連続許可
		tWhitespace.bCanHead = TRUE;			// 先頭許可
		tWhitespace.nCount = 1;					// 利用最大個数
		pCharz->Add( tWhitespace );
	}

	// 左右反転
	m_Mirrorz.SetFilename("mirror.ini");
	{
		typedef struct {
			char*	pLeft;
			char*	pRight;
		} tmpFlip;
		const tmpFlip aFlip[] ={
			{ "↑", "↓" },
			{ "￣", "＿" },
			{ "^","_" },
			{ "'","," },
			{ "⌒","、_," },
			{ "∧","V" },
			{ "∩","∪" },
			{ "人","Y^" },
			{ "／","＼" },
			{ "/","ヽ" },
			{ "彡","ミ" },
			{ ",","´" },
			{ "｀","､" },
		};

		for( int idxFlip=0 ; idxFlip<sizeof(aFlip)/sizeof(tmpFlip) ; idxFlip++ )
		{
			TFlip	tFlip;
			tFlip.strLeft = aFlip[idxFlip].pLeft;
			tFlip.strRight = aFlip[idxFlip].pRight;

			m_Flipz.GetFliperz()->Add( tFlip );
		}
	}

	// 上下反転
	m_Flipz.SetFilename("flip.ini");
	{
		typedef struct {
			char*	pLeft;
			char*	pRight;
		} tmpMirror;
		const tmpMirror aMirror[] ={
			{ "(", ")" },
			{ "<", ">" },
			{ "[","]" },
			{ "＜","＞" },
			{ "（","）" },
			{ "｛","｝" },
			{ "{","}" },
			{ "⊂","つ" },
			{ "／","＼" },
			{ "/","ヽ" },
			{ "彡","ミ" },
			{ "《","》" },
			{ "〈","〉" },
			{ "←","→" },
			{ "｀","´" },
		};

		for( int idxMirror=0 ; idxMirror<sizeof(aMirror)/sizeof(tmpMirror) ; idxMirror++ )
		{
			TFlip	tMirror;
			tMirror.strLeft = aMirror[idxMirror].pLeft;
			tMirror.strRight = aMirror[idxMirror].pRight;

			m_Mirrorz.GetFliperz()->Add( tMirror );
		}
	}
}


/*-----------------------------------------------------------------------------
[名称]	デストラクタ
[機能]	インスタンスの生成。
[戻値]	なし
[備考]	なし
-----------------------------------------------------------------------------*/
CGeneralSetting::~CGeneralSetting()
{
}


/*-----------------------------------------------------------------------------
[名称]	唯一インスタンスの取得
[機能]	singletonパターンによる唯一インスタンスの確保と取得。
[戻値]	CGeneralSetting*
			CGeneralSetting オブジェクトの唯一インスタンス [-] (-)
[備考]	singletonパターン。
-----------------------------------------------------------------------------*/
CGeneralSetting*	CGeneralSetting::GetInstance()
{
	static CGeneralSetting	Instance;
	static BOOL	bInitialize = FALSE;
	if ( !bInitialize )
	{
		bInitialize = TRUE;

		// 初期化ファイルからの読み込み
		Instance.Read();
	}
	return( &Instance );
}

/*-----------------------------------------------------------------------------
[名称]	左端余白幅の取得
[機能]	行番号表示を含む左端余白幅を取得する。
[戻値]	int
			左端余白幅 [Pixel] (-)
[備考]	行番号の有無により幅が異なる。
-----------------------------------------------------------------------------*/
int		CGeneralSetting::GetLeftMargin()
{
	if ( GetVisibleNumber() )
	{
		return( m_iLeftNumberMargin + m_iLeftBlankMargin );
	}
	else
	{
		return( m_iLeftBlankMargin );
	}
}

/*-----------------------------------------------------------------------------
[名称]	上端余白高さの取得
[機能]	ルーラ表示を含む上端余白高さを取得する。
[戻値]	int
			上端余白高さ [Pixel] (-)
[備考]	ルーラの有無により高さが異なる。
-----------------------------------------------------------------------------*/
int		CGeneralSetting::GetTopMargin()
{
	if ( GetVisibleRuler() )
	{
		return( m_uiRulerHeight );
	}
	else
	{
		return( 0 );
	}
}

/*-----------------------------------------------------------------------------
[名称]	ファイル書き込み
[機能]	ファイルへの書き込み処理を行う。
[戻値]	BOOL
			処理結果 [-] (TRUE:成功、FALSE:失敗)
[備考]	ファイル名称は決めうち。フォルダは ::IniFilePath() によって取得できるフォルダ。
-----------------------------------------------------------------------------*/
BOOL	CGeneralSetting::Write()
{
	BOOL	bSuccess = TRUE;

// 設定種類ごとに保存するものは指定フォルダに書き出す
	{
		CString		strGeneralFilename = CSettingPath::GetInstance()->GetFolderPath() + "typegeneral.ini";

		// バージョンの書きだし
		CString		strVersion;
		strVersion.LoadString( IDS_RELEASE_VERSION );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "Version",				strVersion );

		// 属性の書き出し
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "strSettingName",		QuoteString( m_strSettingName ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "strExt",				QuoteString( m_strExt ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bTabConvert",			BoolToString( m_bTabConvert ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "strTabString",		QuoteString( m_strTabString ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "nTab",				LongToString( m_nTab ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "uiRowGap",			LongToString( m_uiRowGap ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "iLeftNumberMargin",	LongToString( m_iLeftNumberMargin ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "iLeftBlankMargin",	LongToString( m_iLeftBlankMargin ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bVisibleNumber",		BoolToString( m_bVisibleNumber ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "uiRulerHeight",		LongToString( m_uiRulerHeight ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bVisibleRuler",		BoolToString( m_bVisibleRuler ) );
// ▼ (3181) BGN 2003.12.22 (moralog) 等幅フォントの時はルーラを文字数に
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bRulerUnitPixel",		BoolToString( m_bRulerUnitPixel ) );
// ▲ (3181) END
// ▼ (3632) BGN 2003.12.28 (moralog) キャレット位置の表示
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bCaretMark",		BoolToString( m_bCaretMark ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bCaretLine",		BoolToString( m_bCaretLine ) );
// ▲ (3632) END
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bFreeCursor",			BoolToString( m_bFreeCursor ) );

		bSuccess &= m_LogFont.Write( strGeneralFilename, "Font" );
		bSuccess &= m_fontRuler.Write( strGeneralFilename, "RulerFont" );
		bSuccess &= m_Whitespace.Write();
		bSuccess &= m_EmphasisDefine.Write();
		bSuccess &= m_PrintDefine.Write( strGeneralFilename );
		bSuccess &= m_BoxCharDefine.Write();
	}

// 共通設定はしたらびあんフォルダに書き出す
	{
// ▼ (3204) BGN 2004.05.10 moralog GetShitarabianFolderPath()は末尾に\\をつけない
		CString		strGeneralFilename = CSettingPath::GetInstance()->GetShitarabianFolderPath() + "\\commongeneral.ini";
// ▽ original BGN
//		CString		strGeneralFilename = CSettingPath::GetInstance()->GetShitarabianFolderPath() + "commongeneral.ini";
// △ original END
// ▲ (3204) END

		// バージョンの書きだし
		CString		strVersion;
		strVersion.LoadString( IDS_RELEASE_VERSION );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "Version",				strVersion );

		// 属性の書き出し
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bOneShotBOXSelect",	BoolToString( m_bOneShotBOXSelect ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "eHScrollUnit",		EScrollUnitToString( m_eHScrollUnit ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "eVScrollUnit",		EScrollUnitToString( m_eVScrollUnit ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bBlockAlignment",		BoolToString( m_bBlockAlignment ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "uiWheelMove",			LongToString( m_uiWheelMove ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "strQuote",			QuoteString( m_strQuote ) );
		bSuccess &= m_Flipz.Write();
		bSuccess &= m_Mirrorz.Write();
		// ▼ (3330) BGN 2003.12.26 (dincom) 
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bRestrainedScroll",	BoolToString( m_bRestrainedScroll ) );
		// ▲ (3330) END

		// 検索文字列群
		int		idxLoop;
		for( idxLoop=0 ; idxLoop<m_aSubStringz.GetSize() ; idxLoop++ )
		{
			CString		strKey;
			strKey.Format( "strSubString%d", idxLoop );
			bSuccess &= WriteGeneralProfile(
				strGeneralFilename,
				strKey,
				m_aSubStringz[idxLoop]
			);
		}

		// 置換文字列群
		for( idxLoop=0 ; idxLoop<m_aReplaceStringz.GetSize() ; idxLoop++ )
		{
			CString		strKey;
			strKey.Format( "strReplaceString%d", idxLoop );
			bSuccess &= WriteGeneralProfile(
				strGeneralFilename,
				strKey,
				m_aReplaceStringz[idxLoop]
			);
		}

		// 検索・置換条件
		::GetMainFrame()->m_dlgFinder.UpdateData( TRUE );
		::GetMainFrame()->m_dlgReplacer.UpdateData( TRUE );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bFindCareCase",	BoolToString( ::GetMainFrame()->m_dlgFinder.m_bCaseCare ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bFindLoop",	BoolToString( ::GetMainFrame()->m_dlgFinder.m_bLoop ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bFindToken",	BoolToString( ::GetMainFrame()->m_dlgFinder.m_bToken ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bFindRegExp",	BoolToString( ::GetMainFrame()->m_dlgFinder.m_bRegExp ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bReplaceCareCase",	BoolToString( ::GetMainFrame()->m_dlgReplacer.m_bCaseCare ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bReplaceLoop",	BoolToString( ::GetMainFrame()->m_dlgReplacer.m_bLoop ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bReplaceToken",	BoolToString( ::GetMainFrame()->m_dlgReplacer.m_bToken ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bReplaceRegExp",	BoolToString( ::GetMainFrame()->m_dlgReplacer.m_bRegExp ) );

		// ▼ (3367) BGN 2004.02.23 (dincom)
		//Grep条件
		::GetMainFrame()->m_dlgGrep.UpdateData( TRUE );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bGrepCareCase",	BoolToString( ::GetMainFrame()->m_dlgGrep.m_bCaseCare ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bGrepToken",	BoolToString( ::GetMainFrame()->m_dlgGrep.m_bToken ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bGrepRegExp",	BoolToString( ::GetMainFrame()->m_dlgGrep.m_bRegexp ) );
		bSuccess &= WriteGeneralProfile( strGeneralFilename, "bSubFolder",	BoolToString( ::GetMainFrame()->m_dlgGrep.m_bSubFolder ) );
		// ▲ (3367) END

		bSuccess &= CBackUp::GetInstance()->Write( strGeneralFilename );
	}

	return( bSuccess );
}

/*-----------------------------------------------------------------------------
[名称]	ファイル読み込み
[機能]	ファイルからの読み込み処理を行う。
[戻値]	BOOL
			処理結果 [-] (TRUE:成功、FALSE:失敗)
[備考]	ファイル名称は決めうち。フォルダは ::IniFilePath() によって取得できるフォルダ。
-----------------------------------------------------------------------------*/
BOOL	CGeneralSetting::Read()
{
	BOOL		bSuccess;

// 設定種類ごとに保存するものは指定フォルダから読む
	{
		CString		strGeneralFilename = CSettingPath::GetInstance()->GetFolderPath() + "typegeneral.ini";

		// バージョンの読み込み
		CString		strVersion;
		bSuccess = ReadGeneralProfile( strGeneralFilename, "Version", &strVersion );
		if ( bSuccess )
		{
			// 属性の読み込み
			CString		strValue;

			bSuccess = ReadGeneralProfile( strGeneralFilename, "strSettingName", &strValue );
			if ( bSuccess ){ m_strSettingName	= DeQuoteString( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "strExt", &strValue );
			if ( bSuccess ){ m_strExt	= DeQuoteString( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bTabConvert", &strValue );
			if ( bSuccess ){ m_bTabConvert	= StringToBool( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "strTabString", &strValue );
			if ( bSuccess ){ m_strTabString	= DeQuoteString( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "nTab", &strValue );
			if ( bSuccess ){ m_nTab	= StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "uiRowGap", &strValue );
			if ( bSuccess ){ m_uiRowGap	= StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "iLeftNumberMargin", &strValue );
			if ( bSuccess ){ m_iLeftNumberMargin	= StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "iLeftBlankMargin", &strValue );
			if ( bSuccess ){ m_iLeftBlankMargin	= StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bVisibleNumber", &strValue );
			if ( bSuccess ){ m_bVisibleNumber	= StringToBool( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "uiRulerHeight", &strValue );
			if ( bSuccess ){ m_uiRulerHeight = StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bVisibleRuler", &strValue );
			if ( bSuccess ){ m_bVisibleRuler = StringToBool( strValue ); }
// ▼ (3181) BGN 2003.12.22 (moralog) 等幅フォントの時はルーラを文字数に
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bRulerUnitPixel", &strValue );
			if ( bSuccess ){ m_bRulerUnitPixel = StringToBool( strValue ); }
// ▲ (3181) END
// ▼ (3632) BGN 2003.12.28 (moralog) キャレット位置の表示
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bCaretMark", &strValue );
			if ( bSuccess ){ m_bCaretMark = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bCaretLine", &strValue );
			if ( bSuccess ){ m_bCaretLine = StringToBool( strValue ); }
// ▲ (3632) END

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bFreeCursor", &strValue );
			if ( bSuccess ){ m_bFreeCursor = StringToBool( strValue ); }
		}

		m_LogFont.Read( strGeneralFilename, "Font" );
		m_fontRuler.Read( strGeneralFilename, "RulerFont" );
		m_Whitespace.Read();
		m_EmphasisDefine.Read();
		m_PrintDefine.Read( strGeneralFilename );
		m_BoxCharDefine.Read();
	}

// 共通設定はしたらびあんフォルダから読む
	{
// ▼ (3204) BGN 2004.05.10 moralog GetShitarabianFolderPath()は末尾に\\をつけない
		CString		strGeneralFilename = CSettingPath::GetInstance()->GetShitarabianFolderPath() + "\\commongeneral.ini";
// ▽ original BGN
//		CString		strGeneralFilename = CSettingPath::GetInstance()->GetShitarabianFolderPath() + "commongeneral.ini";
// △ original END
// ▲ (3204) END

		// バージョンの読み込み
		CString		strVersion;
		bSuccess = ReadGeneralProfile( strGeneralFilename, "Version", &strVersion );
		if ( bSuccess )
		{
			// 属性の読み込み
			CString		strValue;

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bOneShotBOXSelect", &strValue );
			if ( bSuccess ){ m_bOneShotBOXSelect	= StringToBool( strValue ); }


			bSuccess = ReadGeneralProfile( strGeneralFilename, "eHScrollUnit", &strValue );
			if ( bSuccess ){ m_eHScrollUnit	= StringToEScrollUnit( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "eVScrollUnit", &strValue );
			if ( bSuccess ){ m_eVScrollUnit	= StringToEScrollUnit( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bBlockAlignment", &strValue );
			if ( bSuccess ){ m_bBlockAlignment = StringToBool( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "uiWheelMove", &strValue );
			if ( bSuccess ){ m_uiWheelMove	= StringToLong( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "strQuote", &strValue );
			if ( bSuccess ){ m_strQuote	= DeQuoteString( strValue ); }

			// ▼ (3330) BGN 2003.12.26 (dincom) 
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bRestrainedScroll", &strValue );
			if ( bSuccess ){ m_bRestrainedScroll = StringToBool( strValue ); }
			// ▲ (3330) END

			// 検索文字列群
			int		idxLoop;
			bSuccess = TRUE;
			m_aSubStringz.RemoveAll();
			for( idxLoop=0 ; bSuccess ; idxLoop++ )
			{
				CString		strKey;
				strKey.Format( "strSubString%d", idxLoop );
				bSuccess = ReadGeneralProfile(
					strGeneralFilename,
					strKey,
					&strValue
				);
				if ( bSuccess )
				{
					::GetMainFrame()->AddSubString( strValue, NULL );
				}
			}

			// 置換文字列群
			bSuccess = TRUE;
			m_aReplaceStringz.RemoveAll();
			for( idxLoop=0 ; bSuccess ; idxLoop++ )
			{
				CString		strKey;
				strKey.Format( "strReplaceString%d", idxLoop );
				bSuccess = ReadGeneralProfile(
					strGeneralFilename,
					strKey,
					&strValue
				);
				if ( bSuccess )
				{
					::GetMainFrame()->AddReplaceString( strValue, NULL );
				}
			}

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bFindCareCase", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgFinder.m_bCaseCare = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bFindLoop", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgFinder.m_bLoop = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bFindToken", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgFinder.m_bToken = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bFindRegExp", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgFinder.m_bRegExp = StringToBool( strValue ); }

			bSuccess = ReadGeneralProfile( strGeneralFilename, "bReplaceCareCase", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgReplacer.m_bCaseCare = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bReplaceLoop", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgReplacer.m_bLoop = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bReplaceToken", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgReplacer.m_bToken = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bReplaceRegExp", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgReplacer.m_bRegExp = StringToBool( strValue ); }

			// ▼ (3367) BGN 2004.02.24 (dincom)
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bGrepCareCase", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgGrep.m_bCaseCare = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bGrepToken", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgGrep.m_bToken = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bGrepRegExp", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgGrep.m_bRegexp = StringToBool( strValue ); }
			bSuccess = ReadGeneralProfile( strGeneralFilename, "bSubFolder", &strValue );
			if ( bSuccess ){ ::GetMainFrame()->m_dlgGrep.m_bSubFolder = StringToBool( strValue ); }
			::GetMainFrame()->m_dlgGrep.UpdateData( FALSE );
			// ▲ (3367) END

			::GetMainFrame()->m_dlgFinder.UpdateData( FALSE );
			::GetMainFrame()->m_dlgReplacer.UpdateData( FALSE );
		}

		m_Flipz.Read();
		m_Mirrorz.Read();
		CBackUp::GetInstance()->Read( strGeneralFilename );
	}
	return( TRUE );
}

	
// ▼ (3367) BGN 2004.02.19 (dincom)
/*-----------------------------------------------------------------------------
[名称]	ファイル読み込み（設定）
[機能]	ファイルからの読み込み処理を行う。
[戻値]	BOOL
			処理結果 [-] (TRUE:成功、FALSE:失敗)
[備考]  設定種類ごとに保存するものは指定フォルダから読む
-----------------------------------------------------------------------------*/
BOOL	CGeneralSetting::ReadTypeSetting()
{
	BOOL		bSuccess;

	CString		strGeneralFilename = CSettingPath::GetInstance()->GetFolderPath() + "typegeneral.ini";

	// バージョンの読み込み
	CString		strVersion;
	bSuccess = ReadGeneralProfile( strGeneralFilename, "Version", &strVersion );
	if ( bSuccess )
	{
		// 属性の読み込み
		CString		strValue;

		bSuccess = ReadGeneralProfile( strGeneralFilename, "strSettingName", &strValue );
		if ( bSuccess ){ m_strSettingName	= DeQuoteString( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "strExt", &strValue );
		if ( bSuccess ){ m_strExt	= DeQuoteString( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "bTabConvert", &strValue );
		if ( bSuccess ){ m_bTabConvert	= StringToBool( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "strTabString", &strValue );
		if ( bSuccess ){ m_strTabString	= DeQuoteString( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "nTab", &strValue );
		if ( bSuccess ){ m_nTab	= StringToLong( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "uiRowGap", &strValue );
		if ( bSuccess ){ m_uiRowGap	= StringToLong( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "iLeftNumberMargin", &strValue );
		if ( bSuccess ){ m_iLeftNumberMargin	= StringToLong( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "iLeftBlankMargin", &strValue );
		if ( bSuccess ){ m_iLeftBlankMargin	= StringToLong( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "bVisibleNumber", &strValue );
		if ( bSuccess ){ m_bVisibleNumber	= StringToBool( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "uiRulerHeight", &strValue );
		if ( bSuccess ){ m_uiRulerHeight = StringToLong( strValue ); }

		bSuccess = ReadGeneralProfile( strGeneralFilename, "bVisibleRuler", &strValue );
		if ( bSuccess ){ m_bVisibleRuler = StringToBool( strValue ); }
// ▼ (3181) BGN 2003.12.22 (moralog) 等幅フォントの時はルーラを文字数に
		bSuccess = ReadGeneralProfile( strGeneralFilename, "bRulerUnitPixel", &strValue );
		if ( bSuccess ){ m_bRulerUnitPixel = StringToBool( strValue ); }
// ▲ (3181) END
// ▼ (3632) BGN 2003.12.28 (moralog) キャレット位置の表示
		bSuccess = ReadGeneralProfile( strGeneralFilename, "bCaretMark", &strValue );
		if ( bSuccess ){ m_bCaretMark = StringToBool( strValue ); }
		bSuccess = ReadGeneralProfile( strGeneralFilename, "bCaretLine", &strValue );
		if ( bSuccess ){ m_bCaretLine = StringToBool( strValue ); }
// ▲ (3632) END

		bSuccess = ReadGeneralProfile( strGeneralFilename, "bFreeCursor", &strValue );
		if ( bSuccess ){ m_bFreeCursor = StringToBool( strValue ); }
	}

	m_LogFont.Read( strGeneralFilename, "Font" );
	m_fontRuler.Read( strGeneralFilename, "RulerFont" );
	m_Whitespace.Read();
	m_EmphasisDefine.Read();
	m_PrintDefine.Read( strGeneralFilename );
	m_BoxCharDefine.Read();

// ▼ (3204) BGN 2004.05.10 (moralog) ランチャツールバー追加
		// ランチャ定義は CMainFrame::OnCreate() で読み込み
// ▲ (3204) END
	return( TRUE );
}
// ▲ (3367) END