Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - alex

Pages: 1 [2] 3 4 5
16
Scripting, Scripts and Macros / Word Count
« on: January 03, 2013, 01:13:11 am »
Word Count plug-in added to repository.
More details on wiki. Questions are here ;)

Useful if you often need to prepare small texts, for which you need to know word count.

17
Scripting, Scripts and Macros / Shortkeys
« on: January 03, 2013, 12:47:21 am »
Shortkeys plugin is published. More details on wiki.
Look if you edit source in C++, C, PHP or JavaScript.

18
Add-ons, Tools, Plugins / JS Beautifier
« on: November 07, 2012, 08:10:49 pm »
New JS Beautifier plugin is published in online repository.
Details can be found on wiki: JS Beautifier plugin.

And here you can leave your comments and suggestions ;)

19
Hi all,

because now we have Wiki, I have copied some of the topics there.
And in some cases, I have DELETED the ORIGINAL, to not have synchronization problems further.

So, if something is missing - check Wiki. From now on this is main source for structured information about HippoEDIT.

Best regards,
Alex.

20
General Discussion / HippoEDIT Wiki
« on: July 31, 2012, 01:29:42 am »
Hi All,

HippoEDIT now got an own Wiki (based on docuWiki).
Of course it rather empty still, and some stuff is still raw (only content from HippoEDIT Help and some FAQ pages from forum), but I will try to fill as far as I get time or request.
Also will try to move FAQ topics completely from Forum to Wiki.

Contributors are welcome. Your contribution will be paid by Free license.

I have already placed links to Wiki on forum (in menu line) and on HippoEDIT web site.
Another plan is to replace installed chm help by its web version, to keep help always up to date (> 1.50).

BR, Alex.

21
Scripting, Scripts and Macros / List Output
« on: June 18, 2012, 09:01:22 pm »
From latest 1.50 it is possible to use list output in addition to standard text output.
As from scripting as from rich (binary) plug-ins. Useful if you want to output some structured information but do not want to take care about new UI.

Some image of usages:




Script for testing attached.

22
Recently I had a time to check what is possible with Zen Coding integration in HippoEDIT and end up with more a less complete implementation.
What is supported:
- all Zen Coding commands
ila_rendered
- Zen Coding sesstings can be found in Tools->Options->Plugins->Zen Coding
ila_rendered
- Zen Coding abbreviations and snippets are now reigstered as script templates and suggested in Code Hints and also shown in Code Compleation list (if enabled to show Code Templates there)
ila_rendered
ila_rendered

Assigning of the shortcuts to Zen Coding commands goes in standard way: Tools->Options->Keyboard Settings and filter by "ZenCoding".
In the package attached (zen_coding.zip) three main files, which control wrap Zen Coding for HippoEDIT:
- zen_editor.js : main helper object with HippoEDIT related edit functionality used by Zen Coding
- zen_file.js : file related functionality (needed for some commands as "Update Image Size" )
- zen_main.hejs : HippoEDIT plugin file, that does all UI stuff and register handlers (menu creation, commands creation, code template registration etc)
- directory /core contains Zen Coding code, which can be easy updated with newest version from Zen Coding web site, if needed (contains original files from here).

To install plugin, just unpack it somewhere and call zen_main.hejs, by Execute... from Tools or by opening it and Execute zen_main.hejs.
To uninstall -> Tools->Options->Plugins-> and uncheck zen_main.hejs

For more information go to Zen Coding site:
http://code.google.com/p/zen-coding/

For details about integration, you can ask here.

Best regards,
Alex.

23
Scripting, Scripts and Macros / Google Translate for HippoEDIT
« on: March 16, 2012, 04:38:18 am »
Here is one more script plug-in for HippoEDIT. You need to have version 1.50.760 to have all working.

Screenshots:

New button for translation for toolbar (shortcut for command can be assigned in standard way, search for Google in Keyboard settings)


QuickInfo tooltip with translation and additional info


Settings for the plugin:


And plugin file is attached.

