From 9babd5001028e4a5166da2f4e9ed5b6d2cf4f6b3 Mon Sep 17 00:00:00 2001 From: zmatsuo <6488847+zmatsuo@users.noreply.github.com> Date: Mon, 17 Jun 2024 01:01:10 +0900 Subject: [PATCH] =?UTF-8?q?TTXKanjimenuMenu=20=E3=81=AE=E3=83=A1=E3=83=8B?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=81=AE=E4=BD=9C=E6=88=90=E3=82=92=E7=B0=A1?= =?UTF-8?q?=E5=8D=98=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - メニューの順序を自由に変更できるようになった - 変更前は漢字コードの定義順にメニューを作成する必要があった - メニューの設定内に i18n 情報を追加 --- TTXKanjiMenu/ttxkanjimenu.c | 531 ++++++++++++++++-------------------- 1 file changed, 241 insertions(+), 290 deletions(-) diff --git a/TTXKanjiMenu/ttxkanjimenu.c b/TTXKanjiMenu/ttxkanjimenu.c index 7fb15782f..c6f538ea0 100644 --- a/TTXKanjiMenu/ttxkanjimenu.c +++ b/TTXKanjiMenu/ttxkanjimenu.c @@ -12,143 +12,76 @@ Tera Term by Takashi Teranishi (teranishi@rikaxp.riken.go.jp) */ +#include +#include +#include +#include + #include "teraterm.h" #include "tttypes.h" #include "tttypes_charset.h" #include "ttplugin.h" #include "tt_res.h" #include "i18n.h" - -#include -#include -#include - #include "inifile_com.h" #define IniSection "TTXKanjiMenu" #define ORDER 5000 -#define ID_MI_KANJIRECV 54009 -#define ID_MI_KANJISEND 54109 -#define ID_MI_USEONESETTING 54200 - -#define UpdateRecvMenu(val) \ - CheckMenuRadioItem(pvar->hmEncode, \ - ID_MI_KANJIRECV + IdSJIS, \ - ID_MI_KANJIRECV + IdUTF8, \ - ID_MI_KANJIRECV + (val), \ - MF_BYCOMMAND) -#define UpdateSendMenu(val) \ - CheckMenuRadioItem(pvar->hmEncode, \ - ID_MI_KANJISEND + IdSJIS, \ - ID_MI_KANJISEND + IdUTF8, \ - ID_MI_KANJISEND + (val), \ - MF_BYCOMMAND) +#define ID_MI_KANJIRECV 54010 // M/ +#define ID_MI_KANJISEND 54110 // M +#define ID_MI_USEONESETTING 54200 // Use one setting // j[ږ̏ typedef struct { - int menuID; - const char *menuStr; -} KmTextInfo; - -// MR[h ({) -static const KmTextInfo MenuNameRecvJ[] = { - { ID_MI_KANJIRECV + IdSJIS, "Recv: &Shift_JIS" }, - { ID_MI_KANJIRECV + IdEUC, "Recv: &EUC-JP" }, - { ID_MI_KANJIRECV + IdJIS, "Recv: &JIS" }, - { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, -}; - -// MR[h (؍) -static const KmTextInfo MenuNameRecvK[] = { - { ID_MI_KANJIRECV + IdSJIS, "Recv: &KS5601" }, - { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, -}; - -// MR[h ({) -static const KmTextInfo MenuNameSendJ[] = { - { ID_MI_KANJISEND + IdSJIS, "Send: S&hift_JIS" }, - { ID_MI_KANJISEND + IdEUC, "Send: EU&C-JP" }, - { ID_MI_KANJISEND + IdJIS, "Send: J&IS" }, - { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } -}; - -// MR[h (؍) -static const KmTextInfo MenuNameSendK[] = { - { ID_MI_KANJISEND + IdSJIS, "Send: K&S5601" }, - { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } -}; - -// MR[h ({) -static const KmTextInfo MenuNameOneJ[] = { - { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &Shift_JIS" }, - { ID_MI_KANJIRECV + IdEUC, "Recv/Send: &EUC-JP" }, - { ID_MI_KANJIRECV + IdJIS, "Recv/Send: &JIS" }, - { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, -}; - -// MR[h (؍) -static const KmTextInfo MenuNameOneK[] = { - { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &KS5601" }, - { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, -}; - -// j[̂̍ۉp ({) -static DlgTextInfo MenuTitleInfoJ[] = { - { -1, "MENU_KANJI" } -}; - -// j[̂̍ۉp (؍) -static DlgTextInfo MenuTitleInfoK[] = { - { -1, "MENU_KANJI_K" } + UINT id; // j[ID + ULONG_PTR data; // f[^ + const wchar_t *default_text; // eLXg + const char *key; // L[ +} MenuInfo; + +// ʊR[h ({) +static const MenuInfo MenuNameRecvJ[] = { + { ID_MI_KANJIRECV + 0, IdSJIS, L"Recv: &Shift_JIS", "MENU_RECV_SJIS" }, + { ID_MI_KANJIRECV + 1, IdEUC, L"Recv: &EUC-JP", "MENU_RECV_EUCJP" }, + { ID_MI_KANJIRECV + 2, IdJIS, L"Recv: &JIS", "MENU_RECV_JIS" }, + { ID_MI_KANJIRECV + 3, IdUTF8, L"Recv: &UTF-8", "MENU_RECV_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_KANJISEND + 0, IdSJIS, L"Send: S&hift_JIS", "MENU_SEND_SJIS" }, + { ID_MI_KANJISEND + 1, IdEUC, L"Send: EU&C-JP", "MENU_SEND_EUCJP" }, + { ID_MI_KANJISEND + 2, IdJIS, L"Send: J&IS", "MENU_SEND_JIS" }, + { ID_MI_KANJISEND + 3, IdUTF8, L"Send: U&TF-8", "MENU_SEND_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_USEONESETTING, 0, L"Use &one setting", "MENU_USE_ONE_SETTING" }, }; -// j[̊eڂ̍ۉp (M/{) -static const DlgTextInfo MenuInfoSeparateJ[] = { - // M - { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_SJIS" }, - { ID_MI_KANJIRECV + IdEUC, "MENU_RECV_EUCJP" }, - { ID_MI_KANJIRECV + IdJIS, "MENU_RECV_JIS" }, - { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, - // M - { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_SJIS" }, - { ID_MI_KANJISEND + IdEUC, "MENU_SEND_EUCJP" }, - { ID_MI_KANJISEND + IdJIS, "MENU_SEND_JIS" }, - { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, - // UseOneSetting - { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +// 󓯊R[h ({) +static const MenuInfo MenuNameOneJ[] = { + { ID_MI_KANJIRECV + 0, IdSJIS, L"Recv/Send: &Shift_JIS", "MENU_SJIS" }, + { ID_MI_KANJIRECV + 1, IdEUC, L"Recv/Send: &EUC-JP", "MENU_EUCJP" }, + { ID_MI_KANJIRECV + 2, IdJIS, L"Recv/Send: &JIS", "MENU_JIS" }, + { ID_MI_KANJIRECV + 3, IdUTF8, L"Recv/Send: &UTF-8", "MENU_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_USEONESETTING, 0, L"Use &one setting", "MENU_USE_ONE_SETTING" }, }; -// j[̊eڂ̍ۉp (M/؍) -static const DlgTextInfo MenuInfoSeparateK[] = { - // M - { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_KS5601" }, - { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, - // M - { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_KS5601" }, - { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, - // UseOneSetting - { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +// ʊR[h (؍) +static const MenuInfo MenuNameRecvK[] = { + { ID_MI_KANJIRECV + 0, IdKoreanCP949, L"Recv: &KS5601", "MENU_RECV_KS5601" }, + { ID_MI_KANJIRECV + 1, IdUTF8, L"Recv: &UTF-8", "MENU_RECV_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_KANJISEND + 0, IdKoreanCP949, L"Send: K&S5601", "MENU_SEND_KS5601" }, + { ID_MI_KANJISEND + 1, IdUTF8, L"Send: U&TF-8", "MENU_SEND_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_USEONESETTING, 0, L"Use &one setting", "MENU_USE_ONE_SETTING" }, }; -// j[̊eڂ̍ۉp (Mʎ/{) -static const DlgTextInfo MenuInfoOneJ[] = { - // M - { ID_MI_KANJIRECV + IdSJIS, "MENU_SJIS" }, - { ID_MI_KANJIRECV + IdEUC, "MENU_EUCJP" }, - { ID_MI_KANJIRECV + IdJIS, "MENU_JIS" }, - { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, - // UseOneSetting - { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } -}; - -// j[̊eڂ̍ۉp (Mʎ/؍) -static const DlgTextInfo MenuInfoOneK[] = { - // M - { ID_MI_KANJIRECV + IdSJIS, "MENU_KS5601" }, - { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, - // UseOneSetting - { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +// 󓯐MR[h (؍) +static const MenuInfo MenuNameOneK[] = { + { ID_MI_KANJIRECV + 0, IdKoreanCP949, L"Recv/Send: &KS5601", "MENU_KS5601" }, + { ID_MI_KANJIRECV + 1, IdUTF8, L"Recv/Send: &UTF-8", "MENU_UTF8" }, + { 0, 0, NULL, NULL }, + { ID_MI_USEONESETTING, 0, L"Use &one setting", "MENU_USE_ONE_SETTING" }, }; static HANDLE hInst; /* Instance handle of TTX*.DLL */ @@ -162,6 +95,8 @@ typedef struct { PWriteIniFile origWriteIniFile; BOOL UseOneSetting; BOOL NeedResetCharSet; + const MenuInfo *menu_info_ptr; + size_t menu_info_count; } TInstVar; static TInstVar *pvar; @@ -169,6 +104,118 @@ static TInstVar *pvar; /* WIN32 allows multiple instances of a DLL */ static TInstVar InstVar; +/** + * j[쐬 + */ +static void CreateMenuInfo(HMENU hMenu, const MenuInfo *infos, size_t count, + const wchar_t *UILanguageFile, const char *section) +{ + size_t i; + for (i = 0; i < count; i++) { + const MenuInfo *p = &infos[i]; + + if (p->id != 0) { + const char *key = p->key; + const wchar_t *def_text = p->default_text; + + wchar_t *uimsg; + GetI18nStrWW(section, key, def_text, UILanguageFile, &uimsg); + + MENUITEMINFOW mi = {0}; + mi.cbSize = sizeof(mi); + mi.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; + mi.fType = MFT_STRING; + mi.wID = p->id; + mi.dwTypeData = uimsg; + mi.dwItemData = p->data; + InsertMenuItemW(hMenu, ID_HELPMENU, FALSE, &mi); + free(uimsg); + } + else { + AppendMenuA(hMenu, MF_SEPARATOR, 0, NULL); + } + } +} + +/** + * hMenũj[ڂׂč폜 + */ +static void DeleteMenus(HMENU hMenu) +{ + // counťj[폜Ƃׂď + size_t i; + for (i = 0; i < 100; i++) { + // ԏ̍ڂ폜 + BOOL r = DeleteMenu(hMenu, 0, MF_BYPOSITION); + if (r == FALSE) { + // s = ׂĂ̍ڂ폜 + return; + } + } +} + +static void CheckMenu(HMENU hMenu, const MenuInfo *info_ptr, size_t info_count, BOOL send, int code) +{ + int start = 0; + int end = 0; + size_t i; + + for (i = 0; i < info_count; i++) { + const MenuInfo *p = &info_ptr[i]; + const int id = p->id; + if ((send == FALSE && (ID_MI_KANJIRECV <= id && id < ID_MI_KANJISEND)) || + (send == TRUE && (ID_MI_KANJISEND <= id && id < ID_MI_USEONESETTING))) { + start = p->id; + break; + } + } + + i = info_count; + do { + i--; + const MenuInfo *p = &info_ptr[i]; + const int id = p->id; + if ((send == FALSE && (ID_MI_KANJIRECV <= id && id < ID_MI_KANJISEND)) || + (send == TRUE && (ID_MI_KANJISEND <= id && id < ID_MI_USEONESETTING))) { + end = p->id; + break; + } + } while (i > 0); + + int target_id = 0; + for (i = 0; i < info_count; i++) { + const MenuInfo *p = &info_ptr[i]; + const int id = p->id; + if ((send == FALSE && (ID_MI_KANJIRECV <= id && id < ID_MI_KANJISEND)) || + (send == TRUE && (ID_MI_KANJISEND <= id && id < ID_MI_USEONESETTING))) { + if (p->data == code) { + target_id = id; + break; + } + } + } + + CheckMenuRadioItem(hMenu, start, end, target_id, MF_BYCOMMAND); +} + +/** + * M/̃`FbN + */ +static int UpdateRecvMenu(int val) +{ + CheckMenu(pvar->hmEncode, pvar->menu_info_ptr, pvar->menu_info_count, FALSE, val); + return 1; +} + +/** + * M̃`FbN + */ +static int UpdateSendMenu(int val) +{ + CheckMenu(pvar->hmEncode, pvar->menu_info_ptr, pvar->menu_info_count, TRUE, val); + return 1; +} + /* * */ @@ -259,11 +306,11 @@ static void PASCAL TTXKanjiMenuReadIniFile(const wchar_t *fn, PTTSet ts) { else { pvar->UseOneSetting = TRUE; // UseOneSetting on ̏ꍇ́AMݒ肪ɂȂ悤ɒ - if (pvar->ts->Language == IdJapanese) { - pvar->ts->KanjiCodeSend = pvar->ts->KanjiCode; - } - else if (pvar->ts->Language == IdKorean) { + switch (pvar->ts->Language){ + case IdJapanese: + case IdKorean: pvar->ts->KanjiCodeSend = pvar->ts->KanjiCode; + break; } } return; @@ -291,78 +338,6 @@ static void PASCAL TTXGetSetupHooks(TTXSetupHooks *hooks) { *hooks->WriteIniFile = TTXKanjiMenuWriteIniFile; } -/* - * ID̎qƒj[̈ʒuԂ - */ -static int GetMenuPosByChildId(HMENU menu, UINT id) { - UINT i, j, items, subitems, cur_id; - HMENU m; - - items = GetMenuItemCount(menu); - - for (i=0; its->Language == IdJapanese) { - for (i = 0; i < _countof(MenuNameSendJ); i++) { - InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, - MenuNameSendJ[i].menuID, MenuNameSendJ[i].menuStr); - } - } - else { // IdKorean - for (i = 0; i < _countof(MenuNameSendK); i++) { - InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, - MenuNameSendK[i].menuID, MenuNameSendK[i].menuStr); - } - } - - InsertMenu(menu, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); -} - -/* - * MR[hݒp̃j[ڂ폜 - * - * UseOneSetting on ɂꂽɌĂ΂ - */ -static void DeleteSendKcodeMenu(HMENU menu) { - int i; - - if (pvar->ts->Language == IdJapanese) { - for (i=0; i < _countof(MenuNameSendJ); i++) { - DeleteMenu(menu, MenuNameSendJ[i].menuID, MF_BYCOMMAND); - } - // Mj[̒ɗLZp[^폜 - DeleteMenu(menu, _countof(MenuNameRecvJ), MF_BYPOSITION); - } - else { // IdKorean - for (i=0; i < _countof(MenuNameSendK); i++) { - DeleteMenu(menu, MenuNameSendK[i].menuID, MF_BYCOMMAND); - } - // Mj[̒ɗLZp[^폜 - DeleteMenu(menu, _countof(MenuNameRecvK), MF_BYPOSITION); - } -} - /* * j[ڂ̍XV * @@ -373,103 +348,75 @@ static void DeleteSendKcodeMenu(HMENU menu) { * ʏ 1 Őݒ肵ږ 2 ŏ㏑XV邪Alng t@Cݒ肳ĂȂA * ܂ lng t@CɃj[ږ܂܂ĂȂꍇւ̑ΉƂ 1 sĂB */ -static void UpdateMenuCaption(HMENU menu, BOOL UseOneSetting) { -#define doUpdateMenu(nameInfo, i18nInfo) { \ - UINT i, id; \ - for (i=0; i < _countof(nameInfo); i++) { \ - id = (nameInfo)[i].menuID; \ - ModifyMenu(menu, id, MF_BYCOMMAND, id, (nameInfo)[i].menuStr); \ - } \ - SetI18nMenuStrsW(menu, IniSection, i18nInfo, _countof(i18nInfo), pvar->ts->UILanguageFileW); \ -} +static void UpdateMenu(HMENU menu, BOOL UseOneSetting) +{ + const MenuInfo *menu_info_ptr; + size_t menu_info_count; - if (pvar->ts->Language == IdJapanese) { + switch (pvar->ts->Language) { + case IdJapanese: if (UseOneSetting) { - doUpdateMenu(MenuNameOneJ, MenuInfoOneJ); + menu_info_ptr = MenuNameOneJ; + menu_info_count = _countof(MenuNameOneJ); } else { - doUpdateMenu(MenuNameRecvJ, MenuInfoSeparateJ); + menu_info_ptr = MenuNameRecvJ; + menu_info_count = _countof(MenuNameRecvJ); } - } - else { // IdKorean + break; + case IdKorean: if (UseOneSetting) { - doUpdateMenu(MenuNameOneK, MenuInfoOneK); + menu_info_ptr = MenuNameOneK; + menu_info_count = _countof(MenuNameOneK); } else { - doUpdateMenu(MenuNameRecvK, MenuInfoSeparateK); + menu_info_ptr = MenuNameRecvK; + menu_info_count = _countof(MenuNameRecvK); } + break; + default: + assert(FALSE); + return; } + + pvar->menu_info_ptr = menu_info_ptr; + pvar->menu_info_count = menu_info_count; + + CreateMenuInfo(menu, menu_info_ptr, menu_info_count, pvar->ts->UILanguageFileW, IniSection); } /* * This function is called when Tera Term creates a new menu. */ -static void PASCAL TTXModifyMenu(HMENU menu) { +static void PASCAL TTXModifyMenu(HMENU menu) +{ + MENUITEMINFOW mi = {0}; + wchar_t *uimsg; // ꂪ{܂͊؍̎̂݃j[ɒlj if (pvar->ts->Language != IdJapanese && pvar->ts->Language != IdKorean) { return; } - { - MENUITEMINFO mi; - int pos, i; - - pvar->hmEncode = CreateMenu(); + pvar->hmEncode = CreateMenu(); - // Windows 95 Ńj[\Ȃ̂Ńo[W`FbN (2009.2.18 maya) - if (IsWindows2000OrLater()) { - memset(&mi, 0, sizeof(MENUITEMINFO)); - mi.cbSize = sizeof(MENUITEMINFO); - } - else { - memset(&mi, 0, sizeof(MENUITEMINFO)-sizeof(HBITMAP)); - mi.cbSize = sizeof(MENUITEMINFO)-sizeof(HBITMAP); - } - mi.fMask = MIIM_TYPE | MIIM_SUBMENU; - mi.fType = MFT_STRING; - mi.hSubMenu = pvar->hmEncode; - - if (pvar->ts->Language == IdJapanese) { - mi.dwTypeData = "&KanjiCode"; - } - else { // IdKorean - mi.dwTypeData = "Coding(&K)"; - } - InsertMenuItem(menu, ID_HELPMENU, FALSE, &mi); - - if (pvar->ts->Language == IdJapanese) { - for (i = 0; i < _countof(MenuNameRecvJ); i++) { - AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvJ[i].menuID, MenuNameRecvJ[i].menuStr); - } - } - else { // IdKorean - for (i = 0; i < _countof(MenuNameRecvK); i++) { - AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvK[i].menuID, MenuNameRecvK[i].menuStr); - } - } - - AppendMenu(pvar->hmEncode, MF_SEPARATOR, 0, NULL); - AppendMenu(pvar->hmEncode, MF_STRING, ID_MI_USEONESETTING , "Use &one setting"); - - if (!pvar->UseOneSetting) { - InsertSendKcodeMenu(pvar->hmEncode); - } - - pos = GetMenuPosByChildId(menu, ID_MI_KANJIRECV + IdSJIS); - - if (pos > 0) { - if (pvar->ts->Language == IdJapanese) { - MenuTitleInfoJ->nIDDlgItem = pos; - SetI18nMenuStrsW(menu, IniSection, MenuTitleInfoJ, _countof(MenuTitleInfoJ), pvar->ts->UILanguageFileW); - } - else { - MenuTitleInfoK->nIDDlgItem = pos; - SetI18nMenuStrsW(menu, IniSection, MenuTitleInfoK, _countof(MenuTitleInfoK), pvar->ts->UILanguageFileW); - } - } - - UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); + if (pvar->ts->Language == IdJapanese) { + GetI18nStrWW(IniSection, "MENU_KANJI", L"&KanjiCode", pvar->ts->UILanguageFileW, &uimsg); } + else { // IdKorean + GetI18nStrWW(IniSection, "MENU_KANJI_K", L"Coding(&K)", pvar->ts->UILanguageFileW, &uimsg); + } + + // TODO + // Windows 9x ł ANSI APIg悤ɂ + mi.cbSize = sizeof(mi); + mi.fMask = MIIM_TYPE | MIIM_SUBMENU; + mi.fType = MFT_STRING; + mi.hSubMenu = pvar->hmEncode; + mi.dwTypeData = uimsg; + InsertMenuItemW(menu, ID_HELPMENU, FALSE, &mi); + free(uimsg); + + UpdateMenu(pvar->hmEncode, pvar->UseOneSetting); } @@ -493,42 +440,44 @@ static void PASCAL TTXModifyPopupMenu(HMENU menu) { static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) { WORD val; - if ((cmd > ID_MI_KANJIRECV) && (cmd <= ID_MI_KANJIRECV+IdUTF8)) { - val = cmd - ID_MI_KANJIRECV; - pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; - if (pvar->UseOneSetting) { + if ((cmd >= ID_MI_KANJIRECV) && (cmd < ID_MI_USEONESETTING)) { + MENUITEMINFOW mi = {0}; + mi.cbSize = sizeof(mi); + mi.fMask = MIIM_DATA | MIIM_ID; + BOOL r = GetMenuItemInfoW(pvar->hmEncode, cmd, FALSE, &mi); + assert(r != FALSE); (void)r; + val = (WORD)mi.dwItemData; // j[̊R[h + + if (cmd < ID_MI_KANJISEND) { + if (pvar->UseOneSetting) { + // R[h + pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; + pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; + } + else { + // MR[h + pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; + } + } + else { + // MR[h pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; } CallResetCharSet(hWin); return UpdateRecvMenu(pvar->ts->KanjiCode)?1:0; } - else if ((cmd > ID_MI_KANJISEND) && (cmd <= ID_MI_KANJISEND+IdUTF8)) { - val = cmd - ID_MI_KANJISEND; - pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; - if (pvar->UseOneSetting) { - pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; - CallResetCharSet(hWin); - return UpdateRecvMenu(pvar->ts->KanjiCode)?1:0; - } - else { - CallResetCharSet(hWin); - return UpdateSendMenu(pvar->ts->KanjiCodeSend)?1:0; - } - } else if (cmd == ID_MI_USEONESETTING) { if (pvar->UseOneSetting) { pvar->UseOneSetting = FALSE; - InsertSendKcodeMenu(pvar->hmEncode); } else { pvar->UseOneSetting = TRUE; val = pvar->ts->KanjiCode; pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; - - DeleteSendKcodeMenu(pvar->hmEncode); } - UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); + DeleteMenus(pvar->hmEncode); + UpdateMenu(pvar->hmEncode, pvar->UseOneSetting); return 1; } @@ -561,7 +510,9 @@ static TTXExports Exports = { TTXModifyPopupMenu, TTXProcessCommand, NULL, // TTXEnd, - NULL // TTXSetCommandLine + NULL, // TTXSetCommandLine + NULL, // TTXOpenFile + NULL, // TTXCloseFile }; BOOL __declspec(dllexport) PASCAL TTXBind(WORD Version, TTXExports *exports) {