General discussion about plugins.

Browse, download and discuss plugins for Blumentals code editors

Re: General discussion about plugins.

Postby Aivars » Wed Apr 06, 2016 11:33 pm

Ok, since the script is being compiled, using functions that don't exist might be an issue. I can't think of a way to work around this either. I'll need to address this in future but obviously it's already too late for the versions that have been released already... This seems obvious in retrospect but yeah... I guess you'll need different scripts for different editor versions (or simply drop support for the old version) until a better mechanism is available.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Sun Apr 10, 2016 3:20 pm

A couple questions regarding the new Autocomplete functions:

ACType=6 is fired when I enter a CSS property and here I can see the property I add.
ACType=7 is fired when I enter a CSS value, but here nothing shows up (no autocompleter). How do I link values to the properties added in "ACType=6"?

Nothing added to "ACType=0" shows up in the autocompleter. I tried your code with the "shadow" example and it didn't work either. Bug?

And a question regarding the "old" API functions:
How do I test if a specific file is open in the Editor?
I tried "Documents.TabByFileName(FileName)", but it always returns a 9 digit number/pointer no matter what I set "FileName" to.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Tue Apr 12, 2016 11:50 pm

For HTML tags ACType=4 is actually required. I stupidly pasted the code that resulted from me playing around without testing first. I suggest to output ACType in signal handler while developing to see what it is in all the different situations.

I haven't been able to test CSS values/properties yet, so I'll answer it later.

You would do it something like this:
open = false;
Code: Select all
for (i = 0; i < Documents.Count; i++) {
  if (Documents.Tab[i].Filename == FileNameToCheck) {
    open = true;
  }
}
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed Apr 13, 2016 1:55 pm

Thanks for the example code.

Regarding "ACType=0" then not autocompleter is displayed at this state.
I tried adding CSS selector names to this, and then CSS properties on "ACType=6" and their value on "ACType=7", but only the "ACType=6" autocomlleter shows up.

Feature request:
For GUI purpose, I miss functionality to open a File Dialog and/or a Folder Dialog.
At the moment I call a DOS script, which then calls a VBScript which makes a dialog box. It then passes the output of the script back to WeBuilder.
It works fairly well, but in some situations the dialog box ends up behind the editor window which is quite annoying.

Something like:

OpenFolderDialog(rootFolder, startingFolder, description, &result);
OpenFileDialog(rootFolder, startingFolder, description, &result);

- "rootFolder" is the topmost folder of the tree
- "startFolder" is the starting folder when dialog opens
- "description" is text shown in header of dialog box.
- "&result" is the result of the dialog (folderpath, filepath or empty string)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Wed Apr 13, 2016 2:31 pm

I think I see what you're saying. You need to set AllowPopup to true if it's false (because there were no items to display). Something like this:

Code: Select all
if (ACType == 7) {
    //add a hyphotetical CSS property
    AutoComplete.AddItem(Strings, "aaa", "aaa");
    AllowPopup = true;   
}
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby Aivars » Wed Apr 13, 2016 7:08 pm

The new things for 2016 build 183.

Compiler directives.
Includes:
Code: Select all
/*$INCLUDE somefile.js*/

Skipping/adding code for specific builds:
Code: Select all
/*$IF Build > 183*/
FutureFunction(3);
/*$IFEND*/

How to skip code for old versions when compiler directives didn't even exist:
Code: Select all
/*$IF Build < 183*/ // /*$IFEND*/ LoadFileToBitmap(...);

My personal recommendation is not to bother with the old versions because maintaining multi-version scripts can become a nightmare real fast.


Plugin Manager for faster plugin testing (so that it's possible to write a plugin, that restarts another plugin). The plugin must not disable itself.
Code: Select all
  PluginManager.DisablePlugin("Alignment");
  PluginManager.EnablePlugin("Alignment");


Dialogs. Delphi dialog classes added and a new function for browsing to folder.
Browse for file:
Code: Select all
  var opendialog = new TOpenDialog(WeBuilder);
  opendialog.InitialDir = "d:\\Temp"; //leave empty to remember last folder
  opendialog.Title = "Select something great";
  if (opendialog.Execute) {
      alert(opendialog.FileName);
  }
  delete opendialog;


Browse for folder:
Code: Select all
  var s = "d:\\Temp";
  if (BrowseForFolder(s, "Select your favourite folder", true)) { //params: initial folder & result, title, allow creating a new folder in the dialog
    alert(s);
  }
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed Apr 13, 2016 10:17 pm

That was FAST!! :)

The "PluginManager" was just what my aching mouse hand needed! No more constant disable/enable! :D
I already wrote a small plugin that auto disable/enable a selected plugin after saving.

And the dialog functions works perfectly too.

Great work!!
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Tue Apr 19, 2016 3:36 pm

Added Document.FtpFileName. Here's a little sample, that would make a copy of current file opened from FTP:

