Reading Notes for Qian Xin

Culture, Economics, Political... after reading something on internet, i will try to write down some notes. this is the place for me to record these notes.

Saturday, March 07, 2009

Py - The Online Python Zine

Py - The Online Python Zine

Probably the most difficult part of writing macros for jEdit is learning the API. Even though jEdit's API is very well documented, there are lots of classes and methods, so getting started can be a little overwhelming. Here are some resources to get you started.

  • Read existing macros. jEdit comes with over 60 macros written in BeanShell. BeanShell is a Java-like scripting language that jEdit uses internally. Even though the syntax is different from Python, they're still a great reference. My collection of Python macros is available at http://www.rutherfurd.net/jEdit/macros/. However, I've since re-written many of them in BeanShell for inclusion with jEdit 4.2. As a result, they may not all be up-to-date with the API changes in 4.2.
  • Record macros. By default, jEdit has support for executing and recording macros in BeanShell. Though there is no support for recording macros in Python, recording and reading the generated BeanShell code is a good way to see what's going on behind the scenes. To record a temporary macro:
    1. Macros > Record Temporary Macro
    2. Do whatever (note: mouse activities aren't recorded)
    3. Macros > Stop Recording
    4. View "Temporary_Macro.bsh"
  • jEdit only keeps one temporary macro, so any existing temporary macro will be over-written when you record a new one.
  • Part III of jEdit's User's Guide is on writing macros. It assumes one is writing macros in BeanShell, but the concepts are generally applicable.
  • The jEdit API Reference in jEdit's User's Guide provides details on jEdit's API. •Subscribe to users@jedit.org or stop by #jedit on irc.freenode.net.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home