InputState // Typo fix: attributedSting -> attributedString; etc.

This commit is contained in:
ShikiSuen 2022-05-21 10:43:41 +08:00
parent 384a4138f2
commit f0bb232d35
1 changed files with 17 additions and 15 deletions

View File

@ -26,6 +26,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import Cocoa import Cocoa
// InputState 使 Struct Struct
/// Represents the states for the input method controller. /// Represents the states for the input method controller.
/// ///
/// An input method is actually a finite state machine. It receives the inputs /// An input method is actually a finite state machine. It receives the inputs
@ -44,10 +46,10 @@ import Cocoa
/// create a new state object to replace the current state instead of modifying /// create a new state object to replace the current state instead of modifying
/// the existing one. /// the existing one.
/// ///
/// vChewing's input controller has following possible states: /// The input controller has following possible states:
/// ///
/// - Deactivated: The user is not using vChewing yet. /// - Deactivated: The user is not using the input method yet.
/// - Empty: The user has switched to vChewing but did not input anything yet, /// - Empty: The user has switched to this input method but inputted nothing yet,
/// or, he or she has committed text into the client apps and starts a new /// or, he or she has committed text into the client apps and starts a new
/// input phase. /// input phase.
/// - Committing: The input controller is sending text to the client apps. /// - Committing: The input controller is sending text to the client apps.
@ -136,14 +138,14 @@ class InputState {
} }
var attributedString: NSAttributedString { var attributedString: NSAttributedString {
let attributedSting = NSAttributedString( let attributedString = NSAttributedString(
string: composingBuffer, string: composingBuffer,
attributes: [ attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue, .underlineStyle: NSUnderlineStyle.single.rawValue,
.markedClauseSegment: 0, .markedClauseSegment: 0,
] ]
) )
return attributedSting return attributedString
} }
override var description: String { override var description: String {
@ -257,22 +259,22 @@ class InputState {
} }
var attributedString: NSAttributedString { var attributedString: NSAttributedString {
let attributedSting = NSMutableAttributedString(string: composingBuffer) let attributedString = NSMutableAttributedString(string: composingBuffer)
let end = markedRange.location + markedRange.length let end = markedRange.location + markedRange.length
attributedSting.setAttributes( attributedString.setAttributes(
[ [
.underlineStyle: NSUnderlineStyle.single.rawValue, .underlineStyle: NSUnderlineStyle.single.rawValue,
.markedClauseSegment: 0, .markedClauseSegment: 0,
], range: NSRange(location: 0, length: markedRange.location) ], range: NSRange(location: 0, length: markedRange.location)
) )
attributedSting.setAttributes( attributedString.setAttributes(
[ [
.underlineStyle: NSUnderlineStyle.thick.rawValue, .underlineStyle: NSUnderlineStyle.thick.rawValue,
.markedClauseSegment: 1, .markedClauseSegment: 1,
], range: markedRange ], range: markedRange
) )
attributedSting.setAttributes( attributedString.setAttributes(
[ [
.underlineStyle: NSUnderlineStyle.single.rawValue, .underlineStyle: NSUnderlineStyle.single.rawValue,
.markedClauseSegment: 2, .markedClauseSegment: 2,
@ -282,7 +284,7 @@ class InputState {
length: (composingBuffer as NSString).length - end length: (composingBuffer as NSString).length - end
) )
) )
return attributedSting return attributedString
} }
override var description: String { override var description: String {
@ -296,7 +298,7 @@ class InputState {
} }
var validToWrite: Bool { var validToWrite: Bool {
/// vChewing allows users to input a string whose length differs /// The input method allows users to input a string whose length differs
/// from the amount of Bopomofo readings. In this case, the range /// from the amount of Bopomofo readings. In this case, the range
/// in the composing buffer and the readings could not match, so /// in the composing buffer and the readings could not match, so
/// we disable the function to write user phrases in this case. /// we disable the function to write user phrases in this case.
@ -370,14 +372,14 @@ class InputState {
} }
var attributedString: NSAttributedString { var attributedString: NSAttributedString {
let attributedSting = NSAttributedString( let attributedString = NSAttributedString(
string: composingBuffer, string: composingBuffer,
attributes: [ attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue, .underlineStyle: NSUnderlineStyle.single.rawValue,
.markedClauseSegment: 0, .markedClauseSegment: 0,
] ]
) )
return attributedSting return attributedString
} }
override var description: String { override var description: String {
@ -421,14 +423,14 @@ class InputState {
// //
// Crediting Qwertyyb: https://github.com/qwertyyb/Fire/issues/55#issuecomment-1133497700 // Crediting Qwertyyb: https://github.com/qwertyyb/Fire/issues/55#issuecomment-1133497700
override var attributedString: NSAttributedString { override var attributedString: NSAttributedString {
let attributedSting = NSAttributedString( let attributedString = NSAttributedString(
string: " ", string: " ",
attributes: [ attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue, .underlineStyle: NSUnderlineStyle.single.rawValue,
.markedClauseSegment: 0, .markedClauseSegment: 0,
] ]
) )
return attributedSting return attributedString
} }
override var description: String { override var description: String {