v1
This commit is contained in:
@@ -149,6 +149,7 @@ class MainActivity : ComponentActivity() {
|
||||
return 0
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||
val shift = event.isShiftPressed || (event.metaState and KeyEvent.META_SHIFT_ON != 0)
|
||||
if (isShiftPressedState.value != shift) {
|
||||
@@ -506,8 +507,8 @@ fun MainScreen(
|
||||
viewModel.selectLightPen(addr)
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onGraphicTouch = { px, py ->
|
||||
viewModel.handleGraphicTouch(px, py)
|
||||
onGraphicTouch = { clickAddr, px, py ->
|
||||
viewModel.handleGraphicTouch(clickAddr, px, py)
|
||||
},
|
||||
onPasteText = { text ->
|
||||
viewModel.pasteString(text)
|
||||
|
||||
@@ -330,14 +330,14 @@ class TerminalViewModel(application: Application) : AndroidViewModel(application
|
||||
val curRow = curAddr / cols
|
||||
val curCol = curAddr % cols
|
||||
|
||||
var startRow = curRow
|
||||
var startCol = curCol
|
||||
val startRow: Int
|
||||
val startCol: Int
|
||||
if (forward) {
|
||||
startCol = (curCol + 1) % cols
|
||||
if (startCol == 0) startRow = (curRow + 1) % rows
|
||||
startRow = if (startCol == 0) (curRow + 1) % rows else curRow
|
||||
} else {
|
||||
startCol = (curCol - 1 + cols) % cols
|
||||
if (startCol == cols - 1) startRow = (curRow - 1 + rows) % rows
|
||||
startRow = if (startCol == cols - 1) (curRow - 1 + rows) % rows else curRow
|
||||
}
|
||||
|
||||
val dir = if (forward) haus.nightmare.lib3270j.ecl.ECLConstants.SEARCH_FORWARD else haus.nightmare.lib3270j.ecl.ECLConstants.SEARCH_BACKWARD
|
||||
@@ -752,9 +752,13 @@ class TerminalViewModel(application: Application) : AndroidViewModel(application
|
||||
|
||||
fun getGocaDecoder(): haus.nightmare.lib3270j.graphics.GocaDecoder? = client?.gocaDecoder
|
||||
|
||||
fun handleGraphicTouch(px: Int, py: Int, button: Int = 1, shift: Boolean = false, ctrl: Boolean = false) {
|
||||
fun handleGraphicTouch(clickAddr: Int = -1, px: Int, py: Int, button: Int = 1, shift: Boolean = false, ctrl: Boolean = false) {
|
||||
val c = client ?: return
|
||||
val goca = c.gocaDecoder ?: return
|
||||
if (clickAddr >= 0) {
|
||||
c.screenBuffer?.cursorAddress = clickAddr
|
||||
_cursorAddress.value = clickAddr
|
||||
}
|
||||
if (goca.isGraphicsCursorActive) {
|
||||
goca.setGraphicCursorFromPixel(px, py)
|
||||
c.inputProcessor.sendGraphicMouseAid(
|
||||
|
||||
@@ -31,7 +31,7 @@ fun OiaStatusBar(
|
||||
isLightPenMode: Boolean = false,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val row = if (cols > 0) (cursorAddr / cols) + 1 else 1
|
||||
val row = if (cols > 0 && rows > 0) ((cursorAddr / cols) % rows) + 1 else 1
|
||||
val col = if (cols > 0) (cursorAddr % cols) + 1 else 1
|
||||
val posStr = String.format("%02d/%02d", row, col)
|
||||
|
||||
|
||||
@@ -416,15 +416,40 @@ private fun generateBitmap(
|
||||
currentProt = (faVal and FA_PROTECT) != 0
|
||||
currentHi = (faVal and FA_INT_HIGH_SEL) == FA_INT_HIGH_SEL
|
||||
currentHidden = (faVal and FA_INT_HIGH_SEL) == 0
|
||||
} else if (!currentHidden || !maskHidden) {
|
||||
val ch = cell.ucs4
|
||||
if (ch in ' '..'~' || ch > '\u007F') {
|
||||
textPaint.color = when {
|
||||
currentHi -> android.graphics.Color.WHITE
|
||||
currentProt -> android.graphics.Color.parseColor("#3399FF")
|
||||
else -> android.graphics.Color.parseColor("#00FF66")
|
||||
} else {
|
||||
val csVal = cell.cs.toInt() and 0xFF
|
||||
val ecVal = cell.ec.toInt() and 0xFF
|
||||
var drawnAsPs = false
|
||||
if (csVal >= 0x40 && programSymbolManager != null) {
|
||||
val slot = programSymbolManager.getSymbol(csVal, ecVal)
|
||||
if (slot != null) {
|
||||
val symWidth = slot.width
|
||||
val symHeight = slot.height
|
||||
val fgArgb = when {
|
||||
currentHi -> android.graphics.Color.WHITE
|
||||
currentProt -> android.graphics.Color.parseColor("#3399FF")
|
||||
else -> android.graphics.Color.parseColor("#00FF66")
|
||||
}
|
||||
val bgArgb = android.graphics.Color.parseColor("#0A0A0A")
|
||||
val rgbArray = slot.getRgbPixels(fgArgb, bgArgb)
|
||||
if (rgbArray != null && symWidth > 0 && symHeight > 0) {
|
||||
val symBmp = Bitmap.createBitmap(rgbArray, symWidth, symHeight, Bitmap.Config.ARGB_8888)
|
||||
canvas.drawBitmap(symBmp, null, android.graphics.RectF(left, top, left + charWidth, top + charHeight), null)
|
||||
drawnAsPs = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!drawnAsPs && (!currentHidden || !maskHidden)) {
|
||||
val ch = cell.ucs4
|
||||
if (ch in ' '..'~' || ch > '\u007F') {
|
||||
textPaint.color = when {
|
||||
currentHi -> android.graphics.Color.WHITE
|
||||
currentProt -> android.graphics.Color.parseColor("#3399FF")
|
||||
else -> android.graphics.Color.parseColor("#00FF66")
|
||||
}
|
||||
canvas.drawText(ch.toString(), left + 2f, top + 18f, textPaint)
|
||||
}
|
||||
canvas.drawText(ch.toString(), left + 2f, top + 18f, textPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ fun TerminalView(
|
||||
searchHighlightLen: Int = 0,
|
||||
onTapAddress: (Int) -> Unit,
|
||||
onLightPenSelect: ((Int) -> Unit)? = null,
|
||||
onGraphicTouch: ((Int, Int) -> Unit)? = null,
|
||||
onGraphicTouch: ((Int, Int, Int) -> Unit)? = null,
|
||||
onPasteText: (String) -> Unit = {},
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -162,7 +162,8 @@ fun TerminalView(
|
||||
val gHeight = graphicsPlane?.canvasHeight ?: gridH.toInt()
|
||||
val px = if (gridW > 0 && gWidth > 0) (((startPos.x - metrics.offsetX) * gWidth) / gridW).toInt().coerceIn(0, gWidth - 1) else (startPos.x - metrics.offsetX).toInt()
|
||||
val py = if (gridH > 0 && gHeight > 0) (((startPos.y - metrics.offsetY) * gHeight) / gridH).toInt().coerceIn(0, gHeight - 1) else (startPos.y - metrics.offsetY).toInt()
|
||||
onGraphicTouch?.invoke(px, py)
|
||||
screenBuffer?.cursorAddress = clickAddr
|
||||
onGraphicTouch?.invoke(clickAddr, px, py)
|
||||
} else if (isLightPenMode) {
|
||||
onLightPenSelect?.invoke(clickAddr)
|
||||
} else {
|
||||
@@ -351,7 +352,7 @@ fun TerminalView(
|
||||
val symHeight = slot.height
|
||||
val rgbArray = slot.getRgbPixels(fgColor.toArgb(), bgColor.toArgb())
|
||||
if (rgbArray != null && symWidth > 0 && symHeight > 0) {
|
||||
val bmp = android.graphics.Bitmap.createBitmap(rgbArray as IntArray, symWidth, symHeight, android.graphics.Bitmap.Config.ARGB_8888)
|
||||
val bmp = android.graphics.Bitmap.createBitmap(rgbArray, symWidth, symHeight, android.graphics.Bitmap.Config.ARGB_8888)
|
||||
drawContext.canvas.nativeCanvas.drawBitmap(
|
||||
bmp,
|
||||
null,
|
||||
|
||||
Reference in New Issue
Block a user