The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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_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 |                 :    |
%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;

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.

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
    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  (from enum UniMode in source code)
    uni16LE                 | 3             | Alias for UCS2_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)

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.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 1020:

'=item' outside of any '=over'

Around line 1079:

You forgot a '=back' before '=head1'