From 2424d6f6263f351105076195e168a7d65bbfe49c Mon Sep 17 00:00:00 2001 From: PEMessage <1165739182@qq.com> Date: Wed, 7 Jun 2023 01:37:19 +0800 Subject: [PATCH] Add [Method]-[Mod] Option --- src/im-select-imm.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/im-select-imm.cpp b/src/im-select-imm.cpp index db1cc18..df34798 100644 --- a/src/im-select-imm.cpp +++ b/src/im-select-imm.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -#include +#include +#include #include #include @@ -55,11 +56,30 @@ int main(int argc, char** argv) if (argc == 1) { int imID = getInputMethod(); int imMode = getInputMode(); - printf("%d %d\n", imID,imMode); + printf("%d-%d\n", imID,imMode); } else if( argc == 2 ) { - int locale = atoi(argv[1]); - switchInputMethod(locale); + char *dash_p = strchr(argv[1],'-'); + if(dash_p){ + // im-select-imm [Method]-[Mode] + char locale_str[16]; + memccpy(locale_str,argv[1],'-',sizeof locale_str); + locale_str[dash_p-argv[1]] = '\0'; + + int locale = atoi(locale_str); + + LRESULT locale_mode = atoi(dash_p + 1); + switchInputMethod(locale); + switchInputMode(locale_mode); + + + } else { + // Old: im-select [Method] + int locale = atoi(argv[1]); + switchInputMethod(locale); + } + } else { + // im-select-imm [Method] [Mode] int locale = atoi(argv[1]); LRESULT locale_mode = atoi(argv[2]); switchInputMethod(locale);