Merge branch 'feature/orientation' into release/3.2.5

This commit is contained in:
1024jp 2017-11-26 11:21:13 +09:00
commit fc9c95ec66
7 changed files with 23 additions and 9 deletions

View File

@ -14,6 +14,7 @@ Change Log
- Fix an issue where the syntax highlighting indicator could display twice.
- Fix an issue where the separator was selected meaninglessly in the Window pane if the window tabbing setting was set to “Manually”.
- Fix an issue where editor's text orientation was not cascaded to the print operation when the window was restored from the last session.
- Fix the line-wrapping behavior when a line contains a long unbreakable word.
- Fix some missing localized strings.
- Improve general stability.

View File

@ -45,6 +45,7 @@
<ul>
<li>Fix an issue where the syntax highlighting indicator could display twice.</li>
<li>Fix an issue where the separator was selected meaninglessly in the Window pane if the window tabbing setting was set to “Manually”.</li>
<li>Fix an issue where editor's text orientation was not cascaded to the print operation when the window was restored from the last session.</li>
<li>Fix the line-wrapping behavior when a line contains a long unbreakable word.</li>
<li>Fix some missing localized strings.</li>
<li>Improve general stability.</li>

View File

@ -45,6 +45,7 @@
<ul>
<li>シンタックスハイライトの進捗表示が2回出てくることがあった不具合を修正</li>
<li>ウインドウタブの設定が「手動」のとき、ウインドウ設定ペインの該当のメニューでセパレータが選択された不具合を修正</li>
<li>書類ウインドウを前セッションから復帰させたとき、縦書きの状態が印刷に反映されなかった不具合を修正</li>
<li>行が途中で改行できない長い単語を含むときのぶら下がりインデントの挙動を修正</li>
<li>ローカライズ漏れを修正</li>
<li>全般的な安定性を向上</li>

View File

@ -47,6 +47,7 @@ private enum SerializationKey {
static let readingEncoding = "readingEncoding"
static let syntaxStyle = "syntaxStyle"
static let autosaveIdentifier = "autosaveIdentifier"
static let isVerticalText = "isVerticalText"
}
// file extended attributes
@ -63,6 +64,11 @@ private enum FileExtendedAttributeName {
final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
// MARK: Public Properties
var isVerticalText = false
// MARK: Readonly Properties
let textStorage = NSTextStorage()
@ -85,7 +91,6 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
private var readingEncoding: String.Encoding // encoding to read document file
private var isExternalUpdateAlertShown = false
private var fileData: Data?
private var isVerticalText = false
private var odbEventSender: ODBEventSender?
private var shouldSaveXattr = true
private var autosaveIdentifier: String
@ -112,6 +117,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
self.lineEnding = LineEnding(index: UserDefaults.standard[.lineEndCharCode]) ?? .LF
self.syntaxStyle = SyntaxManager.shared.style(name: UserDefaults.standard[.syntaxStyle]) ?? SyntaxStyle()
self.syntaxStyle.textStorage = self.textStorage
self.isVerticalText = UserDefaults.standard[.layoutTextVertical]
// set encoding to read file
// -> The value is either user setting or selection of open panel.
@ -138,6 +144,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
coder.encode(Int(self.encoding.rawValue), forKey: SerializationKey.readingEncoding)
coder.encode(self.autosaveIdentifier, forKey: SerializationKey.autosaveIdentifier)
coder.encode(self.syntaxStyle.styleName, forKey: SerializationKey.syntaxStyle)
coder.encode(self.isVerticalText, forKey: SerializationKey.isVerticalText)
super.encodeRestorableState(with: coder)
}
@ -160,6 +167,9 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
if let styleName = coder.decodeObject(forKey: SerializationKey.syntaxStyle) as? String {
self.setSyntaxStyle(name: styleName)
}
if coder.containsValue(forKey: SerializationKey.isVerticalText) {
self.isVerticalText = coder.decodeBool(forKey: SerializationKey.isVerticalText)
}
}
@ -252,9 +262,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
document.lineEnding = self.lineEnding
document.encoding = self.encoding
document.hasUTF8BOM = self.hasUTF8BOM
// apply text orientation
document.viewController?.verticalLayoutOrientation = self.viewController?.verticalLayoutOrientation ?? self.isVerticalText
document.isVerticalText = self.isVerticalText
return document
}
@ -464,7 +472,6 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
// store current state here, since the main thread will already be unblocked after `data(ofType:)`
let encoding = self.encoding
self.isVerticalText = self.viewController?.verticalLayoutOrientation ?? false
try super.write(to: url, ofType: typeName, for: saveOperation, originalContentsURL: absoluteOriginalContentsURL)

View File

@ -69,7 +69,6 @@ final class DocumentViewController: NSSplitViewController, SyntaxStyleDelegate,
self.showsLineNumber = defaults[.showLineNumbers]
self.showsNavigationBar = defaults[.showNavigationBar]
self.wrapsLines = defaults[.wrapLines]
self.verticalLayoutOrientation = defaults[.layoutTextVertical]
self.showsPageGuide = defaults[.showPageGuide]
NotificationCenter.default.addObserver(self, selector: #selector(didUpdateTheme),
@ -86,7 +85,7 @@ final class DocumentViewController: NSSplitViewController, SyntaxStyleDelegate,
#keyPath(showsLineNumber),
#keyPath(showsPageGuide),
#keyPath(showsInvisibles),
#keyPath(verticalLayoutOrientation)]
]
}
@ -464,9 +463,14 @@ final class DocumentViewController: NSSplitViewController, SyntaxStyleDelegate,
/// if text orientation is vertical
var verticalLayoutOrientation = false {
var verticalLayoutOrientation: Bool {
didSet {
get {
return self.document?.isVerticalText ?? false
}
set {
self.document?.isVerticalText = newValue
let orientation: NSTextLayoutOrientation = verticalLayoutOrientation ? .vertical : .horizontal
for viewController in self.editorViewControllers {