Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
thlstsul committed Jun 14, 2024
1 parent 0ec5943 commit 4ff6c29
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
``` ahk
!j:: {
; 反格式化JSON字符串
^j:: {
A_Clipboard := ""
Send "^c"
ClipWait
deprettify()
Send "^v"
}
PJ_PATH := "json_prettier.dll"
JsonPrettier := DllCall("LoadLibrary", "Str", PJ_PATH, "Ptr")
prepare_proc := DllCall("GetProcAddress", "Ptr", JsonPrettier, "AStr", "prepare", "Ptr")
prettify_proc := DllCall("GetProcAddress", "Ptr", JsonPrettier, "AStr", "prettify", "Ptr")
deprettify_proc := DllCall("GetProcAddress", "Ptr", JsonPrettier, "AStr", "deprettify", "Ptr")
OnClipboardChange clip_changed
clip_changed(clip_type) {
if 1 = clip_type {
prettify_with_clip_changed()
prettify()
}
}
prettify_with_clip_changed() {
prettify() {
global prettify_proc
str := A_Clipboard
str := StrReplace(str, '`r`n')
Expand All @@ -38,4 +41,18 @@ prettify_with_clip_changed() {
ToolTip ; Turn off the tip.
}
}
deprettify() {
global deprettify_proc
str := A_Clipboard
required_bytes := StrPut(str, "UTF-8")
json_utf8 := Buffer(required_bytes, 0)
StrPut(str, json_utf8, "UTF-8")
depretty_json_utf8 := Buffer(required_bytes, 0)
ToolTip "deprettify json..."
ran := DllCall(deprettify_proc, "Ptr", json_utf8, "Ptr", depretty_json_utf8, "Int")
SendText StrGet(depretty_json_utf8, ran, "UTF-8")
ToolTip ; Turn off the tip.
}
```

0 comments on commit 4ff6c29

Please sign in to comment.