您的位置:首页 > 其它

vs自动注释add-in插件编写(二)--CConnect

2015-02-13 01:27 375 查看
void CConnect::EditCode(CComQIPtr<TextSelection> pTextSelection, COMMENT_TYPE ct)
{
if (pTextSelection)
{
CComPtr<UndoContext> pUndoContext;
m_pDTE->get_UndoContext(&pUndoContext);
pUndoContext->Open(CComBSTR("Edit code"), VARIANT_FALSE);

CComBSTR strSelectText;
pTextSelection->get_Text(&strSelectText);

long lCol;
CComPtr<VirtualPoint> pVirtualPoint;
pTextSelection->get_TopPoint(&pVirtualPoint);
pVirtualPoint->get_VirtualDisplayColumn(&lCol);

// 注释头
CString strFinalText = CommentCode(GetCommentHead(), lCol - 1) + "\n";

// 补齐第一行
strFinalText = LeftTabToSpace(strFinalText, 4);
strFinalText = strFinalText.Mid(lCol - 1, strFinalText.GetLength() - lCol + 1);

// 正文
CString strTemp;
strTemp = strSelectText;

// 补齐第一行正文
strTemp = GetTabString(lCol -1, 4) + strTemp;

if (ct != CT_ADD_CODE)
{
strTemp = CommentCode(strTemp, lCol - 1) + "\n";
}

strFinalText += strTemp;

// 注释尾
strFinalText += "\n" + CommentCode(GetCommentTail(), lCol - 1);

InsertText(pTextSelection, strFinalText);

pUndoContext->Close();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: