Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f770d0f
Begin TextView implementation
thecoolwinter Jun 29, 2023
f70e24d
Add height to textline tree
thecoolwinter Jul 15, 2023
dbfe605
Merge branch 'main' into feat/inputview
thecoolwinter Jul 15, 2023
2776c2e
Get something rendering...
thecoolwinter Jul 16, 2023
ab76fef
Wrap lines, remove custom layer
thecoolwinter Jul 17, 2023
864400c
Begin integrating highlighting system
thecoolwinter Jul 17, 2023
6069382
Syntax highlighting integration (no edit)
thecoolwinter Jul 17, 2023
f3d8a5a
Update TODO.md
thecoolwinter Jul 17, 2023
d4780de
Begin layer reuse instead of raw draw
thecoolwinter Jul 22, 2023
6678dc4
Use reusable views for rendering lines
thecoolwinter Aug 16, 2023
a685b9f
Initial cursor implementation
thecoolwinter Aug 16, 2023
2629ec2
Fix some resizing bugs
thecoolwinter Aug 16, 2023
b45ec3d
Begin (completely non functional) text input
thecoolwinter Aug 16, 2023
2a292f0
Refactor TextLineStorage, Add Insert Editing
thecoolwinter Aug 20, 2023
a40000c
Final layout refactor, resizable, copy/paste
thecoolwinter Aug 22, 2023
c3c9e62
Fix scroll jumping on scroll up
thecoolwinter Aug 22, 2023
c37ab5c
Add setNeedsLayout to TextLayoutManager
thecoolwinter Aug 22, 2023
417bd32
Move line storage builder
thecoolwinter Aug 22, 2023
f5cc9f6
Add line number to Line Storage nodes
thecoolwinter Aug 22, 2023
fbe25d8
Add GutterView
thecoolwinter Aug 22, 2023
19500f9
Line Numbers final, fix insert bug
thecoolwinter Aug 23, 2023
1f16841
Selected line highlights, remove strong references
thecoolwinter Aug 23, 2023
eee21f9
Fix Cursor + Selection Background Misalignment
thecoolwinter Aug 23, 2023
8452403
Fix text position calculation
thecoolwinter Aug 23, 2023
edbe8d3
Spelling Error
thecoolwinter Aug 23, 2023
5a7bbcd
Begin RB delete, add docs
thecoolwinter Aug 24, 2023
a757f5c
Begin Delete
thecoolwinter Aug 25, 2023
30a6222
Add TextSelectionManager as NSTextStorage delegate
thecoolwinter Aug 26, 2023
793bf10
Small refactor
thecoolwinter Aug 26, 2023
377c986
Fix TODO, Fix Performance Test
thecoolwinter Aug 26, 2023
8d877cc
Add RB Tree Delete, lazy update cursors
thecoolwinter Aug 31, 2023
a5f077e
Add small test
thecoolwinter Aug 31, 2023
63cff48
Begin `TextLayoutManager` updates for editing
thecoolwinter Sep 3, 2023
203ffca
Add CodeEditTextInput and Common targets
thecoolwinter Sep 3, 2023
3141026
Finish delete
thecoolwinter Sep 3, 2023
2baa6d9
Merge remote-tracking branch 'origin/main' into feat/inputview
thecoolwinter Sep 3, 2023
bdc2d6d
Finalize Insert, Delete, Newlines, Delete Lines
thecoolwinter Sep 11, 2023
1c8aea5
Arrow Left & Right, Fix Lint Errors, Trailing Insets
thecoolwinter Sep 11, 2023
b0ac245
Fix Lint Bugs, Remove Warnings
thecoolwinter Sep 11, 2023
a3aad97
Add Some TextSelectionManager Tests
thecoolwinter Sep 12, 2023
1e42a4c
Add `scrollSelectionToVisible`, Work on Arrow Keys
thecoolwinter Sep 13, 2023
882fa43
Finish Keyboard Navigation
thecoolwinter Sep 15, 2023
18a958c
QOL GutterView Improvements
thecoolwinter Sep 17, 2023
0a00de9
Add line break strategies
thecoolwinter Sep 19, 2023
37a8331
Limit word break lookback to startingOffset
thecoolwinter Sep 19, 2023
307b0b3
Draw Selection Rects
thecoolwinter Sep 19, 2023
f22ae5a
Drag To Select, Autoscroll On Drag
thecoolwinter Oct 2, 2023
7046569
Finalize Selection Modification API
thecoolwinter Oct 6, 2023
668b294
Fix Gutter Clipping, Improve Insert Performance
thecoolwinter Oct 7, 2023
048e7b8
Fix TextLineStorage.update Test
thecoolwinter Oct 7, 2023
5c389da
Fix Undo/Redo, Line Fragment Move, Lint Errors
thecoolwinter Oct 7, 2023
d7050ab
Typing Attributes, Remove STTextView, Integrate Previous Features
thecoolwinter Oct 14, 2023
9e6a7b5
Remove Print Statement
thecoolwinter Oct 14, 2023
61a1b9b
Accessibility
thecoolwinter Oct 14, 2023
181e7ff
Fix Linter
thecoolwinter Oct 14, 2023
5a11ada
Fix Editing Bugs, Pass Tests
thecoolwinter Oct 15, 2023
5384b6b
Fix Basic Editing At End Of Files & New Files
thecoolwinter Oct 17, 2023
f7760af
Fix Empty File, End Of File, LineEndings
thecoolwinter Oct 19, 2023
9586155
Fix TextFormation, EOD Selection, Layout Transactions
thecoolwinter Oct 20, 2023
5bf20ed
Fix textOffsetAtPoint, Add Selection getFillRects
thecoolwinter Oct 21, 2023
d6f399c
Remove Xcode Baselines
thecoolwinter Oct 21, 2023
bdcd0f6
Multi-Cursor, Sync Cursor Animations, Line Highlights
thecoolwinter Oct 22, 2023
af81a47
Fix Lint Errors
thecoolwinter Oct 22, 2023
4d7dbc5
Merge remote-tracking branch 'upstream' into feat/inputview
thecoolwinter Oct 22, 2023
38db0d4
Fix Lint Errors
thecoolwinter Oct 22, 2023
dae9e60
Misc fixes, Fixup SwiftUI API
thecoolwinter Oct 24, 2023
8a221c4
Fix Tests
thecoolwinter Oct 24, 2023
9e0ca63
Correctly Reset `setTextStorage`, background colors
thecoolwinter Nov 2, 2023
f0e6059
Initial Marked Text implementation
thecoolwinter Nov 7, 2023
4716991
Update README.md Icon
austincondiff Nov 8, 2023
05390c5
Update README.md
austincondiff Nov 8, 2023
93bfd76
Marked Text, Remove Common Module, `lineBreakStrategy`
thecoolwinter Nov 9, 2023
81c7f98
Update SwiftUI API, Add `CursorPosition` & `TextViewCoordinator`
thecoolwinter Nov 18, 2023
0016b1d
Merge remote-tracking branch 'upstream' into feat/inputview
thecoolwinter Nov 18, 2023
7cf6937
Remove `internal`, Unnecessary Public Extensions
thecoolwinter Nov 18, 2023
7ca798d
Update TextViewControllerTests.swift
thecoolwinter Nov 18, 2023
2b6ae13
Explicit frame size in test
thecoolwinter Nov 18, 2023
22dfab2
Linter
thecoolwinter Nov 18, 2023
afcafa9
Update Sources/CodeEditInputView/TextView/TextView+Move.swift
austincondiff Dec 9, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream' into feat/inputview
  • Loading branch information
