Exemplo n.º 1
0
LRESULT CScriptEditView::OnFindReplaceCmd( UINT, WPARAM, LPARAM lParam, BOOL& )
{
	CFindReplaceDialog* pDlg = CFindReplaceDialog::GetNotifier(lParam);
	if( pDlg == NULL )
	{
		::MessageBeep( (UINT)-1 );
		return 1;
	}
	ATLASSERT( pDlg == m_pFindDlg );

	if( pDlg->IsTerminating() )
	{
		m_pFindDlg = NULL;
		return 0;
	}

	lstrcpyn( m_fro.StrToFind, pDlg->m_fr.lpstrFindWhat, DIMOF(m_fro.StrToFind) );
	m_fro.bMatchCase = (pDlg->MatchCase() != FALSE);
	m_fro.bWholeWord = (pDlg->MatchWholeWord() != FALSE);

	if( pDlg->FindNext() )
	{
		if( !DoFindText() )
			::MessageBeep( (UINT)-1 );
	}
	else if( pDlg->ReplaceCurrent() )
	{
		long nStart, nEnd;
		GetSel( nStart, nEnd );

		if( nStart != nEnd )
		{
			LPTSTR szFind = (LPTSTR)_alloca( (nEnd - nStart + 1) * sizeof(TCHAR) );
			GetSelText( szFind );
			int nRet;
			if( m_fro.bMatchCase )
				nRet = lstrcmp( szFind, m_fro.StrToFind );
			else
				nRet = lstrcmpi( szFind, m_fro.StrToFind );
			if(nRet == 0)
				ReplaceSel( pDlg->GetReplaceString(), TRUE );
		}

		if( !DoFindText() )
			::MessageBeep( (UINT)-1 );

	}
	else if( pDlg->ReplaceAll() )
	{
		SetRedraw(FALSE);
		CWaitCursor wait;
		while( DoFindText(false) )
			ReplaceSel( pDlg->GetReplaceString(), TRUE );
		SetRedraw( TRUE );
		Invalidate();
		UpdateWindow();
	}

	return 0;
}
Exemplo n.º 2
0
BOOL CFulEditCtrl::ShowMenu(HWND hWnd, POINT &pt){
	ScreenToClient(&pt);
	
	CHARRANGE cr;
	GetSel(cr);
	if(cr.cpMax != cr.cpMin) {
		TCHAR *buf = new TCHAR[cr.cpMax - cr.cpMin + 1];
		GetSelText(buf);
		searchTerm = Util::replace(buf, _T("\r"), _T("\r\n"));
		delete[] buf;
	} else {
		tstring line;
		tstring::size_type ch = TextUnderCursor(pt, line);
        if( ch != tstring::npos ) {
			
			tstring::size_type start = line.find_last_of(_T(" \t\r"), ch) + 1;
			
			tstring::size_type end = line.find_first_of(_T(" \t\r"), start);
			if(end == tstring::npos) {
				end = line.length();
			}

			searchTerm = line.substr(start, end-start);
		}
	}

	ClientToScreen(&pt);

	WinUtil::AppendSearchMenu(searchMenu);
	
	return menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, hWnd );
}
Exemplo n.º 3
0
void CRichEditCtrlExtn::OnLink(NMHDR *pNotifyStruct, LRESULT *pLResult)
{
  ENLINK* pENLink = (ENLINK*)pNotifyStruct;
  CString cs_FName, cs_URL;
  CHARRANGE saveRange;
  *pLResult = 0;

  if (pNotifyStruct->code == EN_LINK) {
    if (pENLink->msg == WM_LBUTTONDOWN || pENLink->msg == WM_LBUTTONDBLCLK) {
      // Find "Friendly Name"
      if (m_vALink.empty())
        return;

      StartEndMatch StartEndMatch(pENLink->chrg.cpMin, pENLink->chrg.cpMax);
      std::vector<ALink>::const_iterator found;
      found = std::find_if(m_vALink.begin(), m_vALink.end(), StartEndMatch);

      if (found == m_vALink.end())
        return;

      // Save current selected text
      saveRange.cpMin = saveRange.cpMax = 0;
      GetSel(saveRange);

      // Select link
      SetSel(pENLink->chrg);

      // Retrieve Friendly Name
      cs_FName = GetSelText();

      // Restore selection
      SetSel(saveRange);

      // Retrieve the URL
      cs_URL = CString(found->tcszURL);
      CWaitCursor waitCursor;

      bool bCallbackProcessed(false);
      if (m_pfcnNotifyLinkClicked != NULL) {
        // Call the supplied Callback routine; if it returns "true", it has processed the link
        bCallbackProcessed = m_pfcnNotifyLinkClicked(cs_URL, cs_FName, m_NotifyInstance);
      }

      if (bCallbackProcessed) {
        *pLResult = 1;
      } else {
        // We do it!
        if (!cs_URL.IsEmpty()) {
          ::ShellExecute(NULL, NULL, cs_URL, NULL, NULL, SW_SHOWNORMAL);
          *pLResult = 1;
        }
      }
      SetSel(-1, -1);
    } else 
      if (pENLink->msg == WM_LBUTTONUP) {
        *pLResult = 1;
      }
  }
}
    string16 NativeTextfieldWin::GetSelectedText() const
    {
        // Figure out the length of the selection.
        long start;
        long end;
        GetSel(start, end);

        // Grab the selected text.
        std::wstring str;
        GetSelText(WriteInto(&str, end-start+1));

        return str;
    }
Exemplo n.º 5
0
void CSynBCGPEditCtrl::ReplaceTextToFormatter( BOOL bAllText /*= TRUE*/ )
{
	if (bAllText)
	{
		SetSel2(0, -1, TRUE, FALSE);
	}
	CString strSelText(GetSelText());
	if (strSelText.IsEmpty())
	{
		return;
	}


	CT2A strTextIn(strSelText, GetACP());	
	CString strTextOut, strMsgOut;
	CFormatterHelp formatterSP;
	if (formatterSP.DoFormatter(m_SynLanguage.GetCurLanguage(), strTextIn, strTextOut, strMsgOut))
	{
		SetLastUndoReason(g_dwUATFormatter);
		DeleteSelectedText (FALSE, FALSE, TRUE);
		if (!globalData.bIsWindowsVista) //XP的时候
		{
			if (theApp.m_bChangedLang)
			{
				strTextOut = CA2T(CT2A(strTextOut), GetACP());
			}
		}
		InsertText (strTextOut, m_nCurrOffset, FALSE);
		if (bAllText)
		{
			SetSel2(0, 0, FALSE);
		}
		else
		{
			RedrawWindow ();
		}
	}
	else
	{
		if (bAllText)
		{
			SetSel2(0, 0, FALSE);
		}
	}
	
	CChildFrame *pFrame = ((CChildFrame *)((CView *)GetParent())->GetParentFrame());
	if (pFrame != NULL)
	{
		pFrame->AddOutputMsg(strMsgOut);
	}
}
Exemplo n.º 6
0
CString ScintillaEditor::GetWord()
{
	int savePos = GetCurrentPos();
	SendEditor(SCI_WORDLEFT);
	DWORD startPos = GetCurrentPos();
	SendEditor(SCI_WORDRIGHTEXTEND);
	DWORD endPos = GetCurrentPos();
	CStringA str;
	LPSTR buf = str.GetBufferSetLength(endPos - startPos);
	GetSelText(buf);
	str.ReleaseBuffer(endPos - startPos);
	SendEditor(SCI_SETCURRENTPOS, savePos);

	return CString(str);
}
Exemplo n.º 7
0
void CRichEditExtn::OnLButtonDblClk(UINT nFlags, CPoint point)
{
  long nStartChar, nEndChar;

  // Do what ever would normally happen
  CRichEditCtrl::OnLButtonDblClk(nFlags, point);

  // Get selection
  CRichEditCtrl::GetSel(nStartChar, nEndChar);

  // Check if this included a trailing whitespace and, if so, trim it
  CString csTemp = GetSelText();
  csTemp.TrimRight();

  // Reselect without trailing whitespace
  SetSel(nStartChar, nStartChar + csTemp.GetLength());
}
Exemplo n.º 8
0
void CUrlRichEditCtrl::PathReplaceSel(LPCTSTR lpszPath, BOOL bFile)
{
	CString sPath(lpszPath);
	sPath.TrimLeft();

	if (bFile || FileMisc::IsPath(lpszPath))
		sPath = CreateFileLink(lpszPath);
	
	// add space fore and aft depending on selection
	CHARRANGE crSel, crSelOrg;
	GetSel(crSelOrg); // save this off
	GetSel(crSel);
	
	// enlarge to include end items
	if (crSel.cpMin > 0)
		crSel.cpMin--;
	
	if (crSel.cpMax < GetTextLength() - 1)
		crSel.cpMax++;
	
	SetSel(crSel);
	CString sSelText = GetSelText();
	SetSel(crSelOrg);
	
	// test
	if (!sSelText.IsEmpty())
	{
		if (!isspace(sSelText[0]))
			sPath = ' ' + sPath;
		
		if (!isspace(sSelText[sSelText.GetLength() - 1]))
			sPath += ' ';
	}
	
	ReplaceSel(sPath, TRUE);
	ParseAndFormatText();
	
	// set the new selection to be the dropped text
	SetSel(crSelOrg.cpMin, crSelOrg.cpMin + sPath.GetLength());
	SetFocus();
}
Exemplo n.º 9
0
/**
 * @brief クリップボードへコピー処理を行います。
 */
bool CFootyDoc::ClipCopy(HWND hWnd)
{
	// 宣言
	std::wstring strSelText;
	HGLOBAL hMem;
	
	// ロックして、コピー文字列を生成
	if (!GetSelText(&strSelText))return false;
	hMem = GlobalAlloc(GHND, strSelText.size()+sizeof(wchar_t));
    memcpy(GlobalLock(hMem),strSelText.c_str(),strSelText.size()+sizeof(wchar_t));
    GlobalUnlock(hMem);
	
	// クリップボードをオープンして、コピー
	if (!OpenClipboard(hWnd))
	{
		GlobalFree(hMem);
		return false;
	}
	EmptyClipboard();
	SetClipboardData(CF_UNICODETEXT, hMem);
	CloseClipboard();
	return true;
}
/*
================
CSyntaxRichEditCtrl::OnKeyDown
================
*/
void CSyntaxRichEditCtrl::OnKeyDown(UINT nKey, UINT nRepCnt, UINT nFlags)
{

	if (m_TextDoc == NULL) {
		return;
	}

	if (autoCompleteStart >= 0) {
		int sel;

		switch (nKey) {
			case VK_UP: {		// up arrow
				sel = Max(0, autoCompleteListBox.GetCurSel() - 1);
				autoCompleteListBox.SetCurSel(sel);
				return;
			}
			case VK_DOWN: {		// down arrow
				sel = Min(autoCompleteListBox.GetCount() - 1, autoCompleteListBox.GetCurSel() + 1);
				autoCompleteListBox.SetCurSel(sel);
				return;
			}
			case VK_PRIOR: {	// page up key
				sel = Max(0, autoCompleteListBox.GetCurSel() - 10);
				autoCompleteListBox.SetCurSel(sel);
				return;
			}
			case VK_NEXT: {		// page down key
				sel = Min(autoCompleteListBox.GetCount() - 1, autoCompleteListBox.GetCurSel() + 10);
				autoCompleteListBox.SetCurSel(sel);
				return;
			}
			case VK_HOME: {		// home key
				autoCompleteListBox.SetCurSel(0);
				return;
			}
			case VK_END: {
				autoCompleteListBox.SetCurSel(autoCompleteListBox.GetCount() - 1);
				return;
			}
			case VK_RETURN:		// enter key
			case VK_TAB: {		// tab key
				AutoCompleteInsertText();
				AutoCompleteHide();
				return;
			}
			case VK_LEFT:		// left arrow
			case VK_RIGHT:		// right arrow
			case VK_INSERT:		// insert key
			case VK_DELETE: {	// delete key
				return;
			}
		}
	}

	BracedSectionHide();

	switch (nKey) {
		case VK_TAB: {		// multi-line tabs
			long selStart, selEnd;

			GetSel(selStart, selEnd);

			// if multiple lines are selected add tabs to, or remove tabs from all of them
			if (selEnd > selStart) {
				CString text;

				text = GetSelText();

				if (GetAsyncKeyState(VK_SHIFT) & 0x8000) {
					if (idStr::CharIsTab(text[0])) {
						text.Delete(0, 1);
					}

					for (int i = 0; i < text.GetLength() - 2; i++) {
						if (idStr::CharIsNewLine(text[i])) {
							do {
								i++;
							} while (idStr::CharIsNewLine(text[i]));

							if (idStr::CharIsTab(text[i])) {
								text.Delete(i, 1);
							}
						}
					}
				} else {
					text.Insert(0, '\t');

					for (int i = 0; i < text.GetLength() - 1; i++) {
						if (idStr::CharIsNewLine(text[i])) {
							do {
								i++;
							} while (idStr::CharIsNewLine(text[i]));

							text.Insert(i, '\t');
						}
					}
				}

				ReplaceSel(text, TRUE);
				SetSel(selStart, selStart + text.GetLength());
			} else {
				ReplaceSel("\t", TRUE);
			}

			return;
		}
		case VK_RETURN: {	// auto-indentation
			long selStart, selEnd;
			int line, length, numTabs, i;
			char buffer[1024];
			idStr text;

			GetSel(selStart, selEnd);
			line = LineFromChar(selStart);
			length = GetLine(line, buffer, sizeof(buffer));

			for (numTabs = 0; numTabs < length; numTabs++) {
				if (!idStr::CharIsTab(buffer[numTabs])) {
					break;
				}
			}

			bool first = true;

			for (i = numTabs; i < length; i++) {
				if (buffer[i] == '{') {
					numTabs++;
					first = false;
				} else if (buffer[i] == '}' && !first) {
					numTabs--;
				}
			}

			text = "\r\n";

			for (i = 0; i < numTabs; i++) {
				text.Append('\t');
			}

			ReplaceSel(text, TRUE);
			return;
		}
	}

	m_TextDoc->Freeze(NULL);

	CRichEditCtrl::OnKeyDown(nKey, nRepCnt, nFlags);

	UpdateVisibleRange();

	m_TextDoc->Unfreeze(NULL);
}
Exemplo n.º 11
0
void CTWScriptEdit::FormatTextRange(int nStart, int nEnd)
{
	if (nStart >= nEnd)
		return;

	m_bInForcedChange = TRUE;

	CHARRANGE crOldSel;

	GetSel(crOldSel);
	LockWindowUpdate();
	HideSelection(TRUE, FALSE);

	WCHAR *pBuffer = NULL;
	try {
		SetSel(nStart, nEnd);
		//pBuffer = new WCHAR[nEnd - nStart + 1];
		CHAR* pBuffer2 = new CHAR[nEnd - nStart + 1];
		long nLen = GetSelText(pBuffer2);
		pBuffer = GetUnicode(pBuffer2);
		ASSERT(nLen <= nEnd - nStart);

		pBuffer[nLen] = 0;

		WCHAR *pStart, *pPtr;
		pStart = pPtr = pBuffer;

		WCHAR* pSymbolStart = NULL;
		SymbolColor ic;

		while (*pPtr != 0) {
			WCHAR ch = *pPtr;

			if (ch == m_chComment && (m_chComment2 == 0 || pPtr[1] == m_chComment2)) {
				pSymbolStart = pPtr;
				do {
					ch = *(++pPtr);
				} while (ch != 0 && ch != '\r');
				ic = m_icComment;
			} else if (IsStringQuote(ch)) { // Process strings
				pSymbolStart = pPtr;
				WCHAR ch1 = ch;
				do {
					ch = *(++pPtr);
				} while (ch != 0 && ch != ch1 && ch != '\r');
				if (ch == ch1) pPtr++;
				ic = m_icString;
			} else if (_istdigit(ch)) { // Process numbers
				pSymbolStart = pPtr;
				wcstod(pSymbolStart, &pPtr);
				ic = m_icNumber;
			} else if (_istalpha(ch) || ch == '_') { // Process keywords
				pSymbolStart = pPtr;
				do {
					ch = *(++pPtr);
				} while (_istalnum(ch) || ch == '_');
				*pPtr = 0;
				int nPos = IsKeyword(pSymbolStart);
				if (nPos >= 0) {
					ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, 
								m_strKeywords.Mid(nPos+1, pPtr - pSymbolStart));
					if (wcsicmp(m_strComment, pSymbolStart) == 0) {
						*pPtr = ch;
						*pSymbolStart = m_chComment;
						if (pSymbolStart[1] != 0 && m_chComment2 != 0)
							pSymbolStart[1] = m_chComment2;
						pPtr = pSymbolStart;
						pSymbolStart = NULL;
						continue;
					}
					ic = m_icKeyword;
				} else {
					nPos = IsConstant(pSymbolStart);
					if (nPos >= 0) {
							ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, 
										m_strConstants.Mid(nPos+1, pPtr - pSymbolStart));
						ic = m_icConstant;
					} else {
						pSymbolStart = NULL;
					}
				}
				*pPtr = ch;
			} else {
				pPtr++;
			}

			if (pSymbolStart != NULL) {
				ASSERT(pSymbolStart < pPtr);
				SetFormatRange(nStart + pStart - pBuffer, nStart + pSymbolStart - pBuffer, FALSE, RGB(0,0,0));
				SetFormatRange(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, ic.bBold, ic.clrColor);
				pStart = pPtr;
				pSymbolStart = 0;
			} else if (*pPtr == 0)
				SetFormatRange(nStart + pStart - pBuffer, nStart + pPtr - pBuffer, FALSE, RGB(0,0,0));
		}

	} catch(...){}

	//delete [] pBuffer;

	SetSel(crOldSel);
	HideSelection(FALSE, FALSE);
	UnlockWindowUpdate();

	m_bInForcedChange = FALSE;
}
Exemplo n.º 12
0
void CSynBCGPEditCtrl::InsertComment(BOOL bForward)
{
	int iStartSel = min (m_iStartSel, m_iEndSel);
	int iEndSel = max (m_iStartSel, m_iEndSel);
	int nFirstSelRow, nLastSelRow;
	if (iStartSel == -1 || iEndSel == -1)
	{
		nFirstSelRow = GetCurrRowStart(FALSE);
		nLastSelRow = GetCurrRowEnd(FALSE);
	} 
	else
	{
		int nEndRowOffset = GetRowStartByOffset (iEndSel, TRUE);

		if (nEndRowOffset == iEndSel)
		{
			iEndSel--;
		}

		nFirstSelRow = GetRowStartByOffset	(iStartSel, TRUE);
		nLastSelRow  = max (iEndSel, GetRowEndByOffset (iEndSel, TRUE));
	}
	

	SetSel2(nFirstSelRow, nLastSelRow + 1, TRUE, FALSE);
	CString strSelText(GetSelText());
	if (strSelText.IsEmpty())
	{
		return;
	}

	CString strComment;
	BOOL bCaseSensitive;
	m_SynLanguage.GetLineComment(strComment, bCaseSensitive);
	int nPosPrior = 0;
	int nPos = strComment.Find(_T(","), nPosPrior);
	if(nPos != -1)
	{
		strComment = strComment.Mid(nPosPrior, nPos - nPosPrior);
	}
	if (strComment.IsEmpty())
	{
		return;
	}

	if (bForward)
	{
		int nCommentLen = strComment.GetLength();
		nPos = nCommentLen;
		strSelText.Insert(0, strComment);
		nPos = strSelText.Find(g_chEOL, nPos);
		while (nPos != -1)
		{
			if (nPos == strSelText.GetLength() - 1)
			{
				break;
			}
			strSelText.Insert(nPos + 1, strComment);
			nPos = strSelText.Find(g_chEOL, nPos + nCommentLen + 1);
		}

		SetLastUndoReason(g_dwUATComment);
		ReplaceSel(strSelText, TRUE);
	} 
	else
	{
		int nCommentLen = strComment.GetLength();
		BOOL bModify = FALSE;
		CString strMid, strLeft;
		int nPosComment;
		nPos = 0, nPosPrior = 0;
		nPos = strSelText.Find(g_chEOL, nPosPrior);
		// 当是最后一行时,也要处理
		if (-1 == nPos)
		{
			nPos = strSelText.GetLength();
		}
		while (nPos != -1)
		{
			strMid = strSelText.Mid(nPosPrior, nPos - nPosPrior);
			strLeft = strMid.TrimLeft();
			strLeft = strLeft.Left(nCommentLen);
			if (strLeft.Compare(strComment) == 0)
			{
				nPosComment = strSelText.Find(strComment, nPosPrior);
				if (nPosComment != -1)
				{
					strSelText.Delete(nPosComment, nCommentLen);
					nPos -= nCommentLen;
					bModify = TRUE;
				}
			}
			nPosPrior = nPos + 1;
			nPos = strSelText.Find(g_chEOL, nPosPrior);
			if (-1 == nPos)
			{
				if (nPosPrior < strSelText.GetLength())
				{
					nPos = strSelText.GetLength();
				}
			}
		}

		if (bModify)
		{
			SetLastUndoReason(g_dwUATUncomment);
			ReplaceSel(strSelText, TRUE);
		}
	}
}
Exemplo n.º 13
0
void CEmoticonRichEditCtrl::FormatTextRange(int nStart, int nEnd)
{	
	BOOL bEmoticon = FALSE;

	if (nStart >= nEnd)
	{
		TRACE("\nreturn!!\n");
		return;
	}

	m_bInForcedChange = TRUE;

	CHARRANGE crOldSel;
	
	GetSel(crOldSel);	

	TRACE("crOldSel MIN [%d] MAX [%d] \n", crOldSel.cpMin, crOldSel.cpMax );
			
	HideSelection(TRUE, FALSE);
	
	TCHAR *pBuffer = NULL;
	//char *pBuffer = NULL;	

	try 
	{
		TRACE("FormatTextRange : nStart [%d] nEnd [%d] \n", nStart, nEnd);

		SetSel(nStart, nEnd);
								
		pBuffer = new TCHAR[nEnd - nStart + 1];
		//pBuffer = new char[nEnd - nStart + 1];

		long nLen = GetSelText(pBuffer);
		pBuffer[nLen] = 0;

		TRACE("new [%d] pBuffer [%S]\n", nEnd - nStart + 1, pBuffer);
		//ASSERT(nLen <= nEnd - nStart);	

		TCHAR *pStart, *pPtr, *pSymbolStart ;		
		//char* pStart = NULL, *pPtr = NULL;		
		//char* pSymbolStart = NULL;

		pStart = pPtr = pBuffer;
		
		while (*pPtr != 0) 
		{			
			TCHAR ch = *pPtr;					
			//char ch = *pPtr;					
			
			if ( _istalpha(ch) || ch == '_') 
			{ 
				pSymbolStart = pPtr;
				
				do 
				{
					ch = *(++pPtr);
				} 
				while (_istalnum(ch) || ch == '_');

				*pPtr = 0;
				
				//TRACE("pSymbolStart  [%s]\n", pSymbolStart );	
								
				int nPos = IsEmoticon(pSymbolStart);
				
				if (nPos >= 0) 
				{					
					bEmoticon = TRUE;					
		
					SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG);					
		
					//TRACE("이모티콘!!! [%s]\n", pSymbolStart );
					
					SetSel(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer  );
					
					ReplaceSel("  ");					
										
					TRACE("이모티콘영역 [%d] [%d]\n", nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer );	
					
					CString strTmp(pSymbolStart);
					int nIndex = atoi( (LPCSTR)strTmp.Mid(2,2) ) ;
					
					HBITMAP hBitmap = GetImage( m_imgListFaces , nIndex );

					if (hBitmap)
					{
						CString strOutID;
						strOutID.Empty();
						CImageDataObject::InsertBitmap(m_pRichEditOle, hBitmap, strOutID ); // strTmp => ec01 , strOutID = 12232132321 

						if(m_nRole == ROLE_SEND_INPUT )
						{
							char* pszID = new char[10+1];
							char* pszVal = new char[10+1];
							strncpy(pszID, (LPCSTR)strOutID, 10);
							strcpy(pszVal, pSymbolStart);
							
							TRACE("WM_EMOTICON_MAP : pszID [%s] pszVal [%s]\n", pszID, pszVal );
							GetParent()->SendMessage( WM_EMOTICON_MAP, (WPARAM) pszID , (LPARAM) pszVal) ;
						}						
					}

					ReplaceSel(" ");
					
					pStart = pPtr;
					pSymbolStart = 0;
										
				}
				else
				{
					pSymbolStart = NULL;
				}
				
				*pPtr = ch;
			}
			else 
			{
				pPtr++;
			}
		}
		
	} 
	catch(...)
	{
		//delete [] pBuffer;
		//pBuffer = NULL ;
	}	
	
	delete [] pBuffer;
	
	if(m_nRole == ROLE_SEND_INPUT )
	{	
		CHARFORMAT2 cf;
		GetSelectionCharFormat(cf);
		cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE    ; 
		cf.crTextColor =  CChatSession::Instance().m_ColorMe;			
		cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR;	
		SetSelectionCharFormat(cf);
	}
	
	SetSel(crOldSel);
	
	if(m_nRole == ROLE_SEND_INPUT )
	{	
		CHARFORMAT2 cf;
		GetSelectionCharFormat(cf);
		cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE    ; 
		cf.crTextColor =  CChatSession::Instance().m_ColorMe;			
		cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR;	
		SetSelectionCharFormat(cf);
	}
	

	HideSelection(FALSE, FALSE);
		
	//UnlockWindowUpdate();		
			
	SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG );	
	
	m_bInForcedChange = FALSE;
}