Commit Graph
502 Commits
Author SHA1 Message Date
David Richardson 2b77b98163 AppKit: Add RTF list and Unicode support, and preserve rich content during internal copy-paste
The RTF producer and parser lacked support for text lists, failed to encode
non-ASCII characters properly (\uN), and treated first-line indents (\fi) as
absolute values rather than offsets relative to left indents (\li).
Additionally, paste operations ingested application-generated RTF rather than
the native internal archive, causing image attachments and tables to be stripped
during copy-paste workflows within the application.

* AppKit/CPTextView/_CPRTFProducer.j:
  - Implement RTF serialization for text lists using list tables, override tables,
    \levelmarker, \levelprepend, \lsN\ilvlK tags, and \listtext marker blocks.
  - Encode non-ASCII characters via \uc0\uN syntax and compute \fi indents
    relative to \li.
  - Omit image attachment characters from text runs and adjust run starting indices
    to accommodate list markers.

* AppKit/CPTextView/_CPRTFParser.j:
  - Implement pre-pass parsing for list and override tables.
  - Assign shared text lists to items using \ls and \ilvl, extracting marker formats
    from \levelmarker or standard number/level definitions.
  - Parse \uN sequences (skipping fallback characters) and evaluate relative \fi offsets.

* AppKit/CPTextView/CPTextView.j:
  - Configure paste handling to prioritize internal archives when clipboard RTF
    originates from the application, ensuring image attachments and tables survive internal copy-paste.

* AppKit/CPTextView/_CPTableTextAttachment.j:
  - Implement keyed archiving and decoding for table headers, rows, widths,
    and configuration settings, reconstructing cell instances upon unarchiving.

* Tests/AppKit/CPRTFTest.j:
  - Add comprehensive unit tests covering Unicode encoding, relative first-line indents,
    TextEdit and Word list interoperability, and nested list round-trip fidelity.

* Tests/AppKit/CPTextAttachmentTest.j:
  - Add test coverage for table attachment archiving.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark intra-application copy and paste testing as completed.
  - Log external rich text exchange limitations as open items.

Intra-application copy and paste now fully preserves images, tables, and lists,
while RTF serialization supports Unicode and structured hierarchical lists.
2026-10-24 14:37:57 -06:00
David Richardson befbbb9c3b AppKit: Apply font changes without a selection to CPTextView typing attributes
When no text was selected, CPTextView's changeFont: implementation
erroneously extracted the font to convert from the text storage at the
insertion point rather than from current typing attributes. Consequently,
repeated adjustments like Bigger or Smaller failed to accumulate, blank
document font sizing remained locked after one step, and output arguments
risked overwriting selection state.

* AppKit/CPTextView/CPTextView.j:
  - Update changeFont: to derive and convert fonts directly from typing
    attributes when no selection is active, and post corresponding typing
    attribute update notifications.
  - Eliminate selection range output arguments that could inadvertently
    modify active selection bounds.

* Tests/AppKit/CPTextViewTest.j:
  - Add unit tests verifying that repeated font modifications accumulate correctly
    at zero-length insertion points.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark Bigger and Smaller actions without a selection as tested.

Bigger and Smaller menu commands now correctly compound font size adjustments for subsequent typed text, matching Cocoa behavior.
2026-10-24 12:59:18 -06:00
David Richardson df78974183 AppKit: Add CPTextAttachment and image support to CPTextView
AppKit lacked a public text attachment class, preventing rich text documents
from embedding or inserting images.

* AppKit/CPTextView/CPTextAttachment.j:
  - Implement CPTextAttachment (modelled on NSTextAttachment) supporting
    initialization via data and file type, contents, file types, images,
    bounds, and keyed archiving.
  - Adopt a TextKit 2-style view rendering architecture that scales images
    to fit text container width and triggers layout updates upon asynchronous loading.

