Fix code style
All checks were successful
SwiftLint / SwiftLint (pull_request) Successful in 6s

This commit is contained in:
david-swift 2025-08-26 13:33:43 +02:00
parent 0af3864058
commit 87b970d844
3 changed files with 55 additions and 24 deletions

View File

@ -1,22 +1,43 @@
//
// WrapMode.swift
// Adwaita
//
// Created by mlm on 24.08.25.
//
import CAdw import CAdw
/// Wrap modes for `TextView`/`TextEditor` /// Wrap modes for `TextView`/`TextEditor`
public enum WrapMode: GtkWrapMode, RawRepresentable { public enum WrapMode: GtkWrapMode, RawRepresentable {
case none // GTK_WRAP_NONE
case char // GTK_WRAP_CHAR
case word // GTK_WRAP_WORD
case wordChar // GTK_WRAP_WORD_CHAR
public var rawValue: GtkWrapMode { // swiftlint:disable discouraged_none_name
switch self { /// GTK_WRAP_NONE
case .none: GTK_WRAP_NONE case none
case .char: GTK_WRAP_CHAR // swiftlint:enable discouraged_none_name
case .word: GTK_WRAP_WORD /// GTK_WRAP_CHAR
case .wordChar: GTK_WRAP_WORD_CHAR case char
/// GTK_WRAP_WORD
case word
/// GTK_WRAP_WORD_CHAR
case wordChar
/// Get the GtkWrapMode.
public var rawValue: GtkWrapMode {
switch self {
case .none:
GTK_WRAP_NONE
case .char:
GTK_WRAP_CHAR
case .word:
GTK_WRAP_WORD
case .wordChar:
GTK_WRAP_WORD_CHAR
}
} }
}
public init?(rawValue: GtkWrapMode) { /// Initialize from the GtkWrapMode.
return nil /// - Parameter rawValue: The GtkWrapMode.
} public init?(rawValue: GtkWrapMode) {
nil
}
} }

View File

@ -1,9 +1,19 @@
//
// GtkWrapMode.swift
// Adwaita
//
// Created by mlm on 24.08.25.
//
import CAdw import CAdw
/// Add ExpressibleByIntegerLiteral conformance to make GtkWrapMode usable as /// Add ExpressibleByIntegerLiteral conformance to make GtkWrapMode usable as
// a RawValue in an enum. /// a RawValue in an enum.
extension GtkWrapMode: @retroactive ExpressibleByIntegerLiteral { extension GtkWrapMode: @retroactive ExpressibleByIntegerLiteral {
public init(integerLiteral value: Int) {
self.init(UInt32(value)) /// Initialize from an integer literal.
} public init(integerLiteral value: Int) {
self.init(UInt32(value))
}
} }

View File

@ -81,12 +81,12 @@ public struct TextView: AdwaitaWidget {
} }
} }
/// Set the wrapMode for the text view. /// Set the wrapMode for the text view.
/// ///
/// Available wrap modes are `none`, `char`, `word`, `wordChar`. Please refer to the /// Available wrap modes are `none`, `char`, `word`, `wordChar`. Please refer to the
/// corresponding `GtkWrapMode` documentation for the details on how they work. /// corresponding `GtkWrapMode` documentation for the details on how they work.
/// ///
/// - Parameter mode: The `WrapMode` to set. /// - Parameter mode: The `WrapMode` to set.
public func wrapMode(_ mode: WrapMode) -> Self { public func wrapMode(_ mode: WrapMode) -> Self {
var newSelf = self var newSelf = self
newSelf.wrapMode = mode newSelf.wrapMode = mode