22using System . Text ;
33using System . Windows . Forms ;
44using System . Collections . Generic ;
5+ using System . Drawing ;
56using System . Runtime . InteropServices ;
67
78namespace Kbg . NppPluginNET
@@ -201,10 +202,17 @@ public enum LangType
201202 L_ASM , L_DIFF , L_PROPS , L_PS , L_RUBY , L_SMALLTALK , L_VHDL , L_KIX , L_AU3 ,
202203 L_CAML , L_ADA , L_VERILOG , L_MATLAB , L_HASKELL , L_INNO , L_SEARCHRESULT ,
203204 L_CMAKE , L_YAML , L_COBOL , L_GUI4CLI , L_D , L_POWERSHELL , L_R , L_JSP ,
205+ L_COFFEESCRIPT ,
204206 // The end of enumated language type, so it should be always at the end
205207 L_EXTERNAL
206208 }
207209
210+ public enum winVer
211+ {
212+ WV_UNKNOWN , WV_WIN32S , WV_95 , WV_98 , WV_ME , WV_NT , WV_W2K ,
213+ WV_XP , WV_S2003 , WV_XPX64 , WV_VISTA , WV_WIN7 , WV_WIN8 , WV_WIN81
214+ }
215+
208216 [ Flags ]
209217 public enum NppMsg : uint
210218 {
@@ -257,6 +265,9 @@ public enum NppMsg : uint
257265
258266 NPPM_GETMENUHANDLE = ( NPPMSG + 25 ) ,
259267 NPPPLUGINMENU = 0 ,
268+ NPPMAINMENU = 1 ,
269+ // INT NPPM_GETMENUHANDLE(INT menuChoice, 0)
270+ // Return: menu handle (HMENU) of choice (plugin menu handle or Notepad++ main menu handle)
260271
261272 NPPM_ENCODESCI = ( NPPMSG + 26 ) ,
262273 //ascii file to unicode
@@ -366,6 +377,7 @@ public enum NppMsg : uint
366377 NPPM_GETPOSFROMBUFFERID = ( NPPMSG + 57 ) ,
367378 // INT NPPM_GETPOSFROMBUFFERID(INT bufferID, 0)
368379 // Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
380+ // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
369381 //
370382 // VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
371383 // Here's the values for the view :
@@ -380,49 +392,58 @@ public enum NppMsg : uint
380392 // allocate fullFilePath with the return values + 1, then call it again to get full path file name
381393
382394 NPPM_GETBUFFERIDFROMPOS = ( NPPMSG + 59 ) ,
395+ // INT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
383396 //wParam: Position of document
384397 //lParam: View to use, 0 = Main, 1 = Secondary
385398 //Returns 0 if invalid
386399
387400 NPPM_GETCURRENTBUFFERID = ( NPPMSG + 60 ) ,
401+ // INT NPPM_GETCURRENTBUFFERID(0, 0)
388402 //Returns active Buffer
389403
390404 NPPM_RELOADBUFFERID = ( NPPMSG + 61 ) ,
405+ // VOID NPPM_RELOADBUFFERID(0, 0)
391406 //Reloads Buffer
392407 //wParam: Buffer to reload
393408 //lParam: 0 if no alert, else alert
394409
395410
396411 NPPM_GETBUFFERLANGTYPE = ( NPPMSG + 64 ) ,
412+ // INT NPPM_GETBUFFERLANGTYPE(INT bufferID, 0)
397413 //wParam: BufferID to get LangType from
398414 //lParam: 0
399415 //Returns as int, see LangType. -1 on error
400416
401417 NPPM_SETBUFFERLANGTYPE = ( NPPMSG + 65 ) ,
418+ // BOOL NPPM_SETBUFFERLANGTYPE(INT bufferID, INT langType)
402419 //wParam: BufferID to set LangType of
403420 //lParam: LangType
404421 //Returns TRUE on success, FALSE otherwise
405422 //use int, see LangType for possible values
406423 //L_USER and L_EXTERNAL are not supported
407424
408425 NPPM_GETBUFFERENCODING = ( NPPMSG + 66 ) ,
426+ // INT NPPM_GETBUFFERENCODING(INT bufferID, 0)
409427 //wParam: BufferID to get encoding from
410428 //lParam: 0
411429 //returns as int, see UniMode. -1 on error
412430
413431 NPPM_SETBUFFERENCODING = ( NPPMSG + 67 ) ,
432+ // BOOL NPPM_SETBUFFERENCODING(INT bufferID, INT encoding)
414433 //wParam: BufferID to set encoding of
415434 //lParam: format
416435 //Returns TRUE on success, FALSE otherwise
417436 //use int, see UniMode
418437 //Can only be done on new, unedited files
419438
420439 NPPM_GETBUFFERFORMAT = ( NPPMSG + 68 ) ,
440+ // INT NPPM_GETBUFFERFORMAT(INT bufferID, 0)
421441 //wParam: BufferID to get format from
422442 //lParam: 0
423443 //returns as int, see formatType. -1 on error
424444
425445 NPPM_SETBUFFERFORMAT = ( NPPMSG + 69 ) ,
446+ // BOOL NPPM_SETBUFFERFORMAT(INT bufferID, INT format)
426447 //wParam: BufferID to set format of
427448 //lParam: format
428449 //Returns TRUE on success, FALSE otherwise
@@ -503,6 +524,51 @@ public enum NppMsg : uint
503524 // Allocates a marker number to a plugin
504525 // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful
505526
527+ NPPM_GETLANGUAGENAME = ( NPPMSG + 83 ) ,
528+ // INT NPPM_GETLANGUAGENAME(int langType, TCHAR *langName)
529+ // Get programing language name from the given language type (LangType)
530+ // Return value is the number of copied character / number of character to copy (\0 is not included)
531+ // You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy.
532+ // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
533+ // by passing allocated buffer as argument langName
534+
535+ NPPM_GETLANGUAGEDESC = ( NPPMSG + 84 ) ,
536+ // INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc)
537+ // Get programing language short description from the given language type (LangType)
538+ // Return value is the number of copied character / number of character to copy (\0 is not included)
539+ // You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy.
540+ // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
541+ // by passing allocated buffer as argument langDesc
542+
543+ NPPM_SHOWDOCSWITCHER = ( NPPMSG + 85 ) ,
544+ // VOID NPPM_ISDOCSWITCHERSHOWN(0, BOOL toShowOrNot)
545+ // Send this message to show or hide doc switcher.
546+ // if toShowOrNot is TRUE then show doc switcher, otherwise hide it.
547+
548+ NPPM_ISDOCSWITCHERSHOWN = ( NPPMSG + 86 ) ,
549+ // BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0)
550+ // Check to see if doc switcher is shown.
551+
552+ NPPM_GETAPPDATAPLUGINSALLOWED = ( NPPMSG + 87 ) ,
553+ // BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0)
554+ // Check to see if loading plugins from "%APPDATA%\Notepad++\plugins" is allowed.
555+
556+ NPPM_GETCURRENTVIEW = ( NPPMSG + 88 ) ,
557+ // INT NPPM_GETCURRENTVIEW(0, 0)
558+ // Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = Secondary
559+
560+ NPPM_DOCSWITCHERDISABLECOLUMN = ( NPPMSG + 89 ) ,
561+ // VOID NPPM_DOCSWITCHERDISABLECOLUMN(0, BOOL disableOrNot)
562+ // Disable or enable extension column of doc switcher
563+
564+ NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR = ( NPPMSG + 90 ) ,
565+ // INT NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR(0, 0)
566+ // Return: current editor default foreground color. You should convert the returned value in COLORREF
567+
568+ NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR = ( NPPMSG + 91 ) ,
569+ // INT NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0)
570+ // Return: current editor default background color. You should convert the returned value in COLORREF
571+
506572 RUNCOMMAND_USER = ( 0x400 /*WM_USER*/ + 3000 ) ,
507573 NPPM_GETFULLCURRENTPATH = ( RUNCOMMAND_USER + FULL_CURRENT_PATH ) ,
508574 NPPM_GETCURRENTDIRECTORY = ( RUNCOMMAND_USER + CURRENT_DIRECTORY ) ,
@@ -2082,6 +2148,8 @@ public class Win32
20822148 public static extern IntPtr SendMessage ( IntPtr hWnd , NppMsg Msg , int wParam , [ MarshalAs ( UnmanagedType . LPWStr ) ] string lParam ) ;
20832149 [ DllImport ( "user32" ) ]
20842150 public static extern IntPtr SendMessage ( IntPtr hWnd , NppMsg Msg , IntPtr wParam , [ MarshalAs ( UnmanagedType . LPWStr ) ] string lParam ) ;
2151+ [ DllImport ( "user32" ) ]
2152+ public static extern IntPtr SendMessage ( IntPtr hWnd , NppMsg Msg , IntPtr wParam , [ MarshalAs ( UnmanagedType . LPWStr ) ] StringBuilder lParam ) ;
20852153
20862154 [ DllImport ( "user32" ) ]
20872155 public static extern IntPtr SendMessage ( IntPtr hWnd , SciMsg Msg , int wParam , IntPtr lParam ) ;
@@ -2107,6 +2175,12 @@ public class Win32
21072175 public static extern int CheckMenuItem ( IntPtr hmenu , int uIDCheckItem , int uCheck ) ;
21082176
21092177 public const int WM_CREATE = 1 ;
2178+
2179+ [ DllImport ( "user32" ) ]
2180+ public static extern bool ClientToScreen ( IntPtr hWnd , ref Point lpPoint ) ;
2181+
2182+ [ DllImport ( "kernel32" ) ]
2183+ public static extern void OutputDebugString ( string lpOutputString ) ;
21102184 }
21112185
21122186 public class ClikeStringArray : IDisposable
@@ -2127,6 +2201,18 @@ public ClikeStringArray(int num, int stringCapacity)
21272201 }
21282202 Marshal . WriteIntPtr ( ( IntPtr ) ( ( int ) _nativeArray + ( num * IntPtr . Size ) ) , IntPtr . Zero ) ;
21292203 }
2204+ public ClikeStringArray ( List < string > lstStrings )
2205+ {
2206+ _nativeArray = Marshal . AllocHGlobal ( ( lstStrings . Count + 1 ) * IntPtr . Size ) ;
2207+ _nativeItems = new List < IntPtr > ( ) ;
2208+ for ( int i = 0 ; i < lstStrings . Count ; i ++ )
2209+ {
2210+ IntPtr item = Marshal . StringToHGlobalUni ( lstStrings [ i ] ) ;
2211+ Marshal . WriteIntPtr ( ( IntPtr ) ( ( int ) _nativeArray + ( i * IntPtr . Size ) ) , item ) ;
2212+ _nativeItems . Add ( item ) ;
2213+ }
2214+ Marshal . WriteIntPtr ( ( IntPtr ) ( ( int ) _nativeArray + ( lstStrings . Count * IntPtr . Size ) ) , IntPtr . Zero ) ;
2215+ }
21302216
21312217 public IntPtr NativePointer { get { return _nativeArray ; } }
21322218 public List < string > ManagedStringsAnsi { get { return _getManagedItems ( false ) ; } }
0 commit comments