* AppKit/CPTextView/CPTextStorage.j:
  - Update attributedStringWithAttachment: to accept CPTextAttachment instances
    alongside direct views, routing rendering through existing attachment pathways.

* AppKit/CPTextView/CPTextView.j:
  - Implement the insertImage: action (invoking browser file pickers) and
    Command-V paste handling for images.
  - Configure inserted attachments with responsive view instances scaled to
    text width, omitting live views during pasteboard archiving.

* AppKit/CPTextView/CPTextContainer.j:
  - Adjust attachment bounds to match updated container widths during layout invalidation.

* AppKit/AppKit.j:
  - Export CPTextAttachment.

* Tests/AppKit/CPTextAttachmentTest.j:
  - Add test coverage for data URLs, archiving, width scaling, insertion,
    and serialized text output.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, MainMenu.cib:
  - Add Edit > Insert Image… menu item.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark image insertion testing as completed; log remaining image tasks as open.

Rich text documents now support embedded images inserted via file selection or clipboard paste.
2026-10-24 12:34:51 -06:00
David Richardson 8a70822a2f AppKit: Integrate Edit menu clipboard actions with the system clipboard
CPTextView previously relied solely on browser clipboard events triggered by
keyboard equivalents, isolating Edit menu actions (Copy, Paste) to an internal
pasteboard. Consequently, menu operations ignored external system clipboard
modifications, and Command-V could mistakenly paste stale internal rich text
following an external copy operation.

* AppKit/CPTextView/CPTextView.j:
  - Distinguish menu- and button-driven clipboard actions from browser keyboard event handlers.
  - Implement asynchronous Clipboard API integration to write plain text to the system clipboard on copy/cut and read external content for Paste and Paste as Plain Text.
  - Implement intelligent clipboard reconciliation: preserve internal rich text if the system clipboard plain text matches, or ingest external system clipboard text (including for Command-V shortcuts).
  - Ensure Cut operates correctly across all input vectors.

* Tests/AppKit/CPTextViewTest.j:
  - Add unit tests verifying text ingestion and pasting from the system clipboard.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark Edit menu clipboard synchronization as tested.
  - Log rich-text serialization over the asynchronous Clipboard API as an opportunity for future improvement.

Copy, Cut, and Paste operations from the Edit menu now seamlessly exchange plain text with external applications.
2026-10-24 11:55:37 -06:00
David Richardson dc074c89dd AppKit: Add CPTextList and list management to CPTextView
AppKit lacked CPTextList and the textLists property on CPParagraphStyle,
preventing rich text from supporting bulleted or numbered lists. Additionally,
CPTextView derived its typing attributes from the character following the
insertion point upon selection changes, causing text appended at the end of a
document (and the Font Panel) to incorrectly revert to default styling.

* AppKit/CPTextView/CPTextList.j:
  - Implement CPTextList following NSTextList specifications, including standard
    Cocoa marker formats, CPTextListPrependEnclosingMarker, starting item numbers,
    markerForItemNumber:, isOrdered, and keyed archiving.
  - Add rangeOfTextList:atIndex: and itemNumberInTextList:atIndex: category
    extensions to CPAttributedString.

* AppKit/CPTextView/CPParagraphStyle.j:
  - Add textLists and setTextLists: properties with copy and archiving support.
  - Implement paragraph style equality checks based on list identity.

* AppKit/CPTextView/CPTextView.j:
  - Implement setTextList: and the changeTextList: action method (routing marker
    styles via sender tags). Adjacent paragraphs with matching styles join automatically.
  - Implement list item keyboard navigation and editing mechanics: Return generates
    subsequent list items, Return on an empty item terminates list context,
    Tab at item origin nests levels, Shift-Tab promotes levels, and Delete at item
    text origin strips list membership.
  - Automate list item renumbering during live edits, paste operations, and undo/redo cycles.
  - Update Paste Ruler routines to correctly synthesize, strip, and merge list markers.
  - Fix typingAttributes and Font Panel attribute resolution to derive from the
    first selected character or the character immediately preceding the insertion point.

* AppKit/CPKeyBinding.j:
  - Bind Shift-Tab selector to insertBacktab:.

* AppKit/CPWindow/CPWindow.j:
  - Update key event routing to dispatch Shift-Tab to first responders that accept Tab.

* AppKit/AppKit.j:
  - Export CPTextList.

* Tests/AppKit/CPTextListTest.j:
  - Add unit test coverage for marker formatting, archiving, list range queries,
    interactive list editing, Paste Ruler execution, and menu action validation.

* Tests/AppKit/CPTextViewTest.j:
  - Add test coverage verifying typing attributes at trailing insertion points.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, MainMenu.cib:
  - Add Format > List menu structures containing bulleted, numbered, and outline choices.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark list interaction testing as completed; log RTF list serialization as an open item.

CPTextView now provides Cocoa-compliant bulleted, numbered, and nested list support.
2026-10-24 11:33:57 -06:00
David Richardson 178a7d2aec AppKit: Add Copy Style and Paste Style to CPTextView
CPTextView lacked implementations for copyFont: and pasteFont:
(declared as abstract methods in CPText), causing standard Copy Style and Paste Style menu items to trigger exceptions when invoked.

* AppKit/CPTextView/CPTextView.j:
  - Implement copyFont: to copy character attributes (excluding paragraph style, matching Cocoa) of the initial selection character or current typing attributes to the font pasteboard.
  - Implement pasteFont: to apply copied character attributes to the selection or typing attributes with undo support, preserving individual paragraph styles.
  - Update menu validation logic to enable Copy Style in rich text and Paste Style in editable rich text when the font pasteboard contains valid styling.

* Tests/AppKit/CPTextViewTest.j:
  - Add unit tests covering style copying and pasting with and without active selections.
  - Add test coverage for menu validation.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Record Copy Style and Paste Style as tested.

Copy Style and Paste Style now function consistently with Cocoa.
2026-10-24 10:36:58 -06:00
David Richardson cc120e514a AppKit: Add superscript, subscript, and baseline management to CPTextView
CPTextView lacked the superscript:, subscript:, unscript:, raiseBaseline:, and lowerBaseline: action methods.
Consequently, standard Baseline menu items targeting these actions were automatically disabled,
even though CPTypesetter and _CPLineFragment already possessed full layout support for baseline offset and superscript attributes.

* AppKit/CPTextView/CPTextView.j:
  - Implement superscript:, subscript:, unscript:, raiseBaseline:, and lowerBaseline:.
  - Apply attribute modifications to selected ranges or current typingAttributes.
  - Register baseline operations with CPUndoManager.
  - Implement menu validation logic to enable baseline actions only when the text view is editable and richText is true.

* Tests/AppKit/CPTextViewTest.j:
  - Add unit tests for superscript levels and baseline offsets across text ranges and typing attributes.
  - Add test coverage for menu validation.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Remove resolved baseline management entry.
  - Expand documentation on text layout and line fragment drawing.
  - Document open items: Justify crash, kerning/ligature settings, and Font Panel integration.
  - Note optimal line breaking as a candidate feature for future improvement.
2026-10-24 09:44:06 -06:00
David Richardson 8e4742a250 AppKit: Carry Interface Builder's Uses Ruler setting into cibs
nib2cib ignored the text view's Uses Ruler setting, and CPTextView, CPRulerView and CPRulerMarker archived none of their ruler state, so a ruler could not be configured in Interface Builder or survive archiving.

* CPScrollView.j: Set itself as the scroll view of decoded rulers.

* CPTextView/CPRulerMarker.j: Archive the marker's ruler, location, image and image origin, movability, removability and represented object.

* CPTextView/CPRulerView.j: Archive the ruler's orientation, client view, accessory view, markers, thicknesses, origin offset and measurement units.

* CPTextView/CPTextView.j: Archive usesRuler.

* Tools/nib2cib/NSTextView.j, Tools/nib2cib/NSTextViewSharedData.j: Read the Uses Ruler flag.

* Tests/AppKit/CPRulerViewTest.j: Add tests for ruler layout, measurement units, archiving and the Uses Ruler setting.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, Resources/MainMenu.cib: Add the standard Format menu, whose Text submenu shows and hides the ruler.

* Tests/Manual/TextEditor/Resources/DocumentWindow.xib, Resources/DocumentWindow.cib: Rebuild the cib with the ruler setting, and adjust the window's initial position.
2026-10-23 21:10:17 -06:00
David Richardson 66ea130c8d AppKit: Disable Undo and Redo when a text view does not allow undo
A text view handled undo: and redo: and registered its changes even when allowsUndo was NO, so Edit > Undo stayed enabled and did nothing.

Behaviour now follows canonical Cocoa: a text view that does not allow undo registers nothing and passes undo: and redo: on to the window, and Undo and Redo are enabled only when there is a change to undo or redo.

* CPTextView/CPTextView.j: Register changes only when undo is allowed, stop responding to undo: and redo: when it is not, and validate the Undo and Redo items against the undo manager.

* CPWindow/CPWindow.j: Validate the Undo and Redo items against the window's undo manager.

* Tests/AppKit/CPTextViewTest.j: Add tests for responding to undo:, registering changes and validating the Undo item.

* Tests/Manual/TextEditor/DocumentWindowController.j: Add toggleAllowsUndo: and validateMenuItem:, so that undo can be turned on and off for the active document.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, Resources/MainMenu.cib: Add Edit > Allow Undo.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this gap, record Allow Undo as tested, and add the key equivalent behaviour of disabled menu items for discussion.
2026-10-23 17:20:27 -06:00
David Richardson 055ae6d04e AppKit: List the application's windows in the Windows menu
The Window menu never listed the application's windows, because AppKit had none of Cocoa's Windows menu support.

* CPApplication.j: Add windowsMenu, setWindowsMenu:, addWindowsItem:title:filename:, changeWindowsItem:title:filename:, removeWindowsItem:, updateWindowsItem: and arrangeInFront:; find the menu named _CPWindowsMenu in the main menu, and list the visible windows when the main menu is set.

* CPWindow/CPWindow.j: Add isExcludedFromWindowsMenu and setExcludedFromWindowsMenu:, and keep the window's item current when the window is ordered in or out, retitled, made main or no longer main, miniaturized, deminiaturized or closed.

* Tests/AppKit/CPApplicationWindowsMenuTest.j: Add tests for listing, retitling, exclusion, the main window check mark, separator handling, file name titles and moving items to another Windows menu.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this gap, and record the Window menu as tested.
2026-10-23 16:29:46 -06:00
David Richardson be8d536565 Merge branch 'main' into refactor-remove-nativehost-target 2026-10-22 12:44:13 -06:00
David Richardson 203bf38b21 AppKit: Size vertical scrollers by scroller style in CPScrollView
CPScrollView's frame and content size calculations sized the vertical scroller with scrollerWidthForControlSize:, passing a scroller style, so it always took the legacy width.

* CPScrollView: Use scrollerWidthInStyle: for the vertical scroller in +contentSizeForFrameSize:… and +frameSizeForContentSize:….
* CPScrollViewTest: Add tests for both methods with a scroller whose widths differ by style.
2026-10-22 12:36:32 -06:00
David Richardson f1a8b154fc AppKit: Fix CPDOMAvailable read before assignment
CPDOMAvailable was read during load before it was assigned.