24
Scripting, Scripts and Macros / Macro-Script Converter
« on: February 29, 2012, 09:56:26 pm »
During design of macro recording in HippoEDIT it was rather hard to select format for storing of the macro steps between sessions.
It was very tempting to merge the macro serialization language and scripting, but after some thoughts and checks I have end up in xml serialization.

Why I did so:
- when selecting of the scripting language for serialization which to take? HippoEDIT supports several languages: JavaScript, VB Script (by default), PHP, Perl, ActionScript (with additional engines for Active Scripting). Shell I did a special setting to select language for storing or ask every time? If I can serialize to known languages, but what to do if would be installed not known scripting language: syntax for every language different?
- where to serialize between session, should be stored in workspace, ideally, but than script  should be escaped to be stored as XML CDATA etc.
- if script would be modified, how to handle special macro play features (till document end, stop if search fails). It is rather complex to handle for ordinary script.

So, because of mentioned problems, I have decided to use xml format for storing of macros. XML serialization is "native" for HippoEDIT, fit good for workspace saving, and XML serialization format does not allow so big flexibility, which can be achieved with scripting, so HE can control macro execution better.

But still I want to have the way to get a script from a macro ;) And this was solved by special Macro Converting script. It can be written in any scripting language, supported by HE (Active Scripting) and does translating of stored macro steps into desired scripting language. So, this make it possible to extend HE with converters in any scripting language, the code is open and can be modified, and feature can be added only if you need it, by installing script-plugin.

Disadvantages:
Macro converted to a script, could not be converted back. There are some limitations during conversion from macro to script.

The Macro to JavaScript converter attached toe the post. To install it, just place file some where and call it from Tool->Execute... If succeeded, you will see Convert to JavaScript... under Macro menu.
Uninstall as other script plugin, Tools->Options->Plugins and uncheck converter scritpt.

25
This example shows how to extend HippoEDIT with syntax specific functionality. Explicitly create small helpers for HTML editing, and call/access with shortcut, with toolbar button and menu.
More detailed description about api and scripting syntax can be found here and here. In this topic just an example.


