jEdit Community - Resources for users of the jEdit Text Editor
autosave on focus lost
Submitted by dmol on Sunday, 24 February, 2013 - 11:35
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");
         }
      }
    }
});
User login
Browse archives
« March 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82338
Context Free Art (*.cfdg)   0.31   46042
JBuilder scheme   .001   18486
BBEdit scheme   1.0   18107
ColdFusion scheme   1.0   18015
R Edit Mode - extensive version   0.1   17461
Advanced HTML edit mode   1.0   16194
Matlab Edit Mode   1.0   16056
jEdit XP icons   1.0   15220
XP icons for jEdit   1.1   14281