From 52db7e6b4805b12146c7adf86ff6fc69ae0053f0 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 29 Jun 2019 15:28:12 +0530 Subject: [PATCH] update documentation --- ExampleExtension/Extension.cpp | 16 +++++++++------- ExampleExtension/ExtensionImpl.cpp | 19 ++++++++++--------- README.md | 2 ++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ExampleExtension/Extension.cpp b/ExampleExtension/Extension.cpp index 4d48adf..ad7204b 100644 --- a/ExampleExtension/Extension.cpp +++ b/ExampleExtension/Extension.cpp @@ -17,19 +17,21 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved //#define COPY_CLIPBOARD //#define EXTRA_NEWLINES -/** - * Param sentence: sentence received by Textractor (UTF-16). - * Param sentenceInfo: contains miscellaneous info about the sentence (see README). - * Return value: whether the sentence was modified. - * Textractor will display the sentence after all extensions have had a chance to process and/or modify it. - * THIS FUNCTION MAY BE RUN SEVERAL TIMES CONCURRENTLY: PLEASE ENSURE THAT IT IS THREAD SAFE! +/* + Param sentence: sentence received by Textractor (UTF-16). Can be modified, Textractor will receive this modification only if true is returned. + Param sentenceInfo: contains miscellaneous info about the sentence (see README). + Return value: whether the sentence was modified. + Textractor will display the sentence after all extensions have had a chance to process and/or modify it. + The sentence will be destroyed if it is empty or if you call Skip(). + This function may be run concurrently with itself: please make sure it's thread safe. + It will not be run concurrently with DllMain. */ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) { // Your code here... #ifdef COPY_CLIPBOARD // This example extension automatically copies sentences from the hook currently selected by the user into the clipboard. - if (sentenceInfo["current select"] == 1) + if (sentenceInfo["current select"]) { HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 2) * sizeof(wchar_t)); memcpy(GlobalLock(hMem), sentence.c_str(), (sentence.size() + 2) * sizeof(wchar_t)); diff --git a/ExampleExtension/ExtensionImpl.cpp b/ExampleExtension/ExtensionImpl.cpp index e333bd4..8decc99 100644 --- a/ExampleExtension/ExtensionImpl.cpp +++ b/ExampleExtension/ExtensionImpl.cpp @@ -2,15 +2,16 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo); -/** - * You shouldn't mess with this or even look at it unless you're certain you know what you're doing. - * Param sentence: pointer to sentence received by Textractor (UTF-16). - * This can be modified. Textractor uses the modified sentence for future processing and display. If empty (starts with null terminator), Textractor will destroy it. - * Textractor will display the sentence after all extensions have had a chance to process and/or modify it. - * The buffer is allocated using HeapAlloc(). If you want to make it larger, please use HeapReAlloc(). - * Param miscInfo: pointer to array containing misc info about the sentence. End of array is marked with name being nullptr. - * Return value: the buffer used for the sentence. Remember to return a new pointer if HeapReAlloc() gave you one. - * THIS FUNCTION MAY BE RUN SEVERAL TIMES CONCURRENTLY: PLEASE ENSURE THAT IT IS THREAD SAFE! +/* + You shouldn't mess with this or even look at it unless you're certain you know what you're doing. + Param sentence: pointer to sentence received by Textractor (UTF-16). + This can be modified. Textractor uses the modified sentence for future processing and display. If empty (starts with null terminator), Textractor will destroy it. + Textractor will display the sentence after all extensions have had a chance to process and/or modify it. + The buffer is allocated using HeapAlloc(). If you want to make it larger, please use HeapReAlloc(). + Param miscInfo: pointer to array containing misc info about the sentence. End of array is marked with name being nullptr. + Return value: the buffer used for the sentence. Remember to return a new pointer if HeapReAlloc() gave you one. + This function may be run concurrently with itself: please make sure it's thread safe. + It will not be run concurrently with DllMain. */ extern "C" __declspec(dllexport) wchar_t* OnNewSentence(wchar_t* sentence, const InfoForExtension* miscInfo) { diff --git a/README.md b/README.md index 9060e7e..149a050 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ After the sentence has been processed by all extensions, it will be displayed. ```"process id"```: process id that the sentence is coming from. 0 for console and clipboard.
```"text number"```: number of the current text thread. Counts up one by one as text threads are created. 0 for console, 1 for clipboard.
```"text name"```: pointer to start of a wchar array of the name of the current text thread.
+```"void (*AddSentence)(void* this, int64_t number, const wchar_t* sentence)"```: pointer to function that adds a sentence to the text thread with the specified number.
+```"this"```: context pointer used for aforementioned function. # Notes