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
/// Wrap modes for `TextView`/`TextEditor`
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 {
switch self {
case .none: GTK_WRAP_NONE
case .char: GTK_WRAP_CHAR
case .word: GTK_WRAP_WORD
case .wordChar: GTK_WRAP_WORD_CHAR
// swiftlint:disable discouraged_none_name
/// GTK_WRAP_NONE
case none
// swiftlint:enable discouraged_none_name
/// GTK_WRAP_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) {
return nil
}
/// Initialize from the GtkWrapMode.
/// - 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
/// Add ExpressibleByIntegerLiteral conformance to make GtkWrapMode usable as
// a RawValue in an enum.
/// a RawValue in an enum.
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.
///
/// Available wrap modes are `none`, `char`, `word`, `wordChar`. Please refer to the
/// corresponding `GtkWrapMode` documentation for the details on how they work.
///
/// - Parameter mode: The `WrapMode` to set.
/// Set the wrapMode for the text view.
///
/// Available wrap modes are `none`, `char`, `word`, `wordChar`. Please refer to the
/// corresponding `GtkWrapMode` documentation for the details on how they work.
///
/// - Parameter mode: The `WrapMode` to set.
public func wrapMode(_ mode: WrapMode) -> Self {
var newSelf = self
newSelf.wrapMode = mode