-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
# Markdown Sample | ||
|
||
This sample is a command-line application that takes the path to a markdown file as an argument and renders that file to the terminal. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Progress Sample | ||
|
||
This sample shows a simulated wget-style download progress. |
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,21 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
application { | ||
mainClass.set("com.github.ajalt.mordant.samples.MainKt") | ||
} | ||
|
||
dependencies { | ||
api(kotlin("stdlib")) | ||
api(project(":mordant")) | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
samples/progress/src/main/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,34 @@ | ||
package com.github.ajalt.mordant.samples | ||
|
||
import com.github.ajalt.mordant.animation.progressAnimation | ||
import com.github.ajalt.mordant.terminal.Terminal | ||
|
||
fun main() { | ||
val terminal = Terminal() | ||
|
||
// Detect the terminal size so our progress bar is as wide as the screen | ||
terminal.info.updateTerminalSize() | ||
|
||
val progress = terminal.progressAnimation { | ||
text("my-file.bin") | ||
percentage() | ||
progressBar() | ||
completed() | ||
speed("B/s") | ||
timeRemaining() | ||
} | ||
|
||
progress.start() | ||
|
||
// Sleep for a few seconds to show the indeterminate state | ||
Thread.sleep(5000) | ||
|
||
// Update the progress as the download progresses | ||
progress.updateTotal(3_000_000_000) | ||
repeat(200) { | ||
progress.advance(15_000_000) | ||
Thread.sleep(100) | ||
} | ||
|
||
progress.stop() | ||
} |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
include("mordant", "samples") | ||
include("mordant") | ||
include("samples:markdown") | ||
include("samples:progress") |