NAME

Win32::Mechanize::NotepadPlusPlus::Notepad::Messages - Define values for using messages, notifications, and their arguments

SYNOPSIS

use Win32::Mechanize::NotepadPlusPlus ':vars';
print "$_\n" for sort { $NPPMSG{$a} <=> $NPPMSG{$b} } keys %NPPMSG;             # prints all message keys in numerical order

DESCRIPTION

Notepad++'s Plugin Communication system defines a set of messages that applications (either plugins embedded in Notepad++, or external programs) can use for communicating with (and thus controlling) Notepad++.

The hashes in Win32::Mechanize::NotepadPlusPlus::Notepad::Messages give named access to the underlying messages, as well as named versions of the constants used as arguments for those messages.

MESSAGES

%NPPMSG

Most of the Notepad++ Messages are already implemented in the Win32::Mechanize::NotepadPlusPlus::Notepad interface, and under normal circumstances, the end-user should never need to access this %NPPMSG hash directly.

However, if you have a reason to use notepad->SendMessage directly, you can use the values from this hash. Usually, this would only be done if you want a unique wrapper around the message, or want to implement a new or unimplemented message.

As an example of using th %NPPMSG hash, this code replicates notepad->getNppVersion behavior:

my $nppv = notepad->SendMessage( $NPPMSG{NPPM_GETNPPVERSION}, 0, 0);
print "npp v", join('.', $v>>16, split//,($v&0xFFFF)), "\n";
DEPRECATED %nppm

Deprecated: This variable has been deleted. If you used it before, please replace with %NPPMSG or the other appropriate hash.

%VIEW

There are two groups of methods that access the views.

The first is getNumberOpenFiles(), which uses three of the %VIEW keys to count the number of files open in the specified view.

Key             | Value | Description
----------------+-------+------------------------------
ALL_OPEN_FILES  | 0     | Total of files in both views
PRIMARY_VIEW    | 1     | Only the files in the primary view (usually the left view: editor1)
SECOND_VIEW     | 2     | Only the files in the second view (usually the right view: editor2)

The second group are the buffer-related methods.

Key             | Value | Description
----------------+-------+------------------------------
MAIN_VIEW       | 0     | Access the main view (usually the left view: editor1)
SUB_VIEW        | 1     | Access the sub view (usually the right view: editor2)

Yes, the two groups have an off-by-one. That's the way the underlying Notepad++ code, and thus the Plugin Interface, was designed.

%MODELESS
TODO: issue #18

These would be used by the $NPPMSG{NPPM_MODELESSDIALOG} message. However, registerModelessDialog() has not yet been implemented.

Key                     | Description
------------------------|------------
MODELESSDIALOGADD       | Registers a dialog's hWnd
MODELESSDIALOGREMOVE    | Un-registers a dialog's hWnd
%STATUSBAR

These are be used by the setStatusBar() method for choosing which section of the status bar to change.

Key                     |   | Description
------------------------+---+-----------------
STATUSBAR_DOC_TYPE      | 0 | Document's syntax lexer (language)
STATUSBAR_DOC_SIZE      | 1 | File size
STATUSBAR_CUR_POS       | 2 | Current cursor position
STATUSBAR_EOF_FORMAT    | 3 | EOL (End-Of-Line) format
STATUSBAR_UNICODE_TYPE  | 4 | Encoding
STATUSBAR_TYPING_MODE   | 5 | Insert (INS) or Overwrite (OVR)
%MENUHANDLE

Used internally by getMainMenuHandle() and getPluginMenuHandle() to return handles to the specified menus.

Key             |   | Description
----------------+---+-----------------
NPPMAINMENU     | 1 | Main menu (contains File, Edit, ...)
NPPPLUGINMENU   | 0 | Plugins menu (a submenu of the Main menu)
%INTERNALVAR

Pass these to getNppDir() to access the internal variables described in the Macros section of the official docs.

Key                 | Description                               | Example
--------------------+-------------------------------------------+----------------------------
FULL_CURRENT_PATH   | full path to the active file              | E:\My Web\main\welcome.html
CURRENT_DIRECTORY   | active file’s directory                   | E:\My Web\main
FILE_NAME           | active file’s name                        | welcome.html
NAME_PART           | filename without extension                | welcome
EXT_PART            | extension                                 | html
CURRENT_WORD        | active selection or word under the cursor | text
CURRENT_LINE        | line number of cursor location            | 1
CURRENT_LINESTR     | text of the current line                  | tex of whole line
CURRENT_COLUMN      | column number of cursor location          | 5
NPP_DIRECTORY       | notepad++ executable's directory          | c:\Program Files\notepad++
NPP_FULL_FILE_PATH  | full path to the notepad++.exe            | c:\Program Files\notepad++\notepad++.exe
%LANGTYPE

Used by language parser methods.

L_TEXT      : 0  | L_CSS       : 20 | L_AU3           : 40 | L_BAANC         : 60 | L_REGISTRY      : 80 |
L_PHP       : 1  | L_PERL      : 21 | L_CAML          : 41 | L_SREC          : 61 | L_RUST          : 81 |
L_C         : 2  | L_PYTHON    : 22 | L_ADA           : 42 | L_IHEX          : 62 | L_SPICE         : 82 |
L_CPP       : 3  | L_LUA       : 23 | L_VERILOG       : 43 | L_TEHEX         : 63 | L_TXT2TAGS      : 83 |
L_CS        : 4  | L_TEX       : 24 | L_MATLAB        : 44 | L_SWIFT         : 64 | L_VISUALPROLOG  : 84 |
L_OBJC      : 5  | L_FORTRAN   : 25 | L_HASKELL       : 45 | L_ASN1          : 65 | L_EXTERNAL      : 85 |
L_JAVA      : 6  | L_BASH      : 26 | L_INNO          : 46 | L_AVS           : 66 |                 :    |
L_RC        : 7  | L_FLASH     : 27 | L_SEARCHRESULT  : 47 | L_BLITZBASIC    : 67 |                 :    |
L_HTML      : 8  | L_NSIS      : 28 | L_CMAKE         : 48 | L_PUREBASIC     : 68 |                 :    |
L_XML       : 9  | L_TCL       : 29 | L_YAML          : 49 | L_FREEBASIC     : 69 |                 :    |
L_MAKEFILE  : 10 | L_LISP      : 30 | L_COBOL         : 50 | L_CSOUND        : 70 |                 :    |
L_PASCAL    : 11 | L_SCHEME    : 31 | L_GUI4CLI       : 51 | L_ERLANG        : 71 |                 :    |
L_BATCH     : 12 | L_ASM       : 32 | L_D             : 52 | L_ESCRIPT       : 72 |                 :    |
L_INI       : 13 | L_DIFF      : 33 | L_POWERSHELL    : 53 | L_FORTH         : 73 |                 :    |
L_ASCII     : 14 | L_PROPS     : 34 | L_R             : 54 | L_LATEX         : 74 |                 :    |
L_USER      : 15 | L_PS        : 35 | L_JSP           : 55 | L_MMIXAL        : 75 |                 :    |
L_ASP       : 16 | L_RUBY      : 36 | L_COFFEESCRIPT  : 56 | L_NIMROD        : 76 |                 :    |
L_SQL       : 17 | L_SMALLTALK : 37 | L_JSON          : 57 | L_NNCRONTAB     : 77 |                 :    |
L_VB        : 18 | L_VHDL      : 38 | L_JAVASCRIPT    : 58 | L_OSCRIPT       : 78 |                 :    |
L_JS        : 19 | L_KIX       : 39 | L_FORTRAN_77    : 59 | L_REBOL         : 79 |                 :    |
%LINENUMWIDTH

Used by setLineNumberWidthMode and getLineNumberWidthMode.

Key                   |   | Description
----------------------+---+-----------------
LINENUMWIDTH_CONSTANT | 1 | Line-number column width always wide enough for largest line number
LINENUMWIDTH_DYNAMIC  | 0 | Line-number column width changes with number of digits in local line number

Added in v7.9.2.

%WINVER

I'm not sure it's really useful, but it's still privided.

print join "\n", map { "$_ => $WINVER{$_}" } sort keys %WINVER;
%WINPLATFORM

I'm not sure it's really useful, but it's still privided.

print join "\n", map { "$_ => $WINPLATFORM{$_}" } sort keys %WINPLATFORM;
%WINMSGBOX

Used by messageBox. The first group set which buttons are in the dialog box. The second group set which button is the default/activge button. The third group affect the icon used for the dialog box. The final group encode the return values.

Key                  | Value      | Description
---------------------+------------+---------------------------------------------------------------------
ABORTRETRYIGNORE     | 0x00000002 | The message box contains three push buttons: Abort, Retry, and Ignore.
CANCELTRYCONTINUE    | 0x00000006 | The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of MB_ABORTRETRYIGNORE.
HELP                 | 0x00004000 | Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner.
OK                   | 0x00000000 | The message box contains one push button: OK. This is the default.
OKCANCEL             | 0x00000001 | The message box contains two push buttons: OK and Cancel.
RETRYCANCEL          | 0x00000005 | The message box contains two push buttons: Retry and Cancel.
YESNO                | 0x00000004 | The message box contains two push buttons: Yes and No.
YESNOCANCEL          | 0x00000003 | The message box contains three push buttons: Yes and No and Cancel.
---------------------+------------+---------------------------------------------------------------------
DEFBUTTON1           | 0x00000000 | The first button is the default button. DEFBUTTON1 is the default unless DEFBUTTON2, DEFBUTTON3, or DEFBUTTON4 is specified.
DEFBUTTON2           | 0x00000100 | The second button is the default button.
DEFBUTTON3           | 0x00000200 | The third button is the default button.
DEFBUTTON4           | 0x00000300 | The fourth button is the default button.
---------------------+------------+---------------------------------------------------------------------
ICONEXCLAMATION      | 0x00000030 | An exclamation-point icon appears in the message box.
ICONWARNING          | 0x00000030 | An exclamation-point icon appears in the message box.
ICONINFORMATION      | 0x00000040 | An icon consisting of a lowercase letter i in a circle appears in the message box.
ICONASTERISK         | 0x00000040 | An icon consisting of a lowercase letter i in a circle appears in the message box.
ICONQUESTION         | 0x00000020 | A question-mark icon appears in the message box. The question-mark message icon is no longer recommended because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition, users can confuse the message symbol question mark with Help information. Therefore, do not use this question mark message symbol in your message boxes. The system continues to support its inclusion only for backward compatibility.
ICONSTOP             | 0x00000010 | A stop-sign icon appears in the message box.
ICONERROR            | 0x00000010 | A stop-sign icon appears in the message box.
ICONHAND             | 0x00000010 | A stop-sign icon appears in the message box.
---------------------+------------+---------------------------------------------------------------------
RETURN_ABORT         | 3          | The Abort button was selected.
RETURN_CANCEL        | 2          | The Cancel button was selected.
RETURN_CONTINUE      | 11         | The Continue button was selected.
RETURN_IGNORE        | 5          | The Ignore button was selected.
RETURN_NO            | 7          | The No button was selected.
RETURN_OK            | 1          | The OK button was selected.
RETURN_RETRY         | 4          | The Retry button was selected.
RETURN_TRYAGAIN      | 10         | The Try Again button was selected.
RETURN_YES           | 6          | The Yes button was selected.
---------------------+------------+---------------------------------------------------------------------

NOTIFICATIONS

Not yet used, but the constants are available.

%NOTIFICATION

If you are interested, you can find all the message keys with code like the following:

use Win32::Mechanize::NotepadPlusPlus ':vars';
printf "%-39s => %d\n", $_, $NOTIFICATION{$_} for sort { $NOTIFICATION{$a} <=> $NOTIFICATION{$b} } keys %NOTIFICATION;   # prints all notification keys in numerical order
%DOCSTATUS

Used by the NPPN_READONLYCHANGED notification.

Key                     |   | Description
------------------------+---+-----------------
DOCSTATUS_READONLY      | 1 | The file changed its "is readonly" status
DOCSTATUS_BUFFERDIRTY   | 0 | The file changed its "is modified" status

Underlying the Notepad++ menu system (and any other Win32-API-based application), there are individual command IDs for each menu command. Notepad++ gives accesss through the NPPM_MENUCOMMAND message, and notepad->menuCommand() allows you to activate any menu entry's command by its menu ID.

You can find out the names and values of all the messages using:

use Win32::Mechanize::NotepadPlusPlus ':vars';
printf "%-40s => %s\n", $_, $NPPIDM{$_} for sort keys %NPPIDM;
%NPPIDM
# both of the next two are equivalent to notepad->close(), but using the command ID for File > Close
notepad->menuCommand( $NPPIDM{IDM_FILE_CLOSE} );
notepad->SendMessage( $NPPMSG{NPPM_MENUCOMMAND} , 0 , $NPPIDM{IDM_FILE_CLOSE} );
DEPRECATED %nppidm

Deprecated name for %NPPIDM. This variable no longer exists. If you were using it, replace it with %NPPIDM.

OTHER USEFUL ENUMERATIONS

DEPRECATED %ENCODINGKEY

Deprecated: The %ENCODINGKEY hash variable no longer exists. Use "%BUFFERENCODING" for the correct values.

This deprecated hash incorrectly assumed there was a simple numerical offset between the values of notepad->getEncoding and the $NPPIDM{IDM_FORMAT_...} entries in "%NPPIDM".

%BUFFERENCODING

The numerical values from this hash can be passed to notepad->setEncoding to change the encoding of the buffer; the numerical values returned from notepad->getEncoding can be passed as keys for this hash to convert the encoding number back to a string.

Keys or values ending in _BOM indicate the Unicode Byte Order Mark will be included as the first bytes in the saved file.

Key                     | Value         | Description
------------------------+---------------+-----------------
ANSI                    | 0             | 256 codepoints
UTF8_BOM                | 1             | UTF-8 Encoding, using Byte Order Mark (BOM) at beginning of file
UCS2_BE_BOM             | 2             | UCS-2 Big Endian, using Byte Order Mark (BOM) at beginning of file
UCS2_LE_BOM             | 3             | UCS-2 Little Endian, using Byte Order Mark (BOM) at beginning of file
UTF16_BE_BOM            | 2             | UTF-16 Big Endian, using Byte Order Mark (BOM) at beginning of file
UTF16_LE_BOM            | 3             | UTF-16 Little Endian, using Byte Order Mark (BOM) at beginning of file
UTF8                    | 4             | UTF-8 Encoding, _not_ using Byte Order Mark (BOM) at beginning of file
------------------------+---------------+-----------------
COOKIE                  | 4             | Alias for UTF8         (name used in PythonScript BUFFERENCODING enum)
uni8Bit                 | 0             | Alias for ANSI         (from enum UniMode in source code)
uniUTF8                 | 1             | Alias for UTF8_BOM     (from enum UniMode in source code)
uni16BE                 | 2             | Alias for UCS2_BE_BOM/UTF16_BE_BOM  (from enum UniMode in source code)
uni16LE                 | 3             | Alias for UCS2_LE_BOM/UTF16_LE_BOM  (from enum UniMode in source code)
uniCookie               | 4             | Alias for UTF8_NO_BOM  (from enum UniMode in source code)
------------------------+---------------+-----------------
0                       | ANSI          | (string)
1                       | UTF8_BOM      | (string)
2                       | UCS2_BE_BOM   | (string)
3                       | UCS2_LE_BOM   | (string)
4                       | UTF8_NO_BOM   | (string)
%MACROSTATUS

These are the values returned by notepad->getCurrentMacroStatus This hash provides a two way map: so its keys include both the string names (with the integers as values) and the integers (with the string names as values).

Name                    | Integer       | Description
------------------------+---------------+-----------------
Idle                    | 0             | No macro activity (normal/default state)
RecordInProgress        | 1             | Macro recording has started
RecordingStopped        | 2             | Macro recording has completed
PlayingBack             | 3             | Macro is being played back (rare)

The PlayingBack state is not common, because your script has to have called getCurrentMacroStatus during the brief time that the macro playback is in progress. (Unless you have a complicated search/replace and a large document, it's not likely to see this state.)

INSTALLATION

Installed as part of Win32::Mechanize::NotepadPlusPlus

AUTHOR

Peter C. Jones <petercj AT cpan DOT org>

Please report any bugs or feature requests emailing <bug-Win32-Mechanize-NotepadPlusPlus AT rt.cpan.org> or thru the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Win32-Mechanize-NotepadPlusPlus, or thru the repository's interface at https://github.com/pryrt/Win32-Mechanize-NotepadPlusPlus/issues.

COPYRIGHT

Copyright (C) 2019,2020 Peter C. Jones

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.