Commit Graph
8 Commits
Author SHA1 Message Date
David Richardson dc6bebd7eb AppKit: Add magnification support to CPScrollView and zoom controls to TextEditor
CPScrollView previously lacked magnification support, preventing document
zooming and leaving view scaling infrastructure without practical test coverage.
Additionally, views resetting to a 1.0 scale retained stale CSS transform properties,
and legacy cibs compiled via nib2cib omitted explicit magnification limits,
breaking zoom functionality in older archives.

* AppKit/CPScrollView.j:
  - Implement magnification methods and properties (`magnification`, `setMagnification:`, `setMagnification:centeredAtPoint:`, `allowsMagnification`, `minMagnification`, and `maxMagnification`) modelled on NSScrollView, with keyed archiving.
  - Scale clip view bounds and synchronize resizing document view widths.
  - Define standard Cocoa default limits (0.25 and 4.0) as named constants.
  - Implement robust decoding validation to assign default limits to unset or invalid archive values and reject non-positive magnification inputs, ensuring full compatibility with legacy cibs.

* AppKit/CPView.j:
  - Remove stale CSS scale styling when a view's scale factor returns to 1.0.

* Tests/AppKit/CPScrollViewTest.j:
  - Add comprehensive unit tests covering magnification scaling, archiving, and fallback decoding for unconfigured limits.

* Tests/Manual/TextEditor/DocumentWindowController.j:
  - Implement zoom action handlers (`zoomToLevel:`, `zoomToActualSize:`, `zoomIn:`, and `zoomOut:`) driven by menu item tag values.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, MainMenu.cib:
  - Add View menu options for Actual Size, Zoom In, Zoom Out, and explicit Zoom Levels (25% to 200%).

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark zoom functionality as tested; log discovered scaling edge cases as open items.

CPScrollView and TextEditor now support robust document magnification from 25% to 200%, validating core view scaling mechanics.
2026-10-24 17:57:21 -06:00
David Richardson 29715948cc TextEditor: Add table demonstration sample via CPMarkdownParser
TextEditor lacked a mechanism to showcase or test CPMarkdownParser's
table rendering capabilities within a live document context.

* Tests/Manual/TextEditor/TableExample.j:
  - Add a Markdown sample containing a heading, a formatted table with a header row and styled cells, and accompanying text, converted to an attributed string via CPMarkdownParser.

* Tests/Manual/TextEditor/DocumentWindowController.j:
  - Implement insertTableExample: action to insert the table sample at the current selection.

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

* Tests/Manual/TextEditor/WORKLIST.md:
  - Record table rendering as tested; log interactive validation and known table limitations as open items.

TextEditor now provides a live demonstration and testing baseline for rich text table layouts.
2026-10-24 13:13:40 -06:00
David Richardson 00851abfa9 AppKit: Model CPRulerView and CPRulerMarker on NSRulerView and NSRulerMarker
Ruler classes departed from canonical NS versions, resulting in functional and visual gaps.:

markers were views that drew text characters and ignored their location argument, the ruler rebuilt its subviews on every update and had no origin offset, measurement units or reserved thicknesses, and CPTextView updated the ruler only on focus and typing attribute changes, had no ruler control methods, and never showed a right indent marker.

* AppKit.j: Import CPRulerMarker and CPRulerView.

* CPScrollView.j: Tile rulers by their required thickness, and give a ruler its scroll view when it is set.

* CPTextView/CPRulerMarker.j: Add CPRulerMarker as an object drawn by its ruler, with a marker location, an image and image origin, movability and removability, and tracking that adds, moves and removes markers through the client view.

* CPTextView/CPRulerView.j: Rewrite CPRulerView with an origin offset, registered measurement units defaulting to the user's region, reserved thicknesses for markers and an accessory view, Cocoa's client view methods, temporary ruler lines, and drawing in a single pass.

* CPTextView/CPTextView.j: Add usesRuler, isRulerVisible, setRulerVisible: and toggleRuler: with a Show Ruler or Hide Ruler title; update the ruler on every selection change; place tab stop, first line, head and tail indent markers relative to the start of the text, with SVG marker images and a context menu for changing tab types and resetting indents.

* Tests/Manual/TextEditor/DocumentWindowController.j: Show the ruler through setRulerVisible:.
2026-10-23 19:30:48 -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 1944382e0e Tests/Manual: Clamp TextEditor document windows to a minimum size
Stop document windows from shrinking below a usable size, and record the AppKit gaps that TextEditor has found.

* DocumentWindowController.j: Implement windowWillResize:toSize: to keep the window at or above provisional minimum dimensions.
* WORKLIST.md: Add a work list of the AppKit gaps found by TextEditor, the planned additions to the app and the tests done.
2026-10-22 19:05:35 -06:00
David Richardson 459a61af58 Tests/Manual: Show a horizontal ruler in the TextEditor document window
Turn on the text view's horizontal ruler in code, because nib2cib does not carry the Interface Builder ruler settings into the cib.

* DocumentWindowController.j: Enable the horizontal ruler on the text view's enclosing scroll view in windowDidLoad, with a comment explaining why it is set up in code.
* Resources/MainMenu.xib, Resources/MainMenu.cib: Remove the Insert Lorem Ipsum key equivalent, which duplicated File > New.
2026-10-22 16:49:29 -06:00
David Richardson 080d9e723e Tests/Manual: Add a text view and Lorem Ipsum insertion to TextEditor
Give the document window a scrolling text view and a toolbar, and add an Edit menu item that inserts placeholder text into the active document.

* LoremIpsum.j: Add a class that supplies the traditional Lorem ipsum passage as static text.
* DocumentWindowController.j: Add a textView outlet and an insertLoremIpsum: action that inserts the placeholder text at the selection through insertText:, so the document's undo manager records it.
* Resources/DocumentWindow.xib, Resources/DocumentWindow.cib: Add a text view in a scroll view that resizes with the window, a toolbar with the default items, and the textView outlet connection.
* Resources/MainMenu.xib, Resources/MainMenu.cib: Add an Insert Lorem Ipsum item to the Edit menu that sends insertLoremIpsum: to First Responder.
2026-10-22 16:33:40 -06:00
David Richardson b58be16e8a Tests/Manual: Make TextEditor a document-based application
Move the main window out of MainMenu.xib into a document window owned by a window controller, so that each document opens in its own window.

* Document.j: Add a CPDocument subclass that creates a DocumentWindowController for each document.
* DocumentWindowController.j: Add a CPWindowController subclass that loads DocumentWindow.cib and sets itself as the window's delegate.
* Resources/DocumentWindow.xib, Resources/DocumentWindow.cib: Add the document window, with DocumentWindowController as File's Owner.
* Resources/MainMenu.xib, Resources/MainMenu.cib: Remove the window, name the application menu Text Editor, rename Preferences to Settings, and remove Quit.
* AppController.j: Remove the window outlet and the code that made the window fill the browser.
* main.j: Import Document.j.
* Info.plist: Declare the Document type with Document as its document class.
2026-10-22 16:07:56 -06:00