thecoolwinter committed Oct 22, 2023
commit 4d7dbc5f1fb1ceaa35386e7f5326df2a33aba0d0
20 changes: 12 additions & 8 deletions Sources/CodeEditInputView/Utils/CEUndoManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ import TextStory
/// - Grouping pasted text
///
/// If needed, the automatic undo grouping can be overridden using the `beginGrouping()` and `endGrouping()` methods.
class CEUndoManager {
public class CEUndoManager {
/// An `UndoManager` subclass that forwards relevant actions to a `CEUndoManager`.
/// Allows for objects like `TextView` to use the `UndoManager` API
/// while CETV manages the undo/redo actions.
class DelegatedUndoManager: UndoManager {
public class DelegatedUndoManager: UndoManager {
weak var parent: CEUndoManager?

override var canUndo: Bool { parent?.canUndo ?? false }
override var canRedo: Bool { parent?.canRedo ?? false }
public override var canUndo: Bool { parent?.canUndo ?? false }
public override var canRedo: Bool { parent?.canRedo ?? false }

func registerMutation(_ mutation: TextMutation) {
public func registerMutation(_ mutation: TextMutation) {
parent?.registerMutation(mutation)
removeAllActions()
}

override func undo() {
public override func undo() {
parent?.undo()
}

override func redo() {
public override func redo() {
parent?.redo()
}

override func registerUndo(withTarget target: Any, selector: Selector, object anObject: Any?) {
public override func registerUndo(withTarget target: Any, selector: Selector, object anObject: Any?) {
// no-op, but just in case to save resources:
removeAllActions()
}
Expand Down Expand Up @@ -87,7 +87,9 @@ class CEUndoManager {
}
isUndoing = true
for mutation in item.mutations.reversed() {
NotificationCenter.default.post(name: .NSUndoManagerWillUndoChange, object: self.manager)
textView.insertText(mutation.inverse.string, replacementRange: mutation.inverse.range)
NotificationCenter.default.post(name: .NSUndoManagerDidUndoChange, object: self.manager)
}
redoStack.append(item)
isUndoing = false
Expand All @@ -100,7 +102,9 @@ class CEUndoManager {
}
isRedoing = true
for mutation in item.mutations {
NotificationCenter.default.post(name: .NSUndoManagerWillRedoChange, object: self.manager)
textView.insertText(mutation.mutation.string, replacementRange: mutation.mutation.range)
NotificationCenter.default.post(name: .NSUndoManagerDidRedoChange, object: self.manager)
}
undoStack.append(item)
isRedoing = false
Expand Down
9 changes: 7 additions & 2 deletions Sources/CodeEditTextView/CodeEditTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
/// character's width between characters, etc. Defaults to `1.0`
/// - bracketPairHighlight: The type of highlight to use to highlight bracket pairs.
/// See `BracketPairHighlight` for more information. Defaults to `nil`
/// - undoManager: The undo manager for the text view. Defaults to `nil`, which will create a new CEUndoManager
public init(
_ text: Binding<String>,
language: CodeLanguage,
Expand All @@ -50,7 +51,8 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
contentInsets: NSEdgeInsets? = nil,
isEditable: Bool = true,
letterSpacing: Double = 1.0,
bracketPairHighlight: BracketPairHighlight? = nil
bracketPairHighlight: BracketPairHighlight? = nil,
undoManager: CEUndoManager? = nil
) {
self._text = text
self.language = language
Expand All @@ -68,6 +70,7 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
self.isEditable = isEditable
self.letterSpacing = letterSpacing
self.bracketPairHighlight = bracketPairHighlight
self.undoManager = undoManager ?? CEUndoManager()
}

@Binding private var text: String
Expand All @@ -86,6 +89,7 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
private var isEditable: Bool
private var letterSpacing: Double
private var bracketPairHighlight: BracketPairHighlight?
private var undoManager: CEUndoManager

public typealias NSViewControllerType = TextViewController

Expand All @@ -106,7 +110,8 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
contentInsets: contentInsets,
isEditable: isEditable,
letterSpacing: letterSpacing,
bracketPairHighlight: bracketPairHighlight
bracketPairHighlight: bracketPairHighlight,
undoManager: undoManager
)
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.