Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
7c4aa92f
Unverified
Commit
7c4aa92f
authored
Nov 04, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editor: updated access type for Capture
parent
6b7cede3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
11 deletions
+75
-11
Sources/iOS/Capture/Capture.swift
+0
-0
Sources/iOS/Editor.swift
+74
-2
Sources/iOS/EditorController.swift
+1
-9
No files found.
Sources/iOS/Capture/Capture.swift
View file @
7c4aa92f
This diff is collapsed.
Click to expand it.
Sources/iOS/Editor.swift
View file @
7c4aa92f
...
...
@@ -54,8 +54,8 @@ public enum CharacterAttribute: String {
case
verticalGlyphForm
=
"NSVerticalGlyphFormAttributeName"
}
public
func
CharacterAttributeToValue
(
preset
:
CharacterAttribute
)
->
String
{
switch
preset
{
public
func
CharacterAttributeToValue
(
attribute
:
CharacterAttribute
)
->
String
{
switch
attribute
{
case
.
font
:
return
NSFontAttributeName
case
.
paragraphStyle
:
...
...
@@ -152,6 +152,78 @@ public protocol EditorDelegate {
}
open
class
Editor
:
View
{
/// A reference to the Text.
open
internal(set)
var
text
:
Text
!
/// A reference to the NSTextContainer.
open
internal(set)
var
textContainer
:
NSTextContainer
!
/// A reference to the NSLayoutManager.
open
internal(set)
var
layoutManager
:
NSLayoutManager
!
/// Reference to the TextView.
open
internal(set)
var
textView
:
TextView
!
/// A reference to an EditorDelegate.
open
weak
var
delegate
:
EditorDelegate
?
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open
override
func
prepare
()
{
super
.
prepare
()
prepareTextContainer
()
prepareLayoutManager
()
prepareText
()
prepareTextView
()
}
}
extension
Editor
{
/// Prepares the textContainer.
fileprivate
func
prepareTextContainer
()
{
textContainer
=
NSTextContainer
(
size
:
bounds
.
size
)
}
/// Prepares the layoutManager.
fileprivate
func
prepareLayoutManager
()
{
layoutManager
=
NSLayoutManager
()
layoutManager
.
addTextContainer
(
textContainer
)
}
/// PRepares the text.
fileprivate
func
prepareText
()
{
text
=
Text
()
text
.
delegate
=
self
text
.
textStorage
.
addLayoutManager
(
layoutManager
)
}
/// Prepares the textView.
fileprivate
func
prepareTextView
()
{
textView
=
TextView
(
textContainer
:
textContainer
)
layout
(
textView
)
.
edges
()
}
}
extension
Editor
:
TextDelegate
{
/**
When changes in the textView text are made, this delegation method
is executed with the added text string and range.
*/
public
func
textWillProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
range
:
NSRange
)
{
textStorage
.
removeAttribute
(
CharacterAttribute
.
font
.
rawValue
,
range
:
range
)
textStorage
.
addAttribute
(
CharacterAttribute
.
font
.
rawValue
,
value
:
RobotoFont
.
regular
,
range
:
range
)
}
/**
When a match is detected within the textView text, this delegation
method is executed with the added text string and range.
*/
public
func
textDidProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
result
:
NSTextCheckingResult
?,
flags
:
NSRegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
{
textStorage
.
addAttribute
(
CharacterAttribute
.
font
.
rawValue
,
value
:
RobotoFont
.
bold
,
range
:
result
!.
range
)
}
}
Sources/iOS/EditorController.swift
View file @
7c4aa92f
...
...
@@ -63,22 +63,14 @@ open class EditorController: ToolbarController {
*/
open
override
func
prepare
()
{
super
.
prepare
()
display
=
.
full
view
.
backgroundColor
=
.
black
view
.
backgroundColor
=
.
white
prepareStatusBar
()
prepareToolbar
()
prepareEditor
()
}
/// Prepares the statusBar.
private
func
prepareStatusBar
()
{
statusBar
.
backgroundColor
=
.
clear
}
/// Prepares the toolbar.
private
func
prepareToolbar
()
{
toolbar
.
backgroundColor
=
.
clear
toolbar
.
depthPreset
=
.
none
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment