NAME

Win32::Mechanize::NotepadPlusPlus - Automate the Windows application Notepad++

SYNOPSIS

use Win32::Mechanize::NotepadPlusPlus ':main';
my $npp = notepad();    # main application

DESCRIPTION

Automate the Windows application Notepad++. This is inspired by the Notepad++ plugin PythonScript, but I decided to automate the application from the outside, rather than from inside a Notepad++ plugin. But this module uses similar naming conventions and interface to the PythonScript plugin.

SUBCLASSES

These give you access to the Notepad++ application GUI and the Scintilla editor components inside Notepad++. The main module exports functions that return the default instances.

Notepad

notepad

Win32::Mechanize::NotepadPlusPlus::Notepad gives access to the actual Notepad++ application.

my $npp = notepad();
$npp->CloseAll();

Editor

editor1
editor2
editor

Win32::Mechanize::NotepadPlusPlus::Editor gives access to the underlying Scintilla component(s) used to actually edit the text files in Notepad++.

In PythonScript, the default instance is called editor for the active editor window. There are two additional instances, editor1 and editor2 for accessing the specific "left" and "right" editor panes.

my $left_pane = editor1();
my $right_pane = editor2();
if( editor() == $left_pane ) { ... }    # do this only if left pane is active pane

What About a Console Object?

The Console was a PythonScript feature, beacuse it had an embedded Python interpreter. Since Win32::Mechanize::NotepadPlusPlus is an outside-in framework, there is no Perl interpreter embedded in Notepad++.

EXPORTS

By default, the module exports nothing.

:main

Exports the "notepad", "editor", "editor1", and "editor2" functions.

:vars

Exports the variables from both Win32::Mechanize::NotepadPlusPlus::Notepad::Messages and Win32::Mechanize::NotepadPlusPlus::Editor::Messages

use Win32::Mechanize::NotepadPlusPlus qw/:vars/;
# from Notepad::Messages: %NPPMSG, %VIEW, %MODELESS, %STATUSBAR, %MENUHANDLE, %INTERNALVAR, %LANGTYPE, %WINVER, %WINPLATFORM, %NOTIFICATION, %DOCSTATUS, %NPPIDM, %ENCODINGKEY
# from Editor::Messages: %SCIMSG, %SCINTILLANOTIFICATION, and more than 50 others.

LIMITATIONS

This is the first public release of the module. In general, it works. As with all first releases, there is room for improvement; I welcome feedback.

The first known limitation is that none of the hooks for Scintilla or Notepad++ callbacks have been enabled. That may come sometime in the future.

All the testing and development was done with a US-English installation of Notepad++, and all the file encodings have been ANSI or UTF-8. I know that I need to include better tests for encoding, and any help you can provide with that is appreciated.

Notepad++ is a Windows application, so that's the intended platform for this module. However, I know Notepad++ can be made to run in Wine and similar environments in Linux, so it may be possible to make this module drive Notepad++ in such an environment. Feedback on this process is welcome.

INSTALLATION

To install this module, use your favorite CPAN client.

For a manual install, type the following:

perl Makefile.PL
make
make test
make install

(On Windows machines, you may need to use "dmake" or "gmake" instead of "make", depending on your setup.)

AUTHOR

Peter C. Jones <petercj AT cpan DOT org>

Please report any bugs or feature requests thru the repository's interface at https://github.com/pryrt/Win32-Mechanize-NotepadPlusPlus/issues, or by 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.

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.