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 

Scripts discussion (2)
Goto page Previous  1, 2, 3 ... 62, 63, 64 ... 94, 95, 96  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Infocatcher



Joined: 06 Aug 2007
Posts: 1614

PostPosted: Tue Dec 18, 2012 8:36 pm    Post subject: Reply with quote

Lenchik wrote:
Только лишний раз проверить по той же википедии, потому что, например, электронвольты сокращаются эВ (В большая).
Спасибо, исправил.
Там и так почти все из википедии. И часть из конвертера, прилагающегося к Компасу.


Пока вот так:
Add symbols for some units
Add English symbols to Russian translation
Fix Russian symbol for electronvolt
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1339
Location: Poland

PostPosted: Wed Dec 19, 2012 9:01 pm    Post subject: Reply with quote

cnnnc
Script InsertNum.js
In order to avoid the suspension of the script, I would suggest a slight amendment.
In line 237, instead of:
AkelPad.MessageBox(hMainWnd, "\""+vLabel[i]+"\" "+sTxtNeedNum, sCaption, 0 /*MB_OK*/);
type:
AkelPad.MessageBox(hWnd, "\""+vLabel[i]+"\" "+sTxtNeedNum, sCaption, 0 /*MB_OK*/);
Back to top
View user's profile Send private message
cnnnc



Joined: 12 Jan 2008
Posts: 116
Location: Shantou, China

PostPosted: Thu Dec 20, 2012 7:29 am    Post subject: Reply with quote

KDJ
Done. Thanks!
Update InsertNum.js:
1) improve CheckNum function;
2) add SetReDraw function.
Back to top
View user's profile Send private message Send e-mail
VladSh



Joined: 29 Nov 2006
Posts: 2610
Location: Киев, Русь

PostPosted: Fri Dec 21, 2012 12:20 pm    Post subject: Reply with quote

Пофиксил FullScreenEx.js, т.к. был баг при такой передаче параметра: `-ToolBar=["ToolBar","1"]`.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1339
Location: Poland

PostPosted: Sat Dec 22, 2012 5:10 pm    Post subject: Reply with quote

FindFiles.js
Added:
- Ctrl+Enter, Shift+Enter - open focused file for editing and select the found text (or close file if is currently edited),
- info on status bar: "NTFS stream".
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5316

PostPosted: Wed Dec 26, 2012 9:31 am    Post subject: Reply with quote

KDJ
GoToEx.js: better to use AKD_GETMODELESS with MLT_GOTO instead of "User32::GetForegroundWindow".
Back to top
View user's profile Send private message Send e-mail
VladSh



Joined: 29 Nov 2006
Posts: 2610
Location: Киев, Русь

PostPosted: Wed Dec 26, 2012 9:47 am    Post subject: Reply with quote

FullScreenEx.js обновлён; параметры изменилось правило задания аргументов на такое, как указано Instructor'ом.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1339
Location: Poland

PostPosted: Wed Dec 26, 2012 8:24 pm    Post subject: Reply with quote

Thanks Instructor. AKD_GETMODELESS - this is what was needed!
Improved: GoToEx.js
Back to top
View user's profile Send private message
cnnnc



Joined: 12 Jan 2008
Posts: 116
Location: Shantou, China

PostPosted: Thu Dec 27, 2012 4:02 am    Post subject: Reply with quote

KDJ
Quote:
FindReplaceEx.js
Good job!
And I'd like to see that Integrate "GotoEx.js" into "FindReplaceEx.js", then I can use it instead of "QSearch::DialogSwitcher". Wink
Back to top
View user's profile Send private message Send e-mail
VladSh



Joined: 29 Nov 2006
Posts: 2610
Location: Киев, Русь

PostPosted: Thu Dec 27, 2012 11:15 am    Post subject: Reply with quote

KDJ
Quote:
FindReplaceEx.js
I agree, good job!
But the script will beautiful, if add the argument, which can be set focus on specified button. Repeatedly been big debate about this, for example here.

It would also be good to get the inscription "Find" and "Replace" from the program, ie to be localized.

cnnnc wrote:
And I'd like to see that Integrate "GotoEx.js" into "FindReplaceEx.js", then I can use it instead of "QSearch::DialogSwitcher".
I do not vote for this proposal, because I think that these dialogues are completely different tasks.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1339
Location: Poland

PostPosted: Thu Dec 27, 2012 7:25 pm    Post subject: Reply with quote

cnnnc, VladSh
All ideas are very good. Showing "Goto" can be parameterized (in .ini file).
I will try to do.
I don't know how to read by the script the localized strings "Find", "Replace", "Go to" from languages dlls.
Does anyone know how to do it?
Back to top
View user's profile Send private message
cnnnc



Joined: 12 Jan 2008
Posts: 116
Location: Shantou, China

PostPosted: Fri Dec 28, 2012 2:25 am    Post subject: Reply with quote