Code: Javascript
  1. var nIconLink = Application.RegisterIconString(
  2. 'R0lGODlhEAAQALMAAFVVVcLCwpmZmX5+fu/v79fX12lpaWZmZoyMjOTk5KKiovT09MzMzN3d3f// \
  3. /wAAACH5BAEHAA4ALAAAAAAQABAAAARM0MlJq704680nU6DCSF84BsKiLkKArmyAEAgihKFQ00Mz \
  4. OIgFYUhYIBy9gYFhaB6e0ObSoDgUEonCAWTFahUOAWAMEEjEZHNnzW5bIgA7'
  5. );
  6.  
  7. Application.AddScriptInfo("HTML Tools", "1.0.0.0", "HTML Tools for HippoEDIT", "HippoEDIT", "[email protected]", "http://www.hippoedit.com");
  8.  
  9. function onInsertLink()
  10. {
  11.         var dialog_template =
  12.         '@<dialog title="Insert Link" resizing="horizontal" modal="false" id="insert_link"> \
  13.            <image> \
  14.                 R0lGODlhMAAwALMAALm5ub29veXl5czMzO7u7tjY2MbGxvb29tzc3P///wAAAAAAAAAAAAAAAAAA \
  15.                 AAAAACH5BAEHAAkALAAAAAAwADAAAAT/MMlJq7046827/1phAEFxgOhFBEDbBkQqJ6trwzNYt0Zx \
  16.                 xznODlCQCH5BzbA4ObpwScvS4nydopPppQoYYCVaDPcbzvha2LLZhR21mJuqN1mFa7jA4OBFEYht \
  17.                 flF7JBM+BlSAX4OHCWcAgUaJX0eMjgF9kl8JCBKWeVyQmp1Pn5k5BHmFpE2mKQcFLCSQngkCBm4t \
  18.                 oSkCsS6Vq1y5QcEAvy8xBDbCOVwDCHO0RgMBAybDNnbRorXYFNqiXHYIwLp03RTAxZrhiDhVV+Yu \
  19.                 dhR5jqkz7ByDAFEHvfMYHM0J4gjgBUcA7slww2gDwnIyfHF4+AUXRFUuLsqgeLBVEn8eJ0Fto9Hr \
  20.                 EaaMI8GUDCQypUps+0y6zFLSo8shKGdK2TdAoc6fQFNEAAA7 \
  21.            </image> \
  22.            <columnbreak/> \
  23.            <group> \
  24.                    <paragraph text="Path:" minwidth="6" style="required" align="left"/> \
  25.                    <edit id="url" cuebanner="Enter here url (required)" autocomplete="url" minwidth="25" required="true"/> \
  26.                    <file_browser filter="All files (*.*)|*.*|HTML Files (*.html)|*.html||" align="right"/> \
  27.            </group> \
  28.            <group> \
  29.                    <paragraph text="Title:" minwidth="6" align="left"/> \
  30.                    <edit id="title" cuebanner="Enter here title" minwidth="25"/> \
  31.            </group> \
  32.            <group uniform="true" align="right|bottom"> \
  33.                    <button title="&amp;OK" returnval="ok" default="true"/> \
  34.                    <button title="&amp;Cancel" returnval="cancel"/> \
  35.            </group> \
  36.         </dialog>@';
  37.        
  38.         var varStorage = CreateStorage();
  39.  
  40.         var sel     = ActiveView.Selection;
  41.         var selText = ActiveDocument.GetText(sel);
  42.         varStorage.write("title", selText);
  43.  
  44.         if ( dialog(dialog_template, varStorage) != 0  )
  45.         {
  46.                 var linkPattern = "<a href=\"" + varStorage.read("url") + "\">" + varStorage.read("title") + "</a>";  
  47.                 ActiveDocument.ReplaceText(sel, linkPattern, HE_ACTION_UNKNOWN);       
  48.         }      
  49. }
  50.  
  51. var vInsertLinkCMD = Application.CreateCommand("HTML.InsertLink", "Insert Link...", "Interactively insert link element into HTML code", nIconLink, onInsertLink);
  52. Application.RegisterCommand(vInsertLinkCMD);
  53.  
  54. ////////////////////////////////////////////////////////////////////////
  55. // Initialize HTML Toolbar
  56. Application.onInitToolbars = function (){
  57.         var MyToolbar = this.GetToolBar("HTML", true);
  58.         MyToolbar.Name = "HTML Tools";
  59.         MyToolbar.AddButton(vInsertLinkCMD);
  60. }
  61.  
  62. ////////////////////////////////////////////////////////////////////////
  63. // Create new main Menu for HTML
  64. Application.onInitMainMenu = function (bUpdate){
  65.         if ( bUpdate == false )
  66.         {
  67.                 var menuHTML = this.InsertSubMenu(this.ItemCount - 4, "HTM&L");
  68.                 if ( menuHTML != null )
  69.                 {
  70.                         menuHTML.AddItem("", vInsertLinkCMD);
  71.                 }
  72.         }
  73. }

For you convenience I have also attached plug-in file.  Just drop it somewhere and than Tools->Execute... After successful execution you should see new menu, toolbar button and command.
Something like this:


And this will be a result:
* html_tools.hejs (3.02 kB - downloaded 522 times.)

Plugin is always reloaded on start-up after execution (using file you point). To disable it, go to Tools->Options->Plugins and uncheck.
To reinitialize, just once more Execute.

26
FAQ / How to select a HTML tag
« on: January 23, 2012, 03:02:15 pm »
There is no special shortcut to select a tag. HE generic editor, and not specified for any language (this would change with 1.50, where specialization will come with help of plugins and scripts).

But you can use command Edit.ExpandSelection (Edit->Selection->Expand). This is smart function that guess, what user want to select and increase selection range from current to larger one.
The functionality is also callable with with double/triple etc clicks (number of clicks correspond to number of calls for ExpandSelection).

The opposite to Edit.ExpandSelection is command Edit.ShrinkSelection, which decrease selection to previous selection scope.

27
FAQ / How to add new file template
« on: January 04, 2012, 06:51:10 pm »
File templates are files with default pattern content used to "pre-fill" newly created documents.

