Index: ProjectEditor/ProjectEditor.cpp
===================================================================
--- ProjectEditor/ProjectEditor.cpp	(revision 22)
+++ ProjectEditor/ProjectEditor.cpp	(revision 24)
@@ -135,9 +135,9 @@
 		if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
 			//コントロールタブスペースの幅と行番号の文字数を更新
-			MdiInfo[WndNum].pmti->iWidth_ControlTabSpace=
-				GetControlTabSpace(WndNum,&MdiInfo[WndNum].pmti->iLineNumberTextCount);
-
-			InvalidateRect(MdiInfo[WndNum].pmti->hEdit,NULL,0);
-			InvalidateRect(MdiInfo[WndNum].pmti->pobj_Ruler->hRulerWnd,NULL,0);
+			MdiInfo[WndNum].pMdiTextEdit->iWidth_ControlTabSpace=
+				GetControlTabSpace(WndNum,&MdiInfo[WndNum].pMdiTextEdit->iLineNumberTextCount);
+
+			InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->hEdit,NULL,0);
+			InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,NULL,0);
 
 			SendTextEditResizeEvent(MdiInfo[WndNum].hwnd);
@@ -160,5 +160,5 @@
 	sw=0;
 	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
-		if(MdiInfo[WndNum].pmti->bModify) sw=1;
+		if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ) sw=1;
 	}
 	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
@@ -205,5 +205,5 @@
 
 		//サイズ
-		BufSize=(double)lstrlen(MdiInfo[WndNum].pmti->buffer);
+		BufSize=(double)lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer);
 		if(IsWindow(hChild)){
 			if(BufSize<1024) sprintf(temporary,"%s: %.0fByte",STRING_SIZE,BufSize);
@@ -225,11 +225,11 @@
 			//日本語
 			sprintf(temporary,"%d 行、%d 列",
-				MdiInfo[WndNum].pmti->StartCaretPos.y+1,
-				MdiInfo[WndNum].pmti->StartCaretPos.x+1);
+				MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
+				MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
 #else
 			//英語
 			sprintf(temporary,"%d : %d",
-				MdiInfo[WndNum].pmti->StartCaretPos.y+1,
-				MdiInfo[WndNum].pmti->StartCaretPos.x+1);
+				MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y+1,
+				MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x+1);
 #endif
 		}
@@ -238,9 +238,9 @@
 
 		//文字コード
-		nkf.GetCharCodeName(MdiInfo[WndNum].pmti->iCharCode,temporary);
+		nkf.GetCharCodeName(MdiInfo[WndNum].pMdiTextEdit->iCharCode,temporary);
 		SendMessage(hStatusBar,SB_SETTEXT,3,(LPARAM)temporary);
 
 		//文字コード
-		nkf.GetLfCodeName(MdiInfo[WndNum].pmti->iLfCode,temporary);
+		nkf.GetLfCodeName(MdiInfo[WndNum].pMdiTextEdit->iLfCode,temporary);
 		SendMessage(hStatusBar,SB_SETTEXT,4,(LPARAM)temporary);
 	}
@@ -310,7 +310,7 @@
 	}
 	else if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
-		i2=MdiInfo[i].edit_undo->NowPos-1;
+		i2=MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos-1;
 		if(i2==-1) i2=MAX_UNDONUM-1;
