Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
8ccbe81
Removes usage of UIKit when compiling for Mac
simonbs Jan 27, 2023
e1c0bf8
Merge branch 'main' into mac
simonbs Jan 27, 2023
b334434
Fixes compile errors when targeting iOS
simonbs Jan 27, 2023
ab78196
Merge branch 'main' into mac
simonbs Jan 27, 2023
d48ce15
Correctly draws line numbers
simonbs Jan 27, 2023
75fc712
Renames Example to iOSExample
simonbs Jan 27, 2023
a26d6bc
Rerender line number when frame changes
simonbs Jan 28, 2023
d5e5788
Removes compiler version checks
simonbs Jan 28, 2023
12d482c
Improves formatting
simonbs Jan 28, 2023
0b5b38a
Fixes firstRect
simonbs Jan 28, 2023
572b365
Improves formatting
simonbs Jan 28, 2023
4388e34
Improves formatting
simonbs Jan 28, 2023
2417a29
Removes compiler version checks
simonbs Jan 28, 2023
6b07413
Prepares for Mac example
simonbs Jan 28, 2023
f8362d1
WIP multi-platform
simonbs Jan 28, 2023
2e4defc
Adds constant.builtin
simonbs Jan 29, 2023
f7a956c
Moves TextView to TextView_iOS
simonbs Jan 29, 2023
91a7632
Improves formatting
simonbs Jan 29, 2023
bef22af
Removes TextInputView
simonbs Jan 29, 2023
e1c793e
Adds missing edit functions
simonbs Jan 29, 2023
47a3843
Adds missing case
simonbs Jan 29, 2023
8b7b678
Adds missing call to textViewController
simonbs Jan 29, 2023
ffc228c
Makes lineEndings backed by equivalent in textViewController
simonbs Jan 29, 2023
bf7d116
Adds text(in:)
simonbs Jan 29, 2023
ba2b1c0
Adds replace(_:with:)
simonbs Jan 29, 2023
24e7f8b
Fixes UI tests
simonbs Jan 29, 2023
4341453
Improves formatting
simonbs Jan 29, 2023
78acd7b
Fixes unit test
simonbs Jan 29, 2023
2a3de76
Fixes caret placement when navigating to line
simonbs Jan 29, 2023
6d87e25
Fixes selection when navigating to highlights
simonbs Jan 29, 2023
aa01614
Removes unused CGContext
simonbs Jan 29, 2023
656b387
Merge branch 'enhancement/removes-unused-cgcontext' into mac
simonbs Jan 29, 2023
ca89628
Improves formatting
simonbs Jan 29, 2023
146b7a8
Adds app icon to Mac example
simonbs Jan 29, 2023
25c1566
Makes NSEdgeInsets conform to Equatable
simonbs Jan 29, 2023
3d4156f
Adds layoutIfNeeded() to NSView
simonbs Jan 29, 2023
79bfbf5
Adds LineMovementController.Direction
simonbs Jan 29, 2023
8ff5426
Uses MultiPlatformEdgeInsets
simonbs Jan 29, 2023
0440c21
Makes iOS TextView available on iOS-only
simonbs Jan 29, 2023
54e2b92
Uses LineMovementController.Direction
simonbs Jan 29, 2023
72255dc
Passes scroll view to TextViewController
simonbs Jan 29, 2023
3270f0a
Handles isSelectable in hitTest(_:with:)
simonbs Jan 29, 2023
3a2394d
Removes TextInputClientView
simonbs Jan 30, 2023
aa5100b
Adds scrollContentView
simonbs Jan 30, 2023
81e85c3
Removes background color
simonbs Jan 30, 2023
32a9447
Removes return
simonbs Jan 30, 2023
2070d26
Updates window title
simonbs Jan 30, 2023
920d19e
Uses UIEdgeInsets
simonbs Jan 30, 2023
e00ea33
Renames layout() to layoutIfNeeded()
simonbs Jan 30, 2023
9c70759
WIP AppKit
simonbs Jan 30, 2023
08e2895
Adds caret
simonbs Jan 30, 2023
76187ad
Ensures caret is instantly visible
simonbs Jan 30, 2023
32e40af
Caret supports light mode
simonbs Jan 31, 2023
d90aacb
Adds @discardableResult
simonbs Jan 31, 2023
7c712a8
Sets initial selectedRange
simonbs Jan 31, 2023
26ebc9a
Adds isEditing and text properties
simonbs Jan 31, 2023
703bc73
Fixes layout order
simonbs Jan 31, 2023
875338b
Introduces StringTokenizer
simonbs Jan 31, 2023
87b30d9
Supports navigation with the keyboard
simonbs Jan 31, 2023
0fae005
Removes return statement
simonbs Jan 31, 2023
ddbfd2e
Fixes navigating between words followed by emojis
simonbs Jan 31, 2023
4bb1142
Supports jumping between words
simonbs Jan 31, 2023
b343fb2
Only stores new offset if destinationLocation is different from sourc…
simonbs Jan 31, 2023
9adea56
Supports jumping to line, paragraph, and document boundaries
simonbs Jan 31, 2023
dc48d41
Supports clicking to jump
simonbs Jan 31, 2023
8ff56e2
Bridges themes to AppKit
simonbs Jan 31, 2023
31f8d0e
Adds theme property
simonbs Jan 31, 2023
4449fb9
Disables drawing of background
simonbs Jan 31, 2023
4bd8db5
Supports inserting tab
simonbs Jan 31, 2023
82cc1f2
Applies theme
simonbs Jan 31, 2023
4271363
Shows invisible characters
simonbs Jan 31, 2023
a764301
Sets lineHeightMultiplier and kern
simonbs Jan 31, 2023
cec198b
Fixes conversion of clicks
simonbs Feb 1, 2023
2656524
Removes debug log
simonbs Feb 1, 2023
871c2dd
Properly handles becomeFirstResponder and resignFirstResponder
simonbs Feb 1, 2023
02ce86e
Ensures gutter hairline has background
simonbs Feb 1, 2023
262df57
Links themes
simonbs Feb 1, 2023
6151dae
Makes TextView open
simonbs Feb 1, 2023
5c83251
Fixes compile issues
simonbs Feb 1, 2023
32b532d
Renames delegateAllowsEditingToBegin to shouldBeginEditing
simonbs Feb 1, 2023
a4c631b
Adds gutter to Mac app
simonbs Feb 1, 2023
31e0524
Sets insertion point color
simonbs Feb 1, 2023
f5c65d2
Fixes selection placement on iOS
simonbs Feb 1, 2023
f2f4a84
Enables automatic scrolling by default
simonbs Feb 1, 2023
68d1979
Removes unneeded pragmas
simonbs Feb 1, 2023
27cede5
Ensures scroll view is scrolled automatically
simonbs Feb 1, 2023
409b3a6
Takes textContainerInset into account when scrolling to range
simonbs Feb 1, 2023
46e4c32
Adds large transparent title bar
simonbs Feb 1, 2023
cd2a6c5
Fixes failing UI tests
simonbs Feb 2, 2023
a30946d
Fixes incorrect content size
simonbs Feb 2, 2023
1e2ecf5
Improves formatting
simonbs Feb 2, 2023
6890bb5
Removes toolbar
simonbs Feb 2, 2023
fdb3552
Ensures scrollers are on top
simonbs Feb 2, 2023
e776fa4
Adds background to title bar
simonbs Feb 2, 2023
a124c4a
Moves contentSize to ContentSizeService
simonbs Feb 3, 2023
23d7daa
Forces dark mode
simonbs Feb 3, 2023
39d2076
Disables scrollers until they are needed
simonbs Feb 3, 2023
5018475
Fixes stringView not being set on tokenizer
simonbs Feb 3, 2023
07952a3
Adds setState(_:)
simonbs Feb 3, 2023
b2d93fa
Respects indent strategy
simonbs Feb 3, 2023
9a53844
Sets indentStrategy
simonbs Feb 3, 2023
4acc3c3
Adds syntax highlighting
simonbs Feb 3, 2023
270cd32
Increases line height
simonbs Feb 3, 2023
d9df81a
Imports RunestoneJavaScriptLanguage
simonbs Feb 3, 2023
fddcf33
Sets characterPairs
simonbs Feb 3, 2023
1fac27d
Calls shouldChangeText(in:replacementText:)
simonbs Feb 3, 2023
780cb20
Passes symbol
simonbs Feb 4, 2023
47ff24d
Renames SelectionRectService to SelectionRectFactory
simonbs Feb 5, 2023
00cba6c
Removes return statement
simonbs Feb 5, 2023
7b61177
Fixes incorrect Y-position of selection rects
simonbs Feb 5, 2023
7dac3df
Fixes calls to -textViewDidChangeSelection(_:)
simonbs Feb 5, 2023
7e50a96
Adds CaretRectFactory and SelectionRectFactory
simonbs Feb 5, 2023
08402e0
Removes safeSelectionRange(from:)
simonbs Feb 5, 2023
7b83fc2
Uses caretRectFactory
simonbs Feb 5, 2023
cd2ef12
Only shows caret when selectedRange is not zero
simonbs Feb 5, 2023
759696e
Removes usage of safeSelectionRange(from:)
simonbs Feb 5, 2023
2fce65f
Hides selected background if selectedRange.length != 0
simonbs Feb 5, 2023
557477c
WIP text selection and copy, paste, and cut
simonbs Feb 5, 2023
27c9b5a
Removes debug log
simonbs Feb 6, 2023
04b8a08
Fixes line manager not updated
simonbs Feb 6, 2023
dcd585b
Fixes line selection
simonbs Feb 6, 2023
04e2e17
Adds implicit_return SwiftLint rule
simonbs Feb 6, 2023
cba1e67
Fixes SwiftLint warnings
simonbs Feb 6, 2023
9ac06b7
Adds implicit_return SwiftLint rule
simonbs Feb 6, 2023
44a0f51
Fixes SwiftLint rules
simonbs Feb 6, 2023
4fd63aa
Merge branch 'enhancement/implicit-return' into mac
simonbs Feb 6, 2023
a432b59
Fixes compile issue
simonbs Feb 6, 2023
75d655b
Fixes SwiftLint warning
simonbs Feb 6, 2023
390b292
Merge branch 'enhancement/implicit-return' into mac
simonbs Feb 6, 2023
711bb9e
Merge branch 'main' into mac
simonbs Feb 6, 2023
b66770b
Fixes incorrect path to query
simonbs Feb 6, 2023
dbc67fe
Removes superfluous disable command
simonbs Feb 6, 2023
9d1a73c
Fixes commands not received
simonbs Feb 6, 2023
2640535
Enables line wrapping
simonbs Feb 8, 2023
19da1bd
Adds default etxt
simonbs Feb 8, 2023
519f9bd
Makes LineSelectionView available on macOS only
simonbs Feb 8, 2023
8660d0b
WIP selection on the Mac
simonbs Feb 8, 2023
09d2c5b
Layout selection rectangles when view size changes
simonbs Feb 9, 2023
7bd6480
Takes gutter width into account when typesetting
simonbs Feb 9, 2023
d227df6
Merge branch 'mac' into selection
simonbs Feb 9, 2023
9e3e0a7
Improves naming of functions
simonbs Feb 9, 2023
3512a88
Uses supplied direction when length of range is zero
simonbs Feb 9, 2023
140f38f
Uses ConsiderateLineNavigationLocationFactory
simonbs Feb 9, 2023
678ccb9
Makes lineControllerStorage private
simonbs Feb 9, 2023
956eb9d
Adds default offset
simonbs Feb 9, 2023
5f1c0a4
Renames ConsiderateLineNavigationLocationFactory to StatefulLineNavig…
simonbs Feb 9, 2023
f507bf9
Fixes SwiftLint warnings
simonbs Feb 9, 2023
2e93d35
Adds double and triple click to select words and lines
simonbs Feb 11, 2023
94ef525
Validates menu items
simonbs Feb 11, 2023
deb8493
Fixes SwiftGen input
simonbs Feb 11, 2023
c693d7f
Adds right-click menu
simonbs Feb 11, 2023
55d21a5
Adds support for undo/redo
simonbs Feb 11, 2023
700cec4
Merge branch 'main' into mac
simonbs Feb 11, 2023
4c8043b
Fixes compile issues on Mac
simonbs Feb 12, 2023
61e19ea
Merge branch 'main' into mac
simonbs Feb 14, 2023
524c21b
Enlarges window
simonbs Feb 16, 2023
59e5c6b
Fixes lines being rehighlighted
simonbs Feb 16, 2023
4b567fa
Fixes SwiftLint warnings
simonbs Feb 16, 2023
6c68c22
Infrastructure for testing key bindings. (#270)
Lukas-Stuehrk Feb 17, 2023
55e18b5
Aligns styling of Mac navigation tests (#275)
simonbs Feb 17, 2023
ba6c7dd
Fixes unit test
simonbs Feb 17, 2023
241a3c6
Removes unused files (#276)
simonbs Feb 17, 2023
5207296
Merge branch 'mac' of github.com:simonbs/Runestone into mac
simonbs Feb 17, 2023
3db2d50
Right click ignores event count
simonbs Feb 17, 2023
e98ce90
Fixes app name
simonbs Feb 17, 2023
cfa85b8
Fixes app name
simonbs Feb 17, 2023
3745faa
Merge branch 'mac' of github.com:simonbs/Runestone into mac
simonbs Feb 17, 2023
59049da
Improves documentation
simonbs Feb 17, 2023
fdf1534
Improves formatting
simonbs Feb 17, 2023
b9bf48a
Improves scroller handling
simonbs Feb 17, 2023
311941e
Fixes errors compiling to iOS
simonbs Feb 17, 2023
5d72cc5
Fixes filename
simonbs Feb 17, 2023
5dbc171
Adds syntaxNode(at:)
simonbs Feb 17, 2023
78cf65f
Adds text(in:)
simonbs Feb 17, 2023
f2efdbd
Fixes infinite loop
simonbs Feb 18, 2023
fc8c41d
Update caret frame and selected rectangles when layoung out text view
simonbs Feb 18, 2023
b856dc1
Call lineControllerDidInvalidateSize(_:) in redisplayLineFragments()
simonbs Feb 18, 2023
7c37a2c
Force layout on macOS
simonbs Feb 18, 2023
217f5ca
Call editorDelegate textViewDidChange in the same place as the iOS Te…
jhalickman Feb 18, 2023
fdf5bc3
Merge branch 'mac' of github.com:simonbs/Runestone into mac
simonbs Feb 18, 2023
7a84f3a
Allow `TextView` setup from within IB (#278)
helje5 Feb 18, 2023
41461e7
Ensures line selection is computed based on new line heights
simonbs Feb 19, 2023
c0ffbe1
Ensures layout after setting state
simonbs Feb 19, 2023
26ba704
Adds comment
simonbs Feb 19, 2023
c241675
Fixes word movement
simonbs Feb 19, 2023
bea6db6
Fixes whitespace
simonbs Feb 19, 2023
60e3d9d
Fixes attempting to delete past last character
simonbs Feb 19, 2023
144bfba
Adds deleteForward(_:)
simonbs Feb 19, 2023
3224951
Supports deleting words
simonbs Feb 19, 2023
ef83371
Updates documentation
simonbs Feb 19, 2023
e1a3fc1
Fixes scroll performance
simonbs Feb 20, 2023
74b66a7
Add Runestone editor to Mac app.
PasiSalenius Oct 6, 2024
dcae9b1
Fixes to first responder state. Fix forced unwrap of line for charact…
PasiSalenius Oct 14, 2024
6b7775f
Fix adjusted position when finding closest index to point in layout m…
PasiSalenius Oct 14, 2024
8449889
Increase caret width to 2 points and fix getting caret x position.
PasiSalenius Oct 15, 2024
f45351b
Update key window state when view moves to a new superview, such as w…
PasiSalenius Oct 15, 2024
7aa7fea
Do not resign first responder status in Runestone when state is updat…
PasiSalenius Oct 17, 2024
3db5677
Do not resign first responder status on window key status change.
PasiSalenius Oct 17, 2024
942c7f3
Remove debugging code.
PasiSalenius Oct 17, 2024
a88455a
Do not use previous operation as it breaks moving between empty lines.
PasiSalenius Oct 17, 2024
7f1ef50
Set caret width back to 1 to not cause other selection rect issues.
PasiSalenius Oct 17, 2024
c130933
Change caret width back to 2 points.
PasiSalenius Oct 17, 2024
15d7f35
Allow text view to become first responder even when it is not editabl…
PasiSalenius Oct 25, 2024
fd464d0
Do not perform keyboard commands when text view is not editable.
PasiSalenius Oct 25, 2024
ea7ffbe
Disable editing menu items when text view is not editable.
PasiSalenius Oct 25, 2024
df2f224
Add key equivalents to menu items and add Select All item.
PasiSalenius Oct 25, 2024
eaaf711
Update isEditing variable in text view instead of text view controlle…
PasiSalenius Oct 25, 2024
2d77399
Add separate selection highlight color and unemphasized selection hig…
PasiSalenius Oct 26, 2024
3ddddd7
Update colors from theme in layout manager when doing layout update.
PasiSalenius Oct 26, 2024
0b305e7
Fix issue when preparing text for insertion. When editor was set to C…
PasiSalenius Nov 30, 2024
5769c08
Fix preparing text for insertion.
PasiSalenius Nov 30, 2024
e4b7fe7
Allow minimising all windows in Mac app.
PasiSalenius Dec 9, 2024
59e9551
Set needsLayoutLineSelection to false when performing layout.
PasiSalenius Jan 13, 2025
2e88cc3
Fix flashing of gutter background between light and dark appearance b…
PasiSalenius Jan 15, 2025
e874c71
Only apply theme to children when set to a different value.
PasiSalenius Jan 15, 2025
53e7ac9
Remove isFirstResponder property from TextView as it falls out of syn…
PasiSalenius Mar 3, 2025
4e2e0ec
Move isFirstResponder computed property to NSView extension so that i…
PasiSalenius Mar 3, 2025
0e6406e
Add keyboard navigation handling for scroll to beginning and end.
PasiSalenius Mar 25, 2025
ca24a42
Add search and replace support to TextView on Mac. Implement new Find…
PasiSalenius Nov 16, 2025
2ce6162
Remove highlights from previously focused text view when focus moves …
PasiSalenius Nov 16, 2025
e1b68c4
Adjust match count label size.
PasiSalenius Nov 16, 2025
29e1ce2
Remove unnecessary macOS 12 availability checks. Reduce max visible s…
PasiSalenius Nov 17, 2025
2c4d4bf
Show find panel when finding next or previous match so that closing t…
PasiSalenius Nov 17, 2025
048ec93
Add padding around rect to scroll to correct offset.
PasiSalenius Nov 17, 2025
2b4a0d2
Fix start x coordinate for highlighted line fragments. Fix repeated i…
PasiSalenius Nov 17, 2025
267afe7
Fix corner radius in highlighted range. Fix drawing parts of highligh…
PasiSalenius Nov 17, 2025
1d8005c
Increase scroll padding.
PasiSalenius Nov 18, 2025
09b77ad
Update autosave name for findpanel search field. Save new search text…
PasiSalenius Nov 18, 2025
6b6e22c
Fix case of ignore case checkbox title in FindPanel.
PasiSalenius Nov 18, 2025
5930aa3
Merge branch 'mac'
PasiSalenius Nov 22, 2025
e356197
Remove unused hairlineLength definition.
PasiSalenius Nov 22, 2025
21b99a4
Add back StringSyntaxHighlighter.
PasiSalenius Nov 22, 2025
82c129d
Add missing #endif statements.
PasiSalenius Nov 22, 2025
15b5f71
Update LineSyntaxHighlighter with new properties.
PasiSalenius Nov 22, 2025
4299b27
Make DefaultStringAttributes multiplatform.
PasiSalenius Nov 22, 2025
1690632
Make TabWidthMeasurer multiplatform.
PasiSalenius Nov 22, 2025
1ac2137
Multiple fixes after merging mac branch to main
PasiSalenius Nov 22, 2025
b1c2f68
Reformat Package.swift file. Remove empty file from project.
PasiSalenius Nov 22, 2025
c9c97ff
Fix finding closest index for CGPoint on iOS and Mac.
PasiSalenius Nov 22, 2025
c67f1a3
Refactor highlighted ranges to support other categories in addition t…
PasiSalenius Nov 23, 2025
0eaac74
Fix replacementText value in textView shouldChangeTextIn delegate cal…
PasiSalenius Nov 23, 2025
deca6bb
Call text view delegate textView shouldChangeTextIn method when repla…
PasiSalenius Nov 23, 2025
a57cde5
Fix assigning highlighted ranges without category to HighlightService.
PasiSalenius Nov 23, 2025
bd501b8
Fix applying text color overrides.
PasiSalenius Nov 23, 2025
e8e0a90
Invalidate highlighted range fragments when size is invalidated so th…
PasiSalenius Nov 24, 2025
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
227 changes: 208 additions & 19 deletions Example/Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ACFDF4AC27983BAA00059A1B"
BuildableName = "Example.app"
BlueprintName = "Example"
BuildableName = "iOSExample.app"
BlueprintName = "iOSExample"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -45,8 +45,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ACFDF4AC27983BAA00059A1B"
BuildableName = "Example.app"
BlueprintName = "Example"
BuildableName = "iOSExample.app"
BlueprintName = "iOSExample"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand All @@ -62,8 +62,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ACFDF4AC27983BAA00059A1B"
BuildableName = "Example.app"
BlueprintName = "Example"
BuildableName = "iOSExample.app"
BlueprintName = "iOSExample"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand Down
2 changes: 1 addition & 1 deletion Example/Languages/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Languages",
platforms: [.iOS(.v14)],
platforms: [.iOS(.v14), .macOS(.v11)],
products: [
.library(name: "RunestoneJavaScriptLanguage", targets: ["RunestoneJavaScriptLanguage"])
],
Expand Down
12 changes: 12 additions & 0 deletions Example/MacExample/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Cocoa

@main
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {}

func applicationWillTerminate(_ aNotification: Notification) {}

func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "ExampleProjectMac_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "ExampleProjectMac_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "ExampleProjectMac_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "ExampleProjectMac_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "ExampleProjectMac_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
719 changes: 719 additions & 0 deletions Example/MacExample/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Example/MacExample/MacExample.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
87 changes: 87 additions & 0 deletions Example/MacExample/MainViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import Cocoa
import Runestone
import RunestoneJavaScriptLanguage
import RunestoneOneDarkTheme
import RunestoneThemeCommon
import RunestoneTomorrowNightTheme
import RunestoneTomorrowTheme

final class MainViewController: NSViewController {
private let theme: EditorTheme = OneDarkTheme()
private let textView: TextView = {
let this = TextView()
this.translatesAutoresizingMaskIntoConstraints = false
this.textContainerInset = NSEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
this.showLineNumbers = true
this.showTabs = true
this.showSpaces = true
this.showLineBreaks = true
this.showSoftLineBreaks = true
this.lineHeightMultiplier = 1.3
this.kern = 0.3
this.lineSelectionDisplayType = .line
this.gutterLeadingPadding = 4
this.gutterTrailingPadding = 4
this.isLineWrappingEnabled = true
this.indentStrategy = .space(length: 2)
this.characterPairs = [
BasicCharacterPair(leading: "(", trailing: ")"),
BasicCharacterPair(leading: "{", trailing: "}"),
BasicCharacterPair(leading: "[", trailing: "]"),
BasicCharacterPair(leading: "\"", trailing: "\""),
BasicCharacterPair(leading: "'", trailing: "'")
]
return this
}()

override var acceptsFirstResponder: Bool {
true
}

override func viewDidLoad() {
super.viewDidLoad()
view.appearance = NSAppearance(named: .vibrantDark)
setupTextView()
applyTheme(theme)
// swiftlint:disable line_length
let text = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ante ex, imperdiet in placerat eu, commodo ac dui. Fusce tincidunt facilisis eros condimentum varius. Ut tellus est, luctus pulvinar rutrum ac, semper at eros. Vestibulum et molestie dui. Nulla sagittis ipsum a dolor consectetur, ut ultrices turpis egestas. Quisque eleifend feugiat massa eget egestas. Donec sed ipsum sed lectus sodales sagittis at sit amet ipsum. Ut facilisis, augue vitae feugiat auctor, lacus metus feugiat augue, quis dictum quam ipsum nec felis. Donec nec orci justo. Pellentesque in est eu dui semper pulvinar. Donec at porta augue, a facilisis magna.

Etiam lacinia et erat et luctus. Phasellus sit amet semper nisi. In nec nulla sit amet est elementum consequat eget sed magna. Maecenas tincidunt augue nec diam egestas dapibus. Cras porta vulputate ex ac fringilla. Proin rhoncus turpis sed hendrerit laoreet. Duis faucibus leo non posuere vulputate. Cras blandit dolor nibh, sit amet luctus massa commodo eget. Praesent a tempus leo, vel pretium urna. Quisque et sollicitudin neque. Morbi pellentesque felis pretium lectus molestie egestas. Suspendisse efficitur odio ac metus vehicula, eget cursus elit fermentum. Nunc maximus lectus eu erat volutpat iaculis. In elementum, risus nec commodo sollicitudin, diam est lobortis justo, vitae consequat erat dolor eu tellus. Pellentesque varius diam at urna eleifend maximus.

Sed sagittis lectus id turpis bibendum, nec iaculis libero malesuada. Etiam nec ipsum vel tellus vestibulum sollicitudin ac ac nunc. Mauris non est vel sapien condimentum feugiat vel ullamcorper arcu. Duis a ligula quis justo ultrices feugiat at vel urna. Praesent erat turpis, convallis a feugiat ac, dictum a justo. Suspendisse venenatis tincidunt massa, nec mollis diam pretium lacinia. Cras non erat ut mauris iaculis lacinia. Cras accumsan purus vitae metus semper, non commodo arcu ullamcorper. Pellentesque porttitor lobortis ipsum, porta accumsan enim viverra ut. Duis ut tortor eget libero vulputate porttitor. Nulla bibendum libero tellus, sed mattis turpis feugiat non.

Nunc lacus augue, tempus eu metus non, venenatis blandit massa. Donec consectetur cursus nibh eget iaculis. Pellentesque vel sem non tellus elementum rhoncus tempus quis est. In in neque sed ligula fermentum faucibus egestas in mauris. Vivamus id nunc non enim iaculis venenatis at vitae orci. Cras nec lacus nec nulla cursus rutrum. Donec vitae dui eget tellus tincidunt pharetra pulvinar id lacus.

Sed et metus imperdiet, viverra lectus at, convallis justo. Suspendisse quis massa sodales, blandit ante vitae, mattis diam. Suspendisse potenti. Sed non odio aliquet, viverra purus quis, rhoncus lectus. Integer dignissim scelerisque lectus ut sagittis. Nunc ac nunc elit. Donec ligula nunc, egestas sed purus sed, ultrices dignissim eros. Ut accumsan porta velit, nec condimentum eros pellentesque et. Nunc ut ante eu turpis consectetur euismod sit amet quis urna. Duis nibh elit, dapibus vitae luctus in, placerat a mauris. Curabitur tincidunt venenatis nisl vitae euismod. Sed tristique sapien purus, sit amet auctor urna sodales a.
"""
// swiftlint:enable line_length
let state = TextViewState(text: text, theme: theme, language: .javaScript)
textView.setState(state)
}

override func viewDidAppear() {
super.viewDidAppear()
view.window?.backgroundColor = theme.backgroundColor
}
}

private extension MainViewController {
private func setupTextView() {
view.addSubview(textView)
NSLayoutConstraint.activate([
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
textView.topAnchor.constraint(equalTo: view.topAnchor),
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}

private func applyTheme(_ theme: EditorTheme) {
textView.theme = theme
textView.wantsLayer = true
textView.layer?.backgroundColor = theme.backgroundColor.cgColor
textView.insertionPointColor = theme.textColor
textView.selectionHighlightColor = theme.textColor.withAlphaComponent(0.2)
}
}
2 changes: 1 addition & 1 deletion Example/Themes/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Themes",
platforms: [.iOS(.v14)],
platforms: [.iOS(.v14), .macOS(.v11)],
products: [
.library(name: "RunestoneTomorrowTheme", targets: ["RunestoneTomorrowTheme"]),
.library(name: "RunestoneTomorrowNightTheme", targets: ["RunestoneTomorrowNightTheme"]),
Expand Down
69 changes: 44 additions & 25 deletions Example/Themes/Sources/RunestoneOneDarkTheme/OneDarkTheme.swift
Original file line number Diff line number Diff line change
@@ -1,55 +1,66 @@
#if os(macOS)
import AppKit
#endif
import Runestone
import RunestoneThemeCommon
#if os(iOS)
import UIKit
#endif

public final class OneDarkTheme: EditorTheme {
public let backgroundColor = UIColor(namedInModule: "OneDarkBackground")
public let backgroundColor = MultiPlatformColor(namedInModule: "OneDarkBackground")
#if os(iOS)
public let userInterfaceStyle: UIUserInterfaceStyle = .dark
#endif

public let font: UIFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let textColor = UIColor(namedInModule: "OneDarkForeground")
public let font: MultiPlatformFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let textColor = MultiPlatformColor(namedInModule: "OneDarkForeground")

public let gutterBackgroundColor = UIColor(namedInModule: "OneDarkCurrentLine")
public let gutterHairlineColor: UIColor = .opaqueSeparator
public let gutterBackgroundColor = MultiPlatformColor(namedInModule: "OneDarkCurrentLine")
#if os(iOS)
public let gutterHairlineColor: MultiPlatformColor = .opaqueSeparator
#else
public let gutterHairlineColor: MultiPlatformColor = .separatorColor
#endif

public let lineNumberColor = UIColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.5)
public let lineNumberFont: UIFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let lineNumberColor = MultiPlatformColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.5)
public let lineNumberFont: MultiPlatformFont = .monospacedSystemFont(ofSize: 14, weight: .regular)

public let selectedLineBackgroundColor = UIColor(namedInModule: "OneDarkCurrentLine")
public let selectedLinesLineNumberColor = UIColor(namedInModule: "OneDarkForeground")
public let selectedLinesGutterBackgroundColor: UIColor = .clear
public let selectedLineBackgroundColor = MultiPlatformColor(namedInModule: "OneDarkCurrentLine")
public let selectedLinesLineNumberColor = MultiPlatformColor(namedInModule: "OneDarkForeground")
public let selectedLinesGutterBackgroundColor: MultiPlatformColor = .clear

public let invisibleCharactersColor = UIColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.7)
public let invisibleCharactersColor = MultiPlatformColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.7)

public let pageGuideHairlineColor = UIColor(namedInModule: "OneDarkForeground")
public let pageGuideBackgroundColor = UIColor(namedInModule: "OneDarkCurrentLine")
public let pageGuideHairlineColor = MultiPlatformColor(namedInModule: "OneDarkForeground")
public let pageGuideBackgroundColor = MultiPlatformColor(namedInModule: "OneDarkCurrentLine")

public let markedTextBackgroundColor = UIColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.1)
public let markedTextBackgroundColor = MultiPlatformColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.1)
public let markedTextBackgroundCornerRadius: CGFloat = 4

public init() {}

public func textColor(for rawHighlightName: String) -> UIColor? {
public func textColor(for rawHighlightName: String) -> MultiPlatformColor? {
guard let highlightName = HighlightName(rawHighlightName) else {
return nil
}
switch highlightName {
case .comment:
return UIColor(namedInModule: "OneDarkComment")
return MultiPlatformColor(namedInModule: "OneDarkComment")
case .operator, .punctuation:
return UIColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.75)
return MultiPlatformColor(namedInModule: "OneDarkForeground").withAlphaComponent(0.75)
case .property:
return UIColor(namedInModule: "OneDarkAqua")
return MultiPlatformColor(namedInModule: "OneDarkAqua")
case .function:
return UIColor(namedInModule: "OneDarkBlue")
return MultiPlatformColor(namedInModule: "OneDarkBlue")
case .string:
return UIColor(namedInModule: "OneDarkGreen")
return MultiPlatformColor(namedInModule: "OneDarkGreen")
case .number:
return UIColor(namedInModule: "OneDarkYellow")
return MultiPlatformColor(namedInModule: "OneDarkYellow")
case .keyword:
return UIColor(namedInModule: "OneDarkPurple")
case .variableBuiltin:
return UIColor(namedInModule: "OneDarkRed")
return MultiPlatformColor(namedInModule: "OneDarkPurple")
case .variableBuiltin, .constantBuiltin:
return MultiPlatformColor(namedInModule: "OneDarkRed")
}
}

Expand All @@ -62,8 +73,16 @@ public final class OneDarkTheme: EditorTheme {
}
}

private extension UIColor {
#if os(iOS)
public extension UIColor {
convenience init(namedInModule name: String) {
self.init(named: name, in: .module, compatibleWith: nil)!
}
}
#else
public extension NSColor {
convenience init(namedInModule name: String) {
self.init(named: name, bundle: .module)!
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
#if os(macOS)
import AppKit
#endif
import Runestone
import RunestoneThemeCommon
#if os(iOS)
import UIKit
#endif

public final class PlainTextTheme: EditorTheme {
public let backgroundColor: UIColor = .white
public let backgroundColor: MultiPlatformColor = .white
#if os(iOS)
public let userInterfaceStyle: UIUserInterfaceStyle = .light
#endif

public let font: UIFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let textColor: UIColor = .black
public let font: MultiPlatformFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let textColor: MultiPlatformColor = .black

public let gutterBackgroundColor: UIColor = .white
public let gutterHairlineColor: UIColor = .white
public let gutterBackgroundColor: MultiPlatformColor = .white
public let gutterHairlineColor: MultiPlatformColor = .white

public let lineNumberColor: UIColor = .black.withAlphaComponent(0.5)
public let lineNumberFont: UIFont = .monospacedSystemFont(ofSize: 14, weight: .regular)
public let lineNumberColor: MultiPlatformColor = .black.withAlphaComponent(0.5)
public let lineNumberFont: MultiPlatformFont = .monospacedSystemFont(ofSize: 14, weight: .regular)

public let selectedLineBackgroundColor: UIColor = .black.withAlphaComponent(0.07)
public let selectedLinesLineNumberColor: UIColor = .black
public let selectedLinesGutterBackgroundColor: UIColor = .black.withAlphaComponent(0.07)
public let selectedLineBackgroundColor: MultiPlatformColor = .black.withAlphaComponent(0.07)
public let selectedLinesLineNumberColor: MultiPlatformColor = .black
public let selectedLinesGutterBackgroundColor: MultiPlatformColor = .black.withAlphaComponent(0.07)

public let invisibleCharactersColor: UIColor = .black.withAlphaComponent(0.5)
public let invisibleCharactersColor: MultiPlatformColor = .black.withAlphaComponent(0.5)

public let pageGuideHairlineColor: UIColor = .black.withAlphaComponent(0.1)
public let pageGuideBackgroundColor: UIColor = .black.withAlphaComponent(0.06)
public let pageGuideHairlineColor: MultiPlatformColor = .black.withAlphaComponent(0.1)
public let pageGuideBackgroundColor: MultiPlatformColor = .black.withAlphaComponent(0.06)

public let markedTextBackgroundColor: UIColor = .black.withAlphaComponent(0.1)
public let markedTextBackgroundColor: MultiPlatformColor = .black.withAlphaComponent(0.1)
public let markedTextBackgroundCornerRadius: CGFloat = 4

public init() {}

public func textColor(for rawHighlightName: String) -> UIColor? {
public func textColor(for rawHighlightName: String) -> MultiPlatformColor? {
nil
}

Expand Down
Loading