本文整理汇总了C++中FV_View::cmdCharInsert方法的典型用法代码示例。如果您正苦于以下问题:C++ FV_View::cmdCharInsert方法的具体用法?C++ FV_View::cmdCharInsert怎么用?C++ FV_View::cmdCharInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FV_View
的用法示例。
在下文中一共展示了FV_View::cmdCharInsert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//
// AiksaurusABI_invoke
// -------------------
// This is the function that we actually call to invoke the thesaurus.
// It should be called when the user hits the thesaurus key (shift+f7?)
// or chooses "thesaurus" from a menu.
//
bool
AiksaurusABI_invoke(AV_View* /*v*/, EV_EditMethodCallData * /*d*/)
{
// Get the current view that the user is in.
XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView());
// If the user is on a word, but does not have it selected, we need
// to go ahead and select that word so that the search/replace goes
// correctly.
pView->moveInsPtTo(FV_DOCPOS_EOW_MOVE);
pView->moveInsPtTo(FV_DOCPOS_BOW);
pView->extSelTo(FV_DOCPOS_EOW_SELECT);
// Now we will figure out what word to look up when we open our dialog.
char* search = 0;
if (!pView->isSelectionEmpty())
{
// We need to get the Ascii version of the current word.
UT_UCS4Char * ucs4ST;
pView->getSelectionText(*&ucs4ST);
search = AiksaurusABI_ucsToAscii(
ucs4ST
);
}
// Now we will run the thesaurus dialog and get a response.
// We will automatically do a search for the selected/current word.
#ifdef _WIN32
AiksaurusApp thesaurus;
thesaurus.setInstance( (HINSTANCE)s_hModule );
#else
AiksaurusGTK thesaurus;
#endif
thesaurus.setTitle("Abiword Thesaurus");
thesaurus.setInitialMessage("Welcome to Aiksaurus");
const char* response = thesaurus.runThesaurus(search);
if (response)
{
// Now that we have our replacement, we need to convert it to UCS-2.
int length;
UT_UCSChar* replacement = AiksaurusABI_asciiToUcs(response, length);
// Now, if our replacement has length, we can go ahead and run the
// replacement. If the replacement has no length, we will do nothing.
if (length)
pView->cmdCharInsert(replacement, length);
// all done with replacement.
delete[] replacement;
}
// Finally, we need to remember to delete search and replacement strings.
// Note that "search" might be null so we only want to delete[] it if it
// was actually initialized above.
if (search)
delete[] search;
return true;
}