### GetNppPath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the installation directory of Notepad++. ```APIDOC ## GetNppPath ### Description Gets the installation directory of Notepad++. ### Method ```csharp public string GetNppPath() ``` ### Parameters *(none)* ### Response `string` - Path to the Notepad++ installation directory ### Example ```csharp string nppPath = notepad.GetNppPath(); ``` ``` -------------------------------- ### Set Notepad++ Styling Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Examples demonstrating how to enable or disable Notepad++ styling for plugin forms. ```csharp // Enable Notepad++ styling Main.settings.use_npp_styling = true; Main.RestyleEverything(); // Apply immediately // Disable styling (use default Windows forms styling) Main.settings.use_npp_styling = false; ``` -------------------------------- ### Set Toolbar Icons Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Examples demonstrating how to set the toolbar_icons property to control the display of plugin icons. ```csharp // Show all three icons in order Main.settings.toolbar_icons = "ash"; // Show only About and HTML tag icons Main.settings.toolbar_icons = "ah"; // Show no icons Main.settings.toolbar_icons = "x"; ``` -------------------------------- ### INI Configuration File Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/docs/README.md Example of a configuration file for the C# plugin. This format is used to store and retrieve plugin settings persistently. ```ini [Styling] ; Use the same colors as the editor window for this plugin's forms? use_npp_styling=True [Testing] ; Ask before running tests, because the test can hijack the user's clipboard ask_before_testing=DO_WITHOUT_ASKING ``` -------------------------------- ### Example JSON5 Translation File (Italian) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md This example shows how to create a new translation file by copying the English file and replacing values with Italian translations. ```json5 { "&Documentation": "&Documentazione", "A&bout": "&About", // ... rest of translations } ``` -------------------------------- ### Get Notepad++ Configuration Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the path to the Notepad++ configuration directory. ```csharp public string GetConfigDirectory() ``` ```csharp string configDir = notepad.GetConfigDirectory(); ``` -------------------------------- ### Set Prompt Before Testing Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Example of setting the ask_before_testing property to prevent prompts before running tests. ```csharp Main.settings.ask_before_testing = AskUserWhetherToDoThing.NEVER_DO; ``` -------------------------------- ### Example INI File Structure Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/configuration.md Demonstrates the standard Windows INI file format with sections and key-value pairs for plugin configuration. ```ini [Miscellaneous] toolbar_icons=ash close_html_tag=false [Styling] use_npp_styling=true [Testing] ask_before_testing=0 ``` -------------------------------- ### AskUserWhetherToDoThing Usage Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/types.md Shows how to check a setting that uses the AskUserWhetherToDoThing enum to determine if tests should be run automatically. ```csharp if (Main.settings.ask_before_testing == AskUserWhetherToDoThing.ALWAYS_DO) RunTests(); ``` -------------------------------- ### Get Notepad++ Installation Path Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the directory path where Notepad++ is installed. Useful for accessing application-specific resources or configurations. ```csharp string nppPath = notepad.GetNppPath(); ``` -------------------------------- ### Basic File Operations in Notepad++ Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Demonstrates how to get the current file path, open an existing file, and create a new document using the NotepadPPGateway. ```csharp // Get current file var gateway = new NotepadPPGateway(); string currentFile = gateway.GetCurrentFilePath(); // Open a new file if (!gateway.OpenFile(@"C:\myfile.txt")) { MessageBox.Show("Could not open file"); } // Create a new document gateway.FileNew(); ``` -------------------------------- ### ScrollInfo Usage Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/types.md Shows how to retrieve ScrollInfo from an editor and access its properties to get the current and maximum scroll positions. ```csharp ScrollInfo scrollInfo = editor.GetScrollInfo(); int currentPos = scrollInfo.nPos; int maxPos = scrollInfo.nMax; ``` -------------------------------- ### Trigger Settings Change and Restyling Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Example demonstrating how changing a setting and calling OnSettingsChanged triggers restyling. ```csharp // This is called automatically by the settings form Main.settings.use_npp_styling = false; Main.settings.OnSettingsChanged(); // Triggers restyling ``` -------------------------------- ### Accessing Plugin Configuration Paths Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the Notepad++ installation directory and the plugin configuration directory to construct a path for a custom configuration file. ```csharp var gateway = new NotepadPPGateway(); string nppDir = gateway.GetNppPath(); string configDir = gateway.GetPluginConfigPath(); string myConfigFile = Path.Combine(configDir, "MyPlugin", "config.ini"); ``` -------------------------------- ### Colour Usage Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/types.md Illustrates creating Colour objects using both the combined RGB integer constructor and the individual component constructor, and accessing the combined value. ```csharp // From combined RGB value var white = new Colour(0xFFFFFF); // From components var red = new Colour(255, 0, 0); var green = new Colour(0, 255, 0); var blue = new Colour(0, 0, 255); // Get combined value int rgbValue = blue.Value; ``` -------------------------------- ### Set HTML Tag Auto-Closing Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Example of enabling HTML tag auto-closing and saving the setting. ```csharp Main.settings.close_html_tag = true; Main.settings.OnSettingsChanged(); // Save to INI ``` -------------------------------- ### Example JSON5 Translation Structure (Spanish) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md This is an example of the JSON5 structure for a Spanish translation file. Keys are the original English strings, and values are the Spanish translations. ```json5 { "&Documentation": "&Documentación", "A&bout": "&Acerca de", "&Settings": "&Configuración", "About Form": "Formulario Acerca de", "Version": "Versión", "OK": "OK", "Cancel": "Cancelar", "Are you sure?": "¿Estás seguro?", "Operation complete!": "¡Operación completada!", } ``` -------------------------------- ### Example JSON5 Translation Structure (English) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md This is an example of the JSON5 structure for an English translation file. Keys are the original English strings, and values are the English text. ```json5 { // Menu items (key is the English text with accelerators) "&Documentation": "&Documentation", "A&bout": "A&bout", "&Settings": "&Settings", // Form titles and controls "About Form": "About Form", "Version": "Version", "OK": "OK", "Cancel": "Cancel", // Message boxes "Are you sure?": "Are you sure?", "Operation complete!": "Operation complete!", } ``` -------------------------------- ### Position Usage Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/types.md Demonstrates how to create and use the Position class for calculating distances between two points in a document. ```csharp var pos1 = new Position(10); var pos2 = new Position(20); Position distance = pos2 - pos1; // 10 ``` -------------------------------- ### Settings Pattern Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md This C# code illustrates the settings pattern using attributes for description, category, and default values. The SettingsBase class automatically handles UI generation, persistence, and type conversion for these settings. ```csharp [Description("User-friendly description")] [Category("CategoryName")] [DefaultValue(42)] public int my_setting { get; set; } ``` -------------------------------- ### GetPluginConfigPath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the plugins configuration directory path. ```APIDOC ## GetPluginConfigPath ### Description Gets the plugins configuration directory path. ### Method ```csharp public string GetPluginConfigPath() ``` ### Parameters *(none)* ### Response `string` - Path to the plugins configuration directory ### Example ```csharp string configPath = notepad.GetPluginConfigPath(); ``` ``` -------------------------------- ### JSON Translation File Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md Create translation files in JSON5 format to support multiple languages within your plugin. Map UI strings to their translated equivalents. ```json5 // translation/spanish.json5 { "My Menu Item": "Mi Elemento de Menú", "Dialog Title": "Título del Diálogo" } ``` -------------------------------- ### Respond to Specific Setting Changes Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md An example of subscribing to the SettingsChanged event and performing an action only when a particular setting, like 'use_npp_styling', is modified. ```csharp Main.settings.SettingsChanged += (sender, args) => { if (args.Property.Name == nameof(Settings.use_npp_styling)) { Main.RestyleEverything(); } }; ``` -------------------------------- ### Get Notepad++ Config Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the path to the Notepad++ configuration directory. This is useful for accessing user-specific settings and configurations. ```csharp string configDir = Npp.notepad.GetConfigDirectory(); ``` -------------------------------- ### Get Plugin Config Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the path to the Notepad++ plugins configuration directory. Use this to store or access plugin-specific configuration files. ```csharp string pluginConfigDir = Npp.notepad.GetPluginConfigPath(); ``` -------------------------------- ### Basic Translator Usage Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md Demonstrates how to get translated menu item names, display translated messages, and how forms are automatically translated using the FormBase class. ```csharp // Get translated menu item name string menuText = Translator.GetTranslatedMenuItem("&Settings"); PluginBase.SetCommand(2, menuText, OpenSettings); // Show translated message Translator.ShowTranslatedMessageBox("Hello World", "Greeting", MessageBoxIcon.Information); // Form translation (automatic in FormBase) public partial class MyForm : FormBase { public MyForm() : base(false, false) { InitializeComponent(); // Translation happens automatically on first display } } ``` -------------------------------- ### LangType Usage Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/types.md Demonstrates how to retrieve the language type of the current buffer and check if it matches a specific language, such as JSON. ```csharp LangType langType = notepad.GetNppLanguage(bufferId); if (langType == LangType.L_JSON) MessageBox.Show("This is a JSON file"); ``` -------------------------------- ### Basic Editor Operations in C# Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Demonstrates how to get information about the current file, modify the document by adding lines or inserting text, and select and modify text within the editor. ```csharp // Get information about current file string fileName = Npp.GetCurrentPath(Npp.PathType.FILE_NAME); string ext = Npp.FileExtension(); // Modify document Npp.AddLine("New content"); Npp.editor.InsertText(0, "// Header\r\n"); // Select and modify Npp.editor.SelectAll(); string all = Npp.editor.GetSelText(); Npp.editor.InsertText(Npp.editor.GetCurrentPos(), all.ToUpper()); ``` -------------------------------- ### Accessing Notepad++ Application Features Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md Utilize the Npp.notepad gateway for core Notepad++ operations like getting the current file path or creating a new file. ```csharp string path = Npp.notepad.GetCurrentFilePath(); Npp.notepad.FileNew(); ``` -------------------------------- ### Get Position from Line Number Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Returns the starting document position (byte offset) of a specified line. Lines are 0-indexed. ```csharp int pos = editor.PositionFromLine(5); ``` -------------------------------- ### Get Current Text Selection in Editor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the start and end positions of the current text selection, as well as the selected text itself, from the Notepad++ editor. ```csharp int selStart = Npp.editor.GetCurrentPos(); int selEnd = Npp.editor.GetAnchor(); string selected = Npp.editor.GetSelText(); ``` -------------------------------- ### Constructor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Initializes a new instance of the NotepadPPGateway for communicating with Notepad++. ```APIDOC ## Constructor ### Description Initializes a new instance of the gateway for communicating with Notepad++. ### Method ```csharp public NotepadPPGateway() ``` ### Parameters *(none)* ### Response *(none)* ``` -------------------------------- ### Example JSON5 with Comments and Trailing Comma Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/JSON_Tools.md Illustrates the syntax of JSON5, including support for line and block comments, unquoted keys, single-quoted strings, and trailing commas in arrays and objects. ```json5 { // Configuration file name: "MyApp", // User-friendly name version: "1.0", settings: [ "option1", "option2", // Trailing comma allowed ], } ``` -------------------------------- ### Checking Notepad++ Version Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Access the 'nppVersion' array to get the major, minor, and patch version numbers. Use 'nppVersionStr' for a human-readable version string. ```csharp if (Npp.nppVersion[0] >= 8 && Npp.nppVersion[1] >= 5) MessageBox.Show("Notepad++ 8.5 or newer"); ``` ```csharp MessageBox.Show($"Running: {Npp.nppVersionStr}"); ``` -------------------------------- ### Get Notepad++ Document Language Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the current language/lexer type for a document using its buffer ID. ```csharp public LangType GetNppLanguage(IntPtr bufferId) ``` ```csharp LangType lang = notepad.GetNppLanguage(currentBufferId); if (lang == LangType.L_TEXT) MessageBox.Show("This is a plain text file"); ``` -------------------------------- ### Initialize SettingsBase Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Initializes settings, optionally loading values from the INI file. Use loadFromFile=false to create fresh settings with defaults. ```csharp public SettingsBase(bool loadFromFile = true) { // Implementation details omitted } ``` ```csharp // Load existing settings var settings = new Settings(loadFromFile: true); // Create fresh with defaults var freshSettings = new Settings(loadFromFile: false); ``` -------------------------------- ### Npp.pluginDllDirectory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Provides the read-only directory path containing the plugin DLL file. This is useful for locating plugin resources and configuration files relative to the plugin's installation. ```APIDOC ## Npp.pluginDllDirectory ### Description The directory containing the plugin DLL file. Useful for locating plugin resources and configuration files relative to the plugin installation. ### Type `string` - Read-only ### Example ```csharp string configFile = Path.Combine(Npp.pluginDllDirectory, "plugin.ini"); ``` ``` -------------------------------- ### SettingsBase Constructor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Initializes settings, optionally loading values from the INI file. ```APIDOC ## SettingsBase Constructor ### Description Initializes settings, optionally loading values from the INI file. ### Method ```csharp public SettingsBase(bool loadFromFile = true) ``` ### Parameters #### Parameters - **loadFromFile** (bool) - Optional - If true, load existing settings from INI file. Default: true ### Behavior - Sets default values from [DefaultValue] attributes - If loadFromFile=true and INI file exists, loads values from file - Creates INI file if it doesn't exist ### Example ```csharp // Load existing settings var settings = new Settings(loadFromFile: true); // Create fresh with defaults var freshSettings = new Settings(loadFromFile: false); ``` ``` -------------------------------- ### Getting File Extension Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Use 'FileExtension' to get the extension of a file without the leading period. If no path is provided, it defaults to the currently open file. ```csharp string ext = Npp.FileExtension(); // Current file string ext2 = Npp.FileExtension(@"C:\\document.pdf"); // Specific file if (ext == "json") MessageBox.Show("This is a JSON file"); ``` -------------------------------- ### Configuration Management with Settings Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/INDEX.md Manage plugin settings and persistence. Add properties with [Description] attributes for automatic INI file handling and UI generation. ```csharp Add properties with [Description] attributes Automatic INI file persistence Auto-generated UI ``` -------------------------------- ### Get Detailed Error Information Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/errors.md Use a try-catch block to capture exceptions and log detailed information including the exception type, message, and stack trace to a debug file. This aids in diagnosing issues. ```csharp try { // Risky operation } catch (Exception ex) { string details = $"Type: {ex.GetType().Name}\n" + $"Message: {ex.Message}\n" + $"Stack: {ex.StackTrace}"; File.AppendAllText("debug.log", details); MessageBox.Show($"Error: {ex.Message}"); } ``` -------------------------------- ### Getting Plugin DLL Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Use the 'pluginDllDirectory' property to get the path to the plugin's DLL. This is useful for locating plugin resources and configuration files. ```csharp string configFile = Path.Combine(Npp.pluginDllDirectory, "plugin.ini"); ``` -------------------------------- ### Initialize Plugin Commands Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/PluginBase.md Initializes all plugin menu items by calling PluginBase.SetCommand for each item. This includes documentation, about, settings, separators, and other custom commands with optional shortcuts and settings. ```csharp static internal void CommandMenuInit() { // Set up all plugin menu items PluginBase.SetCommand(0, Translator.GetTranslatedMenuItem("&Documentation"), Docs); PluginBase.SetCommand(1, Translator.GetTranslatedMenuItem("A&bout"), ShowAboutForm); PluginBase.SetCommand(2, Translator.GetTranslatedMenuItem("&Settings"), OpenSettings); PluginBase.SetCommand(5, Translator.GetTranslatedMenuItem("---"), null); PluginBase.SetCommand(13, Translator.GetTranslatedMenuItem("Close HTML/&XML tag automatically"), CheckInsertHtmlCloseTag, new ShortcutKey(true, true, true, Keys.X), settings.close_html_tag); } ``` -------------------------------- ### Initialize JsonParser with Logging Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/JSON_Tools.md Shows how to create an instance of the JsonParser class, optionally specifying the logging level for parsing operations. The default level is JSON5. ```csharp var parser = new JsonParser(LoggerLevel.JSON5); ``` -------------------------------- ### Npp.notepad Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Provides a static gateway instance for interacting with Notepad++ itself. Use this for file operations, checking the version, and executing Notepad++-specific commands. ```APIDOC ## Npp.notepad ### Description A static gateway instance for interacting with Notepad++ itself. Used for file operations, version checking, and Notepad++-specific commands. ### Type `NotepadPPGateway` ### Example ```csharp string currentFile = Npp.notepad.GetCurrentFilePath(); Npp.notepad.FileNew(); ``` ``` -------------------------------- ### Initialize NotepadPPGateway Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Instantiates the NotepadPPGateway for sending messages to Notepad++. ```csharp var notepad = new NotepadPPGateway(); ``` -------------------------------- ### Get String Representations of Special Float Values Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Gets the string representation for special floating-point values like NaN, Infinity, and Negative Infinity. Use this for handling or displaying these specific numeric types. ```csharp string nan = NanInf.GetNanInfValue("nan"); string inf = NanInf.GetNanInfValue("inf"); string negInf = NanInf.GetNanInfValue("-inf"); ``` -------------------------------- ### Safely Get Document Length as Int Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Attempt to get the document length as an integer using TryGetLengthAsInt. Returns true if the length fits within an int, otherwise false. Useful for preventing overflow errors. ```csharp if (editor.TryGetLengthAsInt(out int length)) MessageBox.Show($"Document has {length} bytes"); ``` -------------------------------- ### FileNew Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Creates a new file in Notepad++. ```APIDOC ## FileNew ### Description Creates a new file in Notepad++. ### Method ```csharp public void FileNew() ``` ### Parameters *(none)* ### Response `void` ### Example ```csharp var notepad = new NotepadPPGateway(); notepad.FileNew(); ``` ``` -------------------------------- ### Locating Plugin Resources in C# Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Demonstrates how to construct paths to plugin resources, such as icons and configuration files, relative to the plugin's DLL directory. ```csharp // Find plugin resources relative to plugin DLL string resourceDir = Path.Combine(Npp.pluginDllDirectory, "resources"); string iconPath = Path.Combine(resourceDir, "icon.ico"); string configPath = Path.Combine(Npp.pluginDllDirectory, "config.ini"); ``` -------------------------------- ### GetCurrentFilePath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the full path of the currently active document. ```APIDOC ## GetCurrentFilePath ### Description Gets the full path of the currently active document. ### Method ```csharp public string GetCurrentFilePath() ``` ### Parameters *(none)* ### Response `string` - The full file path of the active document ### Example ```csharp var notepad = new NotepadPPGateway(); string currentPath = notepad.GetCurrentFilePath(); MessageBox.Show($"Current file: {currentPath}"); ``` ``` -------------------------------- ### PositionFromLine(int line) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Returns the position of the start of a line. ```APIDOC ## PositionFromLine(int line) ### Description Returns the position of the start of a line. ### Method public int PositionFromLine(int line) ### Parameters - **line** (int) - Line number (0-based) ### Returns int - Document position of line start ### Example ```csharp int pos = editor.PositionFromLine(5); ``` ``` -------------------------------- ### Configure Toolbar Icons Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/configuration.md Specify which toolbar icons to display and their order. Only valid icon characters are shown; an empty string displays no icons. Changes take effect on the next Notepad++ startup. ```ini toolbar_icons=ash ; Show all three icons: about, selection, html toolbar_icons=ha ; Show html and about icons only toolbar_icons=s ; Show only selection icon toolbar_icons=xxx ; Show no icons (x is not a valid icon) ``` -------------------------------- ### ArrayExtensions.Slice Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Provides a LINQ-like extension method to get a subset of an array. ```APIDOC ## ArrayExtensions.Slice ### Description Returns a subset of an array, similar to LINQ's Skip and Take operations. ### Method Signature `public static T[] Slice(this T[] array, int start, int length)` ### Parameters #### Path Parameters - **array** (T[]) - Required - The source array from which to slice. - **start** (int) - Required - The starting index of the slice (0-based). - **length** (int) - Required - The number of elements to include in the slice. ### Returns `T[]` - A new array containing the specified elements from the source array. ### Example ```csharp int[] numbers = { 1, 2, 3, 4, 5 }; int[] subset = numbers.Slice(1, 3); // subset will be { 2, 3, 4 } ``` ``` -------------------------------- ### Working with Selections Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Demonstrates how to save and restore editor selections using Notepad++ API. ```APIDOC ## Working with Selections ### Description Provides methods for saving the current editor selection's start and end positions and restoring them later. ### Saving Selection ```csharp // Save selection int start = Npp.editor.GetCurrentPos(); int end = Npp.editor.GetAnchor(); ``` ### Restoring Selection ```csharp // Restore later Npp.editor.SetSelection(start, end); ``` ``` -------------------------------- ### GetFilePath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Gets the file path associated with a specific buffer ID. ```APIDOC ## GetFilePath ### Description Gets the file path associated with a specific buffer ID. Used when multiple documents are open. ### Method ```csharp public unsafe string GetFilePath(IntPtr bufferId) ``` ### Parameters #### Path Parameters - **bufferId** (IntPtr) - Required - The unique identifier for the buffer ### Response `string` - The file path of the specified buffer, or null if not found ### Example ```csharp IntPtr currentBufferId = notification.Header.IdFrom; string filePath = notepad.GetFilePath(currentBufferId); ``` ``` -------------------------------- ### Create and Use Settings Form Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Shows how to instantiate and display the built-in SettingsForm, which automatically generates a UI for editing settings. The form saves changes and updates settings upon successful completion. ```csharp var settingsForm = new SettingsForm(typeof(Settings), Main.settings); if (settingsForm.ShowDialog() == DialogResult.OK) { // Settings have been updated and saved } ``` -------------------------------- ### SetSelection(int start, int end) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Selects a range of text. ```APIDOC ## SetSelection(int start, int end) ### Description Selects a range of text. ### Method public void SetSelection(int start, int end) ### Parameters - **start** (int) - Starting position - **end** (int) - Ending position ### Returns void ### Example ```csharp editor.SetSelection(0, 10); // Select first 10 chars ``` ``` -------------------------------- ### Get Selected Text and Length Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the currently selected text and the length of the selection in bytes. ```csharp string selected = editor.GetSelText(); int selLen = editor.GetSelectionLength()); ``` -------------------------------- ### Create a Docking Form Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Instantiate a docking form by setting `isModal` to false and `isDocking` to true in the base constructor. Call `Show()` to display it. ```csharp public partial class SelectionRememberingForm : FormBase { public SelectionRememberingForm() : base(isModal: false, isDocking: true) { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Initialize docking form content } } // Usage var dockingForm = new SelectionRememberingForm(); dockingForm.Show(); // Shows as docking form ``` -------------------------------- ### Get Current Line Number Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the zero-based index of the current line where the cursor is located. ```csharp int line = editor.GetCurrentLineNumber(); ``` -------------------------------- ### TryGetLengthAsInt Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Safely gets the document length as an int, returning false if the document exceeds int.MaxValue. ```APIDOC ## TryGetLengthAsInt ### Description Safely gets the document length as an int, returning false if the document exceeds int.MaxValue. ### Parameters #### Path Parameters - **result** (out int) - Required - The document length as int, or -1 if too large ### Returns `bool` - True if length fits in int; false if larger than int.MaxValue ### Request Example ```csharp if (editor.TryGetLengthAsInt(out int length)) MessageBox.Show($"Document has {length} bytes"); ``` ``` -------------------------------- ### Get Notepad++ Version Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the version number of Notepad++ as an array of integers [major, minor, patch]. ```csharp public int[] GetNppVersion() ``` ```csharp int[] version = notepad.GetNppVersion(); MessageBox.Show($"Notepad++ version: {version[0]}.{version[1]}.{version[2]}"); ``` -------------------------------- ### Instantiate FormBase with Behavior Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Initialize a new FormBase instance, specifying whether it should be a modal dialog or a docking form. Note that a form cannot be both modal and docking simultaneously. ```csharp // Create a modeless, non-docking form (floats independently) public class MyForm : FormBase { public MyForm() : base(false, false) { InitializeComponent(); } } // Create a docking form (attaches to Notepad++) public class MyDockingForm : FormBase { public MyDockingForm() : base(false, true) { InitializeComponent(); } } // Create a modal pop-up dialog public class MyModalForm : FormBase { public MyModalForm() : base(true, false) { InitializeComponent(); } } ``` -------------------------------- ### GetConfigDirectory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the path to the Notepad++ configuration directory. ```APIDOC ## GetConfigDirectory ### Description Gets the path to the Notepad++ configuration directory. ### Method C# Method Signature ### Parameters *(none)* ### Returns `string` - Path to the configuration directory ### Example ```csharp string configDir = notepad.GetConfigDirectory(); ``` ``` -------------------------------- ### GetUntranslatedFuncItemNames Example Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/PluginBase.md Retrieves a list of untranslated menu item names. Useful for debugging or internationalization checks. ```csharp var untranslated = PluginBase.GetUntranslatedFuncItemNames(); foreach (string name in untranslated) MessageBox.Show(name); ``` -------------------------------- ### Npp.notepad.GetConfigDirectory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the path to the Notepad++ configuration directory. ```APIDOC ## Npp.notepad.GetConfigDirectory ### Description Retrieves the absolute path to the Notepad++ configuration directory, where user settings and preferences are stored. ### Method Signature `string GetConfigDirectory()` ### Returns `string` - The path to the Notepad++ config directory. ### Typical Path `C:\Users\[User]\AppData\Roaming\Notepad++` ``` -------------------------------- ### Get Current Line Text Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the text of the line where the caret is currently located, including the line ending. ```csharp string curLine = editor.GetCurLine(); ``` -------------------------------- ### Get Selected Text Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the text that is currently selected by the user. Returns an empty string if no text is selected. ```csharp string selected = editor.GetSelText(); MessageBox.Show($"Selected: {selected}"); ``` -------------------------------- ### Creating a Translatable Plugin Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md Steps to make a plugin translatable, including using English text in code, creating a JSON5 translation file, and restarting Notepad++ to load the translation. ```csharp // 1. Use English text everywhere in code PluginBase.SetCommand(0, Translator.GetTranslatedMenuItem("&My Command"), MyFunction); // 2. Create translation file: translation/language.json5 { "&My Command": "translated text" } // 3. Restart Notepad++ to load translation ``` -------------------------------- ### Basic Settings Access and Modification Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Demonstrates how to read the current value of a setting and how to modify a setting. Changes made this way are not persisted until SaveToIniFile is called. ```csharp // Access current setting value if (Main.settings.use_npp_styling) { // Apply Notepad++ styling } // Modify setting Main.settings.close_html_tag = true; // Save to INI file Main.settings.OnSettingsChanged(); ``` -------------------------------- ### Load Configuration from JSON File Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/JSON_Tools.md Loads configuration settings from a specified JSON file path. Assumes the configuration is a JSON object. ```csharp public class ConfigLoader { public static Dictionary LoadConfig(string configFilePath) { var parser = new JsonParser(LoggerLevel.JSON5); string configText = File.ReadAllText(configFilePath); JNode parsed = parser.Parse(configText); if (parsed.type != Dtype.OBJ) throw new Exception("Config must be an object"); var config = new Dictionary(); JObject obj = parsed.value as JObject; foreach (var kvp in obj) { config[kvp.Key] = kvp.Value.ToString(); } return config; } } ``` -------------------------------- ### Get Current Line Number Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Returns the 0-based index of the line where the caret is currently located. Useful for line-based operations. ```csharp int lineNum = editor.GetCurrentLineNumber(); ``` -------------------------------- ### Create JSON Objects and Arrays Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/JSON_Tools.md Demonstrates how to programmatically create JSON objects and arrays using the library's JObject and JArray classes. ```csharp // Create an object var settings = new JObject(); settings["theme"] = new JNode() { type = Dtype.STR, value = "dark" }; settings["fontSize"] = new JNode() { type = Dtype.INT, value = 12L }; // Create an array var items = new JArray(); items.Add(new JNode() { type = Dtype.STR, value = "item1" }); items.Add(new JNode() { type = Dtype.STR, value = "item2" }); settings["items"] = new JNode() { type = Dtype.ARR, value = items }; ``` -------------------------------- ### Basic Plugin Form Initialization Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md Inherit from FormBase to create custom plugin forms. Specify modal and docking behavior during initialization. ```csharp public class MyForm : FormBase { public MyForm() : base(isModal: false, isDocking: false) { InitializeComponent(); } } ``` -------------------------------- ### Get Selection Length Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Returns the number of bytes in the current text selection. Useful for determining the extent of selected content. ```csharp int selLen = editor.GetSelectionLength(); ``` -------------------------------- ### File Path Manipulation in C# Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Illustrates how to retrieve different components of the current file path (directory, filename, full path) and how to construct new paths using `Path.Combine`. ```csharp // Get all path components string dir = Npp.GetCurrentPath(Npp.PathType.DIRECTORY); string filename = Npp.GetCurrentPath(Npp.PathType.FILE_NAME); string fullPath = Npp.GetCurrentPath(Npp.PathType.FULL_CURRENT_PATH); // Work with paths string newPath = Path.Combine(dir, "output", filename); ``` -------------------------------- ### Get Line Text Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the entire text content of a specific line, including its line ending. Lines are 0-indexed. ```csharp string firstLine = editor.GetLine(0); ``` -------------------------------- ### Get Plugin Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the directory where the plugin DLL is located. This is helpful for accessing plugin resources or related files. ```csharp string pluginDir = Npp.pluginDllDirectory; ``` -------------------------------- ### File Operations with Notepad++ Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md Manage files using the Npp.notepad gateway. Obtain file paths, names, and extensions, or perform actions like opening existing files and creating new ones. ```csharp // Get current file information string filePath = Npp.notepad.GetCurrentFilePath(); string fileName = Npp.GetCurrentPath(Npp.PathType.FILE_NAME); string directory = Npp.GetCurrentPath(Npp.PathType.DIRECTORY); string ext = Npp.FileExtension(); // Open a file Npp.notepad.OpenFile(@"C:\myfile.txt"); // Create new file Npp.notepad.FileNew(); ``` -------------------------------- ### Handle Settings File Issues Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/errors.md Check if settings loaded correctly from the INI file and use try-catch blocks when saving settings to prevent errors if the file is not writable. Inform the user if default settings are being used. ```csharp // Check if settings loaded properly if (Main.settings.ReadFromIniFile()) MessageBox.Show("Settings loaded successfully"); else MessageBox.Show("Using default settings"); // Save with error handling try { Main.settings.SaveToIniFile(); } catch (Exception ex) { MessageBox.Show($"Could not save settings: {ex.Message}"); } ``` -------------------------------- ### Npp.GetCurrentPath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Npp.md Retrieves path information for the currently active file. You can specify whether to get the full path, just the filename, or just the directory. ```APIDOC ## GetCurrentPath ### Description Gets the path information for the currently active file. Can return the full path, just the filename, or just the directory. ### Method `public static string GetCurrentPath(PathType which = PathType.FULL_CURRENT_PATH)` ### Parameters #### Path Parameters - **which** (PathType) - Optional - Default: `FULL_CURRENT_PATH` - Which path component to return ### Returns `string` - The requested path information ### Throws `ArgumentException` - If an invalid PathType is provided ### Example ```csharp string fullPath = Npp.GetCurrentPath(Npp.PathType.FULL_CURRENT_PATH); string fileName = Npp.GetCurrentPath(Npp.PathType.FILE_NAME); string dirPath = Npp.GetCurrentPath(Npp.PathType.DIRECTORY); ``` ``` -------------------------------- ### Npp.notepad.GetPluginConfigPath Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Retrieves the path to the plugins configuration directory within Notepad++. ```APIDOC ## Npp.notepad.GetPluginConfigPath ### Description Retrieves the absolute path to the directory where plugin-specific configuration files are stored within Notepad++. ### Method Signature `string GetPluginConfigPath()` ### Returns `string` - The path to the plugins config subdirectory. ### Typical Path `C:\Users\[User]\AppData\Roaming\Notepad++\plugins\config\` ``` -------------------------------- ### Set Text Selection Range Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Sets the selection range within the document to the specified start and end positions (in bytes). ```csharp editor.SetSelection(0, 100); ``` -------------------------------- ### Enable Notepad++ Styling Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Enable automatic styling to match Notepad++ editor colors and fonts by setting `use_npp_styling` to true and calling `Main.RestyleEverything()`. ```csharp // In your plugin code Main.settings.use_npp_styling = true; // Enable styling Main.RestyleEverything(); // Apply immediately ``` -------------------------------- ### Set Text Selection Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Selects a range of text within the document defined by start and end positions. Positions are byte-based. ```csharp editor.SetSelection(0, 10); // Select first 10 chars ``` -------------------------------- ### NppListener Constructor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Initializes a new Win32 message listener instance for detecting Notepad++ UI language changes. This is primarily used for older Notepad++ versions that lack native language change notifications. ```APIDOC ## NppListener() ### Description Initializes a new Win32 message listener instance. This listener is designed to detect when Notepad++'s UI language changes, a feature mainly relevant for versions prior to 8.7. ### Method constructor ### Signature public NppListener() ### Behavior When enabled, NppListener intercepts Notepad++ window messages to detect language preference changes, triggering necessary retranslations. **Note**: This class is performance-intensive and only instantiated if FOLLOW_NPP_UI_LANGUAGE constant is true (currently false by default). ``` -------------------------------- ### Get Current Language Name Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md Retrieves the name of the currently loaded language. Useful for debugging or displaying the active language to the user. ```csharp MessageBox.Show($"Current language: {Translator.languageName}"); ``` -------------------------------- ### Define Custom Default Setting Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Settings.md Illustrates how to define a custom setting with a default value using attributes like [Description], [Category], and [DefaultValue]. This allows for plugin-specific configurations. ```csharp [Description("My custom setting")] [Category("CustomCategory")] [DefaultValue(42)] public int my_custom_setting { get; set; } ``` -------------------------------- ### ScintillaGateway Constructor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Initializes a gateway to a Scintilla editor instance using its window handle. ```APIDOC ## ScintillaGateway Constructor ### Description Initializes a gateway to a Scintilla editor instance. ### Parameters #### Path Parameters - **scintilla** (IntPtr) - Required - Window handle to the Scintilla editor component ### Request Example ```csharp IntPtr scintillaHandle = PluginBase.GetCurrentScintilla(); var editor = new ScintillaGateway(scintillaHandle); ``` ``` -------------------------------- ### Slice Array Extension Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Utilities.md Returns a subset of an array. Use this to extract a portion of an existing array based on a starting index and length. ```csharp public static T[] Slice(this T[] array, int start, int length) ``` ```csharp int[] numbers = { 1, 2, 3, 4, 5 }; int[] subset = numbers.Slice(1, 3); // { 2, 3, 4 } ``` -------------------------------- ### SetCommand (Overload 1) Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/PluginBase.md Registers a plugin command in the Notepad++ menu without assigning a keyboard shortcut or an initial checked state. This is the most basic way to add a menu item. ```APIDOC ## SetCommand (Overload 1) ### Description Registers a plugin command without a keyboard shortcut or initial check state. ### Method ```csharp internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer) ``` ### Parameters #### Path Parameters - **index** (int) - Required - Zero-based menu item position - **commandName** (string) - Required - Display name in menu - **functionPointer** (NppFuncItemDelegate) - Required - Function to call when selected ### Returns `void` ### Behavior - Adds item to plugin menu at specified index - Menu name is translatable if Translator has translations - No keyboard shortcut assigned - Menu item not checked at startup ### Example ```csharp PluginBase.SetCommand(0, "&Documentation", Docs); PluginBase.SetCommand(1, "A&bout", ShowAboutForm); ``` ``` -------------------------------- ### Get Current Caret Position Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieves the current position of the caret in the editor. This is useful for operations that require knowing the cursor's location. ```csharp int pos = editor.GetCurrentPos(); ``` -------------------------------- ### FormBase Constructor Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Initializes a new instance of FormBase with specified modal and docking behavior. ```APIDOC ## Constructors ### FormBase ```csharp public FormBase(bool isModal, bool isDocking) ``` Initializes a new instance of FormBase with specified modal and docking behavior. This constructor automatically handles Notepad++ integration, styling, and translation setup. **Parameters**: | Parameter | Type | Description | |-----------|------|-------------| | isModal | bool | True if this should be a blocking pop-up dialog; false for modeless forms | | isDocking | bool | True if this should dock to Notepad++; false for floating windows | **Throws**: `InvalidOperationException` - If both isModal and isDocking are true (not supported) **Example**: ```csharp // Create a modeless, non-docking form (floats independently) public class MyForm : FormBase { public MyForm() : base(false, false) { InitializeComponent(); } } // Create a docking form (attaches to Notepad++) public class MyDockingForm : FormBase { public MyDockingForm() : base(false, true) { InitializeComponent(); } } // Create a modal pop-up dialog public class MyModalForm : FormBase { public MyModalForm() : base(true, false) { InitializeComponent(); } } ``` ``` -------------------------------- ### Initialize ScintillaGateway Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Instantiate ScintillaGateway by passing the window handle of the Scintilla editor component. This is typically obtained using PluginBase.GetCurrentScintilla(). ```csharp IntPtr scintillaHandle = PluginBase.GetCurrentScintilla(); var editor = new ScintillaGateway(scintillaHandle); ``` -------------------------------- ### Get Document Length Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/ScintillaGateway.md Retrieve the total number of bytes in the document using GetLength. This returns a long value representing the document size. ```csharp long docLength = editor.GetLength(); ``` -------------------------------- ### Create a Modeless Floating Form Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Instantiate a floating form by setting `isModal` to false and `isDocking` to false in the base constructor. Call `Show()` to display it. ```csharp public partial class DarkModeTestForm : FormBase { public DarkModeTestForm() : base(isModal: false, isDocking: false) { InitializeComponent(); } } // Usage var floatingForm = new DarkModeTestForm(); floatingForm.Show(); // Shows as floating form ``` -------------------------------- ### Displaying Forms Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/FormBase.md Use `ShowDialog()` for modal forms, checking the `DialogResult`, and `Show()` for docking or floating forms. ```csharp // Modal dialog var modalForm = new AboutForm(); if (modalForm.ShowDialog() == DialogResult.OK) { // User clicked OK } // Docking or floating form var form = new MyForm(); form.Show(); ``` -------------------------------- ### Get Translation File Directory Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/Translator.md Retrieves the path to the directory where translation files are stored. This is typically located within the plugin's directory. ```csharp string translationPath = Translator.translationDir; ``` -------------------------------- ### Get Plugin Configuration Path Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the directory path used for storing plugin configuration files. Essential for managing plugin settings. ```csharp string configPath = notepad.GetPluginConfigPath(); ``` -------------------------------- ### Get Current File Path Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Retrieves the full path of the currently active document in Notepad++. Useful for saving or referencing the active file. ```csharp string currentPath = notepad.GetCurrentFilePath(); MessageBox.Show($"Current file: {currentPath}"); ``` -------------------------------- ### Displaying Different Form Types in C# Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/README.md Demonstrates how to show modal, docking, and floating forms. Modal dialogs block user interaction until closed, while docking and floating forms remain accessible. ```csharp // Modal dialog (blocks until closed) var aboutForm = new AboutForm(); aboutForm.ShowDialog(); // Docking form (stays visible) var dockingForm = new SelectionRememberingForm(); dockingForm.Show(); // Floating form (independent window) var floatingForm = new MyCustomForm(); floatingForm.Show(); ``` -------------------------------- ### OpenFile Source: https://github.com/molsonkiko/nppcsharppluginpack/blob/main/_autodocs/api-reference/NotepadPPGateway.md Opens a file for editing in Notepad++, similar to using File > Open from the menu. ```APIDOC ## OpenFile ### Description Opens a file for editing in Notepad++, similar to using File > Open from the menu. ### Method ```csharp public bool OpenFile(string path) ``` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file to open ### Response `bool` - True if the file was successfully opened, false otherwise ### Example ```csharp bool success = notepad.OpenFile(@"C:\document.txt"); if (!success) MessageBox.Show("Failed to open file"); ``` ```