### EmEditor Plugin Class Implementation with CETLFrame Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Example of defining a plugin class that derives from CETLFrame. This class handles commands, query status, and events, and includes required constants for plugin identification and behavior. ```cpp // Define your plugin class using the ETL framework #define ETL_FRAME_CLASS_NAME CMyPlugin class CMyPlugin : public CETLFrame { public: // Required constants static constexpr UINT _IDS_NAME = IDS_PLUGIN_NAME; static constexpr UINT _IDS_VER = IDS_VERSION; static constexpr UINT _IDS_MENU = IDS_MENU_TEXT; static constexpr UINT _IDS_STATUS = IDS_STATUS_MSG; static constexpr UINT _IDB_BITMAP = IDB_TOOLBAR; static constexpr int _USE_LOC_DLL = LOC_USE_LOC_DLL; static constexpr bool _ALLOW_OPEN_SAME_GROUP = true; static constexpr bool _ALLOW_MULTIPLE_INSTANCES = false; static constexpr bool _SUPPORT_EE_PRO = true; static constexpr bool _USE_CUSTOM_BAR = false; // Command handler - called when user clicks plugin button/menu void OnCommand(HWND hwndView) { // Get selected text UINT_PTR nLen = Editor_GetSelTextW(m_hWnd, 0, NULL); if (nLen > 0) { LPWSTR pszText = new WCHAR[nLen + 1]; Editor_GetSelTextW(m_hWnd, nLen + 1, pszText); // Process text... delete[] pszText; } } // Query command state - return TRUE if enabled BOOL QueryStatus(HWND hwndView, LPBOOL pbChecked) { *pbChecked = FALSE; return TRUE; // Command is enabled } // Event handler - called for editor events void OnEvents(HWND hwndView, UINT nEvent, LPARAM lParam) { if (nEvent & EVENT_FILE_OPENED) { // Handle file opened event } if (nEvent & EVENT_SEL_CHANGED) { // Handle selection changed event } } }; _ETL_IMPLEMENT // Generates required factory functions ``` -------------------------------- ### EmEditor Editor Message Functions - Caret and Selection Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Shows how to get the current caret position and retrieve selected text. For retrieving text, first determine the length, allocate memory, and then fetch the text. ```cpp // Get caret position POINT_PTR ptCaret; Editor_GetCaretPos(hwnd, POS_LOGICAL_W, &ptCaret); // ptCaret.x = column, ptCaret.y = line // Set caret position POINT_PTR ptNew = {0, 100}; // Column 0, line 100 Editor_SetCaretPos(hwnd, POS_LOGICAL_W, &ptNew); // Get selected text UINT_PTR nSelLen = Editor_GetSelTextW(hwnd, 0, NULL); if (nSelLen > 0) { LPWSTR pszSel = new WCHAR[nSelLen + 1]; Editor_GetSelTextW(hwnd, nSelLen + 1, pszSel); // Use pszSel... delete[] pszSel; } ``` -------------------------------- ### Custom Bar and Toolbar Management Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt APIs for creating and managing dockable panels and custom toolbars. ```cpp // Open a custom bar (dockable panel) CUSTOM_BAR_INFO cbi = {0}; cbi.cbSize = sizeof(cbi); cbi.hwndClient = CreateWindow(L"EDIT", L"", WS_CHILD | WS_VISIBLE | ES_MULTILINE, 0, 0, 100, 100, hwndFrame, NULL, hInstance, NULL); cbi.pszTitle = L"My Custom Panel"; cbi.iPos = CUSTOM_BAR_RIGHT; // Dock on right side UINT nBarID = Editor_CustomBarOpen(hwnd, &cbi); // Close custom bar Editor_CustomBarClose(hwnd, nBarID); // Open a custom toolbar TOOLBAR_INFO ti = {0}; ti.cbSize = sizeof(ti); ti.hwndClient = hwndToolbar; // Your toolbar control ti.pszTitle = L"My Toolbar"; ti.nMask = TIM_CLIENT | TIM_TITLE; UINT nToolbarID = Editor_ToolbarOpen(hwnd, &ti); // Show/hide toolbar Editor_ToolbarShow(hwnd, nToolbarID, TRUE); // Show Editor_ToolbarShow(hwnd, nToolbarID, FALSE); // Hide ``` -------------------------------- ### Custom Bar and Toolbar Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt API for creating and managing dockable panels and custom toolbars. ```APIDOC ## Custom Bar and Toolbar ### Description Create custom UI panels and toolbars that dock within the EmEditor window. ### Methods - **Editor_CustomBarOpen / Editor_CustomBarClose**: Manages dockable panels. - **Editor_ToolbarOpen / Editor_ToolbarShow**: Manages custom toolbars. ``` -------------------------------- ### Registry and INI Configuration Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for persisting plugin settings using EmEditor's unified configuration system. ```cpp // In your CETLFrame-derived class: // Read string setting WCHAR szValue[256]; GetProfileString(L"LastPath", szValue, _countof(szValue), L"C:\\Default"); // Read integer setting int nOption = GetProfileInt(L"OptionFlags", 0); // Read binary data BYTE buffer[1024]; DWORD cbRead = GetProfileBinary(L"BinaryData", buffer, sizeof(buffer)); // Write string setting WriteProfileString(L"LastPath", L"C:\\Users\\Documents"); // Write integer setting WriteProfileInt(L"OptionFlags", 0x0F); // Write binary data BYTE data[] = {0x01, 0x02, 0x03, 0x04}; WriteProfileBinary(L"BinaryData", data, sizeof(data), false); // Delete specific entry EraseEntry(L"ObsoleteKey"); // Delete all plugin settings EraseProfile(); ``` -------------------------------- ### Registry and INI Configuration Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for persisting plugin settings using EmEditor's unified configuration system. ```APIDOC ## Registry and INI Configuration ### Description Persist plugin settings using EmEditor's unified configuration system that handles both registry and INI file storage. ### Methods - **GetProfileString / GetProfileInt / GetProfileBinary**: Reads configuration values. - **WriteProfileString / WriteProfileInt / WriteProfileBinary**: Writes configuration values. - **EraseEntry / EraseProfile**: Deletes configuration entries. ``` -------------------------------- ### File Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Methods for loading, saving, and querying file status within the editor. ```cpp // Load file with encoding detection LOAD_FILE_INFO_EX lfi = {0}; lfi.cbSize = sizeof(lfi); lfi.nCP = CODEPAGE_UTF8; lfi.bDetectUnicode = TRUE; lfi.bDetectUTF8 = TRUE; lfi.bDetectAll = TRUE; lfi.nFlags = LFI_ALLOW_NEW_WINDOW; Editor_LoadFileW(hwnd, &lfi, L"C:\\path\\to\\file.txt"); // Save current file Editor_SaveFileW(hwnd, TRUE, NULL); // TRUE = replace current file // Save with new name WCHAR szNewPath[MAX_PATH] = L"C:\\path\\to\\newfile.txt"; Editor_SaveFileW(hwnd, FALSE, szNewPath); // Check if document is modified BOOL bModified = Editor_GetModified(hwnd); // Set modified flag Editor_SetModified(hwnd, FALSE); // Mark as unmodified // Get current file name via EE_INFO WCHAR szFileName[MAX_PATH]; Editor_Info(hwnd, EI_GET_FILE_NAMEW, (LPARAM)szFileName); ``` -------------------------------- ### Execute Regex Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Utilize the regex engine for pattern matching, capturing groups, and text replacement. ```cpp // Test if text matches a pattern MATCH_REGEX_INFO mri = {0}; mri.cbSize = sizeof(mri); mri.nFlags = FLAG_FIND_REG_EXP; mri.pszRegex = L"^\\d{3}-\\d{4}$"; mri.pszText = L"123-4567"; int nMatch = Editor_MatchRegex(hwnd, &mri); // nMatch > 0 if matched // Find regex with captured groups FIND_REGEX_INFO_EX fri = {0}; fri.cbSize = sizeof(fri); fri.nFlags = FLAG_FIND_REG_EXP; fri.pszRegex = L"(\\w+)@(\\w+\\.\\w+)"; fri.pszText = L"user@example.com"; fri.nBackRefBuf = MAX_BACK_REF; LPCWSTR pszStart, pszEnd, pszNext; fri.ppszStart = &pszStart; fri.ppszEnd = &pszEnd; fri.ppszNext = &pszNext; if (Editor_FindRegex(hwnd, &fri)) { // fri.BackRef[0] = full match // fri.BackRef[1] = first capture group "user" // fri.BackRef[2] = second capture group "example.com" } // Regex replace with backreferences mri.pszRegex = L"(\\d{2})/(\\d{2})/(\\d{4})"; mri.pszText = L"12/31/2024"; mri.pszReplace = L"$3-$1-$2"; WCHAR szResult[256]; mri.pszResult = szResult; mri.cchResult = _countof(szResult); Editor_MatchRegex(hwnd, &mri); // szResult = "2024-12-31" ``` -------------------------------- ### Handle Editor Events Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Implement the OnEvents function to respond to file, edit, window, and UI lifecycle events within the editor. ```cpp void OnEvents(HWND hwndView, UINT nEvent, LPARAM lParam) { // File events if (nEvent & EVENT_CREATE) { // Plugin loaded, lParam = command ID UINT nCmdID = LOWORD(lParam); } if (nEvent & EVENT_FILE_OPENED) { // A file was opened } if (nEvent & EVENT_SAVING) { // File is about to be saved } if (nEvent & EVENT_CLOSE) { // Plugin is being unloaded } // Edit events if (nEvent & EVENT_CHANGE) { // Document content changed } if (nEvent & EVENT_SEL_CHANGED) { // Selection changed } if (nEvent & EVENT_CARET_MOVED) { // Caret position changed } if (nEvent & EVENT_SCROLL) { // View scrolled } // Window events if (nEvent & EVENT_CREATE_FRAME) { // New editor frame created } if (nEvent & EVENT_CLOSE_FRAME) { // Editor frame closing } if (nEvent & EVENT_SET_FOCUS) { // View gained focus } if (nEvent & EVENT_KILL_FOCUS) { // View lost focus } // UI events if (nEvent & EVENT_UI_CHANGED) { if (lParam & UI_CHANGED_LANGUAGE) { // UI language changed - reload localized resources } } } ``` -------------------------------- ### Find and Replace Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Search and replace functionality supporting regex, case sensitivity, and batch processing. ```cpp // Simple find - returns count of matches int nFound = Editor_FindW(hwnd, FLAG_FIND_NEXT | FLAG_FIND_CASE | FLAG_FIND_AROUND, L"search term"); // Find with regex int nMatches = Editor_FindW(hwnd, FLAG_FIND_REG_EXP | FLAG_FIND_COUNT, L"\\b[A-Z][a-z]+\\b"); // Replace all occurrences WCHAR szReplace[] = L"oldText\0newText\0"; int nReplaced = Editor_ReplaceW(hwnd, FLAG_REPLACE_ALL | FLAG_FIND_CASE, szReplace); // Find and replace with FIND_REPLACE_INFO structure FIND_REPLACE_INFO fri = {0}; fri.cbSize = sizeof(fri); fri.nFlags = FLAG_REPLACE_ALL | FLAG_FIND_REG_EXP; fri.pszFind = L"(\\d{4})-(\\d{2})-(\\d{2})"; fri.pszReplace = L"$2/$3/$1"; UINT64 nCount = 0, nMatchedLines = 0; HRESULT hr = Editor_FindReplace(hwnd, fri.nFlags, fri.pszFind, fri.pszReplace, &nCount, &nMatchedLines); ``` -------------------------------- ### File Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for loading, saving, and querying file status within the editor. ```APIDOC ## File Operations ### Description Manage file I/O, including encoding detection, saving files, and checking modification status. ### Methods - **Editor_LoadFileW**: Loads a file with encoding detection. - **Editor_SaveFileW**: Saves the current document or saves to a new path. - **Editor_GetModified / Editor_SetModified**: Manages the document's modified state. - **Editor_Info**: Retrieves file information such as the current file name. ``` -------------------------------- ### Event Handling Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Handles various editor events such as file operations, document changes, and UI updates via the OnEvents callback. ```APIDOC ## OnEvents ### Description Callback function to handle editor events including file lifecycle, document modifications, and UI state changes. ### Parameters - **hwndView** (HWND) - Handle to the editor view. - **nEvent** (UINT) - Event type flag (e.g., EVENT_CREATE, EVENT_FILE_OPENED, EVENT_CHANGE). - **lParam** (LPARAM) - Event-specific data. ``` -------------------------------- ### Regex Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Executes regular expression matching, searching, and replacement using the internal EmEditor engine. ```APIDOC ## Regex Operations ### Description Utilities for regex pattern matching, finding captured groups, and performing search-and-replace operations with backreferences. ### Methods - **Editor_MatchRegex**: Tests text against a pattern and performs replacements. - **Editor_FindRegex**: Searches for patterns and extracts captured groups. ``` -------------------------------- ### Text Manipulation Functions Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for inserting, replacing, and converting text, as well as executing built-in editor commands. ```cpp // Insert text at current caret position Editor_InsertW(hwnd, L"Hello, EmEditor!", false); // Insert text, keeping destination line ending type Editor_InsertW(hwnd, L"Line 1\nLine 2\n", true); // Replace text in selection // Format: "find_string\0replace_string\0" WCHAR szFindReplace[] = L"old\0new\0"; int nCount = Editor_ReplaceW(hwnd, FLAG_REPLACE_ALL, szFindReplace); // Convert text case Editor_Convert(hwnd, FLAG_MAKE_UPPER, NULL, NULL, 0, NULL); // Uppercase Editor_Convert(hwnd, FLAG_MAKE_LOWER, NULL, NULL, 0, NULL); // Lowercase Editor_Convert(hwnd, FLAG_CAPITALIZE, NULL, NULL, 0, NULL); // Capitalize // Execute built-in commands Editor_ExecCommand(hwnd, EEID_EDIT_UNDO); // Undo Editor_ExecCommand(hwnd, EEID_EDIT_REDO); // Redo Editor_ExecCommand(hwnd, EEID_FILE_SAVE); // Save Editor_ExecCommand(hwnd, EEID_EDIT_SELECT_ALL); // Select All ``` -------------------------------- ### Perform CSV and TSV Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Use Editor_* functions to read, write, sort, filter, and convert structured data cells. ```cpp // Get cell content GET_CELL_INFO gci = {0}; gci.cch = 1024; gci.flags = CELL_INCLUDE_NONE; gci.yLine = 5; // Row (0-based) gci.iColumn = 2; // Column (0-based) WCHAR szCell[1024]; Editor_GetCell(hwnd, &gci, szCell); // Set cell content gci.flags = CELL_AUTO_QUOTE; Editor_SetCell(hwnd, &gci, L"New Value"); // Sort by column COLUMN_INFO cols[1] = {{0, SORT_ASCEND | SORT_TEXT}}; SORT_INFO si = {0}; si.nVer = VER_SORT_INFO; si.nFlags = SORT_STABLE; si.pszLocale = NULL; si.nNumOfColumns = 1; si.anColumns = cols; BOOL bModified = FALSE; Editor_Sort(hwnd, si.nFlags, si.pszLocale, si.nNumOfColumns, si.anColumns, &bModified); // Filter rows Editor_Filter(hwnd, L"pattern", 0, FLAG_FIND_REG_EXP, 0, 0, -1, -1); // Convert CSV format Editor_ConvertCsv(hwnd, 1, CSV_HALF_WIDTH, 0, NULL); // To TSV ``` -------------------------------- ### EmEditor Editor Message Functions - Line and Text Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Demonstrates how to retrieve the total number of lines and the text content of a specific line using EmEditor's message functions. Ensure correct flags and line numbers are used for accurate results. ```cpp // Get total line count (logical lines) UINT_PTR nLines = Editor_GetLines(hwnd, TRUE); // Get text from a specific line GET_LINE_INFO gli = {0}; gli.cch = 1024; gli.flags = FLAG_LOGICAL | FLAG_WITH_CRLF; gli.yLine = 10; // Line number (0-based) WCHAR szLine[1024]; Editor_GetLineW(hwnd, &gli, szLine); ``` -------------------------------- ### EmEditor Plugin Exports Definition Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Defines the seven standard functions that EmEditor calls to interact with a plugin. These are required for plugin functionality. ```cpp // exports.def - Required DLL exports for EmEditor plugins EXPORTS OnCommand @1 // Called when user executes the plugin command QueryStatus @2 // Called to check if command is enabled/checked OnEvents @3 // Called for editor events (file open, selection change, etc.) GetMenuTextID @4 // Returns resource ID for menu text GetStatusMessageID @5 // Returns resource ID for status bar message GetBitmapID @6 // Returns resource ID for toolbar bitmap PlugInProc @7 // General plugin message handler ``` -------------------------------- ### Find and Replace Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Advanced search and replace functionality including regex support and batch processing. ```APIDOC ## Find and Replace Operations ### Description Perform search and replace operations with support for regular expressions, case sensitivity, and batch processing. ### Methods - **Editor_FindW**: Searches for a term or regex pattern. - **Editor_ReplaceW**: Replaces occurrences of a string. - **Editor_FindReplace**: Advanced find and replace using the FIND_REPLACE_INFO structure. ``` -------------------------------- ### Text Manipulation Functions Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for inserting, replacing, and transforming text within the editor, as well as executing built-in commands. ```APIDOC ## Text Manipulation Functions ### Description Functions to insert text, perform search and replace on selections, convert text case, and trigger built-in editor commands. ### Methods - **Editor_InsertW**: Inserts text at the current caret position. - **Editor_ReplaceW**: Replaces text in the current selection. - **Editor_Convert**: Converts text case (Upper, Lower, Capitalize). - **Editor_ExecCommand**: Executes built-in EmEditor commands (e.g., Undo, Redo, Save). ``` -------------------------------- ### CSV/TSV Operations Source: https://context7.com/emurasoft/emeditor-plugin-library/llms.txt Functions for reading, writing, sorting, and filtering structured data within the editor. ```APIDOC ## CSV/TSV Operations ### Description Provides methods to manipulate cell content, sort columns, filter rows, and convert between delimiter formats. ### Methods - **Editor_GetCell**: Retrieves content from a specific cell. - **Editor_SetCell**: Updates content in a specific cell. - **Editor_Sort**: Sorts rows based on column criteria. - **Editor_Filter**: Filters rows based on a regex pattern. - **Editor_ConvertCsv**: Converts CSV/TSV formats. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.