Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command 'shiftIM.debug' not found error #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ Upgrade from `Ultra IME for VSCode` Extension which is now deprecated.
## 📎 FAQ

- My Input Mode can not be changed.
- Execute `shiftIm.debug` command. This command will help you set Params. If it still doesn't work, please raise an issue [HERE](https://github.com/yfzhao20/Shift-IM-for-VSCode/issues).
- Execute `shiftIm.debug` command. This command will help you set Params. If it still doesn't work, please raise an issue [HERE](https://github.com/yfzhao20/Shift-IM-for-VSCode/issues).
- Not work on Remote/SSH/WSL/Docker
- Add following configuration to settings and reinstall the extension:
```json
"remote.extensionKind": {
"yfzhao.hscopes-booster": ["ui"],
"yfzhao.shift-im-for-math": ["ui"],
}
```
169 changes: 23 additions & 146 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@
"typescript": "^4.5.5"
},
"dependencies": {
"ffi-napi": "^4.0.3"
"koffi": "^2.6.6"
}
}
22 changes: 10 additions & 12 deletions src/shiftIME.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const vscode = require('vscode')
const hscopes = require('./hscopes')
const ffi = require('ffi-napi');
const koffi = require('koffi');

let cnLParam = vscode.workspace.getConfiguration().get("Settings.ChineseModeCode") ?? 1025
let enLParam = vscode.workspace.getConfiguration().get("Settings.EnglishModeCode") ?? 0
Expand Down Expand Up @@ -33,23 +33,21 @@ function activate(context) {
// win32api ////////////////////////////////////////////////

// Import user32
const user32 = new ffi.Library("user32", {
"SendMessageW": ['int32', ['long', 'int32', 'int32', 'int32']],
"GetForegroundWindow":["int32",[]]
});

const imm = new ffi.Library("imm32" ,{
"ImmGetDefaultIMEWnd": ["int32" , ["int32"]]
});
const user32 = koffi.load('user32.dll')
const imm32 = koffi.load('imm32.dll')

const GetForegroundWindow = user32.stdcall("GetForegroundWindow", "int32", [])
const SendMessageW = user32.stdcall("SendMessageW", 'int32', ['long', 'int32', 'int32', 'int32'])
const ImmGetDefaultIMEWnd = imm32.stdcall("ImmGetDefaultIMEWnd", "int32", ["int32"])

/**
* @param {number} wParam wParam for WM_IME_CONTROL
* @param {number} lParam lParam for WM_IME_CONTROL
*/
function imcController(wParam, lParam){
var hwnd = user32.GetForegroundWindow()
var defaultIMEWnd = imm.ImmGetDefaultIMEWnd(hwnd)
return user32.SendMessageW(defaultIMEWnd,0x283,wParam,lParam);
var hwnd = GetForegroundWindow()
var defaultIMEWnd = ImmGetDefaultIMEWnd(hwnd)
return SendMessageW(defaultIMEWnd,0x283,wParam,lParam);
}

// main /////////////////////////////////////////////////////
Expand Down