Table of Contents

Class NotepadPPGateway

Namespace
Npp.DotNet.Plugin
Assembly
Npp.DotNet.Plugin.dll

Helpers for sending messages defined in NppMsg.

public class NotepadPPGateway
Inheritance
NotepadPPGateway
Inherited Members

Methods

AddToolbarIcon(int, ToolbarIcon)

Associates the plugin command identified by funcItemsIndex with the set of icons defined by the given ToolbarIcon instance.

[Obsolete("Use AddToolbarIcon(System.Int32, Npp.DotNet.Plugin.ToolbarIconDarkMode) instead")]
public void AddToolbarIcon(int funcItemsIndex, ToolbarIcon icon)

Parameters

funcItemsIndex int
icon ToolbarIcon

AddToolbarIcon(int, ToolbarIconDarkMode)

Associates the plugin command identified by funcItemsIndex with the set of icons defined by the given ToolbarIconDarkMode instance.

public void AddToolbarIcon(int funcItemsIndex, ToolbarIconDarkMode icon)

Parameters

funcItemsIndex int
icon ToolbarIconDarkMode

AddToolbarIcon(int, Bitmap)

Associates the given bitmap with the plugin command identified by funcItemsIndex.

[Obsolete("Use AddToolbarIcon(System.Int32, Npp.DotNet.Plugin.ToolbarIconDarkMode) instead")]
public void AddToolbarIcon(int funcItemsIndex, Bitmap icon)

Parameters

funcItemsIndex int
icon Bitmap

AllocateIndicators(int, out int[])

Allocates one or more unused indicator IDs, which can then be assigned styles and used to style regions of text.

See https://www.scintilla.org/ScintillaDoc.html#Indicators for more info on the indicator API.

public bool AllocateIndicators(int numberOfIndicators, out int[] indicators)

Parameters

numberOfIndicators int

The number of consecutive indicator IDs to allocate.

indicators int[]

Target buffer of the allocated indicator IDs.

Returns

bool

On success, the return value is true and indicators will be initialzed with the requested range of indicators. If numberOfIndicators is less than 1, or the requested indicators could not be allocated, indicators is left empty and false is returned.

Remarks

Added in 8.5.6

DefaultModificationFlagsChanged()

Returns true if the active SCN_MODIFIED event mask has been changed from NPP_DEFAULT_SC_MOD_MASK.

public bool DefaultModificationFlagsChanged()

Returns

bool

Remarks

Added in 8.7.7

ExecuteMenuCommand(MenuCmdId)

Sends the given MenuCmdId to the Notepad++ application window.

protected void ExecuteMenuCommand(MenuCmdId cmdId)

Parameters

cmdId MenuCmdId

FileNew()

Creates a new buffer by invoking the File - New menu command.

public void FileNew()

GetConfigDirectory()

public string GetConfigDirectory()

Returns

string

The path to the Config folder for plugins.

GetCurrentFilePath()

Gets the path of the current document.

public string GetCurrentFilePath()

Returns

string

GetCurrentLanguage()

Gets the syntax mode of the current buffer.

public LangType GetCurrentLanguage()

Returns

LangType

GetCurrentLine()

Gets the text of the currently active line.

public string GetCurrentLine()

Returns

string

The text of the active line.

GetCurrentWord()

Gets the word currently under the caret.

public string GetCurrentWord()

Returns

string

The word under the caret.

GetFilePath(UIntPtr)

Gets the path of the document with the given bufferId.

public string GetFilePath(UIntPtr bufferId)

Parameters

bufferId UIntPtr

Returns

string

The full file path of the document, if bufferId is valid; otherwise, an empty string.

GetNativeLanguage()

Get the name of the active localization file.

public string GetNativeLanguage()

Returns

string

N++ 8.7 and later

The name of the active localization file, without the .xml extension.

Older versions

"english"

GetNppPath()

public string GetNppPath()

Returns

string

The path to the Notepad++ executable.

GetNppVersion()

public (int, int, int) GetNppVersion()

Returns

(int, int, int)

3-int tuple: (major, minor, bugfix)
Thus GetNppVersion() would return (8, 5, 0) for version 8.5.0 and (7, 7, 1) for version 7.7.1

GetOpenFileNames()

Get the full path names of all files currently open in all views.

public string[] GetOpenFileNames()

Returns

string[]

The combined list of open files in both the PRIMARY_VIEW and the SECOND_VIEW.

GetPluginsHomePath()

public string GetPluginsHomePath()

Returns

string

The path to the top directory of all installed plugins.

GetSessionFilePath()

public string GetSessionFilePath()

Returns

string

The path to session.xml.

IsDarkModeEnabled()

Checks the return value of the NPPM_ISDARKMODEENABLED message.

public bool IsDarkModeEnabled()

Returns

bool

true if NPPM_ISDARKMODEENABLED returns 1, otherwise false.

Remarks

Added in 8.4.1

OpenFile(string)

Open a file for editing in Notepad++, pretty much like using the app's File - Open menu.

public bool OpenFile(string path)

Parameters

path string

The path to the file to open.

Returns

bool

true on success, otherwise false.

SaveCurrentFile()

Open a standard save file dialog to save the current file.

public bool SaveCurrentFile()

Returns

bool

true if the file was saved, otherwise false.

SetCurrentLanguage(LangType)

Sets the syntax mode of the current buffer to the given programming language.

public void SetCurrentLanguage(LangType language)

Parameters

language LangType

SetModificationFlags(ModificationFlags)

Sends NPPM_ADDSCNMODIFIEDFLAGS with the given flags.

public void SetModificationFlags(ModificationFlags flags)

Parameters

flags ModificationFlags

The additional ModificationFlags to monitor.

Remarks

Added in 8.7.7

SetStatusBarSection(string, StatusBarSection)

The status bar is the bar at the bottom with the document type, EOL type, current position, line, etc.
Set the message for one of the sections of that bar.

public void SetStatusBarSection(string message, StatusBarSection section)

Parameters

message string

Text to display.

section StatusBarSection

A StatusBarSection value.