This commit is contained in:
Akash Mozumdar 2019-09-04 12:54:55 -04:00
parent 5807ad35e1
commit fc9cad5978
2 changed files with 12 additions and 15 deletions

View File

@ -8,18 +8,18 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo);
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.
Param sentenceInfo: 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)
extern "C" __declspec(dllexport) wchar_t* OnNewSentence(wchar_t* sentence, const InfoForExtension* sentenceInfo)
{
try
{
std::wstring sentenceStr(sentence);
int origLength = sentenceStr.size();
if (ProcessSentence(sentenceStr, SentenceInfo{ miscInfo }))
if (ProcessSentence(sentenceStr, SentenceInfo{ sentenceInfo }))
{
if (sentenceStr.size() > origLength) sentence = (wchar_t*)HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sentence, (sentenceStr.size() + 1) * sizeof(wchar_t));
wcscpy_s(sentence, sentenceStr.size() + 1, sentenceStr.c_str());

View File

@ -1,21 +1,18 @@
# Example Extension
Every time Textractor has a sentence of text ready,
it will call ```OnNewSentence``` on all extensions it finds sequentially,
plugging the output of ```OnNewSentence``` from the previous extension into the next extension.<br>
Every time Textractor has a sentence of text ready, it will call `ProcessSentence` on all extensions it finds sequentially (via `OnNewSentence`)
After the sentence has been processed by all extensions, it will be displayed.
# SentenceInfo
## The following properties are in ```SentenceInfo```
```"current select"```: always 0 unless the sentence is in the text thread selected by the user.<br>
```"process id"```: process id that the sentence is coming from. 0 for console and clipboard.<br>
```"text number"```: number of the current text thread. Counts up one by one as text threads are created. 0 for console, 1 for clipboard.<br>
```"text name"```: pointer to start of a wchar array of the name of the current text thread.<br>
```"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.<br>
```"this"```: context pointer used for aforementioned function.
## The following properties are in `SentenceInfo`
`"current select"`: always 0 unless the sentence is in the text thread selected by the user.<br>
`"process id"`: process id that the sentence is coming from. 0 for console and clipboard.<br>
`"text number"`: number of the current text thread. Counts up one by one as text threads are created. 0 for console, 1 for clipboard.<br>
`"text name"`: pointer to start of a wchar array of the name of the current text thread.<br>
`"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.<br>
`"this"`: context pointer used for aforementioned function.
# Notes
You just need Visual Studio with basic C++ support to compile this project.<br>
Compile targeting x86 for Textractor and x64 for Textractor64.
You just need Visual Studio with basic C++ support to compile this project.