Selection of file template is done based on extension of new document and name of template: editor searches for file with same extension and name "default" in directory of file templates.
To find directory where file templates are located select File->New->Manage File Templates (usually %HippoEDIT user directory%\templates).



All file templates (files) with name different from default added to menu of File->New->%Syntax% as not auto templates and can be selected manually.
default templates used automatically if document with such extension created, with shortcut for example. To skip template pattern, you can keep Ctrl kept, when creating of the new file from within the menu.

It is allowed to use code templates in file templates - file template text is pre-processed, and all code templates are expanded.

28
Scripting, Scripts and Macros / Script Plugins, Eventing, UI integration
« on: November 07, 2011, 03:53:33 am »
Hi All,

from version 1.50.722 it is now possible to create "script plugins" - this is a rich version of scripts (another type is tool script), similar to real binary plugins, which starts automatically, live in background and react on user interaction as keystroke, menu or toolbar selection.

The easiest way to try it out, download plugin file, save it somewhere on your disk, and run it once with Execute... command from Tools menu. After first run, plugin is installed and enabled. If you would like to disable (unload) it you can do it in Tools->Options->Plugins. This test plugin subscribes on most of of HE public events, register commands and adds its own menu, toolbar and status bar items. To get more details check the code of the plugin (open it in editor) - it is self explanatory and rather easy.

Nevertheless, here I will explain some code blocks and their results.

Handlers
First of all, main difference of the script plugin from tool script, that code is not executed directly as it done on script plugin, but you register handlers, that are called some when later, reacting on user interaction or editor command. Such handlers can be presented or as functions
Code: Javascript
  1. Application.onDocumentNameChanged = function (old_name, new_name, rename) {
  2.         Output().writeln("onDocumentNameChanged : old_name = " + old_name + ", new_name = " + new_name + ", rename = " + rename);
  3. }
or be assigned directly as inline code:
Code: Javascript
  1. Application.onDocumentListUpdate = "Output().writeln(\"onDocumentListUpdate\")";
Handlers always have this object, that represent source of event and can have parameters, which forward additional information to handler. And of course you can always access Application object - it is global.
Code: Javascript
  1. Application.onModifiedChanged = function (modified) {
  2.         Output().writeln("onModifiedChanged : document = " + this.Title + ", modified = " + modified); 
  3. }

Commands
Commands - is a handler, associated with icon, title, description, enable state, check state etc. Mentioned properties can be as static as dynamic.
You need commands to get a shortcut registered with your handler, to put your handler into menu or toolbar, or to associate the handler with status bar indicator.
This is a typical code, necessary to create a command:
Code: Javascript
  1. function onTestCommand()[attachimg=2]
  2. {
  3.         alert(this.Name + " called!" + "\r\nStored Value: " + readStorage("val1", 25));
  4. }
  5.  
  6. var vTestCMD = Application.CreateCommand("Script.TestCommand", "Test", "I will show alert box", nIconTable, onTestCommand);
  7. Application.RegisterCommand(vTestCMD);
In the example:
"Script.TestCommand" - unique identifier of the command. Not script specific, so be careful that you select name that nobody else will choose.
"Test" - title of the command, to be displayed in menu or as button tooltip or in status bar
"I will show alert box" - command description, prompt
nIconTable - icon index, can be -1, if you do not want an icon to be assigned with command
onTestCommand - handler itself. Can be as function name as inline code
If you would skip last line (RegisterCommand) the command object will not appear in command list in Tools->Options->Keyboard and you will be not able to assign a shortcut to it.

Icons
There are several places in framework, where you need to have icons: command handlers and dialogs.
Code: Javascript
  1. var nIconTable = Application.RegisterIconString(
  2. 'R0lGODlhEAAQAMQAAABIAMPN1gBaxQAbis3w/7vFz///AA6iDm14gwCZ/ygzP////0pTXi+6He3y \
  3. 9yKs/67h/wBDsM3V3nuIlFDVPgBdAODl57/J0xeuEWJqdYyVmgBmzPf5/BytHtbz/////yH5BAEH \
  4. AB8ALAAAAAAQABAAAAWD4CaMQkKW57ZBBOElXvvGBKQ++JPkOr9Fg6BwOIxoFsiFJalkaiZMSZQ5 \
  5. mUgC2Cs2oOVOEAuOOBDmMJEIsJhzWS8q8MoiHSjYL5fl22CQLzILDoIFDm9wBh1xgEkFSBV8iA19 \
  6. DAqVlnsHBxibFR+en54AABUUDRWioKkfj6aqqqKoHyEAOw=='
  7. );