* CPCompatibility: Move the CPDOMAvailable assignment ahead of the engine detection, whose AppleWebKit case calls +[CPPlatform isBrowser], which reads it.
* CPCompatibilityTest: Add a test that re-executes CPCompatibility.j with an AppleWebKit user agent and CPDOMAvailable unset, failing on any exception.
2026-10-15 09:26:12 -06:00
David Richardson 7f38fbe7c7 Tests: promote CPDOMDisplayServer.h to a real source file
- the 11 display-server primitives become plain functions in
  Platform/DOM/CPDOMDisplayServer.j; bodies verbatim from the macro
  definitions; the header was force-included into every AppKit
  compilation by the legacy build and invisible to capp-build
- CPView.j, CPImageView.j, _CPDisplayServer.j import the new file;
  this was the last header in either framework
- CPDOMDisplayServerTest: the raw #include replaced by the
  framework-qualified import
2026-10-06 18:50:09 -06:00
David Richardson 7f89b13387 Tests: convert CPLevelIndicatorTest helper macro to direct messages
- the six GET_LEVEL_INDICATOR_SEGMENT call sites become direct
  layoutEphemeralSubviewNamed: messages; the macro was fully
  parameterized with no ambient state
- the segment index is the literal 0 at every site, so the
  concatenation folds to a constant string
- the warning comment about direct ephemeral-subview access is
  retained
2026-10-06 18:33:52 -06:00
David Richardson 2167c1d3b8 AppKit: delete IE-era VML rendering backend
- CoreGraphics/CGContextVML.j removed; it implemented the CGContext
  function family against Internet Explorer's VML, irrelevant in the
  supported browser landscape for over a decade
- its self-replacing CGBitmapGraphicsContextCreate wrapper called
  document.namespaces.add, an IE-only API — a latent crash on modern
  browsers had the branch ever been selected
- CGContext.j: the CPVMLFeature branch of the load-time backend
  selection removed; CPCompatibility.j: the CPVMLFeature constant and
  its feature-table entry removed
- Tests/AppKit/CGContextTest.j: the vacuous VML-incompatibility
  assertion removed
- the canvas backend and the no-canvas stubs are unchanged
2026-10-06 18:08:43 -06:00
David Richardson bdc2b7cd67 test: disable unasserted performance benchmarks in CPArray suites
Prefix unasserted performance tests with 'disabled_' in CPArrayControllerTest
and CPArrayPerformanceTest to eliminate wall-clock timing noise from standard
CI runs.

Add a dummy assertion to CPArrayPerformanceTest to maintain runner
compatibility without executing obsolete micro-benchmarks.
2026-08-31 09:49:44 -06:00
David Richardson 3a140b07fe Fix child-node index arithmetic and expand CPTreeNode test coverage
CPTreeNode.j:
* Correct index calculations in insertObject:inChildNodesAtIndex: and replaceObjectInChildNodesAtIndex:withObject:. Nodes no longer misplace during same-parent or cross-parent moves.
 * Update _removeChildNode: to call removeObjectFromChildNodesAtIndex:. This ensures detaches notify childNodes observers on the original parent.

CPTreeNodeTest.j:
* Add test coverage for same-parent replacement, cycle rejection on replace-path, KVO during cross-parent moves, mutableChildNodes proxy operations, insertion bounds, non-recursive sorting, isLeaf, and descendantNodeAtIndexPath: edge cases.
* Disable same-parent childNodes KVO test. CPKeyValueObserving.j coalesces nested change notifications on the same key, which drops the inner removal event.
* Disable parentNode KVO test. No setParentNode: method exists to instrument.
* Add inline comments to both disabled tests explaining these mechanisms.
2026-08-28 13:35:27 -06:00
David Richardson ee0c6fdf2d CPTreeNodeTest: fix child-move index arithmetic; correct a flawed test expectation
CPTreeNode: same-parent child moves no longer misplace the moved node — this corrects a defect in the class itself, properly exposed by the test.

Separately, the unit test's expectation for a root node's index path was itself wrong.
Corrected to match the class's existing, contract-correct behavior.

