-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some Terminal methods to extensions
- Loading branch information
Showing
6 changed files
with
143 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
mordant/src/commonMain/kotlin/com/github/ajalt/mordant/terminal/TerminalExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.github.ajalt.mordant.terminal | ||
|
||
import com.github.ajalt.mordant.rendering.OverflowWrap | ||
import com.github.ajalt.mordant.rendering.TextAlign | ||
import com.github.ajalt.mordant.rendering.Whitespace | ||
|
||
/** | ||
* Print a line styled with the theme's [danger][Theme.danger] style. | ||
*/ | ||
fun Terminal.danger( | ||
message: Any?, | ||
whitespace: Whitespace = Whitespace.PRE, | ||
align: TextAlign = TextAlign.NONE, | ||
overflowWrap: OverflowWrap = OverflowWrap.NORMAL, | ||
width: Int? = null, | ||
stderr: Boolean = false, | ||
) { | ||
println(theme.danger(message.toString()), whitespace, align, overflowWrap, width, stderr) | ||
} | ||
|
||
/** | ||
* Print a line styled with the theme's [warning][Theme.warning] style. | ||
*/ | ||
fun Terminal.warning( | ||
message: Any?, | ||
whitespace: Whitespace = Whitespace.PRE, | ||
align: TextAlign = TextAlign.NONE, | ||
overflowWrap: OverflowWrap = OverflowWrap.NORMAL, | ||
width: Int? = null, | ||
stderr: Boolean = false, | ||
) { | ||
println(theme.warning(message.toString()), whitespace, align, overflowWrap, width, stderr) | ||
} | ||
|
||
/** | ||
* Print a line styled with the theme's [info][Theme.info] style. | ||
*/ | ||
fun Terminal.info( | ||
message: Any?, | ||
whitespace: Whitespace = Whitespace.PRE, | ||
align: TextAlign = TextAlign.NONE, | ||
overflowWrap: OverflowWrap = OverflowWrap.NORMAL, | ||
width: Int? = null, | ||
stderr: Boolean = false, | ||
) { | ||
println(theme.info(message.toString()), whitespace, align, overflowWrap, width, stderr) | ||
} | ||
|
||
/** | ||
* Print a line styled with the theme's [muted][Theme.muted] style. | ||
*/ | ||
fun Terminal.muted( | ||
message: Any?, | ||
whitespace: Whitespace = Whitespace.PRE, | ||
align: TextAlign = TextAlign.NONE, | ||
overflowWrap: OverflowWrap = OverflowWrap.NORMAL, | ||
width: Int? = null, | ||
stderr: Boolean = false, | ||
) { | ||
println(theme.muted(message.toString()), whitespace, align, overflowWrap, width, stderr) | ||
} | ||
|
||
/** | ||
* Print a line styled with the theme's [success][Theme.success] style. | ||
*/ | ||
fun Terminal.success( | ||
message: Any?, | ||
whitespace: Whitespace = Whitespace.PRE, | ||
align: TextAlign = TextAlign.NONE, | ||
overflowWrap: OverflowWrap = OverflowWrap.NORMAL, | ||
width: Int? = null, | ||
stderr: Boolean = false, | ||
) { | ||
println(theme.success(message.toString()), whitespace, align, overflowWrap, width, stderr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters