int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { AiksaurusApp theApp; theApp.setInstance( hInstance ); if( szCmdLine ) theApp.setLookup( szCmdLine ); theApp.initialize(); return 0; }
// // 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; }