-		if(!MdiInfo[i].edit_undo->Command[i2]){
+		if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[i2]){
 			pobj_MainMenu->EnableItem(IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
 			EnableMenuItem(hEditMenu,IDM_UNDO,MF_BYCOMMAND|MF_GRAYED);
@@ -322,5 +322,5 @@
 			pobj_StandardToolbar->EnableItem(IDM_UNDO,1);
 		}
-		if(!MdiInfo[i].edit_undo->Command[MdiInfo[i].edit_undo->NowPos]){
+		if(!MdiInfo[i].pMdiTextEdit->pTextEditUndoState->Command[MdiInfo[i].pMdiTextEdit->pTextEditUndoState->NowPos]){
 			pobj_MainMenu->EnableItem(IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
 			EnableMenuItem(hEditMenu,IDM_REDO,MF_BYCOMMAND|MF_GRAYED);
@@ -461,6 +461,6 @@
 		hChild=GetWindow(hChild,GW_CHILD);
 		if(!(
-			MdiInfo[WndNum].pmti->StartCaretPos.x==MdiInfo[WndNum].pmti->EndCaretPos.x&&
-			MdiInfo[WndNum].pmti->StartCaretPos.y==MdiInfo[WndNum].pmti->EndCaretPos.y
+			MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.x&&
+			MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y==MdiInfo[WndNum].pMdiTextEdit->EndCaretPos.y
 			)){
 			MenuMsg=MF_BYCOMMAND|MF_ENABLED;
@@ -901,30 +901,26 @@
 			}
 
-			MdiInfo[i].pmti=(MDITEXTEDITINFO *)HeapAlloc(hHeap,0,sizeof(MDITEXTEDITINFO));
-
-			MdiInfo[i].pmti->hEdit=hEdit;
-			MdiInfo[i].pmti->pobj_WebResult=new CWebResult(hChild);
-			MdiInfo[i].pmti->pobj_Ruler=new CRuler(hChild,i);
-			MdiInfo[i].pmti->hIcon=shfi.hIcon;
-			MdiInfo[i].pmti->buffer=buffer;
-			MdiInfo[i].pmti->pColorRef=(COLORREF *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(COLORREF)*lstrlen(buffer));
-			MdiInfo[i].pmti->iUnderStart=-1;
-			MdiInfo[i].pmti->iUnderEnd=-1;
-			MdiInfo[i].pmti->StartCaretPos.x=0;
-			MdiInfo[i].pmti->StartCaretPos.y=0;
-			MdiInfo[i].pmti->EndCaretPos.x=0;
-			MdiInfo[i].pmti->EndCaretPos.y=0;
-			MdiInfo[i].pmti->Temp_UpDown_CaretXPos=-1;
-			MdiInfo[i].pmti->bAutoScroll=0;
-			MdiInfo[i].pmti->iWidth_ControlTabSpace=
-				GetControlTabSpace(i,&MdiInfo[i].pmti->iLineNumberTextCount);
-			MdiInfo[i].pmti->iCharCode=iCharCode;
-			MdiInfo[i].pmti->iLfCode=iLfCode;
-			MdiInfo[i].pmti->bModify=0;
+			MdiInfo[i].pMdiTextEdit = new CMdiTextEdit( &MdiInfo[i] );
+
+			MdiInfo[i].pMdiTextEdit->hEdit=hEdit;
+			MdiInfo[i].pMdiTextEdit->pobj_WebResult=new CWebResult(hChild);
+			MdiInfo[i].pMdiTextEdit->pobj_Ruler=new CRuler(hChild,i);
+			MdiInfo[i].pMdiTextEdit->hIcon=shfi.hIcon;
+			MdiInfo[i].pMdiTextEdit->buffer=buffer;
+			MdiInfo[i].pMdiTextEdit->pColorRef=(COLORREF *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(COLORREF)*lstrlen(buffer));
+			MdiInfo[i].pMdiTextEdit->iUnderStart=-1;
+			MdiInfo[i].pMdiTextEdit->iUnderEnd=-1;
+			MdiInfo[i].pMdiTextEdit->StartCaretPos.x=0;
+			MdiInfo[i].pMdiTextEdit->StartCaretPos.y=0;
+			MdiInfo[i].pMdiTextEdit->EndCaretPos.x=0;
+			MdiInfo[i].pMdiTextEdit->EndCaretPos.y=0;
+			MdiInfo[i].pMdiTextEdit->Temp_UpDown_CaretXPos=-1;
+			MdiInfo[i].pMdiTextEdit->bAutoScroll=0;
+			MdiInfo[i].pMdiTextEdit->iWidth_ControlTabSpace=
+				GetControlTabSpace(i,&MdiInfo[i].pMdiTextEdit->iLineNumberTextCount);
+			MdiInfo[i].pMdiTextEdit->iCharCode=iCharCode;
+			MdiInfo[i].pMdiTextEdit->iLfCode=iLfCode;
 
 			MdiInfo[i].IndentStr=0;
-
-			MdiInfo[i].edit_undo=(TEXTEDIT_UNDOSTATE *)GlobalAlloc(GPTR,sizeof(TEXTEDIT_UNDOSTATE));
-			MdiInfo[i].edit_undo->NowPos=0;
 
 			int flag;
@@ -945,5 +941,5 @@
 
 	//タブに追加
-	pobj_MainTab->insert(str,1,TabColor);
+	pobj_MainTab->InsertItem( str, true, TabColor );
 
 	SetFocus(hEdit);
@@ -1018,5 +1014,5 @@
 
 	//タブコントロールからアイテムを消去
-	if(pobj_MainTab) pobj_MainTab->delete_item(MdiInfo[WndNum].title,1);
+	if(pobj_MainTab) pobj_MainTab->DeleteItem( MdiInfo[WndNum].title, true );
 
 
@@ -1036,31 +1032,25 @@
 		}
 
-		for(i2=0;i2<MAX_UNDONUM;i2++){
-			if(MdiInfo[WndNum].edit_undo->Command[i2])
-				TextEdit_DeleteUndoData(WndNum,i2);
-		}
-		GlobalFree(MdiInfo[WndNum].edit_undo);
-
-		HeapDefaultFree(MdiInfo[WndNum].pmti->buffer);
-		HeapDefaultFree(MdiInfo[WndNum].pmti->pColorRef);
+		HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->buffer);
+		HeapDefaultFree(MdiInfo[WndNum].pMdiTextEdit->pColorRef);
 
 		if(MdiInfo[WndNum].IndentStr) HeapDefaultFree(MdiInfo[WndNum].IndentStr);
 
 		//エディットコントロールを破棄
-		DestroyWindow(MdiInfo[WndNum].pmti->hEdit);
+		DestroyWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit);
 
 		//Web検索ウィンドウを破棄
-		delete MdiInfo[WndNum].pmti->pobj_WebResult;
-		MdiInfo[WndNum].pmti->pobj_WebResult=0;
+		delete MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult;
+		MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult=0;
 
 		//ルーラーウィンドウを破棄
-		delete MdiInfo[WndNum].pmti->pobj_Ruler;
-		MdiInfo[WndNum].pmti->pobj_Ruler=0;
+		delete MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler;
+		MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler=0;
 
 		//アイコンを破棄
-		if(MdiInfo[WndNum].pmti->hIcon) DestroyIcon(MdiInfo[WndNum].pmti->hIcon);
-
-		HeapDefaultFree(MdiInfo[WndNum].pmti);
-		MdiInfo[WndNum].pmti=0;
+		if(MdiInfo[WndNum].pMdiTextEdit->hIcon) DestroyIcon(MdiInfo[WndNum].pMdiTextEdit->hIcon);
+
+		delete MdiInfo[WndNum].pMdiTextEdit;
+		MdiInfo[WndNum].pMdiTextEdit=0;
 	}
 	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
@@ -1122,5 +1112,5 @@
 	if(pobj_nv->bEditor_Ruler){
 		//ルーラー
-		MdiInfo[WndNum].pmti->pobj_Ruler->resize(
+		MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->resize(
 			0,
 			0,
@@ -1130,14 +1120,14 @@
 		iHeightRuler=HEIGHT_RULER;
 
-		ShowWindow(MdiInfo[WndNum].pmti->pobj_Ruler->hRulerWnd,SW_SHOW);
+		ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_SHOW);
 	}
 	else{
 		iHeightRuler=0;
 
-		ShowWindow(MdiInfo[WndNum].pmti->pobj_Ruler->hRulerWnd,SW_HIDE);
+		ShowWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,SW_HIDE);
 	}
 
 	//エディットウィンドウ
-	MoveWindow(MdiInfo[WndNum].pmti->hEdit,
+	MoveWindow(MdiInfo[WndNum].pMdiTextEdit->hEdit,
 		0,
 		iHeightRuler,
@@ -1147,5 +1137,5 @@
 
 	//Web検索ウィンドウ
-	MdiInfo[WndNum].pmti->pobj_WebResult->resize(
+	MdiInfo[WndNum].pMdiTextEdit->pobj_WebResult->resize(
 		0,
 		cy-WebResultWndHeight,
@@ -1687,5 +1677,5 @@
 						hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
 						pTemp=(char *)GlobalLock(hGlobal);
-						memcpy(pTemp,MdiInfo[WndNum].pmti->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
+						memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
 						pTemp[CharRange.cpMax-CharRange.cpMin]=0;
 						GlobalUnlock(hGlobal);
@@ -1743,5 +1733,5 @@
 						hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
 						pTemp=(char *)GlobalLock(hGlobal);
-						memcpy(pTemp,MdiInfo[WndNum].pmti->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
+						memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
 						pTemp[CharRange.cpMax-CharRange.cpMin]=0;
 						GlobalUnlock(hGlobal);
@@ -1853,11 +1843,11 @@
 						hEdit=GetWindow(hChild,GW_CHILD);
 
-						MdiInfo[WndNum].pmti->StartCaretPos.x=0;
-						MdiInfo[WndNum].pmti->StartCaretPos.y=0;
+						MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.x=0;
+						MdiInfo[WndNum].pMdiTextEdit->StartCaretPos.y=0;
 
 						GetCaretPosFromBufferIndex(
-							MdiInfo[WndNum].pmti->buffer,
-							lstrlen(MdiInfo[WndNum].pmti->buffer),
-							&MdiInfo[WndNum].pmti->EndCaretPos);
+							MdiInfo[WndNum].pMdiTextEdit->buffer,
+							lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer),
+							&MdiInfo[WndNum].pMdiTextEdit->EndCaretPos);
 
 						InvalidateRect(hEdit,NULL,0);
@@ -2443,5 +2433,5 @@
 
 					//閉じる
-					MdiInfo[WndNum].pmti->bModify=0;
+					MdiInfo[WndNum].pMdiTextEdit->UnModify();
 					SendMessage(MdiInfo[WndNum].hwnd,WM_CLOSE,0,0);
 
@@ -2552,5 +2542,5 @@
 			UpdateWindow(hChild);
 
-			pTemp=MdiInfo[WndNum].pmti->buffer;
+			pTemp=MdiInfo[WndNum].pMdiTextEdit->buffer;
 
 			//行の先頭インデックスを取得（取得する行の番号はwParamで渡される）
