Skip to content

Commit 2b70b0e

Browse files
author
alferio
committed
fix(android): faulty aab through the store
- The installed package is the store one: - installer=com.android.vending - The crash is immediate on startup. - Fresh logcat shows: java.lang.IllegalStateException: Required web asset not found (internal): com/kotcrab/vis/ui/skin/x1/uiskin.json at com.github.alfu32.sketch.Main.requireWebInternalFile(Main.kt:406) at com.github.alfu32.sketch.Main.create(Main.kt:558) Root cause - The Android store build was compiled with BuildFlags.WEB_BUILD = true. - That puts Android into the web-only VisUI startup path, so it looks for web assets that do not exist in the APK. - This is why the store install crashes while the working adb install does not. - :core:compileKotlin - :android:compileDebugKotlin Both compiled cleanly. - This is not a generic “store vs adb” mystery anymore. - It is a concrete stale build-flag bug in the build pipeline. fix(console): layout fixed the two console issues and added the Windows activation prompt. - this fixes: - the cursor being pushed down - the stray right-edge margin/artifacts from terminal auto-wrap at the last column - core/src/main/kotlin/com/github/alfu32/sketch/console/TerminalController.kt - added awaitActivationIfNeeded() - core/src/main/kotlin/com/github/alfu32/sketch/console/ConsoleThread.kt - now waits for activation before entering raw mode - lwjgl3/src/main/kotlin/com/github/alfu32/sketch/lwjgl3/console/LwjglTerminalController.kt - on Windows, prints: - Octodraw Dev Console - press Enter to activate the terminal UI... - then waits for Enter before enabling VT/raw input - lwjgl3/src/main/kotlin/com/github/alfu32/sketch/lwjgl3/console/WindowsConsole.kt - added openInputStream() needed by the Windows activation path changed the console to render one column narrower than the reported terminal width: - core/src/main/kotlin/com/github/alfu32/sketch/tui/ConsoleTui.kt - width now uses size.columns - 1 Why: - some terminals still auto-wrap or corrupt cursor placement when one writes exactly into the last column - leaving one gutter column unused is the pragmatic fix
1 parent 4cba71f commit 2b70b0e

9 files changed

Lines changed: 55 additions & 14 deletions

File tree

