Commit Graph
19 Commits
Author SHA1 Message Date
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 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 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
Martin Carlberg ab4c87e69f Fixed: Removed warnings and cleanup for test cases when converting to Node 2021-09-15 17:31:20 +02:00
daboe01 9e289574ff Fixed: attachment support was missing in CPTextView (#2872) 2019-12-19 09:08:33 +01:00
jasperdeb 58c08cebd7 Fixed: Added underline support in CPTextView (#2875) 2019-12-06 09:12:31 +01:00
Martin Carlberg 1fe9c39dd5 Fixed: Test cases for the new or changed delegate methods and notifications. 2018-01-08 13:57:53 +01:00
Alexandre Wilhelm 4b0fe879cb Test: [[CPApplication alloc] init]; in instance setUp method 2015-07-07 14:46:38 -07:00
Alexandre Wilhelm b87aeffcd8 Test: updated unittest 2015-07-07 14:29:50 -07:00
daboe01 a3b4e8db44 fix non-working unit test 2015-07-04 17:42:07 +02:00
Alexandre Wilhelm a884b94ac0 Test: fixe global var in CPTextViewTest.j 2015-05-04 14:02:46 -07:00
Alexandre Wilhelm 194e705982 Test: comment future test for CPTextView 2015-05-01 16:09:08 -07:00
Alexandre Wilhelm 82d0f62d73 Added unittest for CPTextView 2015-04-08 13:53:10 -07:00
Alexandre Wilhelm ed61e5c7f7 Added test file CPTextViewTest.j 2015-03-23 20:56:40 -07:00
daboe01 6230a65a79 removed useless unit test 2014-07-20 11:24:22 +02:00
daboe01 c3e6f4f7b6 automated tests and cleanup 2014-05-29 16:27:07 +02:00