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

来源:互联网 发布:广联达软件百度云 编辑:程序博客网 时间:2024/05/24 04:36
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();}}


 

0 0
原创粉丝点击