autosave on focus lost
Submitted by Sunday, 24 February, 2013 - 11:35
on
Hello!
I have written an small beanshell startup script, that does save all modified buffers on jEdit focus lost. It's useful on html/css/php etc. development when you need an result of your changes frequently in other application (browser, curl-output etc.).
Since I have not found how to upload it, I just put it here as is (put it as ~/.jedit/startup/Save-On-Focus-Lost.bsh)
EditBus.addToBus(new EBComponent() { public void handleMessage(EBMessage message) { if (message instanceof EditPaneUpdate) { if(message.getWhat() == EditPaneUpdate.CREATED){ Log.log(Log.MESSAGE, BeanShell.class, "adding deactivation listener... "); myView = message.getEditPane().getView(); myView.addWindowListener(new WindowListener(){ public void windowDeactivated(WindowEvent e){ Log.log(Log.MESSAGE, BeanShell.class, "windowDeactivated event"); oppositeWindow = e.getOppositeWindow(); if(oppositeWindow == null){ Log.log(Log.MESSAGE, BeanShell.class, "application is loosing focus "); //jEdit.saveAllBuffers(myView,false); jEdit.saveAllBuffers(e.getSource(),false); } } invoke( name, args ) { }; }); Log.log(Log.MESSAGE, BeanShell.class, "success"); } } } });