Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes erase sequences #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/ANSIEscapeCode/ANSIEscapeCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ public struct ANSIEscapeCode {
/// - Parameter type: Erase in display type.
/// - Returns: `\u{001B}[(TYPE)J`
public static func eraseInDisplay(_ type: EraseInDisplayType) -> String {
return "\(esc)\(type.hashValue)J"
return "\(esc)\(type.rawValue)J"
}

/// Erase content in line.
///
/// - Parameter type: Erase in line type.
/// - Returns: `\u{001B}[(TYPE)K`
public static func eraseInLine(_ type: EraseInLineType) -> String {
return "\(esc)\(type.hashValue)K"
return "\(esc)\(type.rawValue)K"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ANSIEscapeCode/EraseInDisplayType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ import Foundation
/// - fromCursorToEndOfScreen: Erase from cursor to the end of screen.
/// - fromCursorToBeginningOfScreen: Erase from cursor to the beginning of screen.
/// - entireScreen: Erase entire screen.
public enum EraseInDisplayType {
public enum EraseInDisplayType: Int {
case fromCursorToEndOfScreen, fromCursorToBeginningOfScreen, entireScreen
}
2 changes: 1 addition & 1 deletion Sources/ANSIEscapeCode/EraseInLineType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ import Foundation
/// - fromCursorToEndOfLine: Erase from cursor to the end of line.
/// - fromCursorToBeginningOfLine: Erase from cursor to the beginning of line.
/// - entireLine: Erase entire line.
public enum EraseInLineType {
public enum EraseInLineType: Int {
case fromCursorToEndOfLine, fromCursorToBeginningOfLine, entireLine
}
20 changes: 10 additions & 10 deletions Sources/ANSIEscapeCode/String+ANSIEscapeCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ import Foundation
public extension String {

/// Set text bold on terminal.
public var boldOutput: String {
var boldOutput: String {
return ANSIEscapeCode.Decoration.bold
+ self + ANSIEscapeCode.Decoration.reset
}

/// Set text italic on terminal.
public var italicOutput: String {
var italicOutput: String {
return ANSIEscapeCode.Decoration.italic
+ self + ANSIEscapeCode.Decoration.reset
}

/// Set text underline on terminal.
public var underlineOutput: String {
var underlineOutput: String {
return ANSIEscapeCode.Decoration.underline
+ self + ANSIEscapeCode.Decoration.reset
}

/// Set text blink on terminal.
public var blinkOutput: String {
var blinkOutput: String {
return ANSIEscapeCode.Decoration.blink
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -56,7 +56,7 @@ public extension String {
///
/// - Parameter color: Text color.
/// - Returns: Processed string.
public func color(_ color: TextColor) -> String {
func color(_ color: TextColor) -> String {
return ANSIEscapeCode.Decoration.textColor(color)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -66,7 +66,7 @@ public extension String {
/// - Parameter color: 8 bits color.
/// Refer: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
/// - Returns: Processed string.
public func colorFrom8BitsColorSet(_ color: Int) -> String {
func colorFrom8BitsColorSet(_ color: Int) -> String {
return ANSIEscapeCode.Decoration.text8BitsColor(color)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -79,7 +79,7 @@ public extension String {
/// - green: 8 bits green color value.
/// - blue: 8 bits blue color value.
/// - Returns: Processed string.
public func colorFromRGBColorSet(red: Int, green: Int, blue: Int) -> String {
func colorFromRGBColorSet(red: Int, green: Int, blue: Int) -> String {
return ANSIEscapeCode.Decoration.textRGBColor(red: red, green: green, blue: blue)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -88,7 +88,7 @@ public extension String {
///
/// - Parameter color: Background color.
/// - Returns: Processed string.
public func backgroundColor(_ color: BackgroundColor) -> String {
func backgroundColor(_ color: BackgroundColor) -> String {
return ANSIEscapeCode.Decoration.backgroundColor(color)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -98,7 +98,7 @@ public extension String {
/// - Parameter color: 8 bits color.
/// Refer: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
/// - Returns: Processed string.
public func backgroundColorFrom8BitsColorSet(_ color: Int) -> String {
func backgroundColorFrom8BitsColorSet(_ color: Int) -> String {
return ANSIEscapeCode.Decoration.background8BitsColor(color)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand All @@ -111,7 +111,7 @@ public extension String {
/// - green: 8 bits green color value.
/// - blue: 8 bits blue color value.
/// - Returns: Processed string.
public func backgroundColorFromRGBColorSet(red: Int, green: Int, blue: Int) -> String {
func backgroundColorFromRGBColorSet(red: Int, green: Int, blue: Int) -> String {
return ANSIEscapeCode.Decoration.backgroundRGBColor(red: red, green: green, blue: blue)
+ self + ANSIEscapeCode.Decoration.reset
}
Expand Down