General discussion about plugins.

Browse, download and discuss plugins for Blumentals code editors

Re: General discussion about plugins.

Postby pmk65 » Mon Mar 27, 2017 12:55 am

Aivars wrote:Check out this demo plugin: viewtopic.php?f=33&t=5976


I'll stick with static images for now. (My GIf Anim have too many frames :D)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Mon Mar 27, 2017 12:57 am

I have been playing a bit with "AutoComplete", and got most of it working so far.
Except setting the default item in the dropdown list. (And I still have no clue what AKey is used for :?)

Here's my code:
Code: Select all
function OnAutoComplete(CodeType, ACType, Strings, AKey, AllowPopup, ShowImages) {
   if ((ACType == 2) && (CodeType == 1) && (Strings[0] == "{\\rtf\\b Choose URL... }")) {
      var word = AutoComplete.GetWordBeforeCursor("");
      if (word != "") {
         Script.Message("word:" + word);
         ShowImages = true;
         AllowPopup = true;
         Ajax(word, Strings);
      }
   }
}


And in the "Ajax" function, I add items like this:
Code: Select all
var j = AutoComplete.AddItem(Strings, link, label);
AutoComplete.SetImageIndex(j, 4);


So when you activate the autocomplete inside a JavaScript "src" field, the plugin code is triggered.
This partly works as it should (I still need to figure out a way to trigger it only on JavaScript tags), but it start with the 1st item selected in the list displayed.
:?: How do I get it to start at the X position in the list?

The items I add to AutoComplete are returned in order of importance, not alphabetic.
:?: Is it possible to turn of the alphabetic sorting of the list, and instead display it in the order they are added?

:?: Also, "GetWordBeforeCursor" requires a string argument, but what is it for?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Mon Mar 27, 2017 6:10 pm

1) The selected word will try to match the word that is before the cursor to codeword (e.g. if you have "script" before the cursor then "script" is selected from the list).

2) The AddItem method will add items sorted by codeword.

3) Let's suppose you have Dog.Bark right before cursor. Calling GetWordBeforeCursor with empty string will only get you "Bark", calling GetWordBeforeCursor(".") will get you "Dog.Bark". It's basically a list of additional characters (besides basic alphanumeric) to consider to be a part of the word.

AKey is key that triggered the autocmplete. E.g. user wrote <scr, then waited - in this carse AKey will match "r". If AKey is "!" that means user pressed ctrl + space.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Thu Apr 20, 2017 7:08 pm

Is there any way to intercept the result selected in "onautocomplete" function?

As the sorting of the items prevents my new CDNJS plugin from working correctly. ( I need the items to be displayed in the order I add them, not in sorted order)
So I was thinking of adding a digit string to each item as I add them to the list. And then remove the digit string again before the selected result is inserted in the editor.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Fri Apr 21, 2017 11:51 am

Currently, no, but technically it could be done because e.g. Choose Image... is replaced with whatever image the user select from the Open dialog. But I would need to add the relevant signals for this to work, so most likely for the next major version only.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Mon Apr 24, 2017 8:04 pm

I get random crashes (the ones that shows the Recovery panel) and Im pretty sure it comes from a plugin Im working on. I just can't pinpoint the problem.
Is there any way for normal users, to use the debug info from the Recovery window, to locate errors in plugins?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Mon May 01, 2017 1:01 pm

If the crash is inside the scripting library it's usually hidden too well to figure out the crash location from stack log. If it happens in a function that got called from the scripting library then it's possible to at least determine what was called. If you pasted me a few top lines from the stack dump and provide exception name & message, I could take a look.

One good strategy for cases like this is to write a log file to find out where the crash occurred.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Tue Aug 01, 2017 1:50 pm

Two questions:

1) I have been playing a bit with TTimer, trying to animate an image. I tried 3 different ways: Sprite method (moving the image inside a TPanel), Visibility method (turining on/off visibility of the frames) and Copy method (Copy the source of the image from a sequence of preloaded images)
Im not sure if Im doing something wrong, but all of them has a big flaw. They flicker! :(
Attached is a testplugin showing the 3 animation methods. Maybe you could take a look at it?
AnimationTest.zip
Test plugin with 3 Animation methods: Sprite, Copy & Visibility.
(21.8 KiB) Downloaded 1491 times


2) According to http://help.blumentals.net/webuilder/plugins/develop/api_classes.htm, the TForm object has a "Canvas" property.
But how is that used? Can it be used to draw custom shapes?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Sat Aug 05, 2017 4:21 pm

