"Chm help on selected function" by avion
Rating:









(0 votes)
| Name: | Chm help on selected function |
|---|---|
| Uploaded By: | avion |
| Date Created: | June 24, 2009 1:02 p.m. |
| Date Modified: | June 24, 2009 1:02 p.m. |
| Description: | Open chm file of current language and search for description of selected word (function) It works either with win32help extension or with keyhh.exe app (http://www.keyworks.net/keyhh.htm - 24kb) If none of above is found then fallback to windows hh which just opens the chm help file without searching.. |
| Num Views: | 444 |
| Num Downloads: | 136 |
Contents
""" Open chm file of current language and search
for description of selected word (function)
It works either with win32help extension or
with keyhh.exe app (http://www.keyworks.net/keyhh.htm - 24kb)
If none of above is found then fallback to windows hh
which just opens the chm help file without searching..
Script uses plugin.ini file for storing configuration
on language basis it should be in main app path (pn.exe),
and definition name is taken from currentscheme
Note that path slashes are inversed to prevent escaping!
example:
[python]
chm_path=C:/Python26/Doc/python262.chm
[php]
chm_path=C:/Php/Doc/php5.chm
@TODO@
-Rewrite win32help to ctype
-Add some simple gui
-Parsing directly to output window
Author: Goran Medakovic - avion @ jet-plane
"""
import pn, scintilla, os
import ConfigParser
from pypn.decorators import script
def test_import (module):
"""Check if module imports and return true, else return false"""
try :
exec('import %s' % module)
exec('del %s' % module)
except ImportError :
return False
else :
return True
@script("CHM help", "HELP")
def Help():
doc = pn.CurrentDoc()
if doc is not None:
s = scintilla.Scintilla(doc)
sch = doc.CurrentScheme
config = ConfigParser.ConfigParser()
config.read('plugin.ini')
chm_path = config.get(sch, 'chm_path', 0)
if s.SelectionEnd - s.SelectionStart < 1:
return
pn.AddOutput(sch)
if test_import('win32help'):
import win32help
win32help.HtmlHelp(0, None, win32help.HH_INITIALIZE, None)
link = win32help.HH_AKLINK()
link.indexOnFail = 1
link.keywords = s.SelText
link.url = ""
link.msgText = ""
link.msgTitle = ""
link.window = ""
win32help.HtmlHelp(0, chm_path, win32help.HH_KEYWORD_LOOKUP, link)
elif os.path.isfile(os.environ["WINDIR"]+"\keyHH.exe"):
os.popen ("keyHH.exe -#klink " + s.SelText + " " + chm_path)
else:
pn.AddOutput("win32help api and keyHH.exe not found, falling back to hh.exe")
os.popen("hh " + chm_path)