Skip to content

Commit

Permalink
Update Kotlin to 1.9 (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Sep 17, 2023
1 parent b28f0e9 commit e7d9ef1
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
### Added
- Added `showPulse` parameter to `ProgressLayout.progressBar`, allowing you to disable the pulse animation for a bar.

### Changed
- Update Kotlin to 1.9

### Fixed
- Fixed exception thrown in environments that are missing required shared native libraries.
- Fixed animations clearing too much space when the animation changes size while running. [(#110)](https://github.com/ajalt/mordant/issues/110)
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
kotlin = "1.8.22"
kotlin = "1.9.10"

[libraries]
colormath = "com.github.ajalt.colormath:colormath:3.3.1"
markdown = "org.jetbrains:markdown:0.4.1"
markdown = "org.jetbrains:markdown:0.5.0"
jna-core = "net.java.dev.jna:jna:5.13.0"

# used in tests
kotest = "io.kotest:kotest-assertions-core:5.6.2"
kotest = "io.kotest:kotest-assertions-core:5.7.2"
systemrules = "com.github.stefanbirkner:system-rules:1.19.0"

[plugins]
dokka = "org.jetbrains.dokka:1.8.10"
publish = "com.vanniktech.maven.publish:0.25.2"
dokka = "org.jetbrains.dokka:1.9.0"
publish = "com.vanniktech.maven.publish:0.25.3"
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 6 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.github.ajalt.mordant.internal

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import platform.posix.STDIN_FILENO
import platform.posix.TIOCGWINSZ
import platform.posix.ioctl
import platform.posix.winsize

@OptIn(ExperimentalForeignApi::class)
internal actual fun getTerminalSize(): Pair<Int, Int>? {
return memScoped {
val size = alloc<winsize>()
if (ioctl(STDIN_FILENO, TIOCGWINSZ, size) < 0) {
if (ioctl(STDIN_FILENO, TIOCGWINSZ.toULong(), size) < 0) {
null
} else {
size.ws_col.toInt() to size.ws_row.toInt()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.ajalt.mordant.internal

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import platform.posix.STDIN_FILENO
import platform.posix.TIOCGWINSZ
import platform.posix.ioctl
import platform.posix.winsize

@OptIn(ExperimentalForeignApi::class)
internal actual fun getTerminalSize(): Pair<Int, Int>? {
return memScoped {
val size = alloc<winsize>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalForeignApi::class)

package com.github.ajalt.mordant.internal

import kotlinx.cinterop.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
@file:OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)

package com.github.ajalt.mordant.internal

import com.github.ajalt.mordant.terminal.*
import kotlinx.cinterop.*
import platform.posix.*
import kotlin.native.concurrent.AtomicReference
import kotlin.concurrent.AtomicInt
import kotlin.concurrent.AtomicReference
import kotlin.experimental.ExperimentalNativeApi


internal actual class AtomicInt actual constructor(initial: Int) {
private val backing = kotlin.native.concurrent.AtomicInt(initial)
private val backing = AtomicInt(initial)
actual fun getAndIncrement(): Int {
return backing.addAndGet(1) - 1
}
Expand Down Expand Up @@ -64,7 +68,7 @@ internal actual fun makePrintingTerminalCursor(terminal: Terminal): TerminalCurs

// These are for the NativeTerminalCursor, but are top-level since atexit and signal require static
// functions.
private val registeredAtExit = kotlin.native.concurrent.AtomicInt(0)
private val registeredAtExit = AtomicInt(0)
private const val CURSOR_SHOW_STR = "\u001B[?25h"
private val CURSOR_SHOW_BUF = CURSOR_SHOW_STR.cstr // .ctr allocates, so we need to do it statically

Expand All @@ -87,7 +91,7 @@ private fun cursorSigintHandler(signum: Int) {
STDOUT_FILENO,
CURSOR_SHOW_BUF,
// `CURSOR_SHOW_STR.length == 6`. We use a literal since that parameter is a UInt on mingw and a ULong on posix
6
6u
)
signal(SIGINT, existingSigintHandler.value ?: SIG_DFL) // reset signal handling to previous value
existingSigintHandler.value = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@file:OptIn(ExperimentalForeignApi::class)

package com.github.ajalt.mordant.internal

import kotlinx.cinterop.alloc
import kotlinx.cinterop.convert
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.ptr
import kotlinx.cinterop.*
import platform.posix.*

// https://www.gnu.org/software/libc/manual/html_node/getpass.html
Expand Down

0 comments on commit e7d9ef1

Please sign in to comment.