Try adding
PSForm.DoubleBuffered = true;
right after PSForm is created.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Sun Aug 06, 2017 6:12 pm

Aivars wrote:Try adding
PSForm.DoubleBuffered = true;
right after PSForm is created.


Thanks. That was exactly what was needed :)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Tue Aug 08, 2017 12:58 pm

I have been experimenting with the TForm Events, trying to see if I could draw on Canvas. But I can't get it to trigger the "OnCreate" Event.

The TForm Events is fired in this order (excl. the mouse and key events.)

On creating/showing the form, these events are triggered:
OnResize
OnShow
OnResize
OnActivate
OnPaint

On closing the form, these events are triggered:
OnCloseQuery
OnClose
OnDeactivate
OnHide
OnDestroy

But the "OnCreate" is never triggered.

Edit: I figured out how to use the TForm Canvas drawing options. In the TForm setup, add an "OnPaint" event and a function like this:

Code: Select all
function OnPaint(Sender) {
        // Draw a Green Circle
   Sender.Canvas.Brush.Style = bsClear;
   Sender.Canvas.Pen.Style = psSolid;
   Sender.Canvas.Pen.Color = clGreen;
   Sender.Canvas.Pen.Width = 20;
   Sender.Canvas.Ellipse(100, 100, 200,200);

        // Write the word "WeBuilder" in Green letters
   Sender.Canvas.Font.Color = clRed;
   Sender.Canvas.Font.Size = 20;
   Sender.Canvas.TextOut(100, 100, "WeBuilder");
}
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Wed Jan 31, 2018 11:35 am

Im trying to get a list of browsers installed on system, like this:

Code: Select all
    var res32, res64;
    var reg32 = "C:\\Windows\\System32\\reg.exe";
    var reg64 = "C:\\Windows\\SysWOW64\\reg.exe";
    var key32 = reg32 + " query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Clients\\StartMenuInternet\" 2>nul";
    var key64 = reg64 + " query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Clients\\StartMenuInternet\" 2>nul";

    Script.Message("Command: " + _t(key32));

    ExecuteCommand(key32, res32);

    Script.Message("Result: " + _t(res32));


But it always fails running the "reg.exe" (Doesn't matter if I use 32 or 64 bit versions.) with this output:

Command: C:\Windows\System32\reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" 2>nul
Result: ERROR: Invalid syntax.
Type "REG QUERY /?" for usage.

If I copy "Command:" output and paste it into a DOS prompt, it WORKS. So why doesn't it work using "ExecuteCommand" ?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Wed Jan 31, 2018 2:44 pm

Nevermind. I figured out what was wrong (Was missing a \ at the end)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Thu Feb 08, 2018 6:54 pm

Alright. On unrelated note, I don't think you will get different directories via system32\ and syswow64\ from 32-bit application :)
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Fri Feb 09, 2018 2:54 pm

Aivars wrote:Alright. On unrelated note, I don't think you will get different directories via system32\ and syswow64\ from 32-bit application :)


Yeah. I discovered that too. :)

I got it working now, so I can extract the installed browser names and the path to the executable.

Code: Select all
    var WSO = CreateOleObject("Wscript.Shell");
    var winDir = WSO.ExpandEnvironmentStrings("%windir%"); 
    var SL = new TStringList; 
    ExecuteCommand(winDir + "\\System32\\reg.exe query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Clients\\StartMenuInternet\"", SL.Text);

    if (SL.Count<4) return; // Something went wrong

    for (var i = 4;i < SL.Count;i++) {
        var name = WSO.RegRead(SL[i] + "\\");  // Browser name
   if (name == "") name = RegexMatch(SL[i], "[^\\\\]*$", false);
        Sender.Items.Add(name);
    }
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
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 3 guests