KDJ
It's needn't a ini file. I do the change to FindReplaceEx_Mod.js
Code:
// FindReplaceEx_Mod.js - ver. 2012-12-27
//
// "Find/Replace" dialog extended version
//
// Usage:
// Call("Scripts::Main", 1, "FindReplaceEx.js")      - Find dialog
// Call("Scripts::Main", 1, "FindReplaceEx.js", "H") - Replace dialog

if (AkelPad.ScriptHandle(AkelPad.ScriptHandle(WScript.ScriptName, 3 /*SH_FINDSCRIPT*/), 13 /*SH_GETMESSAGELOOP*/) /*script already running*/
   || (! AkelPad.GetEditWnd()))
  WScript.Quit();

var DT_DWORD = 3;
var IDCANCEL = 2;
var IDLINK   = 3099;

var sTxtFind     = "Find";
var sTxtReplace  = "Replace";
var oSys         = AkelPad.SystemFunction();
var hInstanceDLL = AkelPad.GetInstanceDll();
var hGuiFont     = oSys.Call("Gdi32::GetStockObject", 17 /*DEFAULT_GUI_FONT*/);
var DLG_FIND     = 0;
var DLG_REPLACE  = 1;
var DLG_GOTO     = 2;
var nDlgType     = DLG_FIND;
var bContinue    = true;
var hWndFR;
var hWndCancel;
var hSubClass;

if (WScript.Arguments.length)
{
  if (WScript.Arguments(0).toUpperCase() == "H")
    nDlgType = DLG_REPLACE;
  else if (WScript.Arguments(0).toUpperCase() == "G")
    nDlgType = DLG_GOTO;
}

while (bContinue)
{
  bContinue = false;

  if (nDlgType==DLG_FIND)
  {
    AkelPad.Command(4158 /*IDM_EDIT_FIND*/);
  }
  else if(nDlgType==DLG_REPLACE)
  {
    AkelPad.Command(4161 /*IDM_EDIT_REPLACE*/);
  }
  else if(nDlgType==DLG_GOTO)
  {
    AkelPad.Command(4162 /*IDM_EDIT_GOTO*/);
  }

  if ((! (hWndFR = GetFindReplaceDialog())) || (! (hWndCancel = oSys.Call("User32::GetDlgItem", hWndFR, IDCANCEL))))
    break;

  if (nDlgType==DLG_FIND)
  {
    sLink = sTxtReplace + " (Ctrl+H)";
  }
  else if(nDlgType==DLG_REPLACE)
  {
    sLink = sTxtFind + " (Ctrl+F)";
  }
  else if(nDlgType==DLG_GOTO)
  {
    sLink = "";
  }

  oSys.Call("User32::CreateWindowExW",
            0,                      //dwExStyle
            "SysLink",              //lpClassName
            "<a>" + sLink + "</a>", //lpWindowName
            0x50000000,             //dwStyle=WS_VISIBLE|WS_CHILD
            GetLinkX(),             //x
            GetLinkY(),             //y
            GetLinkW(sLink),        //nWidth
            13,                     //nHeight
            hWndFR,                 //hWndParent
            IDLINK,                 //ID
            hInstanceDLL,           //hInstance
            0);                     //lpParam
  oSys.Call("User32::UpdateWindow", hWndFR);

  hSubClass = AkelPad.WindowSubClass(hWndFR, FindReplaceCallback, 78 /*WM_NOTIFY*/, 256 /*WM_KEYDOWN*/, 2 /*WM_DESTROY*/);

  AkelPad.ScriptNoMutex();
  AkelPad.WindowGetMessage();
  AkelPad.WindowUnsubClass(hWndFR);
}

function FindReplaceCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 78) //WM_NOTIFY
  {
    if ((wParam == IDLINK) && (AkelPad.MemRead(lParam + 8, DT_DWORD) == -2 /*NM_CLICK*/))
    {
      if (nDlgType==DLG_FIND)
      {
        nDlgType=DLG_REPLACE;
        SwitchFindReplace();
      }
      else
      {
        nDlgType=DLG_FIND;
        SwitchFindReplace();
      }
    }
  }
  else if (uMsg == 256) //WM_KEYDOWN
  {
    if (Ctrl() && (! Shift()))
    {
      if (((wParam == 0x46 /*F key*/) && !(nDlgType==DLG_FIND)))
      {
        nDlgType  = DLG_FIND;
        SwitchFindReplace();
      }
      else if(((wParam == 0x48 /*H key*/) && !(nDlgType==DLG_REPLACE)))
      {
        nDlgType  = DLG_REPLACE;
        SwitchFindReplace();
      }
      else if(((wParam == 0x47 /*G key*/) && !(nDlgType==DLG_GOTO)))
      {
        nDlgType  = DLG_GOTO;
        SwitchFindReplace();
      }
    }
  }
  else if (uMsg == 2) //WM_DESTROY
    oSys.Call("User32::PostQuitMessage", 0); //Exit message loop

  return 0;
}

function Ctrl()
{
  return Boolean(oSys.Call("User32::GetKeyState", 0x11 /*VK_CONTROL*/) & 0x8000);
}

