Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: 🐞 Bug report
description: Something is not working as expected.
title: 🐞 YOUR_DESCRIPTION
title: 🐞 <bug title>
labels: bug

body:
- type: textarea
attributes:
label: Description
description: >-
A clear and concise description of what the bug is.
placeholder: >-
A clear and concise description of what the bug is...
validations:
required: true

- type: textarea
attributes:
label: To Reproduce
description: >-
Steps to reproduce the behavior.
Steps to reliably reproduce the behavior.
placeholder: |
1. Go to '...'
2. Click on '....'
Expand All @@ -27,26 +27,30 @@ body:

- type: textarea
attributes:
label: Expected behavior
description: >-
A clear and concise description of what you expected to happen.
label: Expected Behavior
placeholder: >-
A clear and concise description of what you expected to happen...
validations:
required: true

- type: textarea
attributes:
label: Version information
label: Version Information
description: >-
click on the version number on the welcome screen
value: |
CodeEditTextView: [e.g. 1.0]
macOS: [e.g. 12.3.0]
Xcode: [e.g. 13.3]
validations:
required: true
CodeEditTextView: [e.g. 0.x.y]
macOS: [e.g. 13.2.1]
Xcode: [e.g. 14.2]

- type: textarea
attributes:
label: Additional Context
placeholder: >-
Any other context or considerations about the bug...

- type: textarea
attributes:
label: Additional context
description: >-
Add any other context about the problem here.
label: Screenshots
placeholder: >-
If applicable, please provide relevant screenshots or screen recordings...
31 changes: 13 additions & 18 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: ✨ Feature request
description: Suggest an idea for this project
title: ✨ YOUR_DESCRIPTION
title: ✨ <feature title>
labels: enhancement

body:
- type: input
attributes:
label: Is your feature request related to a problem? Please describe.
placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
validations:
required: false

- type: textarea
attributes:
label: Describe the solution you'd like
label: Description
placeholder: >-
A clear and concise description of what you want to happen.
A clear and concise description of what you would like to happen...
validations:
required: true

- type: textarea
attributes:
label: Describe alternatives you've considered
label: Alternatives Considered
placeholder: >-
A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
Any alternative solutions or features you've considered...

- type: textarea
attributes:
label: Additional context
label: Additional Context
placeholder: >-
Add any other context or screenshots about the feature request here.
validations:
required: true
Any other context or considerations about the feature request...

- type: textarea
attributes:
label: Screenshots
placeholder: >-
If applicable, please provide relevant screenshots or screen recordings...
30 changes: 30 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--- IMPORTANT: If this PR addresses multiple unrelated issues, it will be closed until separated. -->

### Description

<!--- REQUIRED: Describe what changed in detail -->

### Related Issues

