-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description Adds the ability to use the system cursor if available and enabled using a `useSystemCursor` variable on either `TextView` or `TextSelectionManager`. ### Related Issues * closes #5 ### Checklist <!--- Add things that are not yet implemented above --> - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots Example usage in CodeEditSourceEditor: https://github.com/CodeEditApp/CodeEditTextView/assets/35942988/5b5adeee-dd80-4f92-92d0-121be18ab6ae
- Loading branch information
1 parent
7d2412c
commit 6653c21
Showing
4 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Sources/CodeEditTextView/Extensions/GC+ApproximateEqual.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// GC+ApproximateEqual.swift | ||
// CodeEditTextView | ||
// | ||
// Created by Khan Winter on 2/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension CGFloat { | ||
func approxEqual(_ other: CGFloat, tolerance: CGFloat = 0.5) -> Bool { | ||
abs(self - other) <= tolerance | ||
} | ||
} | ||
|
||
extension CGPoint { | ||
func approxEqual(_ other: CGPoint, tolerance: CGFloat = 0.5) -> Bool { | ||
return self.x.approxEqual(other.x, tolerance: tolerance) | ||
&& self.y.approxEqual(other.y, tolerance: tolerance) | ||
} | ||
} | ||
|
||
extension CGRect { | ||
func approxEqual(_ other: CGRect, tolerance: CGFloat = 0.5) -> Bool { | ||
return self.origin.approxEqual(other.origin, tolerance: tolerance) | ||
&& self.width.approxEqual(other.width, tolerance: tolerance) | ||
&& self.height.approxEqual(other.height, tolerance: tolerance) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters