- Split core game models from sandbox engine, native level setup, and repo state saving. - Move app overlays and completion helpers out of GitHugApp. - Extract the terminal special key bar into its own component.
30 lines
963 B
Kotlin
30 lines
963 B
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
internal fun fileCompletionCandidates(repo: RepoState): List<String> {
|
|
val prefix = repo.currentDirPrefix()
|
|
return repo.files
|
|
.filterNot { it.deleted }
|
|
.map { it.name }
|
|
.filter { it.startsWith(prefix) }
|
|
.map { it.removePrefix(prefix) }
|
|
.filter { it.isNotBlank() }
|
|
}
|
|
|
|
internal fun directoryCompletionCandidates(repo: RepoState): List<String> {
|
|
val prefix = repo.currentDirPrefix()
|
|
return repo.files
|
|
.filterNot { it.deleted }
|
|
.map { it.name }
|
|
.filter { it.startsWith(prefix) }
|
|
.map { it.removePrefix(prefix) }
|
|
.flatMap { file ->
|
|
val parts = file.split('/').dropLast(1)
|
|
parts.indices.map { index -> parts.take(index + 1).joinToString("/") + "/" }
|
|
}
|
|
.distinct()
|
|
}
|
|
|
|
private fun RepoState.currentDirPrefix(): String {
|
|
return if (currentDir == ".") "" else currentDir.trimEnd('/') + "/"
|
|
}
|