Closed thecoolwinter closed 1 year ago
I'm not linking to #80 yet because that issue I think also covers the need to let users use a tab character. That's outside the scope of this PR though.
I'll wait for one more review before merging since this is a large change.
Way to go @thecoolwinter, great work! This makes CodeEdit feel so much more like what you would expect out of any editor.
@thecoolwinter wow awesome!
I'm very interested in investigating what's up with NewlineFilter
. Almost sounds like a line endings issue.
@thecoolwinter Very nice work man! Only comment that I have is that the order of struct properties and functions is a bit all over the place.
@thecoolwinter wow awesome!
I'm very interested in investigating what's up with
NewlineFilter
. Almost sounds like a line endings issue.
Yes and I was going to open an issue on TextFormation. For some reason it's recognizing the beginning of the previous line as the end of the line, but only every other newline. I found that removing the line ending logic fixed it temporarily.
@thecoolwinter Very nice work man! Only comment that I have is that the order of struct properties and functions is a bit all over the place.
Yeah you're right. I can clean that up a little more real quick
Yes and I was going to open an issue on TextFormation. For some reason it's recognizing the beginning of the previous line as the end of the line, but only every other newline. I found that removing the line ending logic fixed it temporarily.
Looks nice! 👍
Kudos also to @mattmassicotte for his work on the whole Chime suite 😉
I'm so glad you are finding all of this useful. Something that could be interesting is turning the STTextView + TextFormation integration itself into a package. Just food for thought.
We're working though the newline whitespace issue, and I think it's figured out, but not 100% sure.
Description
This PR integrates the
TextFormation
library from the awesome @mattmassicotte and @ChimeHQ. It implements the necessary type conformances forSTTextView
, and adds the correct delegate methods inSTTextViewController
to handle edits.Details:
textFilters
array andsetUpTextFormation()
method toSTTextViewController
to set up filters and store them on the class.textView(_ textView: STTextView, shouldChangeTextIn affectedCharRange: NSTextRange, replacementString: String?)
method toSTTextViewController
to apply edits throughTextFormation
NewlineFilter
: This filter is a near 1:1 copy of TextFormation's newline filter. This may be removed in the future, but TextFormation's default implementation caused every other new line to be broken.DeleteWhitespaceFilter
: Deletes segments of whitespace, eg if I have my whitespace set to 4 spaces, when I try to delete an empty line with 8 spaces it will delete the first 4 instead of just one space.TabReplacementFilter
: Replaces tab characters with the given indentation unit (this can be a tab character, but this is a point at which to handle spaces or any other alternatives).keyDown
implementation onSTTextViewController
. This ended up causing problems, andSTTextView
handles tab insertion fine without it. In the future this should be removed, but it seems thatSTTextViewController
loses focus on tab insertion without it. So, it was left in temporarily.Related Issues
79
80
78
23
37
Screenshots
Newlines:
https://user-images.githubusercontent.com/35942988/215297117-4eb68a67-9059-4022-bd6a-cd9f4ca1b437.mov
Bracket Pairs:
https://user-images.githubusercontent.com/35942988/215297139-42b61021-78b7-4426-8355-6dd95a21ef7b.mov
Tabulation:
https://user-images.githubusercontent.com/35942988/215297144-2d8502ec-e239-4632-8dde-03fd8ff20bdb.mov
^ It's not clear but when it only goes left by a couple characters I'm using my arrow keys not the delete button.