mirror of
https://github.com/roose/nim-wox
synced 2026-01-13 23:31:41 +00:00
No description
|
|
||
|---|---|---|
| .github/workflows | ||
| images | ||
| src | ||
| tests | ||
| .gitignore | ||
| changelog.md | ||
| LICENSE | ||
| README.md | ||
| wox.nimble | ||
nim-wox
Helper library for writing Wox plugins in Nim
Contents
Installation
nimble install wox
Usage
import browsers, json
import wox
proc query(wp: Wox, params: varargs[string]) =
# create a global Wox object
# add an item to Wox
wp.add("Github", # title
"How people build software", # subtitle
"Images\\gh.png", # icon
"", # context data, leave blank if you don't need context menu
"openUrl", # method
"https://github.com/", # method params
false # don't hide
)
# send output to Wox
echo wp.results()
proc openUrl(wp: Wox, params: varargs[string]) =
# open url in default browser
openDefaultBrowser(params[0])
when isMainModule:
var wp = newWox("http://roose.github.io/nim-wox/wox.html")
# register `query` and `openUrl` for call from Wox
wp.register("query", query)
wp.register("openUrl", openUrl)
# run called proc
wp.run()
Context menu example:
import browsers, json
import wox
proc query(wp: Wox, params: varargs[string]) =
# create a global Wox object
# add an item to Wox
wp.add("postcss", # title
"Tool for transforming style", # subtitle
"Images\\postcss.png", # icon
"https://www.npmjs.com/package/postcss", # context data
"openUrl", # method
"https://github.com/postcss/postcss", # method params
false # don't hide
)
# send output to Wox
echo wp.results()
proc contextmenu(wp: Wox, params: varargs[string]) =
# proc for context menu action
wp.add("Open npm page", # title
"", # subtitle, leave blank
"Images\\npm.png", # icon
"", # context data, leave blank
"openUrl", # method
params[0], # method params, given context data from query method
false # don't hide
)
# send output to Wox
echo wp.results()
proc openUrl(wp: Wox, params: varargs[string]) =
# open url in default browser
openDefaultBrowser(params[0])
when isMainModule:
# url for help magic action
var wp = newWox("http://roose.github.io/nim-wox/wox.html")
# register `query` and `openUrl` for call from Wox
wp.register("query", query)
wp.register("openUrl", openUrl)
# register `contextmenu` for call from Wox context menu by pressing Shift+Enter
wp.register("contextmenu", contextmenu)
# run called proc
wp.run()
Attention: newWox is generating info.png and delete.png in the Images folder(if they don't exist).
Attention #2: Wox now wrong show icons in context menu, issue
Documentation
Tests
nimble tests
Changelog
Licensing
The code and documentation are released under the MIT Licence. See the bundled LICENSE file for details.