This code registers new icon and returns in variable nIconTable its identifier. You can use it later in all functions that expect icon ids, in particularly when you register new command.
The way you see in example, is registering of inline image. Inline image it is just an image file (bmp, jpg, png, gif, ico) encoded with base64 encoding and pasted as a string into script. You can register icon also directly from file, but for this you need to use RegisterIconPath function. Icon image should have 16x16 pixel size.
All necessary stuff is available online: first go to some online image repository  and find icon you want filtering them by name and save it as a file. Then go to some online base64 converter upload a file you save and convert it to base64. Copy resulting string into script, escape line breaks if necessary, pass to register code, get an id and you are done.

Options pages
Script plugins as reach binary plugins can have their own options pages integrated in Options Dialog UI. So, if you want to add to your script some settings, you do not need to create a dialog and call it by some handler, but you need to create an Options Page and register it.
Code: Javascript
  1. var bval1 = true;
  2.  
  3. function readStorage(key, def_val)
  4. {
  5.         var vStorage = GetStorage(eStorageTypeWorkspace, "", eAccessTypeRead);
  6.         if ( vStorage != undefined )
  7.         {
  8.                 var val1 = vStorage.read(key);
  9.                 if (val1 != undefined) return val1;    
  10.         }
  11.         return def_val;  
  12. }
  13.  
  14. function onOptionsInit()
  15. {
  16.         this.Layout =
  17.         '@<dialog> \
  18.            <group> \
  19.                <paragraph text="Value:"/> \
  20.                    <edit id="val1" minwidth="10"/> \
  21.            </group> \
  22.            <checkbox id="bval1" title="Check Me"/> \
  23.         </dialog>';
  24.        
  25.         // read "setting" from persistent storage
  26.         this.Parameters.write("val1", readStorage("val1", 25));
  27. }
  28.  
  29. function onOptionsApply()
  30. {
  31.         var val1 = this.Parameters.read("val1");
  32.         Output().writeln("val1 : " + val1);
  33.         Output().writeln("Variable bval1: " + bval1);
  34.        
  35.         // store new "setting" value in persistent storage
  36.         GetStorage(eStorageTypeWorkspace, "", eAccessTypeWrite).write("val1", val1);
  37. }
  38.  
  39. function onOptionsContextHelp(varID)
  40. {
  41.         Output().writeln("varID : " + varID);
  42.         return "I am test description for field: " + varID;
  43. }
  44.  
  45. // here we register script settings options page, passing call back functions
  46. // which will be called when option page is created
  47. // Init is required, Apply is needed if you do not use global options variables, ContextHelp handler is optional
  48. Application.RegisterOptionsPage("Service Script", onOptionsInit, onOptionsApply, onOptionsContextHelp);
  49.  
To register Options Page, you need to define minimum two handlers:
 - to initialize options page (function onOptionsInit()), where you set page layout and initialize variables
 - to apply changes (function onOptionsApply()) where you read new settings and apply or persist them. You can skip even this handler, if you are using only global script variables (like var bval1) as data bindings in your dialog layout.
Third handler (onOptionsContextHelp(varID)) needed, if you want to provide additional information for some controls, when user use context help in dialog.

This is how result looks like:


UI Events basics
There is no way to modify UI directly from any part of code. UI can be changed only during dedicated events, that provide you helper objects and ensure that UI modifications are done in right sequence, objects you want to modify already available and actions you did in code can be undone.