core/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ data class K3DVersion(
7474

7575
tasks.register('generateBuildFlags') {
7676
def outFile = file("src/main/kotlin/com/github/alfu32/sketch/BuildFlags.kt")
77-
outputs.file(outFile)
78-
doLast {
77+
def webBuildProvider = providers.provider {
7978
def explicit = project.findProperty("webBuild")
8079
def taskNames = gradle.startParameter.taskNames
8180
def inferredWeb = taskNames.any { name ->
8281
def lower = name.toLowerCase()
8382
lower.contains(":web:") || lower.startsWith("web:")
8483
}
85-
def webBuild = explicit != null ? explicit.toString().toBoolean() : inferredWeb
84+
explicit != null ? explicit.toString().toBoolean() : inferredWeb
85+
}
86+
inputs.property("webBuild", webBuildProvider)
87+
outputs.file(outFile)
88+
doLast {
89+
def webBuild = webBuildProvider.get()
8690
outFile.parentFile.mkdirs()
8791
outFile.text = """package com.github.alfu32.sketch
8892
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.github.alfu32.sketch
22

33
object BuildFlags {
4-
const val WEB_BUILD: Boolean = true
4+
const val WEB_BUILD: Boolean = false
55
}

core/src/main/kotlin/com/github/alfu32/sketch/console/ConsoleThread.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ConsoleThread(
1010
private var running = true
1111

1212
override fun run() {
13+
terminal.awaitActivationIfNeeded()
1314
terminal.enterRawMode()
1415
try {
1516
tui.history.loadFromDisk()

core/src/main/kotlin/com/github/alfu32/sketch/console/TerminalController.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ open class TerminalController {
1313
private var lastKnownSize: TerminalSize = querySize()
1414
private var lastSizeCheckNanos: Long = 0L
1515

16+
open fun awaitActivationIfNeeded() {
17+
// No-op by default.
18+
}
19+
1620
open fun enterRawMode() {
1721
originalConfig = captureTerminalState()
1822
runShellCommand("stty raw -echo < /dev/tty")

core/src/main/kotlin/com/github/alfu32/sketch/tui/ConsoleTui.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ConsoleTui(
3939
fun render() {
4040
dirty = false
4141
val size = terminal.size()
42-
val width = size.columns.coerceAtLeast(20)
42+
val width = (size.columns - 1).coerceAtLeast(20)
4343
val height = size.rows.coerceAtLeast(12)
4444
val topBarHeight = 1
4545
val outputHeaderHeight = 1
@@ -52,16 +52,16 @@ class ConsoleTui(
5252
builder.append(ANSI_HIDE_CURSOR)
5353
builder.append(ANSI_CLEAR)
5454
builder.append(ANSI_HOME)
55-
56-
builder.append(renderTopBar(width)).append('\n')
57-
builder.append(renderSectionHeader("Console", outputHeaderMeta(), width)).append('\n')
55+
val rows = mutableListOf<String>()
56+
rows += renderTopBar(width)
57+
rows += renderSectionHeader("Console", outputHeaderMeta(), width)
5858

5959
val outputLines = outputPane.visibleLines(outputHeight, width - 2)
6060
for (i in 0 until outputHeight) {
6161
val line = outputLines.getOrNull(i) ?: ""
62-
builder.append(padLine("${truncateAnsi(line, width - 2)}", width)).append('\n')
62+
rows += padLine("${truncateAnsi(line, width - 2)}", width)
6363
}
64-
builder.append(renderSectionHeader("Prompt", promptHeaderMeta(), width)).append('\n')
64+
rows += renderSectionHeader("Prompt", promptHeaderMeta(), width)
6565

6666
val lines = editorPane.lines()
6767
val (cursorLine, cursorColumn) = editorPane.lineAndColumn(editorPane.cursorPosition)
@@ -76,9 +76,13 @@ class ConsoleTui(
7676
val prefix = if (lineIndex == 0) "│> " else ""
7777
val highlighted = highlight(rawLine)
7878
val trimmed = truncateAnsi(highlighted, width - prefix.length)
79-
builder.append(padLine(prefix + trimmed, width)).append('\n')
79+
rows += padLine(prefix + trimmed, width)
80+
}
81+
rows += renderFooter(width)
82+
rows.forEachIndexed { index, row ->
83+
builder.append(ANSI_MOVE_CURSOR.format(Locale.US, index + 1, 1))
84+
builder.append(padLine(row, width))
8085
}
81-
builder.append(renderFooter(width))
8286
val cursorRow = topBarHeight + outputHeaderHeight + outputHeight + promptHeaderHeight + (cursorLine - editorScrollTop) + 1
8387
val prefixLength = 3
8488
val cursorCol = (prefixLength + cursorColumn + 1).coerceAtLeast(1)

lwjgl3/src/main/kotlin/com/github/alfu32/sketch/lwjgl3/console/LwjglTerminalController.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ import java.util.concurrent.TimeUnit
99

1010
class LwjglTerminalController : TerminalController() {
1111
private val isWindows = WindowsConsole.isWindows()
12+
private val activationInput by lazy { WindowsConsole.openInputStream() }
13+
14+
override fun awaitActivationIfNeeded() {
15+
if (!isWindows) {
16+
return
17+
}
18+
print("Octodraw Dev Console - press Enter to activate the terminal UI...\r\n")
19+
flushStdout()
20+
while (true) {
21+
val next = activationInput.read()
22+
if (next == -1 || next == '\n'.code || next == '\r'.code) {
23+
break
24+
}
25+
}
26+
}
1227

1328
override fun enterRawMode() {
1429
if (!isWindows) {

lwjgl3/src/main/kotlin/com/github/alfu32/sketch/lwjgl3/console/WindowsConsole.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.sun.jna.Native
66
import com.sun.jna.NativeLibrary
77
import com.sun.jna.Pointer
88
import com.sun.jna.ptr.IntByReference
9+
import java.io.FileInputStream
10+
import java.io.InputStream
911

1012
object WindowsConsole {
1113
private const val ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
@@ -60,6 +62,17 @@ object WindowsConsole {
6062

6163
fun isWindows(): Boolean = isWindows
6264

65+
fun openInputStream(): InputStream {
66+
if (!isWindows) return System.`in`
67+
val k32 = kernel32 ?: return System.`in`
68+
val handle = k32.GetStdHandle(STD_INPUT_HANDLE)
69+
val fileType = if (handle == null) 0 else k32.GetFileType(handle)
70+
if (fileType == FILE_TYPE_CHAR) {
71+
return System.`in`
72+
}
73+
return runCatching { FileInputStream("CONIN$") }.getOrDefault(System.`in`)
74+
}
75+
6376
fun enableVirtualTerminalProcessing(): Boolean {
6477
if (!isWindows) return true
6578
val k32 = kernel32 ?: return false

web/build/dist/webapp/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Octodraw 4.7.2</title>
4+
<title>Octodraw 4.7.4</title>
55
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
66
<style>
77
body {
@@ -29,6 +29,6 @@
2929
}
3030
window.addEventListener("load", start);
3131
</script>
32-
<script type="text/javascript" charset="utf-8" src="octodraw-4.7.2.js"></script>
32+
<script type="text/javascript" charset="utf-8" src="octodraw-4.7.4.js"></script>
3333
</body>
3434
</html>
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)