Test unit now runs cleanly.
2026-08-27 16:54:31 -06:00
David Richardson 54b7d24081 Merge branch 'main' into CPTreeNode-improve-tests 2026-08-27 16:02:08 -06:00
daboe01 acf410776d Merge pull request #3279 from daboe01/whitespace-cleanup
fixed: usage of tab character instead of 4 spaces
2026-08-26 20:46:52 +02:00
daboe01 6ef3cf776f new: selection tests 2026-08-25 20:39:34 +02:00
David Richardson fad987641b Improve and extend CPTreeNode tests 2026-08-19 11:41:39 -06:00
daboe01 567ec55875 fixed: usage of tab character instead of 4 spaces 2026-08-18 19:46:22 +02:00
David Richardson 1a9a42ff54 Replace #pragma mark with // MARK:
Replace objc directive with native Javascript version // MARK: to facilitate elimination of preproccsing pass.
2026-07-21 15:15:53 -06:00
daboe01 9ecc739e8d Merge pull request #3186 from daboe01/colorpanel-fixes
Fix CPColorWell drag-and-drop and responder chain integration
2026-03-25 19:33:27 +01:00
daboe01 031e5e7ca3 fixed: selection issues 2026-03-08 19:52:58 +01:00
daboe01 b1f2fb44a8 new: CPOutlineView bindings support 2026-03-07 21:43:41 +01:00
daboe01 cd4c3cffe0 fixed: test cases 2026-03-07 20:05:50 +01:00
daboe01 98c01b88e2 fixed various binding issues 2026-03-07 20:00:09 +01:00
daboe01 12960f8160 new: testcase 2026-03-07 19:27:01 +01:00
daboe01 1bbf87e2cb fixed: testcases 2026-02-28 18:26:47 +01:00
daboe01 8db24fcaf6 new: testcases from enquora 2026-02-28 16:46:34 +01:00
daboe01 e198fbdc40 Merge pull request #3122 from daboe01/fixed-keycode-management-in-cptextview
fixed: Keyboard-event handling is based on the deprecated charCode
2026-01-28 20:57:07 +01:00
daboe01 dc23fe49af new: unit tests 2025-09-04 11:54:06 +03:00
daboe01 c2d07b7b06 Merge pull request #3120 from daboe01/nil-in-cpviewcontroller-fix
fixed: subview's window setting did not happen BEFORE _setSuperview
2025-07-17 19:27:36 +02:00
daboe01 e9022d045c Merge pull request #3123 from daboe01/new-viewcontroller-responder-chain-issue
fixed: CPViewController doesn't participate fully in responder chain
2025-07-05 16:41:23 +02:00
daboe01 c70ea739ec fixed: unittest was overambitious 2025-07-05 16:39:10 +02:00
daboe01 85da0164ba fixed: designated initialiser was not used 2025-07-05 16:32:22 +02:00
daboe01 2add37983d new: unittest for responderchain 2025-07-05 15:56:44 +02:00
daboe01 27280f6da1 Update CPMenuTest.j 2025-07-05 12:35:43 +02:00
daboe01 ce7fec170a Update CPEventTest.j 2025-07-05 12:33:21 +02:00
daboe01 98ef6fd902 Update CPEventTest.j 2025-07-05 12:30:58 +02:00
daboe01 1c4d9b1d8f Update CPButtonTest.j 2025-07-05 12:29:11 +02:00
daboe01 b8b988c10b Update CPResponderTest.j 2025-07-05 09:04:26 +02:00
daboe01 d12770c65d fixed: testcase for keyevent 2025-07-05 08:57:29 +02:00
daboe01 bae78b5055 formatting 2025-06-22 21:52:57 +02:00
daboe01 c0705448cd new: testcase 2025-06-22 21:47:26 +02:00
daboe01 3a9db70426 fixed: CPObjectController returns 'null marker' instead of nil 2025-06-22 11:04:46 +02:00
daboe01 2f563fb870 New: give nil values the chance to be transformed to true via CPNegateBoolean (#3103) 2025-04-28 15:40:57 +02:00