function Shift()
{
  return Boolean(oSys.Call("User32::GetKeyState", 0x10 /*VK_SHIFT*/) & 0x8000);
}

function GetLinkX()
{
  var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
  var nX;

  oSys.Call("User32::GetWindowRect", hWndCancel, lpRect);
  oSys.Call("User32::ScreenToClient", hWndFR, lpRect);
  nX = AkelPad.MemRead(lpRect, DT_DWORD);
  AkelPad.MemFree(lpRect);

  return nX;
}

function GetLinkY()
{
  var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
  var nY;

  oSys.Call("User32::GetClientRect", hWndFR, lpRect);
  nY = AkelPad.MemRead(lpRect + 12, DT_DWORD) - 28;
  AkelPad.MemFree(lpRect);

  return nY;
}

function GetLinkW(sText)
{
  var hDC    = AkelPad.SystemFunction().Call("User32::GetDC", hWndCancel);
  var lpSize = AkelPad.MemAlloc(8); //sizeof(SIZE)
  var nW;

  AkelPad.SystemFunction().Call("Gdi32::SelectObject", hDC, hGuiFont);

  AkelPad.SystemFunction().Call("Gdi32::SetMapMode", hDC, 1 /*MM_TEXT*/);
  AkelPad.SystemFunction().Call("Gdi32::GetTextExtentPoint32W", hDC, sText, sText.length, lpSize);

  nW = AkelPad.MemRead(lpSize, DT_DWORD);

  AkelPad.SystemFunction().Call("User32::ReleaseDC", hWndCancel, hDC);
  AkelPad.MemFree(lpSize);

  return nW;
}

function GetFindReplaceDialog()
{
  var lpMLT = AkelPad.MemAlloc(4);
  var hWnd  = AkelPad.SendMessage(AkelPad.GetMainWnd(), 1275 /*AKD_GETMODELESS*/, 0, lpMLT);
  var hDlg  = 0;

  if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 3 /*MLT_FIND*/)
  {
    nDlgType = DLG_FIND;
    hDlg     = hWnd;
  }
  else if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 4 /*MLT_REPLACE*/)
  {
    nDlgType = DLG_REPLACE;
    hDlg     = hWnd;
  }
  else if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 5 /*MLT_GOTO*/)
  {
    nDlgType = DLG_GOTO;
    hDlg     = hWnd;
  }

  AkelPad.MemFree(lpMLT);

  return hDlg;
}

function SwitchFindReplace()
{
  bContinue = true;
  AkelPad.SendMessage(hWndFR, 273 /*WM_COMMAND*/, IDCANCEL, hWndCancel);
}
.
And I think there need to keep the changed of IDC_SEARCH_FIND when Switching between Dlg_Find and Dlg_Replace without click "Find Next" to rember that.
Back to top
View user's profile Send private message Send e-mail
FeyFre



Joined: 07 Aug 2007
Posts: 2038
Location: Vinnitsa, Ukraine

PostPosted: Fri Dec 28, 2012 10:05 am    Post subject: Reply with quote

cnnnc, I'm going to disappoint You. Concept of configuration files was made in order to ease life for users and developers. They made in order to tune up functionality and behaviour of program not cloning it. It will be hell for developer - to support dozen different sources, propagating all tiny changes into each of them. It will be hell for user - to keep updated all versions of program and not to use wrong version. So ini file is preferred, if not required.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
VladSh



Joined: 29 Nov 2006
Posts: 2610
Location: Киев, Русь

PostPosted: Fri Dec 28, 2012 10:15 am    Post subject: Reply with quote

cnnnc
I support FeyFre, as have nearly identical 100500 scripts does not matter. Variant with the option in ini is better.
And it is always better to allocate the common code in Include, not a copy of the script in the script.
Back to top
View user's profile Send private message Visit poster's website
FeyFre



Joined: 07 Aug 2007
Posts: 2038
Location: Vinnitsa, Ukraine

PostPosted: Fri Dec 28, 2012 10:20 am    Post subject: Reply with quote

KDJ, typical code is
Code:
HMODULE hModule = LoadLibrary("lang.dll");
HRSRC hRes = FindResourceEx(hModule, IDS_STRING, RT_STRING, langid);
HGLOBAL hResData = LoadResource(hModule,hRes);
LPVOID pointer= LockResource(hResData);//! Actual pointer to string. String may not include ending zero AFAIR.
DWORD sz = SizeofResource(hModule,hRes);//! Actual size of string
//! Copy string from pointer to separate memory
FreeLibrary(hModule); //! Free when not needed, if handle was obtained by LoadLibrary.

HMODULE , HRSRC, HGLOBAL - typical windows handles of size equal to size of pointer in running architecture.
DWORD - 4 bytes in all architectures.
All function located in kernel32.dll See more at MSDN
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3 ... 62, 63, 64 ... 94, 95, 96  Next
Page 63 of 96

 
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