-
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.
* Turn `TerminalInfo` into a `data class` This allows to easily compare instances and benefit from an auto-generated `toString()` representation. The downside is that `width` and `height` could now be set from the outside after construction, but that is probably not too much of an issue as arbitrary values could also have been passed via the constructor initially anyway. * Add a basic sample to show information for issue reports Later on printing of selected environment variables or similar useful output could be added.
- Loading branch information
1 parent
e7d9ef1
commit 44de090
Showing
5 changed files
with
59 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Detection Sample | ||
|
||
This sample shows the detected terminal, e.g. to collect information for issue reports. |
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,35 @@ | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
application | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
withJava() | ||
} | ||
|
||
macosX64() | ||
linuxX64() | ||
mingwX64() | ||
|
||
targets.filterIsInstance<KotlinNativeTarget>().forEach { target -> | ||
target.binaries.executable { | ||
entryPoint = "com.github.ajalt.mordant.samples.main" | ||
} | ||
} | ||
|
||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation(project(":mordant")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
application { | ||
mainClass.set("com.github.ajalt.mordant.samples.MainKt") | ||
applicationDefaultJvmArgs = listOf("-Dfile.encoding=utf-8") | ||
} |
17 changes: 17 additions & 0 deletions
17
samples/detection/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.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,17 @@ | ||
package com.github.ajalt.mordant.samples | ||
|
||
import com.github.ajalt.mordant.rendering.Theme | ||
import com.github.ajalt.mordant.terminal.Terminal | ||
|
||
fun main() { | ||
val terminal = Terminal() | ||
terminal.println(Theme.Default.info(terminal.info.toString())) | ||
terminal.println( | ||
"Theme colors: " + | ||
"${Theme.Default.success("success")}, " + | ||
"${Theme.Default.danger("danger")}, " + | ||
"${Theme.Default.warning("warning")}, " + | ||
"${Theme.Default.info("info")}, " + | ||
"${Theme.Default.muted("muted")}" | ||
) | ||
} |
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