Re: Joaquin's perl scripting hacks.


Subject: Re: Joaquin's perl scripting hacks.
From: Paolo Molaro (lupus@lettere.unipd.it)
Date: Thu Apr 12 2001 - 09:04:03 CDT


On 04/12/01 Martin Sevior wrote:
> Hi Joaquin,
> Rather than try to produce a patch of this I just bundled up
> all your work into a abi-js.tar.gz tarball. You can download it from

The problem with that is that the tarball contains unrelated changes
that you or Joaquin were working on and I don't have time to clean
them up from my patch: I'll leave that to you or whoever knows this stuff
better. The point is that the perl support requires some tens of
lines of code, but the patch is bigger and messy because of the
unrelated stuff.

So, to get perl scripting to work, you'll need to apply the patch and
untar the tarball in abi/src to produce bindings/perl. Go
to src/bindings/perl and type:

$ perl Makefile.PL
$ make
$ make install

build abiword with the ABI_OPT_JS=1 option and write a script
with something like this in it:

# open an empty document
$frame = abi::XAP_Frame::openFile(undef);
$view = $frame->getCurrentView;
$view->insertData("Hello world!\n");
$view->setCharFormat("font-weight" => "bold");
$view->insertData("Yadda yadda!\n");

and then run abiword with the --script scriptfile option.
This has been tested with the vanilla Unix build, I spent some time
with the gnome build, but the build setup of abiword is so broken
and I have better things to do than fix it or flame about it:-)

The script can do anuthing, even use the perl Gtk module to create
additional user interface dialogs etc. etc.
When you run it abiword opens an additional dummy window, maybe
that should be disable when running a script, since it's annoying.

The things I did involved fixing the perl module, making it use
a more OO interface and fixing other perl embedding issues in Joaquin's
code. There are still some unfixed things (s_perlEvalFile), but I
guess Joaquin can figure out now how things work, I also added
a couple of methods to the view perl bindings (the most useful
setCharFormat) and deleted an assert that broke with the latest
spell-checking update: I guess you know if there is a better fix.

There are a couple of things that should still be done:
1) pass the defines and options used to build abiword also to the
perl module and integrate it in the build process.
2) once it's stabilized, link statically to the module (otherwise it
may have problems on weird platforms: it's ok right now as long as you
use something like Linux or Solaris).
3) add more methods: you know better than me what methods you need more,
just take the ones in abi.xs as examples. If you need advice on how
to implemented specific things in the perl binding, feel free to ask me.
4) add the code that lets add to the toolbars and menus hooks to run
perl code (you just got a powerful macro system)

Hope this helps.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better





This archive was generated by hypermail 2b25 : Thu Apr 12 2001 - 09:04:16 CDT