NotepadNext
NotepadNext copied to clipboard
Make search result text selectable and copyable
Description
Closes #825
This PR makes text inside Search Results rows selectable and copyable without changing the existing copy-all behavior. Individual result text can now be selected with the mouse and copied as plain text via Ctrl+C, Edit > Copy, or the right-click context menu. The toolbar copy button still copies all search results.
Changes
src/docks/SearchResultsDock.cpp
- Added an embedded read-only
QTextEditfor individual search result rows so result text can be selected directly. - Added plain-text copy support for selected result text, without copying highlight formatting.
- Added result-row context menu support for
CopyandCopy Selected Line. - Added
Copy Selected Lineto the tree row context menu so right-clicking the line-number cell also supports copying the full result line. - Preserved double-click activation so opening/navigating to a search result still works.
- Clears previous result-text selection when left-clicking in Search Results.
- Updates embedded result text widget fonts when the configured editor font changes.
- Kept the existing toolbar copy button behavior for copying all search results.
src/docks/SearchResultsDock.h
- Added
copySelectedResultText()so the main window copy action can copy selected Search Results text when appropriate. - Added event filtering and selection-clearing helpers for result text selection handling.
src/dialogs/MainWindow.cpp
- Updated
Edit > Copyto first copy selected Search Results text when a result-text selection exists, then fall back to the current editor copy behavior.
Manual Testing
- Ran a search and selected part of an individual result row.
- Verified
Ctrl+Ccopies only the selected result text as plain text. - Verified
Edit > Copycopies selected result text even after opening the Edit menu. - Verified the result text right-click menu
Copycopies selected text. - Verified
Copy Selected Linecopies the full result line from the result text context menu. - Verified
Copy Selected Lineis also available when right-clicking the line-number cell. - Verified the toolbar copy button still copies all search results.
- Verified double-clicking a result still navigates to the match.
Video of basic manual test below: