Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eugen.kremer@gmail.com
committed
Feb 5, 2013
0 parents
commit 3c59ec0
Showing
94 changed files
with
25,262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright (C)2013 Eugen Kremer | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
|
||
|
||
Using of Common part of jN in non-GPL applications | ||
_______________________________________________________________________________ | ||
|
||
A commercial license to Common part of jN provides you the legal means | ||
both to modify it and to incorporate it into a product, without the obligation | ||
of providing the resulting code under the GPL license. Fees vary depending on | ||
the application and the scale of its use. For more information about licensing, | ||
please contact me at eugen DOT kremer AT gmail DOT com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
var Types = { | ||
DWord : 4, | ||
Word : 2, | ||
BOOL : 'DWord', | ||
BSTR : 'DWord', | ||
DWORD : 'DWord', | ||
HWND : 'DWord', | ||
HANDLE:'DWord', | ||
HINSTANCE : 'DWord', | ||
LPCTSTR : 'BSTR', | ||
UINT : 'DWord', | ||
LPPROC:'DWord', | ||
LPARAM :'DWord', | ||
'int' : 'DWord', | ||
'void': 0, | ||
GetSimple:function(name){ | ||
var ft = this[name]; | ||
if (typeof(ft) == 'number') | ||
return name; | ||
|
||
if (ft == null) | ||
throw "Unknown type: '"+name+"'"; | ||
|
||
return this.GetSimple(ft); | ||
}, | ||
GetSize:function(name){ | ||
var ft = this[this.GetSimple(name)]; | ||
|
||
return ft; | ||
}, | ||
Register:function(name, cfg){ // cfg = {name1:"type1", name2:"type2"} | ||
if (!this.Register.complex) | ||
this.Register.complex = {}; | ||
|
||
if ( this[name]) | ||
throw "Type exists: '"+name+"'"; | ||
|
||
|
||
this.Register.complex[name] = cfg; | ||
this[name] = 'LPCTSTR'; | ||
} | ||
}; | ||
|
||
function Library(path){ | ||
var lib = loadLibrary(path); | ||
this.lib =lib; | ||
|
||
var BufSize = function (formals){ | ||
var result = 0; | ||
for(var i=2, c=formals.length; i<c; i++){ | ||
var ft = Types.GetSize(formals[i]); | ||
result += ft; | ||
} | ||
return result; | ||
}; | ||
|
||
var Push = function(mem,formals, actuals){ | ||
var pos = 0; | ||
for(var i=2, c=formals.length; i<c; i++){ // begin with 2 because of 1. return value and 2. function name | ||
var type = Types.GetSimple(formals[i]); // translate custom type name to type name that undestands library object | ||
lib["write"+type](mem,pos,actuals[i-2]); // write bytes of actual parameter to the mem buffer accordingly to type | ||
pos += Types.GetSize(type); // set next buffer position. | ||
} | ||
}; | ||
|
||
this.Func = function(retType, name ){ | ||
var formals = this.Func.arguments; | ||
var size = BufSize(formals); | ||
this[name] = function(){ | ||
var mem = lib.alloc(size); | ||
Push(mem,formals, this[name].arguments); | ||
return lib.call(name,mem); | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
var kernel32 = new Library("kernel32.dll"); | ||
kernel32.Func("void", "Sleep","DWORD"); | ||
|
||
|
||
Types.Register("OPENFILENAME",{ | ||
lStructSize :"DWORD", | ||
hwndOwner :"HWND", | ||
hInstance :"HINSTANCE", | ||
lpstrFilter :"LPCTSTR", | ||
lpstrCustomFilter :"LPTSTR", | ||
nMaxCustFilter :"DWORD", | ||
nFilterIndex :"DWORD", | ||
lpstrFile :"LPTSTR", | ||
nMaxFile :"DWORD", | ||
lpstrFileTitle :"LPTSTR", | ||
nMaxFileTitle :"DWORD", | ||
lpstrInitialDir :"LPCTSTR", | ||
lpstrTitle :"LPCTSTR", | ||
Flags :"DWORD", | ||
nFileOffset :"WORD", | ||
nFileExtension :"WORD", | ||
lpstrDefExt :"LPCTSTR", | ||
lCustData :"LPARAM", | ||
lpfnHook :"LPPROC", | ||
lpTemplateName :"LPCTSTR" | ||
}); | ||
|
||
|
||
var comdlg32 = new Library("comdlg32.dll"); | ||
comdlg32.Func("BOOL","GetOpenFileName","BOOL"); | ||
|
||
|
||
|
||
var user32 = new Library("user32.dll"); | ||
/* | ||
var cbCfg = { | ||
windows:[], | ||
cmd:function(mem){ | ||
var hwnd = lib.lib.readDWord(mem, 0); | ||
var param = lib.lib.readDWord(mem, 4); | ||
var buf = lib.lib.alloc(100); | ||
//alert("hwnd: " + hwnd + ", param" + param ); | ||
var count = lib.GetWindowTextW(hwnd, buf, 100); | ||
if (count!=0){ | ||
var str = lib.lib.alloc(count); | ||
lib.lib.copy(str,0,buf,0,count*2); | ||
this.windows.push(str.toString()); | ||
} | ||
return true; | ||
} | ||
}; | ||
var cb = System.registerCallBack(cbCfg,8); | ||
try{ | ||
lib.Func("BOOL","EnumWindows","LPPROC","LPARAM"); | ||
lib.Func("int","GetWindowTextW","HWND","LPCTSTR","int"); | ||
*/ | ||
user32.Func("void","MessageBoxW","HWND", "LPCTSTR","LPCTSTR","UINT"); | ||
|
||
// user32.MessageBoxW(0,"ha","haha",0); | ||
/* | ||
lib.EnumWindows(cb,123); | ||
alert(cbCfg.windows.length + cbCfg.windows.join(",\n")); | ||
}catch(e){ | ||
alert(e); | ||
}*/ | ||
/* | ||
var mem = lib.alloc(16); | ||
lib.writeDWord(mem, 0, 1000); | ||
//lib.writeDWord(mem, 4, 21); | ||
lib.call("Sleep",mem); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
This file is part of jN, a plugin for Notepad++ | ||
Copyright (C)2013 Eugen Kremer <eugen DOT kremer AT gmail DOT com> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#define VERSION_MA 0 | ||
#define VERSION_MI 2 | ||
|
||
// increment revision in case of modification | ||
#define REVISION $WCREV$ | ||
#define xstr(s) str(s) | ||
#define str(s) #s | ||
#define _VERSION_STR VERSION_MA ## . ## REVISION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<project name="nppscripting" default="go" basedir="."> | ||
<description> | ||
</description> | ||
|
||
<target name="go" depends=""> | ||
<delete file="deploy/jN.zip"/> | ||
<zip destfile="deploy/jN.zip" > | ||
<zipfileset dir="deploy/[Notepad++ Directory]" prefix="[Notepad++ Directory]"/> | ||
<zipfileset file="deploy/readme.txt"/> | ||
<zipfileset file="Release/jN.dll" prefix="[Notepad++ Directory]/plugins"/> | ||
</zip> | ||
</target> | ||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
This file is part of jN, a plugin for Notepad++ | ||
Copyright (C)2013 Eugen Kremer <eugen DOT kremer AT gmail DOT com> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "AcceleratorHook.h" | ||
|
||
DWORD CALLBACK AcceleratorHook::Handler( int code, DWORD wParam, LONG lParam ){ | ||
AcceleratorHook* instance = AcceleratorHook::getInstance(); | ||
|
||
MSG* msg = (MSG*)lParam; | ||
|
||
if (msg && code == HC_ACTION){ | ||
AcceleratorHandler* handler = NULL; | ||
EnterCriticalSection(&instance->m_CriticalSection); | ||
for(Handlers::iterator it=instance->m_Handlers.begin(); it!=instance->m_Handlers.end(); ++it){ | ||
handler = *it; | ||
if (handler->execute(msg)){ | ||
msg->message = WM_NULL; | ||
break; | ||
} | ||
} | ||
LeaveCriticalSection(&instance->m_CriticalSection); | ||
} | ||
return CallNextHookEx(instance->m_Hook, code, wParam, lParam); | ||
} | ||
|
||
AcceleratorHook::AcceleratorHook(){ | ||
|
||
InitializeCriticalSection(&m_CriticalSection); | ||
|
||
m_Hook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) Handler, 0, GetCurrentThreadId()); | ||
|
||
} | ||
AcceleratorHook::~AcceleratorHook(){ | ||
UnhookWindowsHookEx(m_Hook); | ||
|
||
DeleteCriticalSection(&m_CriticalSection); | ||
} | ||
|
||
AcceleratorHook* AcceleratorHook::getInstance(){ | ||
static AcceleratorHook instance; | ||
|
||
return &instance; | ||
} | ||
|
||
void AcceleratorHook::remove(AcceleratorHandler* h){ | ||
EnterCriticalSection(&m_CriticalSection); | ||
|
||
m_Handlers.erase(h); | ||
|
||
LeaveCriticalSection(&m_CriticalSection); | ||
} | ||
|
||
void AcceleratorHook::add(AcceleratorHandler* h){ | ||
EnterCriticalSection(&m_CriticalSection); | ||
|
||
if (h) | ||
m_Handlers.insert(h); | ||
|
||
LeaveCriticalSection(&m_CriticalSection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
This file is part of jN, a plugin for Notepad++ | ||
Copyright (C)2013 Eugen Kremer <eugen DOT kremer AT gmail DOT com> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include <set> | ||
#include <windows.h> | ||
|
||
// hook Message befor npp receive it | ||
// try to translate accelerator and if was translated | ||
// say npp to do nothing | ||
|
||
class AcceleratorHook{ | ||
private: | ||
HHOOK m_Hook; | ||
CRITICAL_SECTION m_CriticalSection; | ||
|
||
static DWORD CALLBACK Handler( int code, DWORD wParam, LONG lParam ); | ||
|
||
AcceleratorHook(); | ||
~AcceleratorHook(); | ||
|
||
public: | ||
class AcceleratorHandler{ | ||
public: | ||
virtual int execute(MSG* msg){ | ||
// overload this method | ||
return 0; | ||
} | ||
}; | ||
|
||
static AcceleratorHook* getInstance(); | ||
|
||
void remove(AcceleratorHandler* h); | ||
|
||
void add(AcceleratorHandler* h); | ||
|
||
private: | ||
typedef std::set<AcceleratorHandler*> Handlers; | ||
Handlers m_Handlers; | ||
|
||
}; |
Oops, something went wrong.