From 87b970d84483582998b3c449562c86332a8da5b1 Mon Sep 17 00:00:00 2001 From: david-swift Date: Tue, 26 Aug 2025 13:33:43 +0200 Subject: [PATCH] Fix code style --- .../Core/Model/Enumerations/WrapMode.swift | 49 +++++++++++++------ .../Core/Model/Extensions/GtkWrapMode.swift | 18 +++++-- Sources/Core/View/TextEditor.swift | 12 ++--- 3 files changed, 55 insertions(+), 24 deletions(-) diff --git a/Sources/Core/Model/Enumerations/WrapMode.swift b/Sources/Core/Model/Enumerations/WrapMode.swift index f643afc..8abb991 100644 --- a/Sources/Core/Model/Enumerations/WrapMode.swift +++ b/Sources/Core/Model/Enumerations/WrapMode.swift @@ -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 + } } diff --git a/Sources/Core/Model/Extensions/GtkWrapMode.swift b/Sources/Core/Model/Extensions/GtkWrapMode.swift index 9aeb0d1..b99bf11 100644 --- a/Sources/Core/Model/Extensions/GtkWrapMode.swift +++ b/Sources/Core/Model/Extensions/GtkWrapMode.swift @@ -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)) + } + } diff --git a/Sources/Core/View/TextEditor.swift b/Sources/Core/View/TextEditor.swift index 91ad7db..ca6d295 100644 --- a/Sources/Core/View/TextEditor.swift +++ b/Sources/Core/View/TextEditor.swift @@ -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