No description
Find a file
2020-10-16 01:49:07 +06:00
.github/workflows Update test.yml 2020-10-06 19:48:31 +06:00
images chore: add demo image 2020-10-12 16:33:08 +06:00
src refactor!: add contextData to add proc 2020-10-16 01:46:27 +06:00
tests refactor!: add contextData to add proc 2020-10-16 01:46:27 +06:00
.gitignore chore: add *.css to .gitignore 2020-10-06 18:59:32 +06:00
changelog.md chore: add entry for 1.2.1 2020-10-16 01:41:55 +06:00
LICENSE Initial commit 2016-05-07 17:29:02 +06:00
README.md chore: refinement of examples 2020-10-16 01:44:35 +06:00
wox.nimble chore: update version to 1.2.1 2020-10-16 01:41:28 +06:00

nim-wox

Test nim-wox

Helper library for writing Wox plugins in Nim

demo

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

Documentation

Tests

nimble tests

Changelog

Licensing

The code and documentation are released under the MIT Licence. See the bundled LICENSE file for details.