// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Text;
using NppPluginNET.PluginInfrastructure;
namespace Kbg.NppPluginNET.PluginInfrastructure
{
public interface INotepadPPGateway
{
void FileNew();
string GetCurrentFilePath();
unsafe string GetFilePath(int bufferId);
void SetCurrentLanguage(LangType language);
///
/// Returns the response from NPPM_GETFILENAME
///
///
string GetCurrentFileName();
///
/// Returns the response from NPPM_GETCURRENTDIRECTORY
///
///
string GetCurrentDirectory();
}
///
/// This class holds helpers for sending messages defined in the Msgs_h.cs file. It is at the moment
/// incomplete. Please help fill in the blanks.
///
public class NotepadPPGateway : INotepadPPGateway
{
private const int Unused = 0;
public void FileNew()
{
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_MENUCOMMAND, Unused, NppMenuCmd.IDM_FILE_NEW);
}
///
/// Returns the response from NPPM_GETCURRENTDIRECTORY
///
///
public string GetCurrentDirectory()
{
StringBuilder path = new StringBuilder(Win32.MAX_PATH);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETCURRENTDIRECTORY, 0, path);
return path.ToString();
}
///
/// Returns the response from NPPM_GETFILENAME
///
///
public string GetCurrentFileName()
{
StringBuilder fileName = new StringBuilder(Win32.MAX_PATH);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETFILENAME, 0, fileName);
return fileName.ToString();
}
///
/// Gets the path of the current document.
///
public string GetCurrentFilePath()
{
var path = new StringBuilder(2000);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);
return path.ToString();
}
///
/// Gets the path of the current document.
///
public unsafe string GetFilePath(int bufferId)
{
var path = new StringBuilder(2000);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETFULLPATHFROMBUFFERID, bufferId, path);
return path.ToString();
}
public void SetCurrentLanguage(LangType language)
{
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETCURRENTLANGTYPE, Unused, (int) language);
}
}
///
/// This class holds helpers for sending messages defined in the Resource_h.cs file. It is at the moment
/// incomplete. Please help fill in the blanks.
///
class NppResource
{
private const int Unused = 0;
public void ClearIndicator()
{
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) Resource.NPPM_INTERNAL_CLEARINDICATOR, Unused, Unused);
}
}
}