Skip to content

Commit

Permalink
0.0.7
Browse files Browse the repository at this point in the history
- Use `koffi` instead of outdated `ffi-napi`.
- Fix `command 'shiftIM.debug' not found` Error.
  • Loading branch information
wangjiezhe committed Mar 20, 2024
1 parent df4b602 commit 20e19f1
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 161 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode/
node_modules/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
- Add configurations to set `WParam` and `lParam` for `WM_IME_CONTROL`
- Add `shiftIm.debug`(*Shift IM: Debug*) command which will help you set Params.

## [0.0.7]
- Fix `command 'shiftIM.debug' not found` Error.

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.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shift-im-for-math",
"displayName": "Shift IM for Math",
"description": "An extension for automatically shift IM(Input Method) mode. Make it easier to input LaTeX in VSCode.",
"version": "0.0.6",
"version": "0.0.7",
"keywords": [
"input method",
"latex",
Expand Down Expand Up @@ -83,6 +83,6 @@
"typescript": "^4.5.5"
},
"dependencies": {
"ffi-napi": "^4.0.3"
"koffi": "^2.6.6"
}
}
Binary file added shift-im-for-math-0.0.7.vsix
Binary file not shown.
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

0 comments on commit 20e19f1

Please sign in to comment.