Expand manpage and terminal output sizing
This commit is contained in:
@@ -186,7 +186,10 @@ fun GitHugApp() {
|
||||
}
|
||||
}
|
||||
|
||||
fun applyRecommendedPaneWeights(persist: Boolean = true) {
|
||||
fun applyRecommendedPaneWeights(
|
||||
persist: Boolean = true,
|
||||
outputLineCount: Int = terminalOutputLineCount(output),
|
||||
) {
|
||||
updatePaneLayout(
|
||||
transform = { layout ->
|
||||
layout.copy(
|
||||
@@ -194,7 +197,7 @@ fun GitHugApp() {
|
||||
heights = recommendedPaneHeights(
|
||||
level = currentLevel,
|
||||
levelCount = levels.size,
|
||||
outputLineCount = output.size,
|
||||
outputLineCount = outputLineCount,
|
||||
screenHeightDp = screenHeightDp,
|
||||
suggestionsVisible = activeExerciseDetail == ExerciseDetailPanel.SUGGESTIONS,
|
||||
visibleHint = visibleHint,
|
||||
@@ -223,7 +226,7 @@ fun GitHugApp() {
|
||||
editorState = null
|
||||
gitMessageEditorState = null
|
||||
manPageState = null
|
||||
applyRecommendedPaneWeights(persist = false)
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(listOf(message)))
|
||||
}
|
||||
|
||||
fun loadLevel(
|
||||
@@ -307,7 +310,9 @@ fun GitHugApp() {
|
||||
|
||||
val replacement = if (matches.size == 1) matches.first() else commonPrefix(matches)
|
||||
if (replacement == token && matches.size > 1) {
|
||||
output = output + "completion> ${matches.joinToString(" ")}"
|
||||
val newOutput = output + "completion> ${matches.joinToString(" ")}"
|
||||
output = newOutput
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -353,15 +358,17 @@ fun GitHugApp() {
|
||||
AppLog.d("GitHugApp", "All levels completed")
|
||||
scope.launch { persistProgress(updatedCompletedLevels, levels.lastOrNull()?.id) }
|
||||
repo = newRepo
|
||||
output = newOutput + listOf("🏁 All Githug levels completed.")
|
||||
val completedOutput = newOutput + listOf("🏁 All Githug levels completed.")
|
||||
output = completedOutput
|
||||
clearCommandInput()
|
||||
suppressedImeEcho = null
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(completedOutput))
|
||||
}
|
||||
} else {
|
||||
AppLog.d("GitHugApp", "Staying on level=${levelForResult.id}")
|
||||
repo = newRepo
|
||||
output = newOutput
|
||||
applyRecommendedPaneWeights(persist = false)
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +379,7 @@ fun GitHugApp() {
|
||||
} else {
|
||||
runtime.readEditorFile(currentLevel, repo, path)
|
||||
}
|
||||
output = buildList {
|
||||
val newOutput = buildList {
|
||||
addAll(output)
|
||||
add("$ ${invocation.command}")
|
||||
addAll(lines)
|
||||
@@ -380,6 +387,7 @@ fun GitHugApp() {
|
||||
add("Opened ${invocation.editor} editor${if (path.isBlank()) "" else " for $path"}")
|
||||
}
|
||||
}
|
||||
output = newOutput
|
||||
if (lines.isEmpty()) {
|
||||
editorState = TextEditorState(
|
||||
editor = invocation.editor,
|
||||
@@ -389,18 +397,19 @@ fun GitHugApp() {
|
||||
saveAsPath = path,
|
||||
)
|
||||
}
|
||||
applyRecommendedPaneWeights(persist = false)
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
}
|
||||
|
||||
fun openManPage(invocation: GitHelpInvocation) {
|
||||
val content = runtime.gitManPage(currentLevel, repo, invocation.topic)
|
||||
output = buildList {
|
||||
val newOutput = buildList {
|
||||
addAll(output)
|
||||
add("$ ${invocation.command}")
|
||||
add("Opened git help viewer for ${invocation.topic}")
|
||||
}
|
||||
output = newOutput
|
||||
manPageState = ManPageState(topic = invocation.topic, content = content)
|
||||
applyRecommendedPaneWeights(persist = false)
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
}
|
||||
|
||||
fun openGitMessageEditor(invocation: GitEditorInvocation) {
|
||||
@@ -410,16 +419,17 @@ fun GitHugApp() {
|
||||
GitEditorCommandKind.PATCH_HUNK -> "Opened Git patch editor"
|
||||
else -> "Opened Git message editor"
|
||||
}
|
||||
output = buildList {
|
||||
val newOutput = buildList {
|
||||
addAll(output)
|
||||
add("$ ${invocation.command}")
|
||||
add(openedMessage)
|
||||
}
|
||||
output = newOutput
|
||||
gitMessageEditorState = GitMessageEditorState(
|
||||
invocation = invocation.copy(initialContent = initialContent),
|
||||
content = initialContent,
|
||||
)
|
||||
applyRecommendedPaneWeights(persist = false)
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
}
|
||||
|
||||
fun saveEditor() {
|
||||
@@ -490,7 +500,9 @@ fun GitHugApp() {
|
||||
}
|
||||
|
||||
fun showCommandHelp() {
|
||||
output = output + runtime.commandReferenceLines()
|
||||
val newOutput = output + runtime.commandReferenceLines()
|
||||
output = newOutput
|
||||
applyRecommendedPaneWeights(persist = false, outputLineCount = terminalOutputLineCount(newOutput))
|
||||
}
|
||||
|
||||
fun registerHeaderTap() {
|
||||
|
||||
Reference in New Issue
Block a user