Toolbar items
With following sample:
  • script first subscribes to onInitToolbars event (line 1), later when called,
  • creates new toolbar with id "ScriptTest" and makes it visible by default (line 3).
    Creating registering of the new toolbar, automatically adds new commands for displaying of the toolbar (shortcuts can be assigned) and adds menu items under View->Toolbars menu.
  • Names newly created toolbar "ScriptTest" (line 4)
  • adds buttons to toolbar, using previously created handlers (5,7)
  • searches for existing "standard" (toolbar id) toolbar and adds button to it also (lines 8-13).

Code: Javascript
  1. Application.onInitToolbars = function (){
  2.         Output().writeln("onInitToolbars ");
  3.         var MyToolbar = this.GetToolBar("ScriptTest", true);
  4.         MyToolbar.Name = "ScriptTest";
  5.         MyToolbar.AddButton(vTestCMD);
  6.         MyToolbar.AddButton();
  7.         MyToolbar.AddButton(vTestCMD);
  8.         var StandardToolbar = this.GetToolBar("standard", false);
  9.         if ( undefined != StandardToolbar )
  10.         {
  11.                 StandardToolbar.AddButton();
  12.                 StandardToolbar.AddButton(vTestCMD);
  13.         }
  14. }

Added toolbar items looks like this:

first marked button item added to "standard" toolbar, second marking correspond to newly created "ScriptTest" toolbar.

Main Menu extensions
Main menu can be modified in two ways: statically, if item set is known and should not be changed at runtime; or dynamically, if item set is unknown, depends from some conditions or can be changed (like recent list for example).

Static case covered withing onInitMainMenu event. In provided example, scripts insertss command handler after command "Edit.DeleteDuplicates" (found in Format menu) and separate it by separator.
nUpdate parameter indicates that menu is only updated (some times can happen), but normally, static items should be added only one update is false.
Code: Javascript
  1. Application.onInitMainMenu = function (bUpdate){
  2.         Output().writeln("onInitMainMenu : " + this.ItemsCount);
  3.         if ( bUpdate == false )
  4.         {
  5.                 Output().writeln("onInitMainMenu : initialized");
  6.                 var menu_location = this.GetMenuItemPos("Edit.DeleteDuplicates");
  7.                 if ( menu_location.Menu != null && menu_location.Position != -1)
  8.                 {
  9.                         Output().writeln("onInitMainMenu : Insert command into position " + (menu_location.Position + 1));
  10.                         menu_location.Menu.InsertItem(menu_location.Position + 1, "", vTestCMD);
  11.                         menu_location.Menu.InsertItem(menu_location.Position + 1);
  12.                 }
  13.         }
  14. }
  15. }

Snapshot shows added static item, after Edit.DeleteDuplicates item.


Adding of the dynamic items should be added withing onMainSubmenuUpdate event. It called every time, user activates one of top main menu entries (File, Edit Format etc).
Because menu keeps it state, you need to delete old your entries first, and then re-add them.
The menu can be recognized by Name property. 
Code: Javascript
  1. Application.onMainSubmenuUpdate = function (){
  2.         Output().writeln("onMainSubmenuUpdate : " + this.ItemsCount);
  3. }

Context Menu Extension
The following code add new item to context menu, using previously created command handler.
Item added to predefined place - designed by editor (sometimes, sometimes this is just bottom). You can also add items to top, bottom of menu or in specific place. The menu is rebuild on every context menu call.
Parameter eStyle indicates type of the context menu (standard, read-only, format, margin, tab etc).
view, nLine, nPos - indicates current view and location of cursor. Optional - depends on context menu style.
Code: Javascript
  1. Application.onInitContextMenu = function (eStyle, view, nLine, nPos){  
  2.         var sTrace = "onInitContextMenu : count = " + this.ItemsCount + ", style = " + eStyle;
  3.         if (view != undefined) sTrace += ", document = " + view.Document.Title + ", nLine = " + nLine + ", nPos = " + nPos;
  4.         Output().writeln(sTrace);
  5.  
  6.         // add context menu item at "predefined" place
  7.         this.AddItem("Test in Context Menu", vTestCMD);
  8. }
  9.  

This is example of standard context menu. Marked is added in predefined place item.


