QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
-
- Posts: 5
- Joined: Wed 29 Jan, 2025 03:10
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
I've migrated to FAR from Total Commander about 10 years ago and never turned back.
But there is this one plugin (QuickSearch Extended) in Total Commander that I miss from time to time, Actually, one feature in this plugin: pinyin search.
I'm a Chinese and have lots of files with Chinese names. With this feature I can search quickly for the Chinese files I need.
Let me explain a bit. To input Chinese characters, we can use Pinyin method, that is, typing a couple of alphabets for each Chinese Character. for example, by typing "zhong guo" I'll get two Chinese characters (中国).
The beauty of this feature from QuickSearch Extended plugin is that to search for files with this two Chinese characters anywhere in the filenames, I just need to type the first letter of each character "z g" in the search and matching files will be shown.
I wish some geeks at the forum can have a look into this. Maybe it can be done for Far as well?
But there is this one plugin (QuickSearch Extended) in Total Commander that I miss from time to time, Actually, one feature in this plugin: pinyin search.
I'm a Chinese and have lots of files with Chinese names. With this feature I can search quickly for the Chinese files I need.
Let me explain a bit. To input Chinese characters, we can use Pinyin method, that is, typing a couple of alphabets for each Chinese Character. for example, by typing "zhong guo" I'll get two Chinese characters (中国).
The beauty of this feature from QuickSearch Extended plugin is that to search for files with this two Chinese characters anywhere in the filenames, I just need to type the first letter of each character "z g" in the search and matching files will be shown.
I wish some geeks at the forum can have a look into this. Maybe it can be done for Far as well?
-
- Posts: 1420
- Joined: Mon 04 Apr, 2005 13:41
- Location: San Ramon, CA / Kharkov, UA
- Has thanked: 45 times
- Been thanked: 73 times
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
As I understand it looks like there is no one to one conversion from Chinese back to Pinyin due to "tones". But if there is a map/table (one to one) from Pinyin to Chinese characters it should be feasible by creating a plugin or even by macro.
Мы не можем ждать милостей от Фара, взять их у него — наша задача! (C) Мичурин
-
- Posts: 5
- Joined: Wed 29 Jan, 2025 03:10
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
@Yegor
You're absolutely right about "tones". So when I search using only the first letter of each character, there might be a couple of matches (characters with different "tones") instead of one. but that's OK in actual use for file name searches.
In the QuickSearch Extended plugin, there is a file called tcmatch.tbl, I'm not sure if this is the mapping table. If I remember correctly, this file was actually created by Ghisler, the creator of Total Commander.
This plugin also includes the source codes, but I'm not a coder and I cannot read or understand it.
I'm attaching both the plugin files and sources files for anyone who are interested.
You're absolutely right about "tones". So when I search using only the first letter of each character, there might be a couple of matches (characters with different "tones") instead of one. but that's OK in actual use for file name searches.
In the QuickSearch Extended plugin, there is a file called tcmatch.tbl, I'm not sure if this is the mapping table. If I remember correctly, this file was actually created by Ghisler, the creator of Total Commander.
This plugin also includes the source codes, but I'm not a coder and I cannot read or understand it.
I'm attaching both the plugin files and sources files for anyone who are interested.
- Attachments
-
- QuickSearch eXtended.zip
- (3.42 MiB) Downloaded 12 times
-
- QuickSearch eXtended - source.zip
- (1.22 MiB) Downloaded 12 times
-
- Posts: 5
- Joined: Wed 29 Jan, 2025 03:10
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
I tried to peek into the source code (tcmatch.cpp) and indeed, tcmatch.tbl is the mapping table. here's the part of codes that refers to the file tcmatch.tbl.
Code: Select all
void LoadPinYinTable() {
if(TableCreated) return;
TableCreated = 1;
memset(&PinYinTable, 0, sizeof(PinYinTable));
char cName[MAX_PATH];
GetModuleFileNameA(hInst, cName, sizeof(cName) - 12);
char* cPos = strrchr(cName, '\\');
if(!cPos) return;
cPos[0] = 0;
strncat(cName, "\\tcmatch.tbl", MAX_PATH - 1);
HANDLE File = CreateFileA(cName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if(File != INVALID_HANDLE_VALUE) {
int Filesize = GetFileSize(File, 0);
DWORD bytesread;
if(Filesize == sizeof(PinYinTable)) ReadFile(File, &PinYinTable, sizeof(PinYinTable), &bytesread, 0);
CloseHandle(File);
}
}
- John Doe
- Бюрократ
- Posts: 14174
- Joined: Wed 27 Apr, 2005 20:42
- Location: github.com/FarManagerLegacy
- Has thanked: 80 times
- Been thanked: 454 times
- Contact:
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
The good news is that it's definitely possible. The challenge is that you'll have to implement it yourselves using Lua.
For example, here are a couple of possibilities:
- Integrate it into a script like PanelFilter.
- Create a menu that displays a list of files based on your custom filter logic.
I took a quick look at the C++ source code, and it seems like the implementation there isn't very straightforward either.
P.S.
The same approach can be used not only for PinYin (or Korean lead syllable) search, but for general-purpose fuzzy matching as well.
E.g. with one of the similarity search algorithms (Levenshtein distance was implemented in QuickSearch eXtended).
Edit: previously mentioned here viewtopic.php?p=156490#p156490
https://t.me/FarManager — Telegram чат
-
- Posts: 1420
- Joined: Mon 04 Apr, 2005 13:41
- Location: San Ramon, CA / Kharkov, UA
- Has thanked: 45 times
- Been thanked: 73 times
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
Here is the actual logic, but it looks like it searches by only the first 'letter' (like in your example 'z g') and it looks like it won't work if you search by 'zh gu'.
Anyway, as @John Doe said it is feasible.
Code: Select all
if(INI_use_pinyin && wcChineseKoreanChar == 0x3007) return (wcSearchChar == 'l');
else if(INI_use_pinyin && wcChineseKoreanChar >= 0x4E00 && wcChineseKoreanChar <= 0x9FA5) { // Chinese character > search pattern char contains english PinYin
LoadPinYinTable();
WORD Dbl = PinYinTable[wcChineseKoreanChar - 0x4E00];
WCHAR wcEnglishChar1 = (Dbl & 0x1F) - 1 + 'a';
WCHAR wcEnglishChar2 = ((Dbl >> 5) & 0x1F) - 1 + 'a';
WCHAR wcEnglishChar3 = ((Dbl >> 10) & 0x1F) - 1 + 'a';
int result = (wcSearchChar == wcEnglishChar1 || wcSearchChar == wcEnglishChar2 || wcSearchChar == wcEnglishChar3);
if(!result) { // there are only 3 ideographs with more than 3 spellings:
switch(wcChineseKoreanChar) {
case 0x7AD3: // qian1 fen1 zhi1 yi1 gong1 sheng1
result = (wcSearchChar == 'y' || wcSearchChar == 'g' || wcSearchChar == 's');
break;
case 0x7AD5: // shi2 fen1 zhi1 yi1 gong1 sheng1
result = (wcSearchChar == 'y' || wcSearchChar == 'g');
break;
case 0x7AE1: // yi1 gong1 sheng1 bai3 bei4
result = (wcSearchChar == 'b');
break;
}
}
return result;
Last edited by Yegor on Thu 30 Jan, 2025 00:52, edited 1 time in total.
Мы не можем ждать милостей от Фара, взять их у него — наша задача! (C) Мичурин
-
- Posts: 5
- Joined: Wed 29 Jan, 2025 03:10
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
Yes, this is more intuitive for people already familiar with PanelFilter. Or maybe integrated with Alt key search and filtering, The QuickSearch Extended is integrated into the Alt key search and filtering in Total Commander
My problem is that I just don't know how to get started. For example, how do you load this tcmatch.tbl in lua codes? The lua scripting I've done so far in FAR has always been changes or modifications on Lua scripts you guys created.
I can certainly help with testing or trouble-shooting , though, since I know Chinese.
- John Doe
- Бюрократ
- Posts: 14174
- Joined: Wed 27 Apr, 2005 20:42
- Location: github.com/FarManagerLegacy
- Has thanked: 80 times
- Been thanked: 454 times
- Contact:
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
pandaprada wrote: Thu 30 Jan, 2025 01:28 For example, how do you load this tcmatch.tbl in lua codes?
Code: Select all
local tcmatch_tbl = assert(io.open("tcmatch.tbl","rb"))
local bytes = tcmatch_tbl:read("*a")
assert(#bytes==20902*2)
local PinYinTable = {}
for i = 1, #bytes, 2 do
local b1, b2 = string.byte(bytes, i, i+1)
PinYinTable[19967+i] = b2 * 256 + b1
end
I'd make so:
- Find most relevant functions in C++ source code.
- Use DeepSeek R1 to translate it into lua code
-
- Posts: 5
- Joined: Wed 29 Jan, 2025 03:10
QuickSearch Extended plugin in Total Commander - can similar feature be implemented in FAR?
Thanks for the scode and the suggestion.
I'll give it a try.
I'll give it a try.