Code: Select all
  if (Document.FtpFileName != "") {
    var s = Document.FtpFileName;
    var txt = Editor.Text;
    Documents.NewDocument("bak");
    Editor.Text = txt;
    Document.FtpFileName = s + ".bak";
    Document.Save(s + ".bak");
  }
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed Apr 20, 2016 3:42 pm

To access the current document, I use the "Document" object.
But how do I access a document in a different tab (I want to switch the other tab into view)?

I tried something like this:

doc = Documents.TabByFileName(currentFileName);
doc.Activate;

(currentFileName is the filename of a document in a different tab than the active one.)
I tried with "currentFileName" as a full file path and with just the filename alone.

But I just get an error: Undeclared identifier: 'Activate'
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Wed Apr 20, 2016 4:29 pm

I did some tests and it appears that TabByFileName is documented but not really implemented. Sorry! It will be fixed in the next update but for now loop through all tabs and check their filename to find the one that you need.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed Apr 20, 2016 6:38 pm

No problem. With your current rate of updates and new features, I'll just wait for the next release ;)

And it's so much easier to write plugins now, when you don't have to disable/enable the plugins constantly.
Only feature I really miss now, is the ability to add "links" to Script.Message() output.

Like in my Node-Sass plugin, I parse the error messages and get back the line number and column of the line with error.
Here it would be nice, if the user could click on the error message in the Message window, and then the editor cursor would move to the line in the Editor window. (Similar to how "Search All" results work.)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Thu Apr 21, 2016 10:33 am

I think the most reasonable way to implement it would be doing this for messages in a specific format e.g.
Code: Select all
[13:45] Unknown identifier

or
Code: Select all
Unknown identifier [13:45]

where line number and column appears in the text in some form. This would also be backwards compatible (old versions could display the error messages but clicking them wouldn't do anything). Search All uses a completely different approach to link to the text position which I feel could be too complicated for scripting.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Thu Apr 21, 2016 3:49 pm

Sounds fine, but maybe the marker should be a bit more "complicated", like "[[13]:[45]] Unknown identifier" to prevent accidental replacements.

Another option would be to add two optional parameters to Script.Message, like: Script.Message(<message>, [<line>], [<column>]);
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby dave » Fri May 06, 2016 1:36 am

Can you please provide some examples for manipulating lists in a listbox please?

I have the following

var listSetsID = new TListBox(f);
listSetsID.Parent = f;
listSetsID.SetBounds(14, 80, 570, 200);

which I've then populated from an ini file. So good so far.

I have an OnClick event

listSetsID.OnClick = &OnClick_listSetsID;

which takes me to this function

function OnClick_listSetsID(Sender) {

}

How can I establish the item that was clicked on in the on click event? The value of Sender just has a numerical value?

Elsewhere, I have a button, that when clicked I would like to get the currently highlighted item in the listbox? Is this possible?

How do I highlight an item through code?

Is it possible to highlight multiple lines in the listbox, I can only seem to highlight one line at a time? I have tried using CTRL and Shift, but only one item will highlight at any one time?

Thanks for your help.
dave
 
Posts: 23
Joined: Fri Mar 31, 2006 2:45 pm

Re: General discussion about plugins.

Postby pmk65 » Fri May 06, 2016 10:58 am

dave wrote:Can you please provide some examples for manipulating lists in a listbox please?


"Sender" is a reference to the calling object.
So in your case, the "Sender" variable in your "OnClick_listSetsID(Sender)" function is equal to the "listSetsID" object.

To enable multi-select in the ListBox, you set:

listSetsID.MultiSelect = true;

This will enable multi-select when holding down the CTRL button:

If you also set:

listSetsID.ExtendedSelect = false;

Then it's possible to multi-select without the CTRL button.

One program that have helped me a LOT when doing plugin GUIs, is pdScript IDE:
http://www.be-precision.com/download/

With that you can create GUI setups and export the setup in Pascal format (It's quite easy to translate that into WeBuilder plugin format) and allows you to see/test various options/settings.

Here's 2 functions from one of my plugins, for manipulating TListBox items.

Code: Select all
/**
* Set active selections
*
* @param  tListBox Object   Sender
* @param  string            selected (Comma separated list of selected values)
*
* @return void
*/
function SetSelection(Sender, selected) {
    selected = Split(selected, ",");
    for (var j=0;j<Length(selected);j++) {
        for (var i=0;i < Sender.Items.Count;i++) {
            if (selected[j] == Sender.Items[i]) {
                Sender.Selected[i] = true;
                break;
            }
        }
    }
}

/**
* Get active selections
*
* @param  tListBox Object   Sender
*
* @return string (Comma separated list of selected values)
*/
function GetSelection(Sender) {
    var res = "";
    for (var i=0;i<Sender.Items.Count;i++) {
        if (Sender.Selected[i] == true) {
            if (res != "") res += ",";
            res += Sender.Items[i];
        }
    }
    return res;
}
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

PreviousNext

Return to Plugins for HTMLPad / Rapid CSS / Rapid PHP / WeBuilder

Who is online

Users browsing this forum: No registered users and 1 guest

cron