Status Bar Extension
The following sample code adds to new indicators to status bar using already registered command handlers (vTestCMD and vTestCMD2).
By default, click on indicator will execute the command. If you want to show menu as for vTestCMD you need to register onMenuCreate event and add items when corresponding command will be triggered.
If indicator are not visible initially, enable them with status bar context menu.
Code: Javascript
  1. Application.onInitStatusBar = function () {
  2.         Output().writeln("onInitStatusBar : indicators = " + this.ItemsCount);
  3.         this.AddIndicator(vTestCMD, 50);
  4.         this.AddIndicator(vTestCMD2, 50);
  5. }
  6. Application.onMenuCreate = function (command) {
  7.         Output().writeln("onMenuCreate : command = " + command);
  8.         if ( command == "Script.TestCommand" )
  9.         {
  10.                 this.AddItem("", vTestCMD);
  11.                 this.AddItem();
  12.                 this.AddItem("", vTestCMD);
  13.         }
  14. }

This is a result of the script execution.


Generic (not UI) events
In addition to UI events, there are of course, normal, functional events informing you about internal processes as: changing of cursor position, changing of active document, closing of the workspace, change of global  settings etc.
Code: Javascript
  1. Application.onCursorPosChange = function (pos) {
  2.         // "this" corresponds to View object
  3.         Output().writeln("onCursorPosChange : document = " + this.Document.Title + ", View Version = " + this.Version + ", position = (" + pos.Line + ", " + pos.Pos + ")");
  4. }
  5. Application.onDocumentSwitch = function (document) {
  6.         // "this" corresponds to Application object
  7.         if (document != undefined)
  8.                 Output().writeln("onDocumentSwitch : document = " + document.Title);
  9.         else
  10.                 Output().writeln("onDocumentSwitch");
  11. }
  12. Application.onWorkspaceClose = function (bSaveState) {
  13.         Output().writeln("onWorkspaceClose : save_state = " + bSaveState);
  14. }
  15. Application.onSettingsChange = function () {
  16.         // "this" corresponds to Settings object
  17.         Output().writeln("onSettingsChange : user_der = " + this.UserDirectory);
  18. }
Given above template subscribes to mentioned events, and outputs details about event to default Output pane.

Command listeners
Command listeners allows script:
  • to be informed about standard commands and interrupt processing before or after it
  • execute some code code before or after standard (or any registered) command
  • replace execution of standard code by own code (for example commenting or processing)

To be notified, script should register command listener, with assigned handlers for before and after execution.
Code: Javascript
  1. function onBeforeExecute(command)
  2. {
  3.         Output().writeln("onBeforeExecute : command = " + command);
  4.         return true;
  5. }
  6.  
  7. function onAfterExecute(command)
  8. {
  9.         Output().writeln("onAfterExecute : command = " + command);
  10.         return true;
  11. }
  12. Application.RegisterCommandListener("Edit.Find", Application.CreateCommandListener(onBeforeExecute, onAfterExecute));

Script Code Templates

Code: Javascript
  1. var vCodeTemplate = Application.CreateCodeTemplate("return \"SCRIPT-TEMPLATE\";", "return \"Script TEMPLATE Description\";", null);
  2. Application.RegisterCodeTemplate("tmpl+", vCodeTemplate);

to be continued...

29
Еще назрел такой вопрос, редактирую я допустим функцию JS или элементы вложенные в какой то html тег, можно ли на комбинацию клавишь повесить, чтобы по нажатию выделялось все содержимое функции или элемента.

И по области видимости такой вопрос, бывает закрываю функцию фигурной JS скобкой, и мне на какое то время подсвечивается все ее тело, можно как то принудительно вызвать такой же показ всего тела функции?

так должен был сделать Reniel

30
Выделяю текст в режиме "Line Mode" и потом пытаюсь переместить этот текст вверх(ctrl+alt+(up/down)), то строки перенесенные ниже веделения, становятся тоже частью выделенного, а вот когда перемещаю вниз - все нормально (перенесенные строки перед выделением, не становятся частью выделенного).

так должен был сделать Reniel

Pages: 1 [2] 3 4 5