Commit Graph
25 Commits
Author SHA1 Message Date
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 7cd6295359 AppKit: Apply line fragment padding in text layout
CPTextContainer's line fragment padding was 0 and the typesetter never applied it, so text started 2 points from the text view's edge and ruler markers at 0 were cut off. It now follows Cocoa, with a default padding of 5 points at each end of every line fragment.

* CPTextView/CPTextContainer.j: Default the line fragment padding to 5 points, and archive it.

* CPTextView/CPTypesetter.j: Lay lines out inside the padding: offset line fragment origins by it, compute the right margin, right indent, centred and right alignment within the width inside it, and subtract it when layout resumes from a stored line fragment.

* CPTextView/CPTextView.j: Start the caret in empty text inside the padding.
2026-10-23 19:33:16 -06:00
David Richardson b4bff7ffe1 AppKit: Fit a tracking text container inside the text view's inset
A text container that tracked its text view's size took the text view's full width, while the text started after the text container inset, so lines could run past the visible right edge.
It now follows Cocoa: a tracking container fills the text view minus the inset on both sides.

* CPTextView/CPTextContainer.j: Subtract the text container inset on both sides when tracking the text view's width and height.

* CPTextView/CPTextView.j: Refit the text container when a text view is created and when its text container inset changes.
2026-10-23 19:32:07 -06: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 beb4aef424 new: heightTracksTextView support in CPTextContainer 2026-06-19 09:47:39 +02:00
Martin Carlberg f74fed5ee0 Fixed: CPTextView now handles more options from Interface Builder
The new options are:
1. Resizable Horizontally
2. Resizable Vertically
3. Max Size

Also two options from the Text Container is recognized:
1. Tracks text view width
2. Tracks text view height

The last two are needed to allow the text view to recalculate
the size of its content if the frame size is changed.
2020-12-16 11:29:11 +01:00
bedalton 7e6e117b17 Formatting: add semi-colon to CPTextContainer.j (#2675) 2018-04-09 12:40:41 +02:00
daboe01 928f14872e Fixed: call to nonexistent method (#2588) 2018-03-06 08:59:36 +01:00
Alexandre Wilhelm be129d243b Fixed: refactoring of CPTextView 2016-03-06 21:48:42 -08:00
Alexandre Wilhelm 3581ac5ebd Fixed: nib2cib with CPTextView works. Editable, Selectable, RichText, StringValue, BackgroundColor, InsertionPointColor works 2015-03-23 14:50:43 -07:00
Alexandre Wilhelm ed6be510fb Fixed: first work on nib2cib for the CPTextView. The example does not crash anymore 2015-03-20 12:22:23 -07:00
Andrew Hankinson a3ef2a43ac Fix file modes on CPTextView files
Was 755; now 644
2014-12-17 20:48:29 -05:00
Andrew Hankinson 47d963b585 Fixed: Forward declaration of classes and types
Typedef in the ObjJ compiler introduced a few new warnings in this branch. This commit fixes the warnings by either declaring a type or forward-declaring a class.
2014-12-17 12:39:39 -05:00
daboe01 1af7d01d96 fix of resizing regression 2014-09-15 18:20:53 +02:00
daboe01 2c110f7796 fixed: display error at bottom in case of resizing 2014-08-06 13:17:35 +02:00
Alexandre Wilhelm f13c96839e Fixed synthax in CPTextView 2014-07-19 19:07:08 -07:00
Alexandre Wilhelm 776f68c9dd Fixed style in CPTextView 2014-07-19 18:46:25 -07:00
Alexandre Wilhelm c6fd14afd2 Fixed: capp_lint 2014-05-30 11:12:29 -07:00
daboe01 da0d3133df typesetter fix 2014-04-17 11:11:53 +02:00
daboe01 7abd9a3db9 removed debugging code 2014-04-17 10:03:24 +02:00
daboe01 b5a63ed3fc style 2014-04-17 09:58:04 +02:00
daboe01 147edddb90 added support for setWidthTracksTextView: 2014-04-17 09:55:25 +02:00
daboe01 d647258856 formatting 2014-02-12 05:59:34 +01:00
daboe01 85abd5a8c3 eliminate warnings + style 2014-02-09 11:00:25 +01:00
daboe01 9edd8d6f66 CPTextView commit 2014-02-08 20:43:15 +01:00