Skip to content

Commit 4d6ea14

Browse files
committed
Update the READMEs
...
1 parent 48d86b1 commit 4d6ea14

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,39 @@ struct MyEditor: View {
9999
Note: The `CodeEditor` doesn't do automatic theme changes if the appearance
100100
changes.
101101

102+
103+
### Smart Indent and Open/Close Pairing
104+
105+
Inspired by [NTYSmartTextView](https://github.com/naoty/NTYSmartTextView),
106+
`CodeEditor` now also supports (on macOS):
107+
- smarter indents (preserving the indent of the previous line)
108+
- soft indents (insert a configurable amount of spaces if the user presses tabs)
109+
- auto character pairing, e.g. when entering `{`, the matching `}` will be auto-added
110+
111+
To enable smart indents, add the `smartIndent` flag, e.g.:
112+
```swift
113+
CodeEditor(source: $source, language: language,
114+
flags: [ .selectable, .editable, .smartIndent ])
115+
```
116+
It is enabled for editors by default.
117+
118+
To configure soft indents, use the `indentStyle` parameter, e.g.
119+
```swift
120+
CodeEditor(source: $source, language: language,
121+
indentStyle: .softTab(width: 2))
122+
```
123+
It defaults to tabs, as per system settings.
124+
125+
Auto character pairing is automatic based on the language. E.g. there is a set of
126+
defaults for C like languages (e.g. Swift), Python or XML. The defaults can be overridden
127+
using the respective static variable in `CodeEditor`,
128+
or the desired pairing can be set explicitly:
129+
```swift
130+
CodeEditor(source: $source, language: language,
131+
autoPairs: [ "{": "}", "<": ">", "'": "'" ])
132+
```
133+
134+
102135
### Font Sizing
103136

104137
On macOS the editor supports sizing of the font (using Cmd +/Cmd - and the

Sources/CodeEditor/CodeEditor.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,37 @@ import Highlightr
5959
* Note: The `CodeEditor` doesn't do automatic theme changes if the appearance
6060
* changes.
6161
*
62+
* ### Smart Indent and Open/Close Pairing
63+
*
64+
* Inspired by [NTYSmartTextView](https://github.com/naoty/NTYSmartTextView),
65+
* `CodeEditor` now also supports (on macOS):
66+
* - smarter indents (preserving the indent of the previous line)
67+
* - soft indents (insert a configurable amount of spaces if the user presses tabs)
68+
* - auto character pairing, e.g. when entering `{`, the matching `}` will be auto-added
69+
*
70+
* To enable smart indents, add the `smartIndent` flag, e.g.:
71+
*
72+
* CodeEditor(source: $source, language: language,
73+
* flags: [ .selectable, .editable, .smartIndent ])
74+
*
75+
* It is enabled for editors by default.
76+
*
77+
* To configure soft indents, use the `indentStyle` parameter, e.g.
78+
*
79+
* CodeEditor(source: $source, language: language,
80+
* indentStyle: .softTab(width: 2))
81+
*
82+
* It defaults to tabs, as per system settings.
83+
*
84+
* Auto character pairing is automatic based on the language. E.g. there is a set of
85+
* defaults for C like languages (e.g. Swift), Python or XML. The defaults can be overridden
86+
* using the respective static variable in `CodeEditor`,
87+
* or the desired pairing can be set explicitly:
88+
*
89+
* CodeEditor(source: $source, language: language,
90+
* autoPairs: [ "{": "}", "<": ">", "'": "'" ])
91+
*
92+
*
6293
* ### Font Sizing
6394
*
6495
* On macOS the editor supports sizing of the font (using Cmd +/Cmd - and the

0 commit comments

Comments
 (0)