Skip to content

Commit 82092ae

Browse files
author
Simon Schubert
committed
Improve web UI
1 parent 79d6bae commit 82092ae

4 files changed

Lines changed: 383 additions & 242 deletions

File tree

common/src/commonMain/kotlin/com/linuxcommandlibrary/shared/App.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ fun String.getCommandList(
5858
command.replace(cmd, " ü${it}ä")
5959
} else {
6060
if (hasBrackets) {
61-
command.replace("(?:[\\s,])($it)".toRegex(), " ü${it}ä")
61+
val escapedIt = Regex.escape(it) // Escapes special characters, e.g., "pbmto\\*\\*\\*"
62+
val regex = "(?:[\\s,])($escapedIt)".toRegex()
63+
command.replace(regex, " ü${it}ä")
6264
} else {
6365
command.replace(it, " ü${it}ä")
6466
}
@@ -122,3 +124,5 @@ fun CommandSection.getSortPriority(): Int = when (this.title) {
122124
"AUTHOR" -> 100
123125
else -> 50
124126
}
127+
128+
fun String.isLetter(): Boolean = this.firstOrNull() in 'a'..'z' || this.firstOrNull() in 'A'..'Z'

common/src/commonMain/kotlin/com/linuxcommandlibrary/shared/Platform.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DatabaseHelper {
4141

4242
fun getCommand(name: String): Command? = commandQueries.selectCommandByName(name).executeAsOneOrNull()
4343

44-
fun getCommands(): List<Command> = commandQueries.selectCommands().executeAsList()
44+
fun getCommands(): List<Command> = commandQueries.selectCommands().executeAsList().sortedBy { !it.name.isLetter() }
4545

4646
fun getBasics(): List<BasicCategory> = commandQueries.selectBasicCategories().executeAsList()
4747

0 commit comments

Comments
 (0)