From 3ca2acd6f8383f6dec56cbad93ea3901e0d14b3b Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 11:24:59 -0700 Subject: [PATCH] Rename Terminal.info to terminalInfo --- CHANGELOG.md | 1 + .../github/ajalt/mordant/markdown/Markdown.kt | 2 +- mordant/api/mordant.api | 196 ++++-------------- .../ajalt/mordant/animation/Animation.kt | 4 +- .../com/github/ajalt/mordant/input/RawMode.kt | 2 +- .../github/ajalt/mordant/terminal/Terminal.kt | 20 +- .../ajalt/mordant/terminal/PromptTest.kt | 2 +- .../com/github/ajalt/mordant/samples/main.kt | 2 +- .../com/github/ajalt/mordant/samples/main.kt | 2 +- 9 files changed, 58 insertions(+), 173 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3489d29c..d021372a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Renamed `TerminalInfo.crClearsLine` to `supportsAnsiCursor` - Combined all `ColumnWidth` subclasses into a single class with factory methods. If you were using `ColumnWidth.Custom`, you should now use the `ColumnWidth` constructor. - The following `Terminal` methods are now extensions: `prompt()`, `info()`, `danger()`, `warning()`, `success()`, `muted()` +- Renamed `Terminal.info` property to `Terminal.terminalInfo` ### Removed - Removed constructor overloads for `Terminal`. There is now one constructor with all default parameters. diff --git a/mordant-markdown/src/commonMain/kotlin/com/github/ajalt/mordant/markdown/Markdown.kt b/mordant-markdown/src/commonMain/kotlin/com/github/ajalt/mordant/markdown/Markdown.kt index 7d489309e..8cb64bbf1 100644 --- a/mordant-markdown/src/commonMain/kotlin/com/github/ajalt/mordant/markdown/Markdown.kt +++ b/mordant-markdown/src/commonMain/kotlin/com/github/ajalt/mordant/markdown/Markdown.kt @@ -22,7 +22,7 @@ class Markdown( private var document: Widget? = null private fun document(t: Terminal): Widget { if (document == null) { - document = MarkdownRenderer(markdown, t.theme, showHtml, hyperlinks ?: t.info.ansiHyperLinks).render() + document = MarkdownRenderer(markdown, t.theme, showHtml, hyperlinks ?: t.terminalInfo.ansiHyperLinks).render() } return document!! } diff --git a/mordant/api/mordant.api b/mordant/api/mordant.api index 8742dca8d..59a24f2ac 100644 --- a/mordant/api/mordant.api +++ b/mordant/api/mordant.api @@ -1,6 +1,5 @@ public abstract class com/github/ajalt/mordant/animation/Animation : com/github/ajalt/mordant/animation/StoppableAnimation { - public fun (ZLcom/github/ajalt/mordant/terminal/Terminal;)V - public synthetic fun (ZLcom/github/ajalt/mordant/terminal/Terminal;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lcom/github/ajalt/mordant/terminal/Terminal;)V public final fun clear ()V public final fun getTerminal ()Lcom/github/ajalt/mordant/terminal/Terminal; protected abstract fun renderData (Ljava/lang/Object;)Lcom/github/ajalt/mordant/rendering/Widget; @@ -9,37 +8,9 @@ public abstract class com/github/ajalt/mordant/animation/Animation : com/github/ } public final class com/github/ajalt/mordant/animation/AnimationKt { - public static final fun animation (Lcom/github/ajalt/mordant/terminal/Terminal;ZLkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/animation/Animation; - public static synthetic fun animation$default (Lcom/github/ajalt/mordant/terminal/Terminal;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/github/ajalt/mordant/animation/Animation; - public static final fun textAnimation (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Ljava/lang/Integer;ZLkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/animation/Animation; - public static synthetic fun textAnimation$default (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Ljava/lang/Integer;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/github/ajalt/mordant/animation/Animation; -} - -public final class com/github/ajalt/mordant/animation/ProgressAnimation { - public final fun advance (J)V - public static synthetic fun advance$default (Lcom/github/ajalt/mordant/animation/ProgressAnimation;JILjava/lang/Object;)V - public final fun clear ()V - public final fun restart ()V - public final fun start ()V - public final fun stop ()V - public final fun update ()V - public final fun update (I)V - public final fun update (J)V - public final fun update (JLjava/lang/Long;)V - public final fun updateTotal (Ljava/lang/Long;)V -} - -public final class com/github/ajalt/mordant/animation/ProgressAnimationBuilder : com/github/ajalt/mordant/widgets/ProgressBuilder { - public final fun getAnimationFrameRate ()I - public final fun getHistoryLength ()F - public final fun getTextFrameRate ()I - public final fun setAnimationFrameRate (I)V - public final fun setHistoryLength (F)V - public final fun setTextFrameRate (I)V -} - -public final class com/github/ajalt/mordant/animation/ProgressAnimationKt { - public static final fun progressAnimation (Lcom/github/ajalt/mordant/terminal/Terminal;Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/animation/ProgressAnimation; + public static final fun animation (Lcom/github/ajalt/mordant/terminal/Terminal;Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/animation/Animation; + public static final fun textAnimation (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Ljava/lang/Integer;Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/animation/Animation; + public static synthetic fun textAnimation$default (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Ljava/lang/Integer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/github/ajalt/mordant/animation/Animation; } public abstract interface class com/github/ajalt/mordant/animation/Refreshable { @@ -810,7 +781,6 @@ public final class com/github/ajalt/mordant/table/Borders : java/lang/Enum { public static final field LEFT_TOP_RIGHT Lcom/github/ajalt/mordant/table/Borders; public static final field NONE Lcom/github/ajalt/mordant/table/Borders; public static final field RIGHT Lcom/github/ajalt/mordant/table/Borders; - public static final field TOM_BOTTOM Lcom/github/ajalt/mordant/table/Borders; public static final field TOP Lcom/github/ajalt/mordant/table/Borders; public static final field TOP_BOTTOM Lcom/github/ajalt/mordant/table/Borders; public static final field TOP_RIGHT Lcom/github/ajalt/mordant/table/Borders; @@ -838,13 +808,11 @@ public final class com/github/ajalt/mordant/table/CellBuilder$DefaultImpls { } public abstract interface class com/github/ajalt/mordant/table/CellStyleBuilder : com/github/ajalt/mordant/table/CellStyleBuilderBase { - public abstract fun getBorders ()Lcom/github/ajalt/mordant/table/Borders; public abstract fun getCellBorders ()Lcom/github/ajalt/mordant/table/Borders; public abstract fun getPadding ()Lcom/github/ajalt/mordant/widgets/Padding; public abstract fun getVerticalAlign ()Lcom/github/ajalt/mordant/rendering/VerticalAlign; public abstract fun padding (I)V public abstract fun padding (Lkotlin/jvm/functions/Function1;)V - public abstract fun setBorders (Lcom/github/ajalt/mordant/table/Borders;)V public abstract fun setCellBorders (Lcom/github/ajalt/mordant/table/Borders;)V public abstract fun setPadding (Lcom/github/ajalt/mordant/widgets/Padding;)V public abstract fun setVerticalAlign (Lcom/github/ajalt/mordant/rendering/VerticalAlign;)V @@ -890,23 +858,15 @@ public abstract interface class com/github/ajalt/mordant/table/ColumnHolderBuild public abstract fun setAddPaddingWidthToFixedWidth (Z)V } -public abstract class com/github/ajalt/mordant/table/ColumnWidth { -} - -public final class com/github/ajalt/mordant/table/ColumnWidth$Auto : com/github/ajalt/mordant/table/ColumnWidth { - public static final field INSTANCE Lcom/github/ajalt/mordant/table/ColumnWidth$Auto; - public fun equals (Ljava/lang/Object;)Z - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class com/github/ajalt/mordant/table/ColumnWidth$Custom : com/github/ajalt/mordant/table/ColumnWidth { - public fun (Ljava/lang/Integer;Ljava/lang/Float;I)V - public final fun component1 ()Ljava/lang/Integer; - public final fun component2 ()Ljava/lang/Float; - public final fun component3 ()I - public final fun copy (Ljava/lang/Integer;Ljava/lang/Float;I)Lcom/github/ajalt/mordant/table/ColumnWidth$Custom; - public static synthetic fun copy$default (Lcom/github/ajalt/mordant/table/ColumnWidth$Custom;Ljava/lang/Integer;Ljava/lang/Float;IILjava/lang/Object;)Lcom/github/ajalt/mordant/table/ColumnWidth$Custom; +public final class com/github/ajalt/mordant/table/ColumnWidth { + public static final field Companion Lcom/github/ajalt/mordant/table/ColumnWidth$Companion; + public fun (ILjava/lang/Integer;Ljava/lang/Float;)V + public synthetic fun (ILjava/lang/Integer;Ljava/lang/Float;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()I + public final fun component2 ()Ljava/lang/Integer; + public final fun component3 ()Ljava/lang/Float; + public final fun copy (ILjava/lang/Integer;Ljava/lang/Float;)Lcom/github/ajalt/mordant/table/ColumnWidth; + public static synthetic fun copy$default (Lcom/github/ajalt/mordant/table/ColumnWidth;ILjava/lang/Integer;Ljava/lang/Float;ILjava/lang/Object;)Lcom/github/ajalt/mordant/table/ColumnWidth; public fun equals (Ljava/lang/Object;)Z public final fun getExpandWeight ()Ljava/lang/Float; public final fun getPriority ()I @@ -915,17 +875,11 @@ public final class com/github/ajalt/mordant/table/ColumnWidth$Custom : com/githu public fun toString ()Ljava/lang/String; } -public final class com/github/ajalt/mordant/table/ColumnWidth$Expand : com/github/ajalt/mordant/table/ColumnWidth { - public fun ()V - public fun (F)V - public synthetic fun (FILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/lang/Number;)V - public final fun getWeight ()F -} - -public final class com/github/ajalt/mordant/table/ColumnWidth$Fixed : com/github/ajalt/mordant/table/ColumnWidth { - public fun (I)V - public final fun getWidth ()I +public final class com/github/ajalt/mordant/table/ColumnWidth$Companion { + public final fun Expand (Ljava/lang/Number;)Lcom/github/ajalt/mordant/table/ColumnWidth; + public static synthetic fun Expand$default (Lcom/github/ajalt/mordant/table/ColumnWidth$Companion;Ljava/lang/Number;ILjava/lang/Object;)Lcom/github/ajalt/mordant/table/ColumnWidth; + public final fun Fixed (I)Lcom/github/ajalt/mordant/table/ColumnWidth; + public final fun getAuto ()Lcom/github/ajalt/mordant/table/ColumnWidth; } public final class com/github/ajalt/mordant/table/CsvQuoting : java/lang/Enum { @@ -1023,12 +977,10 @@ public abstract interface class com/github/ajalt/mordant/table/TableBuilder : co public abstract fun footer (Lkotlin/jvm/functions/Function1;)V public abstract fun getBorderStyle ()Lcom/github/ajalt/mordant/rendering/TextStyle; public abstract fun getBorderType ()Lcom/github/ajalt/mordant/rendering/BorderType; - public abstract fun getOuterBorder ()Z public abstract fun getTableBorders ()Lcom/github/ajalt/mordant/table/Borders; public abstract fun header (Lkotlin/jvm/functions/Function1;)V public abstract fun setBorderStyle (Lcom/github/ajalt/mordant/rendering/TextStyle;)V public abstract fun setBorderType (Lcom/github/ajalt/mordant/rendering/BorderType;)V - public abstract fun setOuterBorder (Z)V public abstract fun setTableBorders (Lcom/github/ajalt/mordant/table/Borders;)V } @@ -1046,12 +998,8 @@ public final class com/github/ajalt/mordant/table/TableCsvKt { } public final class com/github/ajalt/mordant/table/TableDslKt { - public static final fun column (ILkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/rendering/Widget; - public static synthetic fun column$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/github/ajalt/mordant/rendering/Widget; public static final fun grid (Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/rendering/Widget; public static final fun horizontalLayout (Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/rendering/Widget; - public static final fun row (ILkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/rendering/Widget; - public static synthetic fun row$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/github/ajalt/mordant/rendering/Widget; public static final fun table (Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/table/Table; public static final fun verticalLayout (Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/rendering/Widget; } @@ -1121,9 +1069,6 @@ public abstract interface class com/github/ajalt/mordant/terminal/CursorMovement public abstract fun up (I)V } -public abstract interface annotation class com/github/ajalt/mordant/terminal/ExperimentalTerminalApi : java/lang/annotation/Annotation { -} - public final class com/github/ajalt/mordant/terminal/HtmlRendererKt { public static final fun outputAsHtml (Lcom/github/ajalt/mordant/terminal/TerminalRecorder;ZZLcom/github/ajalt/colormath/Color;)Ljava/lang/String; public static synthetic fun outputAsHtml$default (Lcom/github/ajalt/mordant/terminal/TerminalRecorder;ZZLcom/github/ajalt/colormath/Color;ILjava/lang/Object;)Ljava/lang/String; @@ -1167,6 +1112,13 @@ public abstract class com/github/ajalt/mordant/terminal/Prompt { protected fun renderValue (Ljava/lang/Object;)Ljava/lang/String; } +public final class com/github/ajalt/mordant/terminal/PromptKt { + public static final fun prompt (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/Object;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun prompt (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/String;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; + public static synthetic fun prompt$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/Object;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun prompt$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/String;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; +} + public abstract class com/github/ajalt/mordant/terminal/StandardTerminalInterface : com/github/ajalt/mordant/terminal/TerminalInterface { public fun ()V public fun completePrintRequest (Lcom/github/ajalt/mordant/terminal/PrintRequest;)V @@ -1188,19 +1140,12 @@ public final class com/github/ajalt/mordant/terminal/StringPrompt : com/github/a public final class com/github/ajalt/mordant/terminal/Terminal { public fun (Lcom/github/ajalt/mordant/rendering/AnsiLevel;Lcom/github/ajalt/mordant/rendering/Theme;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;ILjava/lang/Boolean;Lcom/github/ajalt/mordant/terminal/TerminalInterface;)V public synthetic fun (Lcom/github/ajalt/mordant/rendering/AnsiLevel;Lcom/github/ajalt/mordant/rendering/Theme;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;ILjava/lang/Boolean;Lcom/github/ajalt/mordant/terminal/TerminalInterface;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun danger (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V - public static synthetic fun danger$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V - public final fun getColors ()Lcom/github/ajalt/mordant/terminal/TerminalColors; public final fun getCursor ()Lcom/github/ajalt/mordant/terminal/TerminalCursor; - public final fun getInfo ()Lcom/github/ajalt/mordant/terminal/TerminalInfo; public final fun getSize ()Lcom/github/ajalt/mordant/rendering/Size; public final fun getTabWidth ()I + public final fun getTerminalInfo ()Lcom/github/ajalt/mordant/terminal/TerminalInfo; public final fun getTerminalInterface ()Lcom/github/ajalt/mordant/terminal/TerminalInterface; public final fun getTheme ()Lcom/github/ajalt/mordant/rendering/Theme; - public final fun info (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V - public static synthetic fun info$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V - public final fun muted (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V - public static synthetic fun muted$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V public final fun print (Lcom/github/ajalt/mordant/rendering/Widget;Z)V public final fun print (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V public static synthetic fun print$default (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Widget;ZILjava/lang/Object;)V @@ -1211,61 +1156,13 @@ public final class com/github/ajalt/mordant/terminal/Terminal { public static synthetic fun println$default (Lcom/github/ajalt/mordant/terminal/Terminal;Lcom/github/ajalt/mordant/rendering/Widget;ZILjava/lang/Object;)V public static synthetic fun println$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V public static synthetic fun println$default (Lcom/github/ajalt/mordant/terminal/Terminal;ZILjava/lang/Object;)V - public final fun prompt (Ljava/lang/String;Ljava/lang/Object;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public final fun prompt (Ljava/lang/String;Ljava/lang/String;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; - public static synthetic fun prompt$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/Object;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; - public static synthetic fun prompt$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;Ljava/lang/String;ZZZLjava/util/Collection;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; public final fun rawPrint (Ljava/lang/String;Z)V public static synthetic fun rawPrint$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/String;ZILjava/lang/Object;)V public final fun readLineOrNull (Z)Ljava/lang/String; public final fun render (Lcom/github/ajalt/mordant/rendering/Widget;)Ljava/lang/String; public final fun render (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;)Ljava/lang/String; public static synthetic fun render$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ILjava/lang/Object;)Ljava/lang/String; - public final fun success (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V - public static synthetic fun success$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V public final fun updateSize ()Lcom/github/ajalt/mordant/rendering/Size; - public final fun warning (Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V - public static synthetic fun warning$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V -} - -public final class com/github/ajalt/mordant/terminal/TerminalColors { - public final fun cmyk (IIII)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun color (Lcom/github/ajalt/colormath/Color;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBlack ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBlue ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBold ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightBlue ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightCyan ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightGreen ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightMagenta ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightRed ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightWhite ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getBrightYellow ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getCyan ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getDanger ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getDim ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getGray ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getGreen ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getInfo ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getInverse ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getItalic ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getMagenta ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getMuted ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getPlain ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getRed ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getStrikethrough ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getSuccess ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getUnderline ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getWarning ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getWhite ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun getYellow ()Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun gray (Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun hsl (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun hsv (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun lab (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun rgb (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun rgb (Ljava/lang/String;)Lcom/github/ajalt/mordant/rendering/TextStyle; - public final fun xyz (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lcom/github/ajalt/mordant/rendering/TextStyle; } public abstract interface class com/github/ajalt/mordant/terminal/TerminalCursor { @@ -1284,6 +1181,19 @@ public final class com/github/ajalt/mordant/terminal/TerminalDetection { public final fun detectTerminal (Lcom/github/ajalt/mordant/rendering/AnsiLevel;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;ZZ)Lcom/github/ajalt/mordant/terminal/TerminalInfo; } +public final class com/github/ajalt/mordant/terminal/TerminalExtensionsKt { + public static final fun danger (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V + public static synthetic fun danger$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V + public static final fun info (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V + public static synthetic fun info$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V + public static final fun muted (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V + public static synthetic fun muted$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V + public static final fun success (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V + public static synthetic fun success$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V + public static final fun warning (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;Z)V + public static synthetic fun warning$default (Lcom/github/ajalt/mordant/terminal/Terminal;Ljava/lang/Object;Lcom/github/ajalt/mordant/rendering/Whitespace;Lcom/github/ajalt/mordant/rendering/TextAlign;Lcom/github/ajalt/mordant/rendering/OverflowWrap;Ljava/lang/Integer;ZILjava/lang/Object;)V +} + public final class com/github/ajalt/mordant/terminal/TerminalInfo { public fun (Lcom/github/ajalt/mordant/rendering/AnsiLevel;ZZZZ)V public final fun component1 ()Lcom/github/ajalt/mordant/rendering/AnsiLevel; @@ -1296,10 +1206,10 @@ public final class com/github/ajalt/mordant/terminal/TerminalInfo { public fun equals (Ljava/lang/Object;)Z public final fun getAnsiHyperLinks ()Z public final fun getAnsiLevel ()Lcom/github/ajalt/mordant/rendering/AnsiLevel; - public final fun getCrClearsLine ()Z public final fun getInputInteractive ()Z public final fun getInteractive ()Z public final fun getOutputInteractive ()Z + public final fun getSupportsAnsiCursor ()Z public fun hashCode ()I public final fun setAnsiHyperLinks (Z)V public final fun setAnsiLevel (Lcom/github/ajalt/mordant/rendering/AnsiLevel;)V @@ -1654,32 +1564,6 @@ public final class com/github/ajalt/mordant/widgets/ProgressBar : com/github/aja public fun render (Lcom/github/ajalt/mordant/terminal/Terminal;I)Lcom/github/ajalt/mordant/rendering/Lines; } -public class com/github/ajalt/mordant/widgets/ProgressBuilder { - public final fun completed (Ljava/lang/String;ZLcom/github/ajalt/mordant/rendering/TextStyle;)V - public static synthetic fun completed$default (Lcom/github/ajalt/mordant/widgets/ProgressBuilder;Ljava/lang/String;ZLcom/github/ajalt/mordant/rendering/TextStyle;ILjava/lang/Object;)V - public final fun getPadding ()I - public final fun percentage ()V - public final fun progressBar (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Ljava/lang/Boolean;)V - public static synthetic fun progressBar$default (Lcom/github/ajalt/mordant/widgets/ProgressBuilder;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Ljava/lang/Boolean;ILjava/lang/Object;)V - public final fun setPadding (I)V - public final fun speed (Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;)V - public static synthetic fun speed$default (Lcom/github/ajalt/mordant/widgets/ProgressBuilder;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;ILjava/lang/Object;)V - public final fun spinner (Lcom/github/ajalt/mordant/widgets/Spinner;I)V - public static synthetic fun spinner$default (Lcom/github/ajalt/mordant/widgets/ProgressBuilder;Lcom/github/ajalt/mordant/widgets/Spinner;IILjava/lang/Object;)V - public final fun text (Ljava/lang/String;)V - public final fun timeRemaining (Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;)V - public static synthetic fun timeRemaining$default (Lcom/github/ajalt/mordant/widgets/ProgressBuilder;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/TextStyle;ILjava/lang/Object;)V -} - -public final class com/github/ajalt/mordant/widgets/ProgressLayout { - public final fun build (JLjava/lang/Long;DLjava/lang/Double;)Lcom/github/ajalt/mordant/rendering/Widget; - public static synthetic fun build$default (Lcom/github/ajalt/mordant/widgets/ProgressLayout;JLjava/lang/Long;DLjava/lang/Double;ILjava/lang/Object;)Lcom/github/ajalt/mordant/rendering/Widget; -} - -public final class com/github/ajalt/mordant/widgets/ProgressLayoutKt { - public static final fun progressLayout (Lkotlin/jvm/functions/Function1;)Lcom/github/ajalt/mordant/widgets/ProgressLayout; -} - public final class com/github/ajalt/mordant/widgets/SelectList : com/github/ajalt/mordant/rendering/Widget { public fun (Ljava/util/List;Lcom/github/ajalt/mordant/rendering/Widget;IZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/Widget;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;)V public synthetic fun (Ljava/util/List;Lcom/github/ajalt/mordant/rendering/Widget;IZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/github/ajalt/mordant/rendering/Widget;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;Lcom/github/ajalt/mordant/rendering/TextStyle;ILkotlin/jvm/internal/DefaultConstructorMarker;)V diff --git a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/animation/Animation.kt b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/animation/Animation.kt index e8c81578f..b3901c81e 100644 --- a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/animation/Animation.kt +++ b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/animation/Animation.kt @@ -148,7 +148,7 @@ abstract class Animation( text = terminal.render(rendered) ) } - if (!old.interceptorInstalled && terminal.info.outputInteractive) { + if (!old.interceptorInstalled && terminal.terminalInfo.outputInteractive) { terminal.addInterceptor(interceptor) } // Print an empty widget to trigger our interceptor, which will add the rendered text @@ -169,7 +169,7 @@ abstract class Animation( startOfLine() if (CR_IMPLIES_LF) up(1) - if (terminal.info.supportsAnsiCursor) { + if (terminal.terminalInfo.supportsAnsiCursor) { // IntelliJ doesn't support cursor moves, so this is all we can do return@getMoves } diff --git a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/input/RawMode.kt b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/input/RawMode.kt index d9ab4fc85..fb3780898 100644 --- a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/input/RawMode.kt +++ b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/input/RawMode.kt @@ -13,7 +13,7 @@ import kotlin.time.TimeSource * @throws RuntimeException if the terminal is not interactive or raw mode cannot be entered. */ fun Terminal.enterRawMode(mouseTracking: MouseTracking = MouseTracking.Off): RawModeScope { - if (!info.inputInteractive) { + if (!terminalInfo.inputInteractive) { throw IllegalStateException("Cannot enter raw mode on a non-interactive terminal") } return RawModeScope(this, terminalInterface.enterRawMode(mouseTracking), mouseTracking) diff --git a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/terminal/Terminal.kt b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/terminal/Terminal.kt index 44a953ea6..798887df2 100644 --- a/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/terminal/Terminal.kt +++ b/mordant/src/commonMain/kotlin/com/github/ajalt/mordant/terminal/Terminal.kt @@ -29,7 +29,7 @@ class Terminal private constructor( private val nonInteractiveWidth: Int?, private val nonInteractiveHeight: Int?, /** The terminal capabilities that were detected or set in the constructor. */ - val info: TerminalInfo, + val terminalInfo: TerminalInfo, ) { /** @@ -65,7 +65,7 @@ class Terminal private constructor( forceHeight = height, nonInteractiveWidth = nonInteractiveWidth, nonInteractiveHeight = nonInteractiveHeight, - info = terminalInterface.info( + terminalInfo = terminalInterface.info( ansiLevel = ansiLevel, hyperlinks = hyperlinks, outputInteractive = interactive, @@ -79,7 +79,7 @@ class Terminal private constructor( private val atomicSize: MppAtomicRef = MppAtomicRef( terminalInterface.detectSize( - info, + terminalInfo, forceWidth, forceHeight, nonInteractiveWidth, @@ -103,7 +103,7 @@ class Terminal private constructor( fun updateSize(): Size { return atomicSize.update { terminalInterface.detectSize( - info, + terminalInfo, forceWidth, forceHeight, nonInteractiveWidth, @@ -118,7 +118,7 @@ class Terminal private constructor( * If the terminal is not interactive, all the cursor functions are no-ops. */ val cursor: TerminalCursor = when { - info.interactive -> makePrintingTerminalCursor(this) + terminalInfo.interactive -> makePrintingTerminalCursor(this) else -> DisabledTerminalCursor } @@ -126,7 +126,7 @@ class Terminal private constructor( * Print a [message] to the terminal. * * Any contained [TextColors] and [TextStyles] will be automatically downsampled based on the - * current terminal's [info]. + * current terminal's [terminalInfo]. * * @param message The message to print as a string. * @param whitespace How to handle whitespace and line wrapping. By default, whitespace is @@ -152,7 +152,7 @@ class Terminal private constructor( * Print a [message] to the terminal, followed by a line break. * * Any contained [TextColors] and [TextStyles] will be automatically downsampled based on the - * current terminal's [info]. + * current terminal's [terminalInfo]. * * @param message The message to print as a string. * @param whitespace How to handle whitespace and line wrapping. By default, whitespace is @@ -200,7 +200,7 @@ class Terminal private constructor( * Render a [message] to a string. * * Any contained [TextColors] and [TextStyles] will be automatically downsampled based on the - * current terminal's [info]. + * current terminal's [terminalInfo]. * * @param message The message to render as a string. * @param whitespace How to handle whitespace and line wrapping. By default, whitespace is @@ -218,7 +218,7 @@ class Terminal private constructor( width: Int? = null, ): String { return when (message) { - is Lines -> renderLinesAnsi(message, info.ansiLevel, info.ansiHyperLinks) + is Lines -> renderLinesAnsi(message, terminalInfo.ansiLevel, terminalInfo.ansiHyperLinks) is Widget -> render(message) else -> render(Text(message.toString(), whitespace, align, overflowWrap, width)) } @@ -226,7 +226,7 @@ class Terminal private constructor( /** Render a [widget] as a string */ fun render(widget: Widget): String { - return renderLinesAnsi(widget.render(this), info.ansiLevel, info.ansiHyperLinks) + return renderLinesAnsi(widget.render(this), terminalInfo.ansiLevel, terminalInfo.ansiHyperLinks) } /** diff --git a/mordant/src/commonTest/kotlin/com/github/ajalt/mordant/terminal/PromptTest.kt b/mordant/src/commonTest/kotlin/com/github/ajalt/mordant/terminal/PromptTest.kt index 8897dad9a..8f884c7c6 100644 --- a/mordant/src/commonTest/kotlin/com/github/ajalt/mordant/terminal/PromptTest.kt +++ b/mordant/src/commonTest/kotlin/com/github/ajalt/mordant/terminal/PromptTest.kt @@ -42,7 +42,7 @@ class PromptTest { @[Test JsName("custom_Prompt")] fun `custom Prompt`() { - t.info.ansiLevel = AnsiLevel.NONE + t.terminalInfo.ansiLevel = AnsiLevel.NONE class IntPrompt : Prompt("pr", t) { override fun convert(input: String): ConversionResult { return input.toIntOrNull() diff --git a/samples/detection/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt b/samples/detection/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt index 16d92e34a..2084fb6b9 100644 --- a/samples/detection/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt +++ b/samples/detection/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt @@ -11,7 +11,7 @@ fun main() { val theme = terminal.theme terminal.println( Panel( - Text(terminal.info.toString(), whitespace = NORMAL).withPadding(1), + Text(terminal.terminalInfo.toString(), whitespace = NORMAL).withPadding(1), Text(theme.info("Detected Terminal Info")) ) ) diff --git a/samples/hexviewer/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt b/samples/hexviewer/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt index 8131a3472..fc67a0314 100644 --- a/samples/hexviewer/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt +++ b/samples/hexviewer/src/commonMain/kotlin/com/github/ajalt/mordant/samples/main.kt @@ -40,7 +40,7 @@ fun main(args: Array) { } // 4 chars per octet, -20 for borders + address - val w = (terminal.info.width - 20) / 4 + val w = (terminal.size.width - 20) / 4 // round down to nearest multiple of 8 val octetsPerRow = (w - w % 8).coerceAtLeast(1)