Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Alias (5735)

Alias
  (email not shown publicly)
http://ali.as/

Journal of Alias (5735)

Wednesday May 06, 2009
10:54 PM

Padre now has working single-instance support

[ #38933 ]

Now that Padre is running fast enough to well and truly keep up with my typing, I'm making another attempt to switch over and make Padre my primary editor.

As a result, I've been forced into implementing one of my shop-stopper features.

"Single Instance" support is a fairly common feature in major applications which keeps only one instance of the application running, and causes new invocations to communicate with the primary instance and open any files in the existing one, instead of spawning a new instance.

It seems simple, but implementing it involves implementing a Wx::Socket-based server inside of Padre (so that it can run in the main thread), writing a protocol for two Padre instances to talk to each other and communicate commands, and then writing a client for it into the startup sequence of Padre that talks to the server, all in a way that doesn't block for long periods of time.

To enable single-instance mode, set the flag main_singleinstance: 1 in your config.yml (by hand in the short term).

Once enabled, it should become much simpler to integrate Padre into other applications as an "external editor" so that double clicking in your version control gui or anything else that supports editor integration does the expected thing and just loads the specified file in the current Padre instance.

With single instance support out of the way, now I only need to get recursive find and replace working, and there should be no reasons left to go back to Ultraedit any more.

Single instance support should appear on the CPAN in Padre 0.35.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • It is good to see ticket:117 finished :) I think we need to focus/activate the single instance Padre if another is launched.
    • It does that too.

      An example of the command stream from the child to the server is

      open C:\project\Makefile.PL
      open C:\project\lib\Foo.pm
      focus

      The last command is sent even if there's no files to open, and triggers the single instance into bringing itself to the foreground.

  • Have you tried wxSingleInstanceChecker btw?

    http://docs.wxwidgets.org/2.8/wx_wxsingleinstancechecker.html#wxsinglein stancechecker
    • That's not really what I was looking for...

      I'd just prefer to go straight to hitting a localhost port.

  • I finally made the switch from Eclipse + EPIC to Padre this week. So far the positives are outweighing the itches which makes me happy. Really amazing how far Padre has come since YAPC::EU 2008. You guys rock.
  • Though I don't use padre myself, reading your post mention 'recursive find and replace' made me think .. would it be possible to integrate ack with padre in a simple plugin? http://search.cpan.org/~petdance/ack/ [cpan.org] more horsepower available than anything you'd write yourself, since most of the work is already done. I'm not exactly sure what feature set you're looking for but ack might fit the bill.
    • It's already there.

      I think the ack support could do with some spit and polish, but it's been part of the editor for a long time. It *should* be a plugin, though.

    • Although I appreciate ack, I'm not entirely sure if deep integration is worth it.

      It mainly hinges on how well we can deal with callbacks from Ack back into Padre, and whether the search parameter set up is clean enough.

  • I've just published the bindings for libunique to CPAN this week ( Gtk2::Unique [cpan.org]). Libunique doest exactly what you need but it works only with Gtk2 and through D-Bus (although it can default to use sockets if D-Bus is not present). This dependencies make it almost Linux/Unix exclusive. It's a pity that you can't reuse it for your project as it would have saved you a lot of troubles.

    Perhaps you could do something similar to what libunique does and provide a framework and a separate module for other wx applica