<!--- REQUIRED: Tag all related issues (e.g. * #123) -->
<!--- If this PR resolves the issue please specify (e.g. * closes #123) -->
<!--- If this PR addresses multiple issues, these issues must be related to one other -->

* #ISSUE_NUMBER

### Checklist

<!--- Add things that are not yet implemented above -->

- [ ] 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)
- [ ] The issues this PR addresses are related to each other
- [ ] My changes generate no new warnings
- [ ] My code builds and runs on my machine
- [ ] My changes are all related to the related issue above
- [ ] I documented my code

### Screenshots

<!--- REQUIRED: if issue is UI related -->

<!--- IMPORTANT: Fill out all required fields. Otherwise we might close this PR temporarily -->
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
),
.package(
url: "https://github.com/CodeEditApp/CodeEditLanguages.git",
exact: "0.1.11"
exact: "0.1.13"
),
.package(
url: "https://github.com/lukepistrol/SwiftLintPlugin",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ Licensed under the [MIT license](https://github.com/CodeEditApp/CodeEdit/blob/ma
<td align="center">
<a href="https://github.com/CodeEditApp/CodeEdit">
<img src="https://user-images.githubusercontent.com/806104/163099605-4eaedd33-8441-4125-9ca1-a7ccb2f62a74.png" height="128">
<p>CodeEdit</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeEdit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</a>
</td>
<td align="center">
<a href="https://github.com/CodeEditApp/CodeEditKit">
<img src="https://user-images.githubusercontent.com/806104/193877051-c60d255d-0b6a-408c-bb21-6fabc5e0e60c.png" height="128">
<p>CodeEditKit</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeEditKit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</a>
</td>
<td align="center">
Expand All @@ -103,7 +103,7 @@ Licensed under the [MIT license](https://github.com/CodeEditApp/CodeEdit/blob/ma
<td align="center">
<a href="https://github.com/CodeEditApp/CodeEditCLI">
<img src="https://user-images.githubusercontent.com/806104/205848006-f2654778-21f1-4f97-b292-32849cc1eff6.png" height="128">
<p>CodeEdit CLI</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;CodeEdit&nbsp;CLI&nbsp;&nbsp;&nbsp;&nbsp;</p>
</a>
</td>
</tr>
Expand Down
28 changes: 28 additions & 0 deletions Sources/CodeEditTextView/CEScrollView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// CEScrollView.swift
//
//
// Created by Renan Greca on 18/02/23.
//

import AppKit
import STTextView

class CEScrollView: NSScrollView {

override func mouseDown(with event: NSEvent) {

if let textView = self.documentView as? STTextView,
!textView.visibleRect.contains(event.locationInWindow) {
// If the `scrollView` was clicked, but the click did not happen within the `textView`,
// set cursor to the last index of the `textView`.

let endLocation = textView.textLayoutManager.documentRange.endLocation
let range = NSTextRange(location: endLocation)
_ = textView.becomeFirstResponder()
textView.setSelectedRange(range)
}

super.mouseDown(with: event)
}
}
36 changes: 27 additions & 9 deletions Sources/CodeEditTextView/CodeEditTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,63 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
/// - text: The text content
/// - language: The language for syntax highlighting
/// - theme: The theme for syntax highlighting
/// - useThemeBackground: Whether CodeEditTextView uses theme background color or is transparent
/// - font: The default font
/// - tabWidth: The tab width
/// - tabWidth: The visual tab width in number of spaces
/// - indentOption: The option to use for indentation when the tab key is pressed. Defaults to 4 spaces
/// - lineHeight: The line height multiplier (e.g. `1.2`)
/// - wrapLines: Whether lines wrap to the width of the editor
/// - editorOverscroll: The percentage for overscroll, between 0-1 (default: `0.0`)
/// - highlightProvider: A class you provide to perform syntax highlighting. Leave this as `nil` to use the
/// built-in `TreeSitterClient` highlighter.
/// - contentInsets: Insets to use to offset the content in the enclosing scroll view. Leave as `nil` to let the
/// scroll view automatically adjust content insets.
/// - isEditable: A Boolean value that controls whether the text view allows the user to edit text.
public init(
_ text: Binding<String>,
language: CodeLanguage,
theme: Binding<EditorTheme>,
font: Binding<NSFont>,
tabWidth: Binding<Int>,
indentOption: Binding<IndentOption> = .constant(.string(count: 4)),
lineHeight: Binding<Double>,
wrapLines: Binding<Bool>,
editorOverscroll: Binding<Double> = .constant(0.0),
cursorPosition: Published<(Int, Int)>.Publisher? = nil,
cursorPosition: Binding<(Int, Int)>,
useThemeBackground: Bool = true,
highlightProvider: HighlightProviding? = nil,
contentInsets: NSEdgeInsets? = nil
contentInsets: NSEdgeInsets? = nil,
isEditable: Bool = true
) {
self._text = text
self.language = language
self._theme = theme
self.useThemeBackground = useThemeBackground
self._font = font
self._tabWidth = tabWidth
self._indentOption = indentOption
self._lineHeight = lineHeight
self._wrapLines = wrapLines
self._editorOverscroll = editorOverscroll
self.cursorPosition = cursorPosition
self._cursorPosition = cursorPosition
self.highlightProvider = highlightProvider
self.contentInsets = contentInsets
self.isEditable = isEditable
}

@Binding private var text: String
private var language: CodeLanguage
@Binding private var theme: EditorTheme
@Binding private var font: NSFont
@Binding private var tabWidth: Int
@Binding private var indentOption: IndentOption
@Binding private var lineHeight: Double
@Binding private var wrapLines: Bool
@Binding private var editorOverscroll: Double
private var cursorPosition: Published<(Int, Int)>.Publisher?
@Binding private var cursorPosition: (Int, Int)
private var useThemeBackground: Bool
private var highlightProvider: HighlightProviding?
private var contentInsets: NSEdgeInsets?
private var isEditable: Bool

public typealias NSViewControllerType = STTextViewController

Expand All @@ -77,20 +84,21 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
font: font,
theme: theme,
tabWidth: tabWidth,
indentOption: indentOption,
wrapLines: wrapLines,
cursorPosition: cursorPosition,
cursorPosition: $cursorPosition,
editorOverscroll: editorOverscroll,
useThemeBackground: useThemeBackground,
highlightProvider: highlightProvider,
contentInsets: contentInsets
contentInsets: contentInsets,
isEditable: isEditable
)
controller.lineHeightMultiple = lineHeight
return controller
}

public func updateNSViewController(_ controller: NSViewControllerType, context: Context) {
controller.font = font
controller.tabWidth = tabWidth
controller.wrapLines = wrapLines
controller.useThemeBackground = useThemeBackground
controller.lineHeightMultiple = lineHeight
Expand All @@ -105,6 +113,16 @@ public struct CodeEditTextView: NSViewControllerRepresentable {
controller.theme = theme
}

// Updating the tab width (will) reset the default paragraph style, needing a re-render.
if controller.tabWidth != tabWidth {
controller.tabWidth = tabWidth
}

// Updating the indentation unit causes regeneration of text filters.
if controller.indentOption != indentOption {
controller.indentOption = indentOption
}

controller.reloadUI()
return
}
Expand Down
Loading