Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
private var streamedOutput: TerminalOutputBuffer? = null
private var cols = 0
private var rows = 0
private var cellSize = 0 to 0
private var measuredCols = 0
private var measuredRows = 0
private var clearingInput = false
Expand Down Expand Up @@ -356,25 +357,24 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
applyGrid()
}

@Suppress("ComplexCondition")
private fun applyGrid() {
if (measuredCols <= 0 || measuredRows <= 0 || isCleanedUp) return
val shared = sharedGrid.takeIf { it.size == 2 && it[0] > 0 && it[1] > 0 }
val nextCols = shared?.get(0)?.coerceAtMost(measuredCols) ?: measuredCols
val nextRows = shared?.get(1)?.coerceAtMost(measuredRows) ?: measuredRows
if (nextCols == cols && nextRows == rows && terminalHandle != 0L) return
val nextCellSize = terminalCanvas.cellWidthPx.toInt() to terminalCanvas.cellHeightPx.toInt()
if (nextCols == cols && nextRows == rows && nextCellSize == cellSize && terminalHandle != 0L) {
return
}
cols = nextCols
rows = nextRows
cellSize = nextCellSize
val response = if (terminalHandle == 0L) {
createTerminal()
ByteArray(0)
} else {
GhosttyBridge.nativeResize(
terminalHandle,
cols,
rows,
terminalCanvas.cellWidthPx.toInt(),
terminalCanvas.cellHeightPx.toInt(),
)
GhosttyBridge.nativeResize(terminalHandle, cols, rows, cellSize.first, cellSize.second)
}
emitResponse(response)
if (!hasPendingBuffer) feedPendingBuffer()
Expand All @@ -387,8 +387,8 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
terminalHandle = GhosttyBridge.nativeCreate(
cols,
rows,
terminalCanvas.cellWidthPx.toInt(),
terminalCanvas.cellHeightPx.toInt(),
cellSize.first,
cellSize.second,
foregroundColorValue,
backgroundColorValue,
cursorColorValue,
Expand Down
Loading