diff --git a/Readme.md b/Readme.md index ce7d91bbee..aa5f4d3d2b 100644 --- a/Readme.md +++ b/Readme.md @@ -35,7 +35,7 @@ Notepad3 is a free, open-source text editor with syntax highlighting for Windows - **Virtual space** rectangular selection (Alt+Drag) - **Accelerated word navigation** with configurable delimiters - **Insert GUIDs** directly into your document -- **Clipboard monitoring mode** (`/b` command-line switch) — automatically appends every clipboard change as a new entry at the end of the document; stop at any time via **Edit → Stop Clipboard Monitoring** without closing the editor. +- **[Clipboard monitoring mode](readme/config/ClipboardMonitoring.md)** (`/b` command-line switch) — automatically pastes copied text at the caret, with configurable separators, timestamps, and startup minimize delay; stop via **Edit → Toggle Clipboard Monitoring** without closing the editor. ### Syntax Highlighting Over 55 languages supported, including: diff --git a/readme/MenuEntriesAndCmds.md b/readme/MenuEntriesAndCmds.md index 32279f8df9..326e14af1c 100644 --- a/readme/MenuEntriesAndCmds.md +++ b/readme/MenuEntriesAndCmds.md @@ -161,7 +161,7 @@ Editing operations on the document's text. The **Edit** menu is split: the top o | **Select All** | `Ctrl+A` | Select the whole document. | | **Delete** | `Del` | Remove the selection (no clipboard write). | | **Clear Clipboard** | — | Empty the Windows clipboard. | -| **Toggle Clipboard Monitoring** | — | "Pasteboard" mode — every clipboard change is auto-pasted into the document. Mutually exclusive with *Monitoring Log* (see *View → Display*). This is a session-only toggle and is not persisted. Can also be enabled at startup via the `/B` switch (see [`cmdln/CmdLnOptions.md`](cmdln/CmdLnOptions.md)). | +| **Toggle Clipboard Monitoring** | — | "Pasteboard" mode — pasteable clipboard updates are inserted at the caret/selection. Mutually exclusive with *Monitoring Log* (see *View → Display*). This is a session-only toggle and is not persisted. Can also be enabled at startup via `/B`; see the [Clipboard Monitoring guide](config/ClipboardMonitoring.md). | ### Words diff --git a/readme/README.md b/readme/README.md index dd67e47f40..f156bff1bc 100644 --- a/readme/README.md +++ b/readme/README.md @@ -15,6 +15,7 @@ This folder collects the user-facing reference documentation for Notepad3 and it - [config/Configuration.md](config/Configuration.md) — Full reference for the portable `Notepad3.ini` (`[Settings2]` keys, restart-required settings, etc.). - [config/FileContentFlags.md](config/FileContentFlags.md) — Markers inside a file (mode lines, BOMs) that change how Notepad3 opens or styles it. +- [config/ClipboardMonitoring.md](config/ClipboardMonitoring.md) — Pasteboard startup capture, delayed minimize, entry formatting, and the optional discard-prompt safety net. - [cmdln/CmdLnOptions.md](cmdln/CmdLnOptions.md) — Every command-line option, switch, and positional argument accepted by `Notepad3.exe`. ### File handling diff --git a/readme/cmdln/CmdLnOptions.md b/readme/cmdln/CmdLnOptions.md index b9e9fa416d..4d5b808495 100644 --- a/readme/cmdln/CmdLnOptions.md +++ b/readme/cmdln/CmdLnOptions.md @@ -180,11 +180,11 @@ Open a new (untitled) Notepad3 window and **paste the current clipboard contents ## Pasteboard (clipboard collector): `/b` ### `/b` -Activates **Pasteboard mode**: every clipboard change observed while the editor is running is appended as a new entry at the end of the document. Stop at any time via **Edit → Stop Clipboard Monitoring** or by pressing the Pasteboard toolbar toggle. The mode is *runtime-only* (process-local) and is not persisted to the INI. +Activates **Pasteboard mode**: pasteable clipboard updates are inserted at the current caret/selection. Stop via **Edit → Toggle Clipboard Monitoring** or by double-clicking **CBS** in the status bar. The mode is *runtime-only* (process-local) and is not persisted to the INI. See the [Clipboard Monitoring guide](../config/ClipboardMonitoring.md) for workflow examples and the optional discard-prompt safety net. #### Initial paste behaviour -When `/b` is passed at startup, Notepad3 will additionally **paste the current clipboard once** — but **only** if the buffer is otherwise empty: no file argument, no `/c`, and no MRU auto-load. This asymmetry is intentional. The runtime toggle (`Edit → Toggle Pasteboard`) never auto-pastes. +When `/b` is passed at startup, Notepad3 will additionally **paste the current clipboard once** — but **only** if the buffer is empty and Untitled after startup loading. This asymmetry is intentional. The runtime toggle (**Edit → Toggle Clipboard Monitoring**) never auto-pastes. #### Separator between entries @@ -192,9 +192,9 @@ Subsequent entries are separated according to `Settings2.PasteBoardSeparator`: | Value | Meaning | |---|---| -| `\x01` (default) | One document EOL between entries | -| `\0` | No separator | -| anything else | Verbatim character(s) used as separator | +| Key absent (default) | One document EOL between entries | +| Empty value (`PasteBoardSeparator=`) | No separator | +| Custom value | Character(s) used as separator, with escape sequences decoded | The separator is suppressed for the first paste after enable and when the caret is already at the start of a line. @@ -204,7 +204,7 @@ The separator is suppressed for the first paste after enable and when the caret #### Combining with `/i` — deferred minimize **(N3)** -When `/b` and `/i` are passed together, Notepad3 keeps the window visible for `Settings2.PasteBoardInitialShowMs` (clamped to 500–5000 ms; default 2000 ms) before minimizing, so the user can briefly see what landed in the buffer. **Holding `Ctrl` at the moment the minimize-timer fires cancels the auto-minimize and keeps the window visible** — useful for inspecting or editing the captured clipboard immediately. Pasteboard mode itself remains active either way. Releasing `Ctrl` before the timer expires has no effect; the check is at the firing instant only. +When `/b` and `/i` are passed together, Notepad3 keeps the window visible for `Settings2.PasteBoardInitialShowMs` (clamped to 500–5000 ms; default 1500 ms) before minimizing. **Holding `Ctrl` at the moment the minimize-timer fires cancels the auto-minimize and keeps the window visible**. Auto-minimize is also skipped if the clipboard has nothing pasteable at that instant; this is not a document-empty check or a guarantee of successful pasting. Pasteboard mode itself remains active either way. Releasing `Ctrl` before the timer expires has no effect. --- diff --git a/readme/config/ClipboardMonitoring.md b/readme/config/ClipboardMonitoring.md new file mode 100644 index 0000000000..dae038223f --- /dev/null +++ b/readme/config/ClipboardMonitoring.md @@ -0,0 +1,96 @@ +# Clipboard Monitoring (Pasteboard Mode) + +Use Notepad3 as a clipboard scratchpad: capture text copied from other applications, edit the collected snippets, and save them when needed. This guide covers the workflow extended for [rizonesoft/Notepad3#5425](https://github.com/rizonesoft/Notepad3/issues/5425). + +**Monitoring is off by default and its active state is not persisted to the INI.** Start it with `/b` or **Edit -> Toggle Clipboard Monitoring**. Stop it with the same menu command, or double-click **CBS** in the status bar's INS/OVR field. Stopping leaves the document open and restores normal save-prompt behavior. + +## Capture once, or keep collecting + +```bat +Notepad3.exe /c +Notepad3.exe /b +Notepad3.exe /b /i +``` + +| Launch | Behavior | +|---|---| +| `/c` | Open a new window containing the current clipboard text once; no ongoing monitoring. | +| `/b` | Start monitoring. Also paste the current clipboard once if the document is empty and Untitled after startup loading. | +| `/b /i` | Start monitoring, briefly show the window, then minimize if the conditions below allow it. | + +The startup paste does not replace an opened file or content already loaded into the document. **Turning monitoring on through the menu does not paste the current clipboard immediately**; it waits for a new clipboard update. + +Clipboard text is pasted **at the current caret/selection**, not forced to the end of the document. Leave the caret at the end with no selection when collecting a running list. Automatic pasting temporarily disables auto-indent; an entry and its separator/timestamp form one undo transaction. + +This is not a clipboard-history manager. Clipboard updates are debounced, so several rapid copies can result in only the latest text being captured. Repeated notifications for an unchanged clipboard sequence are ignored, and Notepad3's own copy/cut commands are excluded from automatic recapture. + +## Briefly show, then minimize + +With `/b /i`, the default delay is **1500 ms**. Edit the active INI with **Ctrl+F7**, put the setting under `[Settings2]`, and restart: + +```ini +[Settings2] +PasteBoardInitialShowMs=1000 +``` + +Allowed range: **500-5000 ms**. The delay applies only to the `/b /i` startup combination, not to a later paste or the menu toggle. Minimization uses the configured tray/taskbar preference. + +When the timer fires, Notepad3 stays visible if: + +- **Ctrl is held down** at that instant. +- The clipboard has **nothing pasteable**. + +The second check concerns the clipboard, not whether the document is empty. The delay is not a guarantee that a paste succeeded. Monitoring remains active whether the window minimizes or stays visible. + +## Format collected entries + +The default separator is one line break using the document's current line ending. To add blank lines and local-time timestamps: + +```ini +[Settings2] +PasteBoardSeparator=\r\n\r\n +PasteBoardAddTimestamp=1 +PasteBoardDebounceMs=200 +``` + +This example uses CRLF; use `\n\n` for an LF document. Timestamps have the form `[HH:MM:SS] `. + +**An absent separator setting and an empty setting are different:** omit `PasteBoardSeparator` to use the document's line ending; use `PasteBoardSeparator=` to concatenate entries without an added separator. Custom separators include only the characters you specify: for a dashed line, use `\r\n---\r\n`. The separator is skipped on the first paste after activation and whenever the caret is already at a line start. + +The debounce setting waits for a quiet interval after clipboard updates (default **200 ms**, range **0-5000 ms**). A larger value can coalesce more rapid copies; it does not preserve all intermediate clipboard contents. + +See the [configuration reference](Configuration.md#clipboard-monitoring) for the full setting syntax. + +## Optional disposable scratchpad + +Normally, captured text marks the document as modified and closing asks whether to save it. To make the prompt suppressible for an **Untitled document while monitoring is active**: + +```ini +[Settings2] +DiscardOnClosingUntitledPasteBoard=1 +``` + +This setting **does not immediately discard anything or remove the first prompt**. Restart, launch with `/b`, and close a modified Untitled document. To opt out, check **Don't display this message again** and choose **No** (discard). If the active INI is writable, that answer is saved as `MsgDiscardUntitled` under `[Suppressed Messages]`; later matching prompts replay it silently. Choosing Yes remembers the save answer instead; Cancel is never saved. + +**Warning:** after opting out with No, even manually edited text in an Untitled Pasteboard can be discarded without a save prompt. There is no special exemption for edits made after automatic pasting. Save important content explicitly. + +The opt-out does not apply when monitoring is off or the document has an associated file path. To restore the prompt, remove `MsgDiscardUntitled` from `[Suppressed Messages]` while Notepad3 is closed, or set `DiscardOnClosingUntitledPasteBoard=0` and restart (this also clears the remembered answer). + +See [DiscardOnClosingUntitledPasteBoard](Configuration.md#discardonclosinguntitledpasteboard0) for the setting reference. + +## Interaction with Monitoring Log + +Clipboard Monitoring and **Monitoring Log** (tailing a file) are mutually exclusive. Turn the active mode off before enabling the other. If `/b` is supplied while `MonitoringLog=true` is saved in the INI, clipboard monitoring wins for that launch without changing the saved log-monitoring preference. + +## Source references + +These descriptions were checked against source, not an interactive Windows GUI test; human review is pending. + +- [`src/Notepad3.c:1019`](../../src/Notepad3.c#L1019): `PasteBoard_Start` and `PasteBoard_Stop` manage activation; `InitInstance` at line 2451 implements startup capture, and `WM_CLIPBOARDUPDATE` at line 2669 schedules subsequent pastes. +- [`src/Notepad3.c:13542`](../../src/Notepad3.c#L13542): `PasteBoardTimerProc` handles caret insertion, separators, timestamps, debouncing, and duplicate detection. +- [`src/Notepad3.c:2112`](../../src/Notepad3.c#L2112): `_DeferMinimizeTimerProc` checks Ctrl and clipboard pasteability. +- [`src/Notepad3.c:12735`](../../src/Notepad3.c#L12735): `FileSave` gates the optional `MsgDiscardUntitled` prompt on Untitled + active Pasteboard + the setting. +- [`src/Config/Config.cpp:1425`](../../src/Config/Config.cpp#L1425) and [line 1523](../../src/Config/Config.cpp#L1523): `LoadSettings` loads the five Pasteboard settings and clears the remembered discard answer when its gate is disabled. +- [`src/Dialogs.c:467`](../../src/Dialogs.c#L467) and [line 514](../../src/Dialogs.c#L514): `_InfoBoxLngDlgProc` and `InfoBoxLng` handle saved answers and the opt-out checkbox. + +For other startup switches, see the [command-line reference](../cmdln/CmdLnOptions.md#pasteboard-clipboard-collector-b). diff --git a/readme/config/Configuration.md b/readme/config/Configuration.md index e4505aefb1..b1c69608f6 100644 --- a/readme/config/Configuration.md +++ b/readme/config/Configuration.md @@ -214,11 +214,13 @@ CopyMultiSelectionSeparator=\r\n ;CRLF between each selection ### Clipboard Monitoring -Notepad3 can be launched in **clipboard monitoring mode** with the `/b` command-line switch. In this mode, every clipboard change is automatically appended as a new entry at the end of the document. Stop monitoring at any time via **Edit → Stop Clipboard Monitoring** without closing the editor. While active, the status bar shows **`CBS`** in the INS/OVR field. +Notepad3 can be launched in **clipboard monitoring mode** with the `/b` command-line switch. Pasteable clipboard updates are automatically inserted at the current caret/selection. Stop monitoring via **Edit → Toggle Clipboard Monitoring** without closing the editor. While active, the status bar shows **`CBS`** in the INS/OVR field. + +For startup capture, delayed minimize, entry-formatting examples, and the optional discard-prompt safety net, see the [Clipboard Monitoring guide](ClipboardMonitoring.md). #### `PasteBoardDebounceMs=200` -Debounce interval in milliseconds before a clipboard change is pasted into the document. Increase this value if rapid successive copies result in missed or doubled entries. Range: `0`–`5000`. +Quiet interval in milliseconds after a clipboard update before its content is pasted into the document. Rapid successive updates can be coalesced into one paste of the latest content; increasing the interval can therefore skip more intermediate copies. Range: `0`–`5000`. #### `PasteBoardSeparator=` diff --git a/readme/faq/FAQ.md b/readme/faq/FAQ.md index fa63c31668..67465c0e83 100644 --- a/readme/faq/FAQ.md +++ b/readme/faq/FAQ.md @@ -559,9 +559,9 @@ Run `Notepad3.exe /?` from a command prompt — Notepad3 opens a help dialog lis Two modes are available: - **`/c`** — open a new window pre-populated with the **current** clipboard contents. One-shot. -- **`/b`** — start in *pasteboard mode*: every time the clipboard changes, that text is appended as a new entry in the document. Useful for collecting snippets across many copy operations. Stop it any time via **Edit → Stop Clipboard Monitoring** (the editor stays open with the collected text). +- **`/b`** — start in *pasteboard mode*: clipboard updates paste text at the current caret/selection. Useful for collecting snippets across many copy operations. Stop via **Edit → Toggle Clipboard Monitoring** (the editor stays open with the collected text). -Combine either with `/i` to start minimised to the tray. +Combine either with `/i` to minimize according to your tray/taskbar preference. With `/b /i`, startup minimization is delayed and can be skipped; see the [Clipboard Monitoring guide](../config/ClipboardMonitoring.md). ### Can I run Notepad3 with administrator privileges?