AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Применение скрипта ко всем вкладкам

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian)
View previous topic :: View next topic  
Author Message
vadim



Joined: 16 Aug 2012
Posts: 13

PostPosted: Thu Dec 03, 2015 6:09 pm    Post subject: Применение скрипта ко всем вкладкам Reply with quote

В AkelPad открыто несколько файлов, каждый в своей вкладке.
Есть Ява скрипт Script.js. Я могу его применить в AkelPad примерно так:
-"Скрипт" Call("Scripts::Main", 1, "Script.js")
Но это скрипт применится только к активной в данный момент вкладке.
А как его применить ко всем открытым в AkelPad файлам, не переходя из вкладки во вкладку вручную?

В операции "Поиск/Замена" такая возможность есть.
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1841
Location: Poland

PostPosted: Thu Dec 03, 2015 8:37 pm    Post subject: Reply with quote

vadim
Example.js
Code:
var hMainWnd     = AkelPad.GetMainWnd();
var lpFrameStart = AkelPad.SendMessage(hMainWnd, 1290 /*AKD_FRAMEFINDW*/, 1 /*FWF_CURRENT*/, 0);
var lpFrameCur   = lpFrameStart;

if (lpFrameStart)
{
  do
  {
    WScript.Echo("Edit file: " + AkelPad.GetEditFile(0));

    lpFrameCur = AkelPad.SendMessage(hMainWnd, 1290 /*AKD_FRAMEFINDW*/, 9 /*FWF_TABNEXT*/, lpFrameCur);
    AkelPad.SendMessage(hMainWnd, 1285 /*AKD_FRAMEACTIVATE*/, 0, lpFrameCur);
  }
  while (lpFrameCur && (lpFrameCur != lpFrameStart))
}
Back to top
View user's profile Send private message
vadim



Joined: 16 Aug 2012
Posts: 13

PostPosted: Sat Dec 05, 2015 7:59 am    Post subject: Reply with quote

Спасибо, KDJ!
Насколько я понял, чтобы скрипты применялись ко всем вкладкам, эту часть нужно вставлять в каждый JS-скрипт. И вставлять нужно примерно так:
Code:
var hMainWnd     = AkelPad.GetMainWnd();
var lpFrameStart = AkelPad.SendMessage(hMainWnd, 1290 /*AKD_FRAMEFINDW*/, 1 /*FWF_CURRENT*/, 0);
var lpFrameCur   = lpFrameStart;

if (lpFrameStart)
{
  do
  {
    WScript.Echo("Edit file: " + AkelPad.GetEditFile(0));

   -------------
    КОД СКРИПТА
   -------------

    lpFrameCur = AkelPad.SendMessage(hMainWnd, 1290 /*AKD_FRAMEFINDW*/, 9 /*FWF_TABNEXT*/, lpFrameCur);
    AkelPad.SendMessage(hMainWnd, 1285 /*AKD_FRAMEACTIVATE*/, 0, lpFrameCur);
  }
  while (lpFrameCur && (lpFrameCur != lpFrameStart))
}

Запрос:
Code:
    WScript.Echo("Edit file: " + AkelPad.GetEditFile(0));

вероятно, можно исключить? Мне он мешает.
Back to top
View user's profile Send private message
Skif_off



Joined: 20 Oct 2013
Posts: 968

PostPosted: Sat Dec 05, 2015 8:26 am    Post subject: Reply with quote

vadim
WScript.Echo для примера, замените на код скрипта или, наверное, проще на вызов нужного скрипта с AkelPad.Call(), чтобы использовать для каждой вкладки только при необходимости.
Back to top
View user's profile Send private message
vadim



Joined: 16 Aug 2012
Posts: 13

PostPosted: Sat Dec 05, 2015 8:49 am    Post subject: Reply with quote

Вроде работает, спасибо!
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1841
Location: Poland

PostPosted: Sun Dec 06, 2015 5:56 pm    Post subject: Reply with quote

vadim
New script can be useful: RunScriptOnEachTab.js.
Back to top
View user's profile Send private message
Lenchik



Joined: 10 Jan 2011
Posts: 358

PostPosted: Sun Dec 06, 2015 6:44 pm    Post subject: Reply with quote

KDJ
Thank you. Would be great also to have not only command interface, buta visual also. Some text block (like one i am writing this post in). And some dropdown list-menu or something to select template from scripts available - "scriptname(|cursor|)" with insert button because we can call several scripts from command option of your script.
Maybe also check for line length if it is restricted somehow.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1841
Location: Poland

PostPosted: Sun Dec 06, 2015 8:58 pm    Post subject: Reply with quote

Lenchik
This GUI already exists: runScript.js.
It is necessary to connect in some way both scripts.
I think it will be easier for Infocatcher to add in runScript.js the option of running on all tabs.
Back to top
View user's profile Send private message
vadim



Joined: 16 Aug 2012
Posts: 13

PostPosted: Mon Dec 07, 2015 3:37 pm    Post subject: Reply with quote

KDJ wrote:
vadim
New script can be useful: RunScriptOnEachTab.js.

Ну! Так даже лучше, возможностей больше. Спасибо!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group