Menu

#976 Event for scripts

3.1
closed-fixed
None
5
2014-04-14
2014-03-23
No

From Briac:

You can now have sub-folders in your script corresponding to different events in OmT, and the application will run the scripts in these folders each time the event occurs.
There are currently five events supported, the "application_start" event is not working because the application has already started when the scripting engine is available. Some of these events add new binding to the script.
Here is a summary of each event :
• new_word : called when a a new word is edited in the Editor window. The new word is available with "newWord".
• project_changed : called when the state of the project changes. An "eventType" object is binded and can take the following values: CLOSE, COMPILE, CREATE, LOAD, SAVE
• entry_activated : called when editing a new segment. The segment is in the "newEntry" binding.
• new_file : called when the editor switches to the next file in the project. The new filename is in the "activeFileName" binding.
• application_shutdown : called before OmT is closed
All of the folders are of course optional, but for the moment, you can't deactivate a script inside OmegaT.
You can move it elsewhere or rename it with a non-script extension to disable it though.
If there is more than one script in the folder, it will execute them all but the order is not guaranteed.

Didier

Discussion

  • Didier Briel

    Didier Briel - 2014-03-23
    • Group: 3.0 --> 3.1
     
  • Didier Briel

    Didier Briel - 2014-03-23

    Implemented in SVN (/trunk).

    Didier

     
  • Didier Briel

    Didier Briel - 2014-03-26

    New comment from Briac:

    A word of warnings for the scripted events : Remember that they also fire when you are executing other scripts. That means
    that on a large project, an "entry_activated" script will be called a lot of time when using a search/replace type of script that loops through all the segments, rendering the application unresponsive.

     
    • Samuel Murray

      Samuel Murray - 2016-09-30

      Is it possible (or would it be) for a script (e.g. the looping script) to contain a line that disables other scripts (e.g. by name or by wildcards), either entirely while that script runs or only at certain points in the script?

       
      • Briac Pilpré

        Briac Pilpré - 2016-10-01

        Sorry, it is not currently possible to disable/enable event scripts. Feel free to create an new RFE for this feature, I'll try to have a look at how it could be achieved.

         
  • Didier Briel

    Didier Briel - 2014-04-14
    • status: open-fixed --> closed-fixed
     
  • Didier Briel

    Didier Briel - 2014-04-14

    Implemented in the released version 3.1.0 of OmegaT.

    Didier

     

Log in to post a comment.