Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
14bf7ba4b1
|
|||
|
bdfe6eec2a
|
|||
|
c28c097e25
|
|||
|
46a022d86b
|
|||
|
59925c2787
|
|||
|
f8fc0e4b22
|
|||
|
dbcb0aa1b6
|
|||
|
50a4279446
|
|||
|
6331e0108b
|
|||
|
79d493c24d
|
|||
|
74e30d1ead
|
|||
|
cbb310b889
|
|||
|
6296cf4341
|
+18
-10
@@ -9,8 +9,12 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build JAR & Run Tests
|
||||
name: Build JAR & Run Tests (Java ${{ matrix.java }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java: [ '11', '17', '21' ]
|
||||
|
||||
steps:
|
||||
- name: Configure Dynamic DNS Resolvers
|
||||
@@ -23,21 +27,21 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java JDK (Temurin 17)
|
||||
- name: Set up Java JDK (Temurin ${{ matrix.java }})
|
||||
uses: actions/setup-java@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Ensure Java Available
|
||||
run: |
|
||||
if ! command -v javac >/dev/null 2>&1; then
|
||||
echo "Installing OpenJDK 17 via package manager..."
|
||||
echo "Installing OpenJDK ${{ matrix.java }} via package manager..."
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get update && apt-get install -y openjdk-17-jdk-headless || true
|
||||
apt-get update && apt-get install -y openjdk-${{ matrix.java }}-jdk-headless || true
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
apk add --no-cache openjdk17 || true
|
||||
apk add --no-cache openjdk${{ matrix.java }} || true
|
||||
fi
|
||||
fi
|
||||
echo "Java compiler:"
|
||||
@@ -53,23 +57,27 @@ jobs:
|
||||
run: |
|
||||
sh ./test_all.sh
|
||||
|
||||
- name: Prepare Versioned JAR
|
||||
run: |
|
||||
cp build/j3270.jar "build/j3270-java${{ matrix.java }}.jar"
|
||||
|
||||
- name: Upload j3270 Executable JAR Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: j3270-executable-jar
|
||||
path: build/j3270.jar
|
||||
name: j3270-java${{ matrix.java }}-jar
|
||||
path: build/j3270-java${{ matrix.java }}.jar
|
||||
|
||||
- name: Upload Test Reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: test-reports
|
||||
name: test-reports-java${{ matrix.java }}
|
||||
path: build/reports/tests/
|
||||
|
||||
- name: Report Build Status
|
||||
if: failure()
|
||||
run: |
|
||||
echo "### ❌ Build or Test Failed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### ❌ Build or Test Failed for Java ${{ matrix.java }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Please check the runner logs above for details." >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -9,8 +9,12 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build JAR & Run Tests
|
||||
name: Build JAR & Run Tests (Java ${{ matrix.java }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java: [ '11', '17', '21' ]
|
||||
|
||||
steps:
|
||||
- name: Configure Dynamic DNS Resolvers
|
||||
@@ -23,21 +27,21 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java JDK (Temurin 17)
|
||||
- name: Set up Java JDK (Temurin ${{ matrix.java }})
|
||||
uses: actions/setup-java@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Ensure Java Available
|
||||
run: |
|
||||
if ! command -v javac >/dev/null 2>&1; then
|
||||
echo "Installing OpenJDK 17 via package manager..."
|
||||
echo "Installing OpenJDK ${{ matrix.java }} via package manager..."
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get update && apt-get install -y openjdk-17-jdk-headless || true
|
||||
apt-get update && apt-get install -y openjdk-${{ matrix.java }}-jdk-headless || true
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
apk add --no-cache openjdk17 || true
|
||||
apk add --no-cache openjdk${{ matrix.java }} || true
|
||||
fi
|
||||
fi
|
||||
echo "Java compiler:"
|
||||
@@ -53,23 +57,27 @@ jobs:
|
||||
run: |
|
||||
sh ./test_all.sh
|
||||
|
||||
- name: Prepare Versioned JAR
|
||||
run: |
|
||||
cp build/j3270.jar "build/j3270-java${{ matrix.java }}.jar"
|
||||
|
||||
- name: Upload j3270 Executable JAR Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: j3270-executable-jar
|
||||
path: build/j3270.jar
|
||||
name: j3270-java${{ matrix.java }}-jar
|
||||
path: build/j3270-java${{ matrix.java }}.jar
|
||||
|
||||
- name: Upload Test Reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: test-reports
|
||||
name: test-reports-java${{ matrix.java }}
|
||||
path: build/reports/tests/
|
||||
|
||||
- name: Report Build Status
|
||||
if: failure()
|
||||
run: |
|
||||
echo "### ❌ Build or Test Failed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### ❌ Build or Test Failed for Java ${{ matrix.java }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Please check the runner logs above for details." >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
j3270.log.*
|
||||
*.bin
|
||||
*.txt
|
||||
*.py
|
||||
*.pcap
|
||||
@@ -8,3 +9,4 @@ build/*
|
||||
*.jar
|
||||
build
|
||||
.gradle
|
||||
*.txt
|
||||
|
||||
@@ -2,29 +2,43 @@
|
||||
|
||||
[](https://git.hugfreevikings.wtf/rudi/j3270/actions)
|
||||
[](https://git.hugfreevikings.wtf/rudi/j3270/releases)
|
||||
[](https://adoptium.net)
|
||||
[-blue.svg)](https://adoptium.net)
|
||||
[]()
|
||||
[](LICENSE)
|
||||
|
||||
An **x3270-aligned IBM 3270 mainframe terminal emulator** written in pure Java. Designed for high compatibility with IBM z/OS, z/VM, CMS, and TSO systems over TN3270 and TN3270E.
|
||||
An **x3270-aligned and IBM Host On-Demand (HoD) compatible IBM 3270 mainframe terminal emulator & protocol library** written in pure Java with zero third-party runtime dependencies. Designed for high fidelity and compatibility with IBM z/OS, z/VM, and 3270-based systems over TN3270 and TN3270E.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Download & Run
|
||||
|
||||
### Latest Standalone JAR
|
||||
You can download the ready-to-run executable JAR directly from the releases or CI builds:
|
||||
### Latest Standalone JARs
|
||||
Ready-to-run executable JARs are built and tested across all three Java LTS baselines (**Java 11, Java 17, and Java 21**) by Gitea Actions:
|
||||
|
||||
- **[Download Latest Tagged Release (`j3270.jar`)](https://git.hugfreevikings.wtf/rudi/j3270/releases)**
|
||||
- **[Latest Nightly CI Artifacts](https://git.hugfreevikings.wtf/rudi/j3270/actions)** (Download under the latest successful workflow run)
|
||||
- **[Latest Nightly CI Artifacts](https://git.hugfreevikings.wtf/rudi/j3270/actions)**: Download standalone JARs tailored for each LTS runtime under the latest workflow run:
|
||||
- `j3270-java11-jar` (Java 11 LTS)
|
||||
- `j3270-java17-jar` (Java 17 LTS — primary Gitea runner baseline)
|
||||
- `j3270-java21-jar` (Java 21 LTS)
|
||||
|
||||
### Java Runtime Requirements
|
||||
Requires **Java 11 or higher** (LTS versions: **Java 11, 17, 21**; also compatible with Java 24).
|
||||
|
||||
The project is tested and verified against:
|
||||
- **Eclipse Temurin** (Adoptium OpenJDK HotSpot) — used in Gitea Actions CI workflows.
|
||||
- **IBM Semeru Runtimes** (OpenJ9) — e.g. `11.0.32-sem`, `21.0.6-sem`, and `24.0.2-sem` via SDKMAN.
|
||||
|
||||
### Running `j3270`
|
||||
Requires **Java 11 or higher** (Java 11, 17, 21+):
|
||||
|
||||
```bash
|
||||
# Launch interactive GUI
|
||||
# Launch interactive Swing GUI
|
||||
java -jar j3270.jar
|
||||
|
||||
# Connect to TLS/SSL mainframe with custom port
|
||||
# Connect to mainframe with host, port, and terminal model (Models 2-5 or 'dynamic')
|
||||
java -jar j3270.jar mainframe.example.com 23 4
|
||||
java -jar j3270.jar mainframe.example.com 23 dynamic
|
||||
|
||||
# Connect to TLS/SSL mainframe on custom or standard (992) port
|
||||
java -jar j3270.jar -s mainframe.example.com 992
|
||||
# Or using standard x3270 L: prefix
|
||||
java -jar j3270.jar L:mainframe.example.com:992
|
||||
@@ -35,12 +49,19 @@ java -jar j3270.jar -P mainframe.example.com 23
|
||||
java -jar j3270.jar P:mainframe.example.com:23
|
||||
|
||||
# Connect with unverified/self-signed certificate verification bypass
|
||||
java -jar j3270.jar --tls --insecure mainframe.example.com 992
|
||||
java -jar j3270.jar -s --insecure mainframe.example.com 992
|
||||
|
||||
# Launch with custom configuration file
|
||||
# Enable GDDM/GOCA host graphics explicitly (or disable via --no-graphics)
|
||||
java -jar j3270.jar -g GOCA mainframe.example.com
|
||||
java -jar j3270.jar --no-graphics mainframe.example.com
|
||||
|
||||
# Launch with custom INI configuration profile
|
||||
java -jar j3270.jar -c config.ini
|
||||
|
||||
# Launch directly from source runner
|
||||
# Enable protocol and diagnostic debug logging to j3270.log
|
||||
java -jar j3270.jar -d mainframe.example.com
|
||||
|
||||
# Launch directly from source runner script
|
||||
./run.sh
|
||||
```
|
||||
|
||||
@@ -48,39 +69,108 @@ java -jar j3270.jar -c config.ini
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- **TN3270 & TN3270E Protocol Support**: RFC 2355 compliant state machine, negotiation, Device-Type query, plain TN3270 fallback, and SSL/TLS encryption.
|
||||
- **SSL/TLS Security**:
|
||||
- Encrypted TN3270 over TLS connections on standard port `992` or custom ports.
|
||||
- Interactive certificate verification prompt for self-signed or untrusted certificates with fingerprint, subject, issuer, and validity inspection.
|
||||
- Optional unverified/insecure mode for testing and headless scripting.
|
||||
- **IND$FILE File Transfer**: Full support for both **CUT** and **DFT (DDM)** high-speed structured field transfers with ASCII/binary translation, CRLF handling, and recfm/lrecl formatting for TSO, VM/CMS, and CICS.
|
||||
- **z/VM & Line-Mode Support**: Proper SSCP-LU and unformatted line handling (`CP TERM CONMODE 3270` supported).
|
||||
- **APL & Graphic Escape**: Comprehensive box-drawing and math symbol character rendering.
|
||||
- **Terminal Models**:
|
||||
### 🌐 Protocol & Telnet Engine
|
||||
- **TN3270 & TN3270E (RFC 2355)**: Full compliant finite-state machine, Device-Type negotiation, Functions negotiation (`BIND-IMAGE`, `RESPONSES`, `SYSREQ`), plain TN3270 fallback, and NVT (Network Virtual Terminal) mode.
|
||||
- **SSCP-LU & Unformatted Line Mode**: Native z/VM line-mode support (`CP TERM CONMODE 3270`).
|
||||
- **Terminal Models & Dynamic Geometry**:
|
||||
- Model 2 (24x80)
|
||||
- Model 3 (32x80)
|
||||
- Model 4 (43x80)
|
||||
- Model 5 (27x132)
|
||||
- **Zero-Dependency Core**: Modular architecture separated into:
|
||||
- `lib3270j`: Reusable Java 3270 protocol, data stream parser, charset translation, and telnet state machine.
|
||||
- `j3270`: Desktop Swing user interface and session management.
|
||||
- `IBM-DYNAMIC` (Model 0 dynamic geometry auto-negotiation via Usable Area Query Reply).
|
||||
- **Enterprise Proxy Support**: SOCKS5 and HTTP CONNECT proxy tunneling with optional authentication.
|
||||
|
||||
### 🔒 Security & Encryption
|
||||
- **Modern TLS 1.2 / 1.3**: Encrypted TN3270 over TLS on standard port `992` or custom ports via JSSE.
|
||||
- **Interactive Certificate Verification**: Security dialog for untrusted or self-signed certificates displaying SHA-256 fingerprints, subject, issuer, and validity dates with user approval prompt.
|
||||
- **Headless Insecure Mode**: `--insecure` / `-k` option for scripted environments and test mainframes.
|
||||
|
||||
### 🎨 GDDM / GOCA Host Vector Graphics (IBM 3179G)
|
||||
- **Vector Drawing Orders**: Polylines, relative lines, circular & elliptical arcs, fillets, and multi-polygon area fills with boundary detection and alternate/winding rules.
|
||||
- **1:1 Color Calibration**: 16-color GOCA palette and base 4-color mapping calibrated 1:1 against IBM Host On-Demand (HoD).
|
||||
- **Shading, Patterns & Overlays**: Patterned area fills, geometric markers, and uncompressed / run-length bit-image and wallpaper overlays.
|
||||
- **Vector Symbol Fonts (VSS)**: Stroked vector typography with baseline rotation angle (`GSCA`), shear (`GSCR`), and micro-scale anti-aliased sub-pixel rendering.
|
||||
- **Programmed Symbols (PSS / PSA)**: Support for single-plane and triple-plane multi-color composite symbols.
|
||||
- **Interactive Graphics Input**: Mouse click pick correlation mapping display coordinates to host graphics space, 56-byte Graphic Input structured field generation, and immediate/deferred light pen selection.
|
||||
|
||||
### 🖨️ IBM 3287/3286 Host Printing Emulation
|
||||
- **Autonomous Printer Sessions**: TN3270E host print sessions supporting SCS (SNA Character String / LU-Type 1) and DSC/DSE (Data Stream Compatibility / LU-Type 3).
|
||||
- **Double-Byte DBCS Printing**: Pitch adjustments, character spacing, and grid line formatting (`PrintSCS3270DB`, `PrintPS3270DB`).
|
||||
- **Flexible Print Output**: Printer Definition Table (PDT) integration, print spooling to local files, or dispatch directly to system print queues.
|
||||
|
||||
### 📁 IND$FILE File Transfer & Host Catalog
|
||||
- **Full Protocol Coverage**: Support for both **CUT** and high-speed **DFT (DDM)** structured field transfers for TSO, VM/CMS, and CICS.
|
||||
- **Translation Modes**: Automatic ASCII/EBCDIC text translation, CRLF conversions, and transparent binary transfers.
|
||||
- **Dataset Formatting**: Full control over Record Format (`RECFM` F/V/U), Logical Record Length (`LRECL`), Block Size (`BLKSIZE`), and Space allocation.
|
||||
- **Host Catalog Browser**: Interactive directory dialog to query, parse, and browse CMS and TSO host dataset catalogs.
|
||||
|
||||
### 🌍 Internationalization & Character Sets
|
||||
- **22+ Single-Byte EBCDIC Codepages**: US/Canada (037), Open Systems / z/OS Unix (1047), International (500, 1148 Euro), UK (285), Germany/Austria (273, 1141 Euro), France (297), Italy (280), Spain (284), Scandinavia (277, 278), Greece (875), Turkey (1026, 1155, 905), Eastern Europe (870), Iceland (871), Cyrillic (1025, 1123, 1154, 880), Hebrew (424, 803), Arabic (420), Thai (838, 1160).
|
||||
- **Mixed DBCS Support**: Japanese Katakana (930), Japanese Latin (939), Simplified Chinese (935, 1388), Traditional Chinese (937, 1371), and Korean (933) with Shift-In (`0x0E`) / Shift-Out (`0x0F`) state handling.
|
||||
- **APL & Special Graphics**: APL keyboard mode, box-drawing characters, and Graphic Escape (`GE`) symbol translations.
|
||||
|
||||
### 🏛️ IBM Host On-Demand ECL API Alignment
|
||||
- Reusable public API compliant with IBM Host On-Demand (HoD) v14 specifications under `com.ibm.eNetwork.ECL.*` and `haus.nightmare.lib3270j.ecl.*`.
|
||||
- Drop-in implementations for `ECLSession`, `ECLPS` (Presentation Space), `ECLOIA` (Operator Information Area), `ECLConnection`, `ECLField`, `ECLFieldList`, `ECLScreenDesc`, `ECLScreenReco`, and `ECLXfer`.
|
||||
|
||||
### 🖥️ Desktop User Interface (j3270)
|
||||
- **Themes**: Modern Dark and Light UI themes with instant switching.
|
||||
- **Dynamic Font Scaling**: Real-time font size adjustments (`Cmd/Ctrl +`, `Cmd/Ctrl -`, `Cmd/Ctrl 0`) with smooth scaling and guarded window repacking.
|
||||
- **Screen Search**: Full-screen text search dialog (`Cmd/Ctrl + F`) with forward/backward navigation and case-sensitivity controls.
|
||||
- **Screen Exporter**: Save screen images and content as plain text, HTML, or PNG.
|
||||
- **Field Inspector**: Interactive inspection tool displaying 3270 field boundaries, buffer addresses, protection, highlighting, and color attributes.
|
||||
- **Scripting & Keystroke Macros**: Interactive mnemonic keystroke playback dialog supporting standard x3270 action strings.
|
||||
- **Word Processing Modes**: Document Mode (DOC), Word Wrap, audible margin bell, and tab stop navigation.
|
||||
- **Visual Aids**: Crosshair ruler and configurable cursor styles (block cursor, underline cursor with alpha blending).
|
||||
- **Persistent Profiles**: Configuration profiles and session preferences saved in INI files (`j3270.ini`).
|
||||
|
||||
### 📦 Modular Zero-Dependency Core
|
||||
- **`lib3270j`**: Standalone Java protocol and terminal engine with **zero third-party dependencies** (`java.base`, `java.desktop` only).
|
||||
- **`j3270`**: Standalone desktop Swing terminal application.
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Building from Source
|
||||
|
||||
### Standalone Build (No Gradle Required)
|
||||
The project includes self-contained, portable build scripts:
|
||||
### Quick Setup & Build for End Users
|
||||
|
||||
Self-contained setup scripts automatically locate an installed Java 11+ JDK (searching `JAVA_HOME`, system `PATH`, macOS `java_home`, Homebrew, Linux JVM paths, Windows Registry, standard installation directories, and package managers), compile `lib3270j` and `j3270`, and package the standalone executable JAR (`build/j3270.jar`):
|
||||
|
||||
**Linux / macOS (POSIX Shell):**
|
||||
```bash
|
||||
# Build executable JAR in 2 seconds:
|
||||
sh ./build_all.sh
|
||||
# Setup and build standalone executable JAR:
|
||||
./setup.sh
|
||||
|
||||
# Run all 57 automated unit tests in ~500ms:
|
||||
sh ./test_all.sh
|
||||
# Build and immediately launch:
|
||||
./setup.sh --run
|
||||
|
||||
# Clean build and connect to host:
|
||||
./setup.sh --clean --run -- mainframe.example.com 23 4
|
||||
```
|
||||
|
||||
The resulting standalone JAR is created at `build/j3270.jar`.
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
# Setup and build standalone executable JAR:
|
||||
.\setup.ps1
|
||||
|
||||
# Build and immediately launch:
|
||||
.\setup.ps1 -Run
|
||||
|
||||
# Clean build and connect to host:
|
||||
.\setup.ps1 -Clean -Run -- mainframe.example.com 23 4
|
||||
```
|
||||
*(Also available as `.\setup.ps`)*
|
||||
|
||||
### Standalone Build (Advanced / CI)
|
||||
The project also provides low-level scripts and optional Gradle support:
|
||||
|
||||
```bash
|
||||
# Direct compile and package without diagnostics:
|
||||
sh ./build_all.sh
|
||||
|
||||
# Run all 539+ automated unit tests (~7s):
|
||||
sh ./test_all.sh
|
||||
```
|
||||
|
||||
### Gradle Build (Optional)
|
||||
```bash
|
||||
@@ -88,6 +178,9 @@ The resulting standalone JAR is created at `build/j3270.jar`.
|
||||
./gradlew test
|
||||
```
|
||||
|
||||
### Continuous Integration
|
||||
All pushes and pull requests are verified across **Java 11, 17, and 21 LTS** runners via Gitea Actions (`.gitea/workflows/build.yaml`).
|
||||
|
||||
---
|
||||
|
||||
## 📜 Acknowledgements
|
||||
|
||||
@@ -17,6 +17,7 @@ subprojects {
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
jvmArgs '-Djava.awt.headless=true'
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
@@ -24,5 +25,6 @@ subprojects {
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
}
|
||||
}
|
||||
|
||||
+24
-10
@@ -14,16 +14,32 @@ if [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/javac" ] && [ -x "$JAVA_HOME/bin/
|
||||
JAVAC_BIN="$JAVA_HOME/bin/javac"
|
||||
JAR_BIN="$JAVA_HOME/bin/jar"
|
||||
elif command -v javac >/dev/null 2>&1 && command -v jar >/dev/null 2>&1; then
|
||||
JAVAC_BIN="$(command -v javac)"
|
||||
JAR_BIN="$(command -v jar)"
|
||||
else
|
||||
# Check common SDKMAN / macOS / Linux JDK locations
|
||||
for h in "$HOME/.sdkman/candidates/java/current" \
|
||||
if javac -version >/dev/null 2>&1; then
|
||||
JAVAC_BIN="$(command -v javac)"
|
||||
JAR_BIN="$(command -v jar)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVAC_BIN" ] || [ -z "$JAR_BIN" ]; then
|
||||
if [ -x /usr/libexec/java_home ]; then
|
||||
MAC_JAVA_HOME="$(/usr/libexec/java_home 2>/dev/null || true)"
|
||||
if [ -n "$MAC_JAVA_HOME" ] && [ -x "$MAC_JAVA_HOME/bin/javac" ] && [ -x "$MAC_JAVA_HOME/bin/jar" ]; then
|
||||
export JAVA_HOME="$MAC_JAVA_HOME"
|
||||
JAVAC_BIN="$JAVA_HOME/bin/javac"
|
||||
JAR_BIN="$JAVA_HOME/bin/jar"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVAC_BIN" ] || [ -z "$JAR_BIN" ]; then
|
||||
# Check standard system JDK installation locations
|
||||
for h in /usr/lib/jvm/default-java \
|
||||
/usr/lib/jvm/java-21-openjdk* \
|
||||
/usr/lib/jvm/java-17-openjdk* \
|
||||
/usr/lib/jvm/java-11-openjdk* \
|
||||
/usr/lib/jvm/default-java \
|
||||
/Library/Java/JavaVirtualMachines/*/Contents/Home; do
|
||||
/Library/Java/JavaVirtualMachines/*/Contents/Home \
|
||||
/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home \
|
||||
/opt/homebrew/opt/openjdk; do
|
||||
if [ -d "$h" ] && [ -x "$h/bin/javac" ] && [ -x "$h/bin/jar" ]; then
|
||||
export JAVA_HOME="$h"
|
||||
JAVAC_BIN="$JAVA_HOME/bin/javac"
|
||||
@@ -131,9 +147,7 @@ public class TestRunner {
|
||||
summary.printTo(new PrintWriter(System.out));
|
||||
summary.printFailuresTo(new PrintWriter(System.err));
|
||||
|
||||
if (summary.getTotalFailureCount() > 0) {
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(summary.getTotalFailureCount() > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Gitea Actions Runner Configuration for j3270
|
||||
|
||||
This repository includes Gitea Actions workflows in `.gitea/workflows/build.yaml` to automatically:
|
||||
1. Compile and run the JUnit 5 test suite via `test_all.sh`.
|
||||
2. Build the standalone `j3270.jar` executable via `build_all.sh`.
|
||||
3. Upload `j3270.jar` as a downloadable artifact.
|
||||
4. Report test results and diagnostics.
|
||||
1. Compile and run the JUnit 5 test suite across the 3 LTS Java versions (Java 11, 17, and 21) via `test_all.sh`.
|
||||
2. Build standalone executables for each LTS version via `build_all.sh`.
|
||||
3. Upload `j3270-java11.jar`, `j3270-java17.jar`, and `j3270-java21.jar` as downloadable artifacts.
|
||||
4. Report test results and diagnostics per runtime.
|
||||
|
||||
---
|
||||
|
||||
@@ -98,7 +98,7 @@ This means Docker's bridge network inside the runner container cannot resolve th
|
||||
You can verify the entire build and test suite locally at any time without external tools:
|
||||
|
||||
```bash
|
||||
# Compile and run all 25 unit tests (130ms):
|
||||
# Compile and run all 539 unit tests (~7s):
|
||||
sh ./test_all.sh
|
||||
|
||||
# Build executable standalone JAR:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,2 +1,249 @@
|
||||
#!/bin/sh
|
||||
exec "$(dirname "$0")/build_all.sh" "$@"
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -45,6 +45,17 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
private FieldInspectorDialog fieldInspectorDialog;
|
||||
private PrinterSessionDialog printerSessionDialog;
|
||||
|
||||
// Modes menu items
|
||||
private JCheckBoxMenuItem docModeItem;
|
||||
private JCheckBoxMenuItem wordWrapItem;
|
||||
private JCheckBoxMenuItem aplModeItem;
|
||||
private JCheckBoxMenuItem insertModeItem;
|
||||
private JCheckBoxMenuItem fourColorItem;
|
||||
private JCheckBoxMenuItem numLockItem;
|
||||
private JCheckBoxMenuItem autoSkipItem;
|
||||
private JCheckBoxMenuItem insertOffAidItem;
|
||||
private JCheckBoxMenuItem statusBarItem;
|
||||
|
||||
public J3270App() {
|
||||
super("j3270 — Java TN3270 Terminal Emulator");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@@ -59,12 +70,15 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
setLocationRelativeTo(null);
|
||||
setMinimumSize(new Dimension(640, 400));
|
||||
|
||||
// Status refresh timer — also ensures focus stays on terminal
|
||||
// Status refresh timer — also ensures focus stays on terminal (guarding against focus stealing)
|
||||
refreshTimer = new Timer(100, e -> {
|
||||
if (client != null) {
|
||||
statusBar.updateStatus();
|
||||
if (isActive() && !terminalPanel.hasFocus()) {
|
||||
terminalPanel.requestFocusInWindow();
|
||||
syncModeMenuItems();
|
||||
if (!isAnyChildDialogActive() && KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() == this) {
|
||||
if (!terminalPanel.hasFocus()) {
|
||||
terminalPanel.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -84,14 +98,38 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
terminalPanel.requestFocusInWindow();
|
||||
if (!isAnyChildDialogActive()) {
|
||||
terminalPanel.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isAnyChildDialogActive() {
|
||||
Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
|
||||
if (focusedWindow != null && focusedWindow != this) {
|
||||
return true;
|
||||
}
|
||||
if (findDialog != null && findDialog.isVisible()) return true;
|
||||
if (scriptDialog != null && scriptDialog.isVisible()) return true;
|
||||
if (fieldInspectorDialog != null && fieldInspectorDialog.isVisible()) return true;
|
||||
if (printerSessionDialog != null && printerSessionDialog.isVisible()) return true;
|
||||
for (Window owned : getOwnedWindows()) {
|
||||
if (owned != null && owned.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void buildUI() {
|
||||
terminalPanel = new TerminalPanel();
|
||||
statusBar = new StatusBar();
|
||||
terminalPanel.setStatusBar(statusBar);
|
||||
terminalPanel.setStatusBarToggleCallback(this::toggleStatusBar);
|
||||
terminalPanel.addModeChangeListener(this::syncModeMenuItems);
|
||||
|
||||
statusBar.setVisible(haus.nightmare.j3270.config.Settings.getStatusBarVisible());
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().setBackground(Color.BLACK);
|
||||
@@ -99,6 +137,17 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
getContentPane().add(statusBar, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
private void syncModeMenuItems() {
|
||||
if (docModeItem != null) docModeItem.setSelected(terminalPanel.isDocMode());
|
||||
if (wordWrapItem != null) wordWrapItem.setSelected(terminalPanel.isWordWrap());
|
||||
if (aplModeItem != null) aplModeItem.setSelected(terminalPanel.isAplMode());
|
||||
if (insertModeItem != null) insertModeItem.setSelected(terminalPanel.isInsertMode());
|
||||
if (fourColorItem != null) fourColorItem.setSelected(haus.nightmare.j3270.config.Settings.getFourColorOverride());
|
||||
if (numLockItem != null) numLockItem.setSelected(haus.nightmare.j3270.config.Settings.getNumericFieldLock());
|
||||
if (autoSkipItem != null) autoSkipItem.setSelected(haus.nightmare.j3270.config.Settings.getAutoSkipEnabled());
|
||||
if (insertOffAidItem != null) insertOffAidItem.setSelected(haus.nightmare.j3270.config.Settings.getInsertOffOnAid());
|
||||
}
|
||||
|
||||
private void onThemeChanged(UITheme theme) {
|
||||
buildMenuBar();
|
||||
statusBar.applyTheme(theme);
|
||||
@@ -178,6 +227,44 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
viewMenu.add(themeMenu);
|
||||
viewMenu.addSeparator();
|
||||
|
||||
statusBarItem = new JCheckBoxMenuItem("Status Bar", statusBar != null ? statusBar.isVisible() : haus.nightmare.j3270.config.Settings.getStatusBarVisible());
|
||||
ThemeManager.styleMenuItem(statusBarItem);
|
||||
statusBarItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.ALT_DOWN_MASK));
|
||||
statusBarItem.addActionListener(e -> setStatusBarVisible(statusBarItem.isSelected()));
|
||||
viewMenu.add(statusBarItem);
|
||||
|
||||
JCheckBoxMenuItem rulerItem = new JCheckBoxMenuItem("Crosshair Ruler", terminalPanel.isCrosshairRulerEnabled());
|
||||
ThemeManager.styleMenuItem(rulerItem);
|
||||
rulerItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
|
||||
rulerItem.addActionListener(e -> {
|
||||
boolean en = rulerItem.isSelected();
|
||||
terminalPanel.setCrosshairRulerEnabled(en);
|
||||
haus.nightmare.j3270.config.Settings.setCrosshairRuler(en);
|
||||
});
|
||||
viewMenu.add(rulerItem);
|
||||
|
||||
JMenu cursorMenu = createMenu("Cursor Style");
|
||||
ButtonGroup cursorGroup = new ButtonGroup();
|
||||
JRadioButtonMenuItem blockCursorItem = new JRadioButtonMenuItem("Block Cursor", terminalPanel.getCursorStyle() == TerminalPanel.CursorStyle.BLOCK);
|
||||
ThemeManager.styleMenuItem(blockCursorItem);
|
||||
blockCursorItem.addActionListener(e -> {
|
||||
terminalPanel.setCursorStyle(TerminalPanel.CursorStyle.BLOCK);
|
||||
haus.nightmare.j3270.config.Settings.setCursorStyle("BLOCK");
|
||||
});
|
||||
cursorGroup.add(blockCursorItem);
|
||||
cursorMenu.add(blockCursorItem);
|
||||
|
||||
JRadioButtonMenuItem underlineCursorItem = new JRadioButtonMenuItem("Underline Cursor", terminalPanel.getCursorStyle() == TerminalPanel.CursorStyle.UNDERLINE);
|
||||
ThemeManager.styleMenuItem(underlineCursorItem);
|
||||
underlineCursorItem.addActionListener(e -> {
|
||||
terminalPanel.setCursorStyle(TerminalPanel.CursorStyle.UNDERLINE);
|
||||
haus.nightmare.j3270.config.Settings.setCursorStyle("UNDERLINE");
|
||||
});
|
||||
cursorGroup.add(underlineCursorItem);
|
||||
cursorMenu.add(underlineCursorItem);
|
||||
viewMenu.add(cursorMenu);
|
||||
viewMenu.addSeparator();
|
||||
|
||||
// CodePage Submenu
|
||||
JMenu cpMenu = createMenu("Code Page");
|
||||
String[] codePages = {
|
||||
@@ -227,7 +314,77 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
viewMenu.add(createMenuItem("Field Inspector...", -1, this::showFieldInspectorDialog));
|
||||
menuBar.add(viewMenu);
|
||||
|
||||
// 4. Actions menu
|
||||
// 4. Modes menu
|
||||
JMenu modesMenu = createMenu("Modes");
|
||||
docModeItem = new JCheckBoxMenuItem("Document Mode (DOC)", terminalPanel.isDocMode());
|
||||
ThemeManager.styleMenuItem(docModeItem);
|
||||
docModeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.ALT_DOWN_MASK));
|
||||
docModeItem.addActionListener(e -> terminalPanel.toggleDocMode());
|
||||
modesMenu.add(docModeItem);
|
||||
|
||||
wordWrapItem = new JCheckBoxMenuItem("Word Wrap Mode", terminalPanel.isWordWrap());
|
||||
ThemeManager.styleMenuItem(wordWrapItem);
|
||||
wordWrapItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, InputEvent.ALT_DOWN_MASK));
|
||||
wordWrapItem.addActionListener(e -> terminalPanel.toggleWordWrap());
|
||||
modesMenu.add(wordWrapItem);
|
||||
|
||||
aplModeItem = new JCheckBoxMenuItem("APL Keyboard Mode", terminalPanel.isAplMode());
|
||||
ThemeManager.styleMenuItem(aplModeItem);
|
||||
aplModeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.ALT_DOWN_MASK));
|
||||
aplModeItem.addActionListener(e -> terminalPanel.toggleAplMode());
|
||||
modesMenu.add(aplModeItem);
|
||||
|
||||
insertModeItem = new JCheckBoxMenuItem("Insert Mode", terminalPanel.isInsertMode());
|
||||
ThemeManager.styleMenuItem(insertModeItem);
|
||||
insertModeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0));
|
||||
insertModeItem.addActionListener(e -> terminalPanel.toggleInsertMode());
|
||||
modesMenu.add(insertModeItem);
|
||||
|
||||
modesMenu.addSeparator();
|
||||
|
||||
fourColorItem = new JCheckBoxMenuItem("Base 4-Color Override", haus.nightmare.j3270.config.Settings.getFourColorOverride());
|
||||
ThemeManager.styleMenuItem(fourColorItem);
|
||||
fourColorItem.addActionListener(e -> {
|
||||
haus.nightmare.j3270.config.Settings.setFourColorOverride(fourColorItem.isSelected());
|
||||
terminalPanel.repaint();
|
||||
});
|
||||
modesMenu.add(fourColorItem);
|
||||
|
||||
numLockItem = new JCheckBoxMenuItem("Numeric Field Lock", haus.nightmare.j3270.config.Settings.getNumericFieldLock());
|
||||
ThemeManager.styleMenuItem(numLockItem);
|
||||
numLockItem.addActionListener(e -> {
|
||||
haus.nightmare.j3270.config.Settings.setNumericFieldLock(numLockItem.isSelected());
|
||||
terminalPanel.applyModeSettings();
|
||||
});
|
||||
modesMenu.add(numLockItem);
|
||||
|
||||
autoSkipItem = new JCheckBoxMenuItem("Auto-Skip Across Fields", haus.nightmare.j3270.config.Settings.getAutoSkipEnabled());
|
||||
ThemeManager.styleMenuItem(autoSkipItem);
|
||||
autoSkipItem.addActionListener(e -> {
|
||||
haus.nightmare.j3270.config.Settings.setAutoSkipEnabled(autoSkipItem.isSelected());
|
||||
terminalPanel.applyModeSettings();
|
||||
});
|
||||
modesMenu.add(autoSkipItem);
|
||||
|
||||
insertOffAidItem = new JCheckBoxMenuItem("Reset Insert on AID Key", haus.nightmare.j3270.config.Settings.getInsertOffOnAid());
|
||||
ThemeManager.styleMenuItem(insertOffAidItem);
|
||||
insertOffAidItem.addActionListener(e -> {
|
||||
haus.nightmare.j3270.config.Settings.setInsertOffOnAid(insertOffAidItem.isSelected());
|
||||
terminalPanel.applyModeSettings();
|
||||
});
|
||||
modesMenu.add(insertOffAidItem);
|
||||
|
||||
modesMenu.addMenuListener(new javax.swing.event.MenuListener() {
|
||||
@Override
|
||||
public void menuSelected(javax.swing.event.MenuEvent e) {
|
||||
syncModeMenuItems();
|
||||
}
|
||||
@Override public void menuDeselected(javax.swing.event.MenuEvent e) {}
|
||||
@Override public void menuCanceled(javax.swing.event.MenuEvent e) {}
|
||||
});
|
||||
menuBar.add(modesMenu);
|
||||
|
||||
// 5. Actions menu
|
||||
JMenu actionsMenu = createMenu("Actions");
|
||||
actionsMenu.add(createMenuItem("Send Enter", KeyEvent.VK_ENTER, () -> {
|
||||
if (client != null && client.getConnectionState().isFullSession()) {
|
||||
@@ -555,6 +712,10 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
return terminalPanel;
|
||||
}
|
||||
|
||||
public Telnet3270Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
void connect(ConnectionConfig config) {
|
||||
lastHost = config.getHost();
|
||||
lastPort = config.getPort();
|
||||
@@ -607,12 +768,26 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
fileTransfer.cancel();
|
||||
fileTransfer = null;
|
||||
}
|
||||
client.disconnect();
|
||||
Telnet3270Client c = client;
|
||||
client = null;
|
||||
terminalPanel.setClient(null);
|
||||
statusBar.setClient(null, terminalPanel);
|
||||
terminalPanel.repaint();
|
||||
setTitle("j3270 — Java TN3270 Terminal Emulator");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
c.disconnect();
|
||||
} catch (Exception ignored) {}
|
||||
}, "Disconnect-Thread").start();
|
||||
|
||||
Runnable uiReset = () -> {
|
||||
terminalPanel.setClient(null);
|
||||
statusBar.setClient(null, terminalPanel);
|
||||
syncModeMenuItems();
|
||||
terminalPanel.repaint();
|
||||
setTitle("j3270 — Java TN3270 Terminal Emulator");
|
||||
};
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
uiReset.run();
|
||||
} else {
|
||||
SwingUtilities.invokeLater(uiReset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,6 +798,27 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
terminalPanel.guardedPack();
|
||||
}
|
||||
|
||||
public void toggleStatusBar() {
|
||||
if (statusBar != null) {
|
||||
setStatusBarVisible(!statusBar.isVisible());
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatusBarVisible(boolean visible) {
|
||||
if (statusBar != null) {
|
||||
statusBar.setVisible(visible);
|
||||
}
|
||||
haus.nightmare.j3270.config.Settings.setStatusBarVisible(visible);
|
||||
if (statusBarItem != null) {
|
||||
statusBarItem.setSelected(visible);
|
||||
}
|
||||
getContentPane().revalidate();
|
||||
getContentPane().repaint();
|
||||
if ((getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
|
||||
terminalPanel.guardedPack();
|
||||
}
|
||||
}
|
||||
|
||||
// ========== ConnectionListener ==========
|
||||
|
||||
@Override
|
||||
@@ -632,7 +828,16 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
statusBar.updateStatus();
|
||||
terminalPanel.repaint();
|
||||
|
||||
if (newState.isFullSession() && !oldState.isFullSession()) {
|
||||
if (newState == ConnectionState.RECONNECTING) {
|
||||
setTitle("j3270 — " + lastHost + ":" + lastPort + " [Reconnecting...]");
|
||||
} else if (newState == ConnectionState.NOT_CONNECTED) {
|
||||
setTitle("j3270 — Java TN3270 Terminal Emulator");
|
||||
} else if (newState.isFullSession() && !oldState.isFullSession()) {
|
||||
String tlsIndicator = (client != null && client.getConfig().isUseTls()) ?
|
||||
(client.getConfig().isTlsVerifyCert() ? " [TLS]" : " [TLS/Unverified]") : "";
|
||||
String dev = (client != null && client.getTelnetFSM() != null && client.getTelnetFSM().getConnectedLu() != null) ?
|
||||
" [" + client.getTelnetFSM().getConnectedLu() + "]" : "";
|
||||
setTitle("j3270 — " + lastHost + ":" + lastPort + tlsIndicator + dev);
|
||||
terminalPanel.guardedPack();
|
||||
terminalPanel.requestFocusInWindow();
|
||||
}
|
||||
@@ -671,6 +876,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
}
|
||||
terminalPanel.repaint();
|
||||
statusBar.updateStatus();
|
||||
syncModeMenuItems();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -688,6 +894,19 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCursorMoved(int oldAddress, int newAddress) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
terminalPanel.repaint();
|
||||
statusBar.updateStatus();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyboardUnlocked() {
|
||||
SwingUtilities.invokeLater(statusBar::updateStatus);
|
||||
}
|
||||
|
||||
// ========== Help dialogs ==========
|
||||
|
||||
private void showKeyMappings() {
|
||||
@@ -703,8 +922,8 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
"End — Erase to end of field\n" +
|
||||
"Delete — Delete character\n" +
|
||||
"Backspace — Backspace\n" +
|
||||
"Insert — Toggle insert mode\n" +
|
||||
"Escape — Reset\n" +
|
||||
"Insert / Help / Alt+I — Toggle insert mode\n" +
|
||||
"Escape / Alt+R — Reset\n" +
|
||||
"PageUp/Down — PF7/PF8\n" +
|
||||
"Alt+C / Alt+K — Clear\n" +
|
||||
"Alt+E — Erase Input\n" +
|
||||
@@ -713,7 +932,12 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
"Alt+Q — Cursor Select\n" +
|
||||
"Alt+L — Toggle Light Pen\n" +
|
||||
"Alt+T — File Transfer\n" +
|
||||
"Alt+Shift+R — Crosshair Ruler\n" +
|
||||
"Alt+B — Toggle Status Bar\n" +
|
||||
"Alt+=/-/0 — Font size +/-/reset\n" +
|
||||
"Cmd/Ctrl+C / Ctrl+Ins — Copy\n" +
|
||||
"Cmd/Ctrl+V / Shift+Ins — Paste\n" +
|
||||
"Cmd/Ctrl+A — Select All\n" +
|
||||
"Cmd/Ctrl+F — Find on Screen\n" +
|
||||
"Cmd/Ctrl+G / F3— Find Next\n" +
|
||||
"Cmd/Ctrl+D — Disconnect\n" +
|
||||
@@ -778,13 +1002,78 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
"About j3270", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure application logging. When debug is false, disables all logging
|
||||
* to console and file, preventing creation of j3270.log.
|
||||
*/
|
||||
public static void configureLogging(boolean debug) {
|
||||
Logger globalRoot = Logger.getLogger("");
|
||||
for (java.util.logging.Handler h : globalRoot.getHandlers()) {
|
||||
globalRoot.removeHandler(h);
|
||||
try {
|
||||
h.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
Level logLevel = Level.ALL;
|
||||
globalRoot.setLevel(Level.ALL);
|
||||
|
||||
java.util.logging.Filter appFilter = record -> record.getLoggerName() != null &&
|
||||
(record.getLoggerName().startsWith("haus.nightmare") || record.getLoggerName().startsWith("org.pubvm"));
|
||||
|
||||
ConsoleHandler consoleHandler = new ConsoleHandler();
|
||||
consoleHandler.setLevel(Level.ALL);
|
||||
consoleHandler.setFormatter(new SimpleFormatter());
|
||||
consoleHandler.setFilter(appFilter);
|
||||
globalRoot.addHandler(consoleHandler);
|
||||
|
||||
Logger.getLogger("haus.nightmare").setLevel(Level.ALL);
|
||||
Logger.getLogger("haus.nightmare.j3270").setLevel(Level.ALL);
|
||||
Logger.getLogger("haus.nightmare.lib3270j").setLevel(Level.ALL);
|
||||
|
||||
try {
|
||||
java.util.logging.FileHandler fileHandler = new java.util.logging.FileHandler("j3270.log", 10 * 1024 * 1024, 1, false) {
|
||||
@Override
|
||||
public synchronized void publish(java.util.logging.LogRecord record) {
|
||||
super.publish(record);
|
||||
flush();
|
||||
}
|
||||
};
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(new SimpleFormatter());
|
||||
fileHandler.setFilter(appFilter);
|
||||
globalRoot.addHandler(fileHandler);
|
||||
log.info("Logging protocol trace to j3270.log (debug=" + debug + ", level=" + logLevel + ")");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Could not create j3270.log: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
globalRoot.setLevel(Level.OFF);
|
||||
for (String pkg : new String[]{"haus.nightmare", "haus.nightmare.j3270", "haus.nightmare.lib3270j", "org.pubvm"}) {
|
||||
Logger l = Logger.getLogger(pkg);
|
||||
l.setLevel(Level.OFF);
|
||||
for (java.util.logging.Handler h : l.getHandlers()) {
|
||||
l.removeHandler(h);
|
||||
try {
|
||||
h.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Main ==========
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean debug = false;
|
||||
boolean cliTls = false;
|
||||
boolean cliNoVerifyCert = false;
|
||||
Boolean cliTn3270e = null;
|
||||
Boolean cliAutoSysUnlock = null;
|
||||
GraphicsMode cliGraphicsMode = null;
|
||||
String configFile = null;
|
||||
|
||||
@@ -801,6 +1090,10 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
cliTn3270e = false;
|
||||
} else if ("--tn3270e".equals(arg)) {
|
||||
cliTn3270e = true;
|
||||
} else if ("--auto-sys-unlock".equals(arg)) {
|
||||
cliAutoSysUnlock = true;
|
||||
} else if ("--no-auto-sys-unlock".equals(arg)) {
|
||||
cliAutoSysUnlock = false;
|
||||
} else if (arg.startsWith("--graphics=")) {
|
||||
cliGraphicsMode = GraphicsMode.fromString(arg.substring(11));
|
||||
} else if (("--graphics".equals(arg) || "-g".equals(arg)) && i + 1 < args.length && !args[i + 1].startsWith("-")) {
|
||||
@@ -816,42 +1109,8 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
}
|
||||
}
|
||||
|
||||
Level logLevel = debug ? Level.FINE : Level.INFO;
|
||||
configureLogging(debug);
|
||||
|
||||
Logger globalRoot = Logger.getLogger("");
|
||||
for (java.util.logging.Handler h : globalRoot.getHandlers()) {
|
||||
globalRoot.removeHandler(h);
|
||||
}
|
||||
|
||||
java.util.logging.Filter appFilter = record -> record.getLoggerName() != null &&
|
||||
(record.getLoggerName().startsWith("haus.nightmare") || record.getLoggerName().startsWith("org.pubvm"));
|
||||
|
||||
ConsoleHandler consoleHandler = new ConsoleHandler();
|
||||
consoleHandler.setLevel(Level.ALL);
|
||||
consoleHandler.setFormatter(new SimpleFormatter());
|
||||
consoleHandler.setFilter(appFilter);
|
||||
globalRoot.addHandler(consoleHandler);
|
||||
|
||||
Logger.getLogger("haus.nightmare").setLevel(Level.ALL);
|
||||
Logger.getLogger("haus.nightmare.j3270").setLevel(Level.ALL);
|
||||
Logger.getLogger("haus.nightmare.lib3270j").setLevel(Level.ALL);
|
||||
|
||||
try {
|
||||
java.util.logging.FileHandler fileHandler = new java.util.logging.FileHandler("j3270.log", 10 * 1024 * 1024, 1, false) {
|
||||
@Override
|
||||
public synchronized void publish(java.util.logging.LogRecord record) {
|
||||
super.publish(record);
|
||||
flush();
|
||||
}
|
||||
};
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(new SimpleFormatter());
|
||||
fileHandler.setFilter(appFilter);
|
||||
globalRoot.addHandler(fileHandler);
|
||||
log.info("Logging protocol trace to j3270.log (debug=" + debug + ", level=" + logLevel + ")");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Could not create j3270.log: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (configFile != null) {
|
||||
try {
|
||||
@@ -877,6 +1136,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
final boolean finalTls = cliTls;
|
||||
final boolean finalNoVerify = cliNoVerifyCert;
|
||||
final Boolean finalTn3270e = cliTn3270e;
|
||||
final Boolean finalAutoSysUnlock = cliAutoSysUnlock;
|
||||
final GraphicsMode finalGraphicsMode = cliGraphicsMode;
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@@ -893,10 +1153,15 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
}
|
||||
TerminalModel model = TerminalModel.IBM_3279_4;
|
||||
if (remainingArgs.size() >= 3) {
|
||||
try {
|
||||
int modelNum = Integer.parseInt(remainingArgs.get(2));
|
||||
model = TerminalModel.forModel(modelNum, true);
|
||||
} catch (Exception ignored) {}
|
||||
String mArg = remainingArgs.get(2).trim();
|
||||
if (mArg.equalsIgnoreCase("dynamic") || mArg.equals("0")) {
|
||||
model = TerminalModel.IBM_DYNAMIC;
|
||||
} else {
|
||||
try {
|
||||
int modelNum = Integer.parseInt(mArg);
|
||||
model = TerminalModel.forModel(modelNum, true);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
ConnectionConfig config = ConnectionConfig.parseHostString(hostArg, port, model);
|
||||
if (finalTls) {
|
||||
@@ -908,6 +1173,11 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
if (finalTn3270e != null) {
|
||||
config.setTn3270eEnabled(finalTn3270e);
|
||||
}
|
||||
if (finalAutoSysUnlock != null) {
|
||||
config.setAutoSysUnlock(finalAutoSysUnlock);
|
||||
} else {
|
||||
config.setAutoSysUnlock(haus.nightmare.j3270.config.Settings.getAutoSysUnlock());
|
||||
}
|
||||
if (finalGraphicsMode != null) {
|
||||
config.setGraphicsMode(finalGraphicsMode);
|
||||
} else {
|
||||
@@ -931,6 +1201,9 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
||||
ConnectionConfig config = new ConnectionConfig(host, port, TerminalModel.IBM_3279_4, tls);
|
||||
config.setTlsVerifyCert(verify);
|
||||
config.setTn3270eEnabled(finalTn3270e != null ? finalTn3270e : tn3270e);
|
||||
config.setAutoReconnect(haus.nightmare.j3270.config.Settings.getAutoConnectAutoReconnect());
|
||||
config.setReconnectMaxRetries(haus.nightmare.j3270.config.Settings.getAutoConnectReconnectMaxRetries());
|
||||
config.setAutoSysUnlock(finalAutoSysUnlock != null ? finalAutoSysUnlock : haus.nightmare.j3270.config.Settings.getAutoSysUnlock());
|
||||
if (finalGraphicsMode != null) {
|
||||
config.setGraphicsMode(finalGraphicsMode);
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class Settings {
|
||||
|
||||
public static void setFontFamily(String family) {
|
||||
prefs.put("fontFamily", family);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static int getFontSize() {
|
||||
@@ -41,6 +42,14 @@ public class Settings {
|
||||
|
||||
public static void setFontSize(int size) {
|
||||
prefs.putInt("fontSize", size);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
private static void flushPrefs() {
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static StartupBehavior getStartupBehavior() {
|
||||
@@ -96,6 +105,85 @@ public class Settings {
|
||||
prefs.putBoolean("autoConnectTn3270e", tn3270e);
|
||||
}
|
||||
|
||||
public static boolean getAutoSysUnlock() {
|
||||
return prefs.getBoolean("autoSysUnlock", true);
|
||||
}
|
||||
|
||||
public static void setAutoSysUnlock(boolean autoSysUnlock) {
|
||||
prefs.putBoolean("autoSysUnlock", autoSysUnlock);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getAutoConnectKeepAlive() {
|
||||
return prefs.getBoolean("autoConnectKeepAlive", true);
|
||||
}
|
||||
|
||||
public static void setAutoConnectKeepAlive(boolean keepAlive) {
|
||||
prefs.putBoolean("autoConnectKeepAlive", keepAlive);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static int getAutoConnectKeepAliveInterval() {
|
||||
return prefs.getInt("autoConnectKeepAliveInterval", 120);
|
||||
}
|
||||
|
||||
public static void setAutoConnectKeepAliveInterval(int interval) {
|
||||
prefs.putInt("autoConnectKeepAliveInterval", interval);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getAutoConnectAutoReconnect() {
|
||||
return prefs.getBoolean("autoConnectAutoReconnect", false);
|
||||
}
|
||||
|
||||
public static void setAutoConnectAutoReconnect(boolean autoReconnect) {
|
||||
prefs.putBoolean("autoConnectAutoReconnect", autoReconnect);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getAutoReconnect() {
|
||||
return getAutoConnectAutoReconnect();
|
||||
}
|
||||
|
||||
public static void setAutoReconnect(boolean autoReconnect) {
|
||||
setAutoConnectAutoReconnect(autoReconnect);
|
||||
}
|
||||
|
||||
public static int getAutoConnectReconnectMaxRetries() {
|
||||
return prefs.getInt("autoConnectReconnectMaxRetries", 5);
|
||||
}
|
||||
|
||||
public static void setAutoConnectReconnectMaxRetries(int retries) {
|
||||
prefs.putInt("autoConnectReconnectMaxRetries", retries);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getInputMask() {
|
||||
return prefs.getBoolean("inputMask", true);
|
||||
}
|
||||
|
||||
public static void setInputMask(boolean mask) {
|
||||
prefs.putBoolean("inputMask", mask);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getInputMaskEnabled() {
|
||||
return getInputMask();
|
||||
}
|
||||
|
||||
public static void setInputMaskEnabled(boolean enabled) {
|
||||
setInputMask(enabled);
|
||||
}
|
||||
|
||||
public static String getInputMaskChar() {
|
||||
return prefs.get("inputMaskChar", "*");
|
||||
}
|
||||
|
||||
public static void setInputMaskChar(String ch) {
|
||||
prefs.put("inputMaskChar", (ch != null && !ch.trim().isEmpty()) ? ch.trim().substring(0, 1) : "*");
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static haus.nightmare.lib3270j.graphics.GraphicsMode getGraphicsMode() {
|
||||
String modeStr = prefs.get("graphicsMode", haus.nightmare.lib3270j.graphics.GraphicsMode.BOTH.name());
|
||||
return haus.nightmare.lib3270j.graphics.GraphicsMode.fromString(modeStr);
|
||||
@@ -113,6 +201,22 @@ public class Settings {
|
||||
prefs.put("codePage", (codePage != null && !codePage.trim().isEmpty()) ? codePage.trim() : "037");
|
||||
}
|
||||
|
||||
public static int getDynamicRows() {
|
||||
return prefs.getInt("dynamicRows", 62);
|
||||
}
|
||||
|
||||
public static void setDynamicRows(int rows) {
|
||||
prefs.putInt("dynamicRows", Math.max(1, rows));
|
||||
}
|
||||
|
||||
public static int getDynamicCols() {
|
||||
return prefs.getInt("dynamicCols", 160);
|
||||
}
|
||||
|
||||
public static void setDynamicCols(int cols) {
|
||||
prefs.putInt("dynamicCols", Math.max(1, cols));
|
||||
}
|
||||
|
||||
public static Color getColorOverride(int index, Color defaultColor) {
|
||||
String hex = prefs.get("color_" + index, null);
|
||||
try {
|
||||
@@ -139,8 +243,61 @@ public class Settings {
|
||||
prefs.put("mono_" + key, String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()));
|
||||
}
|
||||
|
||||
public static boolean isMac() {
|
||||
String os = System.getProperty("os.name");
|
||||
return os != null && os.toLowerCase().contains("mac");
|
||||
}
|
||||
|
||||
public static String getDefaultBinding(String action) {
|
||||
boolean mac = isMac();
|
||||
switch (action) {
|
||||
case "COPY":
|
||||
return mac ? "meta C, ctrl C, ctrl INSERT, ctrl shift C" : "ctrl C, ctrl INSERT, ctrl shift C";
|
||||
case "PASTE":
|
||||
return mac ? "meta V, ctrl V, shift INSERT, ctrl shift V" : "ctrl V, shift INSERT, ctrl shift V";
|
||||
case "SELECTALL":
|
||||
return mac ? "meta A, ctrl A" : "ctrl A";
|
||||
case "INSERT":
|
||||
return mac ? "INSERT, HELP, alt I" : "INSERT, ctrl I";
|
||||
case "ERASE_INPUT":
|
||||
return "alt E";
|
||||
case "NEWLINE":
|
||||
return "shift ENTER";
|
||||
case "DUP":
|
||||
return "alt D";
|
||||
case "FIELD_MARK":
|
||||
return "alt M";
|
||||
case "ATTN":
|
||||
return "alt A";
|
||||
case "SYSREQ":
|
||||
return "alt S";
|
||||
case "CURSEL":
|
||||
return "alt Q";
|
||||
case "CLEAR":
|
||||
return "alt C";
|
||||
case "STATUS_BAR":
|
||||
return "alt B";
|
||||
default:
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getKeyBinding(String action, String defaultBinding) {
|
||||
return prefs.get("key_" + action, defaultBinding);
|
||||
String val = prefs.get("key_" + action, null);
|
||||
if (val == null) {
|
||||
return defaultBinding;
|
||||
}
|
||||
// If stored binding is the legacy single-key "INSERT" default, migrate it to the current platform default
|
||||
if ("INSERT".equals(action) && "INSERT".equals(val)) {
|
||||
prefs.put("key_INSERT", defaultBinding);
|
||||
return defaultBinding;
|
||||
}
|
||||
// If stored binding is the legacy or corrupted "alt STE" for PASTE, migrate it to the current platform default
|
||||
if ("PASTE".equals(action) && ("alt STE".equals(val) || "PASTE".equals(val))) {
|
||||
prefs.put("key_PASTE", defaultBinding);
|
||||
return defaultBinding;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public static void setKeyBinding(String action, String binding) {
|
||||
@@ -233,6 +390,151 @@ public class Settings {
|
||||
prefs.putBoolean("blockSelectMode", block);
|
||||
}
|
||||
|
||||
// ========== Clipboard & Tabular Paste ==========
|
||||
|
||||
public static boolean getEnablePasteFromExcel() {
|
||||
return prefs.getBoolean("enablePasteFromExcel", true);
|
||||
}
|
||||
|
||||
public static void setEnablePasteFromExcel(boolean val) {
|
||||
prefs.putBoolean("enablePasteFromExcel", val);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
public static boolean getPasteStopAtProtectedLine() {
|
||||
return prefs.getBoolean("pasteStopAtProtectedLine", false);
|
||||
}
|
||||
|
||||
public static void setPasteStopAtProtectedLine(boolean val) {
|
||||
prefs.putBoolean("pasteStopAtProtectedLine", val);
|
||||
flushPrefs();
|
||||
}
|
||||
|
||||
// ========== Crosshair Ruler ==========
|
||||
|
||||
public static boolean getCrosshairRuler() {
|
||||
return prefs.getBoolean("crosshairRuler", false);
|
||||
}
|
||||
|
||||
public static void setCrosshairRuler(boolean enabled) {
|
||||
prefs.putBoolean("crosshairRuler", enabled);
|
||||
}
|
||||
|
||||
// ========== Status Bar Visibility ==========
|
||||
|
||||
public static boolean getStatusBarVisible() {
|
||||
return prefs.getBoolean("statusBarVisible", true);
|
||||
}
|
||||
|
||||
public static void setStatusBarVisible(boolean visible) {
|
||||
prefs.putBoolean("statusBarVisible", visible);
|
||||
}
|
||||
|
||||
// ========== Cursor Style ==========
|
||||
|
||||
public static String getCursorStyle() {
|
||||
return prefs.get("cursorStyle", "BLOCK");
|
||||
}
|
||||
|
||||
public static void setCursorStyle(String style) {
|
||||
prefs.put("cursorStyle", style != null ? style.toUpperCase() : "BLOCK");
|
||||
}
|
||||
|
||||
// ========== Entry Assist & Modes ==========
|
||||
|
||||
public static boolean getEntryAssistDocMode() {
|
||||
return prefs.getBoolean("entryAssistDocMode", false);
|
||||
}
|
||||
public static void setEntryAssistDocMode(boolean docMode) {
|
||||
prefs.putBoolean("entryAssistDocMode", docMode);
|
||||
}
|
||||
|
||||
public static boolean getEntryAssistWordWrap() {
|
||||
return prefs.getBoolean("entryAssistWordWrap", false);
|
||||
}
|
||||
public static void setEntryAssistWordWrap(boolean wordWrap) {
|
||||
prefs.putBoolean("entryAssistWordWrap", wordWrap);
|
||||
}
|
||||
|
||||
public static int getEntryAssistStartCol() {
|
||||
return prefs.getInt("entryAssistStartCol", 1);
|
||||
}
|
||||
public static void setEntryAssistStartCol(int startCol) {
|
||||
prefs.putInt("entryAssistStartCol", startCol);
|
||||
}
|
||||
|
||||
public static int getEntryAssistEndCol() {
|
||||
return prefs.getInt("entryAssistEndCol", 80);
|
||||
}
|
||||
public static void setEntryAssistEndCol(int endCol) {
|
||||
prefs.putInt("entryAssistEndCol", endCol);
|
||||
}
|
||||
|
||||
public static boolean getEntryAssistBell() {
|
||||
return prefs.getBoolean("entryAssistBell", false);
|
||||
}
|
||||
public static void setEntryAssistBell(boolean bell) {
|
||||
prefs.putBoolean("entryAssistBell", bell);
|
||||
}
|
||||
|
||||
public static int getEntryAssistBellCol() {
|
||||
return prefs.getInt("entryAssistBellCol", 75);
|
||||
}
|
||||
public static void setEntryAssistBellCol(int col) {
|
||||
prefs.putInt("entryAssistBellCol", col);
|
||||
}
|
||||
|
||||
public static String getEntryAssistTabStops() {
|
||||
return prefs.get("entryAssistTabStops", "5,10,15,20,25,30,35,40,45,50,55,60,65,70,75");
|
||||
}
|
||||
public static void setEntryAssistTabStops(String stops) {
|
||||
prefs.put("entryAssistTabStops", stops != null ? stops : "");
|
||||
}
|
||||
|
||||
public static int[] getEntryAssistTabStopsArray() {
|
||||
String s = getEntryAssistTabStops();
|
||||
if (s == null || s.trim().isEmpty()) return new int[0];
|
||||
String[] parts = s.split(",");
|
||||
java.util.List<Integer> list = new java.util.ArrayList<>();
|
||||
for (String p : parts) {
|
||||
try {
|
||||
int val = Integer.parseInt(p.trim());
|
||||
if (val > 0) list.add(val - 1);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
int[] res = new int[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) res[i] = list.get(i);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static boolean getInsertOffOnAid() {
|
||||
return prefs.getBoolean("insertOffOnAid", true);
|
||||
}
|
||||
public static void setInsertOffOnAid(boolean val) {
|
||||
prefs.putBoolean("insertOffOnAid", val);
|
||||
}
|
||||
|
||||
public static boolean getFourColorOverride() {
|
||||
return prefs.getBoolean("fourColorOverride", false);
|
||||
}
|
||||
public static void setFourColorOverride(boolean val) {
|
||||
prefs.putBoolean("fourColorOverride", val);
|
||||
}
|
||||
|
||||
public static boolean getNumericFieldLock() {
|
||||
return prefs.getBoolean("numericFieldLock", true);
|
||||
}
|
||||
public static void setNumericFieldLock(boolean val) {
|
||||
prefs.putBoolean("numericFieldLock", val);
|
||||
}
|
||||
|
||||
public static boolean getAutoSkipEnabled() {
|
||||
return prefs.getBoolean("autoSkipEnabled", true);
|
||||
}
|
||||
public static void setAutoSkipEnabled(boolean val) {
|
||||
prefs.putBoolean("autoSkipEnabled", val);
|
||||
}
|
||||
|
||||
private static void applyConfigEntry(String section, String key, String value) {
|
||||
switch (section) {
|
||||
case "appearance":
|
||||
@@ -244,6 +546,19 @@ public class Settings {
|
||||
case "uiTheme":
|
||||
setJavaUiTheme(UITheme.fromString(value));
|
||||
break;
|
||||
case "crosshairRuler":
|
||||
case "ruler":
|
||||
setCrosshairRuler(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "statusBarVisible":
|
||||
case "statusbar":
|
||||
case "statusBar":
|
||||
case "showStatusBar":
|
||||
setStatusBarVisible(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "cursorStyle":
|
||||
setCursorStyle(value);
|
||||
break;
|
||||
default:
|
||||
log.warning("Unknown appearance key: " + key);
|
||||
}
|
||||
@@ -284,12 +599,71 @@ public class Settings {
|
||||
case "charset":
|
||||
setCodePage(value);
|
||||
break;
|
||||
case "dynamicRows":
|
||||
case "dynamic_rows":
|
||||
setDynamicRows(Integer.parseInt(value));
|
||||
break;
|
||||
case "dynamicCols":
|
||||
case "dynamic_cols":
|
||||
setDynamicCols(Integer.parseInt(value));
|
||||
break;
|
||||
case "blockSelectMode": setBlockSelectMode(Boolean.parseBoolean(value)); break;
|
||||
case "autoReconnect":
|
||||
case "auto_reconnect":
|
||||
case "autoConnectAutoReconnect":
|
||||
setAutoConnectAutoReconnect(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "reconnectMaxRetries":
|
||||
case "autoConnectReconnectMaxRetries":
|
||||
setAutoConnectReconnectMaxRetries(Integer.parseInt(value));
|
||||
break;
|
||||
case "inputMask":
|
||||
case "input_mask":
|
||||
case "inputMaskEnabled":
|
||||
case "maskInput":
|
||||
setInputMask(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "inputMaskChar":
|
||||
case "input_mask_char":
|
||||
case "maskChar":
|
||||
setInputMaskChar(value);
|
||||
break;
|
||||
case "autoSysUnlock":
|
||||
case "auto_sys_unlock":
|
||||
setAutoSysUnlock(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "enablePasteFromExcel":
|
||||
case "pasteFromExcel":
|
||||
case "excelPaste":
|
||||
setEnablePasteFromExcel(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "pasteStopAtProtectedLine":
|
||||
case "stopAtProtected":
|
||||
case "pasteStopAtProtected":
|
||||
setPasteStopAtProtectedLine(Boolean.parseBoolean(value));
|
||||
break;
|
||||
default:
|
||||
log.warning("Unknown behavior/connection key: " + key);
|
||||
}
|
||||
break;
|
||||
|
||||
case "clipboard":
|
||||
switch (key) {
|
||||
case "enablePasteFromExcel":
|
||||
case "pasteFromExcel":
|
||||
case "excelPaste":
|
||||
setEnablePasteFromExcel(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "pasteStopAtProtectedLine":
|
||||
case "stopAtProtected":
|
||||
case "pasteStopAtProtected":
|
||||
setPasteStopAtProtectedLine(Boolean.parseBoolean(value));
|
||||
break;
|
||||
default:
|
||||
log.warning("Unknown clipboard key: " + key);
|
||||
}
|
||||
break;
|
||||
|
||||
case "colors":
|
||||
if (key.startsWith("color_")) {
|
||||
int index = Integer.parseInt(key.substring(6));
|
||||
@@ -314,6 +688,55 @@ public class Settings {
|
||||
}
|
||||
break;
|
||||
|
||||
case "entryassist":
|
||||
case "modes":
|
||||
switch (key) {
|
||||
case "docMode":
|
||||
case "entryAssistDocMode":
|
||||
setEntryAssistDocMode(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "wordWrap":
|
||||
case "entryAssistWordWrap":
|
||||
setEntryAssistWordWrap(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "startCol":
|
||||
case "entryAssistStartCol":
|
||||
setEntryAssistStartCol(Integer.parseInt(value));
|
||||
break;
|
||||
case "endCol":
|
||||
case "entryAssistEndCol":
|
||||
setEntryAssistEndCol(Integer.parseInt(value));
|
||||
break;
|
||||
case "bell":
|
||||
case "entryAssistBell":
|
||||
setEntryAssistBell(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "bellCol":
|
||||
case "entryAssistBellCol":
|
||||
setEntryAssistBellCol(Integer.parseInt(value));
|
||||
break;
|
||||
case "tabStops":
|
||||
case "entryAssistTabStops":
|
||||
setEntryAssistTabStops(value);
|
||||
break;
|
||||
case "insertOffOnAid":
|
||||
setInsertOffOnAid(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "fourColorOverride":
|
||||
setFourColorOverride(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "numericFieldLock":
|
||||
setNumericFieldLock(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "autoSkip":
|
||||
case "autoSkipEnabled":
|
||||
setAutoSkipEnabled(Boolean.parseBoolean(value));
|
||||
break;
|
||||
default:
|
||||
log.warning("Unknown entryassist/modes key: " + key);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Allow bare keys outside any section — treat as raw prefs
|
||||
log.fine("Setting raw preference: " + key + " = " + value);
|
||||
@@ -340,6 +763,9 @@ public class Settings {
|
||||
w.println("javaUiTheme = " + getJavaUiTheme().name());
|
||||
w.println("fontFamily = " + getFontFamily());
|
||||
w.println("fontSize = " + getFontSize());
|
||||
w.println("crosshairRuler = " + getCrosshairRuler());
|
||||
w.println("statusBarVisible = " + getStatusBarVisible());
|
||||
w.println("cursorStyle = " + getCursorStyle());
|
||||
w.println();
|
||||
|
||||
// [behavior]
|
||||
@@ -354,7 +780,35 @@ public class Settings {
|
||||
w.println("autoConnectTn3270e = " + getAutoConnectTn3270e());
|
||||
}
|
||||
w.println("codePage = " + getCodePage());
|
||||
w.println("dynamicRows = " + getDynamicRows());
|
||||
w.println("dynamicCols = " + getDynamicCols());
|
||||
w.println("blockSelectMode = " + getBlockSelectMode());
|
||||
w.println("autoReconnect = " + getAutoConnectAutoReconnect());
|
||||
w.println("autoConnectReconnectMaxRetries = " + getAutoConnectReconnectMaxRetries());
|
||||
w.println("inputMask = " + getInputMask());
|
||||
w.println("inputMaskChar = " + getInputMaskChar());
|
||||
w.println("autoSysUnlock = " + getAutoSysUnlock());
|
||||
w.println("enablePasteFromExcel = " + getEnablePasteFromExcel());
|
||||
w.println("pasteStopAtProtectedLine = " + getPasteStopAtProtectedLine());
|
||||
w.println();
|
||||
|
||||
// [entryassist]
|
||||
w.println("[entryassist]");
|
||||
w.println("docMode = " + getEntryAssistDocMode());
|
||||
w.println("wordWrap = " + getEntryAssistWordWrap());
|
||||
w.println("startCol = " + getEntryAssistStartCol());
|
||||
w.println("endCol = " + getEntryAssistEndCol());
|
||||
w.println("bell = " + getEntryAssistBell());
|
||||
w.println("bellCol = " + getEntryAssistBellCol());
|
||||
w.println("tabStops = " + getEntryAssistTabStops());
|
||||
w.println();
|
||||
|
||||
// [modes]
|
||||
w.println("[modes]");
|
||||
w.println("insertOffOnAid = " + getInsertOffOnAid());
|
||||
w.println("fourColorOverride = " + getFourColorOverride());
|
||||
w.println("numericFieldLock = " + getNumericFieldLock());
|
||||
w.println("autoSkip = " + getAutoSkipEnabled());
|
||||
w.println();
|
||||
|
||||
// [graphics]
|
||||
@@ -383,9 +837,10 @@ public class Settings {
|
||||
|
||||
// [keybindings]
|
||||
w.println("[keybindings]");
|
||||
// Navigation keys
|
||||
// Navigation & clipboard keys
|
||||
String[] navActions = {"ENTER", "TAB", "shift TAB", "UP", "DOWN", "LEFT", "RIGHT",
|
||||
"HOME", "END", "PAGE_UP", "PAGE_DOWN", "ESCAPE", "INSERT", "DELETE", "BACK_SPACE", "CLEAR"};
|
||||
"HOME", "END", "PAGE_UP", "PAGE_DOWN", "ESCAPE", "INSERT", "DELETE", "BACK_SPACE", "CLEAR",
|
||||
"STATUS_BAR", "COPY", "PASTE", "SELECTALL"};
|
||||
for (String act : navActions) {
|
||||
String val = prefs.get("key_" + act, null);
|
||||
if (val != null) {
|
||||
|
||||
@@ -12,6 +12,50 @@ import java.io.File;
|
||||
|
||||
public class FileTransferDialog extends JDialog {
|
||||
|
||||
public static class TransferSessionState {
|
||||
public FTConfig.HostType hostType = FTConfig.HostType.TSO;
|
||||
public boolean isSend = false;
|
||||
public String localFile = "";
|
||||
public String hostFile = "";
|
||||
public boolean isAscii = true;
|
||||
public int mtu = FTConstants.DFT_BUF;
|
||||
public boolean crFlag = true;
|
||||
public boolean remapFlag = true;
|
||||
public boolean append = false;
|
||||
public boolean overwrite = false;
|
||||
public String recfm = "";
|
||||
public String lrecl = "";
|
||||
public String blksize = "";
|
||||
public String space = "";
|
||||
public String options = "";
|
||||
}
|
||||
|
||||
private static TransferSessionState lastTransferState = null;
|
||||
|
||||
public static TransferSessionState getLastTransferState() {
|
||||
return lastTransferState;
|
||||
}
|
||||
|
||||
public static void setLastTransferState(TransferSessionState state) {
|
||||
lastTransferState = state;
|
||||
}
|
||||
|
||||
public static void resetSessionState() {
|
||||
lastTransferState = null;
|
||||
}
|
||||
|
||||
public static String formatHostFilename(String localPath, FTConfig.HostType hostType) {
|
||||
if (localPath == null || localPath.trim().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
File f = new File(localPath.trim());
|
||||
String name = f.getName();
|
||||
if (hostType == FTConfig.HostType.CMS) {
|
||||
name = name.replace('.', ' ');
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private final FileTransfer coordinator;
|
||||
private final Frame owner;
|
||||
|
||||
@@ -66,6 +110,16 @@ public class FileTransferDialog extends JDialog {
|
||||
|
||||
// Host Type
|
||||
hostTypeCombo = new JComboBox<>(FTConfig.HostType.values());
|
||||
hostTypeCombo.addActionListener(e -> {
|
||||
updateOptionStates();
|
||||
FTConfig.HostType hostType = (FTConfig.HostType) hostTypeCombo.getSelectedItem();
|
||||
if (hostType == FTConfig.HostType.CMS) {
|
||||
String hostText = hostFileField.getText().trim();
|
||||
if (hostText.contains(".")) {
|
||||
hostFileField.setText(hostText.replace('.', ' '));
|
||||
}
|
||||
}
|
||||
});
|
||||
formPanel.add(createRow("Host Environment:", hostTypeCombo));
|
||||
|
||||
// Direction
|
||||
@@ -88,6 +142,15 @@ public class FileTransferDialog extends JDialog {
|
||||
|
||||
// Local File
|
||||
localFileField = new JTextField(20);
|
||||
localFileField.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(java.awt.event.FocusEvent e) {
|
||||
if (hostFileField.getText().trim().isEmpty() && !localFileField.getText().trim().isEmpty()) {
|
||||
FTConfig.HostType hostType = (FTConfig.HostType) hostTypeCombo.getSelectedItem();
|
||||
hostFileField.setText(formatHostFilename(localFileField.getText(), hostType));
|
||||
}
|
||||
}
|
||||
});
|
||||
browseLocalButton = new JButton("Browse...");
|
||||
ThemeManager.styleButton(browseLocalButton, ThemeManager.ButtonVariant.DEFAULT);
|
||||
browseLocalButton.addActionListener(e -> browseLocalFile());
|
||||
@@ -211,13 +274,47 @@ public class FileTransferDialog extends JDialog {
|
||||
|
||||
setContentPane(mainPanel);
|
||||
|
||||
prefillFromLastTransfer();
|
||||
ThemeManager.applyThemeToWindow(this);
|
||||
updateOptionStates();
|
||||
}
|
||||
|
||||
private void prefillFromLastTransfer() {
|
||||
if (lastTransferState != null) {
|
||||
if (lastTransferState.hostType != null) {
|
||||
hostTypeCombo.setSelectedItem(lastTransferState.hostType);
|
||||
}
|
||||
sendRadio.setSelected(lastTransferState.isSend);
|
||||
receiveRadio.setSelected(!lastTransferState.isSend);
|
||||
if (lastTransferState.localFile != null) {
|
||||
localFileField.setText(lastTransferState.localFile);
|
||||
}
|
||||
if (lastTransferState.hostFile != null) {
|
||||
hostFileField.setText(lastTransferState.hostFile);
|
||||
}
|
||||
asciiRadio.setSelected(lastTransferState.isAscii);
|
||||
binaryRadio.setSelected(!lastTransferState.isAscii);
|
||||
if (lastTransferState.mtu > 0) {
|
||||
mtuCombo.setSelectedItem(lastTransferState.mtu);
|
||||
}
|
||||
crCheck.setSelected(lastTransferState.crFlag);
|
||||
remapCheck.setSelected(lastTransferState.remapFlag);
|
||||
appendCheck.setSelected(lastTransferState.append);
|
||||
overwriteCheck.setSelected(lastTransferState.overwrite);
|
||||
if (lastTransferState.recfm != null) recfmField.setText(lastTransferState.recfm);
|
||||
if (lastTransferState.lrecl != null) lreclField.setText(lastTransferState.lrecl);
|
||||
if (lastTransferState.blksize != null) blksizeField.setText(lastTransferState.blksize);
|
||||
if (lastTransferState.space != null) spaceField.setText(lastTransferState.space);
|
||||
if (lastTransferState.options != null) optionsField.setText(lastTransferState.options);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOptionStates() {
|
||||
boolean isSend = sendRadio.isSelected();
|
||||
boolean isAscii = asciiRadio.isSelected();
|
||||
FTConfig.HostType hostType = (FTConfig.HostType) hostTypeCombo.getSelectedItem();
|
||||
boolean isTso = (hostType == FTConfig.HostType.TSO);
|
||||
boolean isCms = (hostType == FTConfig.HostType.CMS);
|
||||
|
||||
appendCheck.setEnabled(!isSend);
|
||||
overwriteCheck.setEnabled(!isSend);
|
||||
@@ -225,10 +322,11 @@ public class FileTransferDialog extends JDialog {
|
||||
crCheck.setEnabled(isAscii);
|
||||
remapCheck.setEnabled(isAscii);
|
||||
|
||||
recfmField.setEnabled(isSend);
|
||||
lreclField.setEnabled(isSend);
|
||||
blksizeField.setEnabled(isSend);
|
||||
spaceField.setEnabled(isSend);
|
||||
recfmField.setEnabled(isSend && isTso);
|
||||
lreclField.setEnabled(isSend && isTso);
|
||||
blksizeField.setEnabled(isSend && isTso);
|
||||
spaceField.setEnabled(isSend && isTso);
|
||||
optionsField.setEnabled(isCms);
|
||||
}
|
||||
|
||||
private JPanel createRow(String labelText, Component comp) {
|
||||
@@ -245,9 +343,13 @@ public class FileTransferDialog extends JDialog {
|
||||
private void browseLocalFile() {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
localFileField.setText(chooser.getSelectedFile().getAbsolutePath());
|
||||
if (hostFileField.getText().trim().isEmpty()) {
|
||||
hostFileField.setText(chooser.getSelectedFile().getName());
|
||||
File selected = chooser.getSelectedFile();
|
||||
localFileField.setText(selected.getAbsolutePath());
|
||||
FTConfig.HostType hostType = (FTConfig.HostType) hostTypeCombo.getSelectedItem();
|
||||
boolean shouldAutofill = hostFileField.getText().trim().isEmpty() ||
|
||||
(lastTransferState != null && hostFileField.getText().trim().equals(lastTransferState.hostFile));
|
||||
if (shouldAutofill) {
|
||||
hostFileField.setText(formatHostFilename(selected.getName(), hostType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,10 +362,21 @@ public class FileTransferDialog extends JDialog {
|
||||
|
||||
if (dialog.isConfirmed() && dialog.getSelectedHostFile() != null) {
|
||||
hostFileField.setText(dialog.getSelectedHostFile());
|
||||
if (localFileField.getText().trim().isEmpty()) {
|
||||
boolean shouldAutofill = localFileField.getText().trim().isEmpty() ||
|
||||
(lastTransferState != null && localFileField.getText().trim().equals(lastTransferState.localFile));
|
||||
if (shouldAutofill) {
|
||||
String cleanName = dialog.getSelectedHostFile().replace("'", "").replace("\"", "");
|
||||
int lastDot = cleanName.lastIndexOf('.');
|
||||
if (lastDot > 0) cleanName = cleanName.substring(lastDot + 1);
|
||||
if (hostType == FTConfig.HostType.CMS) {
|
||||
String[] tokens = cleanName.trim().split("\\s+");
|
||||
if (tokens.length >= 2) {
|
||||
cleanName = tokens[0].toLowerCase() + "." + tokens[1].toLowerCase();
|
||||
} else if (tokens.length == 1) {
|
||||
cleanName = tokens[0].toLowerCase();
|
||||
}
|
||||
} else {
|
||||
int lastDot = cleanName.lastIndexOf('.');
|
||||
if (lastDot > 0) cleanName = cleanName.substring(lastDot + 1);
|
||||
}
|
||||
localFileField.setText(cleanName);
|
||||
}
|
||||
}
|
||||
@@ -298,6 +411,8 @@ public class FileTransferDialog extends JDialog {
|
||||
config.setSpace(spaceField.getText().trim());
|
||||
config.setOptions(optionsField.getText().trim());
|
||||
|
||||
recordSessionTransfer();
|
||||
|
||||
String error = coordinator.startTransfer(config);
|
||||
if (error != null) {
|
||||
JOptionPane.showMessageDialog(this, error, "Transfer Error", JOptionPane.ERROR_MESSAGE);
|
||||
@@ -306,6 +421,45 @@ public class FileTransferDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
public void recordSessionTransfer() {
|
||||
TransferSessionState state = new TransferSessionState();
|
||||
state.hostType = (FTConfig.HostType) hostTypeCombo.getSelectedItem();
|
||||
state.isSend = sendRadio.isSelected();
|
||||
state.localFile = localFileField.getText().trim();
|
||||
state.hostFile = hostFileField.getText().trim();
|
||||
state.isAscii = asciiRadio.isSelected();
|
||||
Integer mtu = (Integer) mtuCombo.getSelectedItem();
|
||||
state.mtu = (mtu != null) ? mtu : FTConstants.DFT_BUF;
|
||||
state.crFlag = crCheck.isSelected();
|
||||
state.remapFlag = remapCheck.isSelected();
|
||||
state.append = appendCheck.isSelected();
|
||||
state.overwrite = overwriteCheck.isSelected();
|
||||
state.recfm = recfmField.getText().trim();
|
||||
state.lrecl = lreclField.getText().trim();
|
||||
state.blksize = blksizeField.getText().trim();
|
||||
state.space = spaceField.getText().trim();
|
||||
state.options = optionsField.getText().trim();
|
||||
lastTransferState = state;
|
||||
}
|
||||
|
||||
public JComboBox<FTConfig.HostType> getHostTypeCombo() { return hostTypeCombo; }
|
||||
public JRadioButton getSendRadio() { return sendRadio; }
|
||||
public JRadioButton getReceiveRadio() { return receiveRadio; }
|
||||
public JTextField getLocalFileField() { return localFileField; }
|
||||
public JTextField getHostFileField() { return hostFileField; }
|
||||
public JRadioButton getAsciiRadio() { return asciiRadio; }
|
||||
public JRadioButton getBinaryRadio() { return binaryRadio; }
|
||||
public JComboBox<Integer> getMtuCombo() { return mtuCombo; }
|
||||
public JCheckBox getCrCheck() { return crCheck; }
|
||||
public JCheckBox getRemapCheck() { return remapCheck; }
|
||||
public JCheckBox getAppendCheck() { return appendCheck; }
|
||||
public JCheckBox getOverwriteCheck() { return overwriteCheck; }
|
||||
public JTextField getRecfmField() { return recfmField; }
|
||||
public JTextField getLreclField() { return lreclField; }
|
||||
public JTextField getBlksizeField() { return blksizeField; }
|
||||
public JTextField getSpaceField() { return spaceField; }
|
||||
public JTextField getOptionsField() { return optionsField; }
|
||||
|
||||
private void applyTheme(Container container) {
|
||||
Color fg = new Color(200, 200, 200);
|
||||
Color bg = new Color(40, 40, 40);
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.DefaultPixelBuffer;
|
||||
import haus.nightmare.lib3270j.graphics.PixelBuffer;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SinglePixelPackedSampleModel;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
/**
|
||||
* Desktop Swing/AWT bridge for converting between lib3270j PixelBuffer and java.awt BufferedImage.
|
||||
*/
|
||||
public final class AwtPixelBufferBridge {
|
||||
|
||||
private AwtPixelBufferBridge() {}
|
||||
|
||||
/**
|
||||
* Converts a PixelBuffer to a BufferedImage.
|
||||
* Uses TYPE_INT_ARGB with backed raster for optimal Java2D hardware acceleration.
|
||||
*/
|
||||
public static BufferedImage toBufferedImage(PixelBuffer buffer) {
|
||||
if (buffer == null) return null;
|
||||
int w = buffer.getWidth();
|
||||
int h = buffer.getHeight();
|
||||
if (w <= 0 || h <= 0) {
|
||||
return new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
|
||||
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
copyIntoBufferedImage(buffer, img);
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies pixels from a PixelBuffer directly into an existing BufferedImage.
|
||||
*/
|
||||
public static void copyIntoBufferedImage(PixelBuffer buffer, BufferedImage target) {
|
||||
if (buffer == null || target == null) return;
|
||||
int w = Math.min(buffer.getWidth(), target.getWidth());
|
||||
int h = Math.min(buffer.getHeight(), target.getHeight());
|
||||
if (w <= 0 || h <= 0) return;
|
||||
|
||||
int[] srcPixels = buffer.getPixels();
|
||||
if (srcPixels == null) return;
|
||||
|
||||
if (target.getType() == BufferedImage.TYPE_INT_ARGB || target.getType() == BufferedImage.TYPE_INT_RGB) {
|
||||
if (target.getRaster().getDataBuffer() instanceof DataBufferInt) {
|
||||
int[] dstPixels = ((DataBufferInt) target.getRaster().getDataBuffer()).getData();
|
||||
int srcW = buffer.getWidth();
|
||||
int dstW = target.getWidth();
|
||||
if (srcW == dstW && srcW == w && srcPixels.length >= w * h && dstPixels.length >= w * h) {
|
||||
System.arraycopy(srcPixels, 0, dstPixels, 0, w * h);
|
||||
return;
|
||||
}
|
||||
for (int y = 0; y < h; y++) {
|
||||
System.arraycopy(srcPixels, y * srcW, dstPixels, y * dstW, w);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for custom or incompatible image formats
|
||||
target.setRGB(0, 0, w, h, srcPixels, 0, buffer.getWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps or converts a java.awt BufferedImage into a PixelBuffer.
|
||||
*/
|
||||
public static PixelBuffer toPixelBuffer(BufferedImage img) {
|
||||
if (img == null) return null;
|
||||
int w = img.getWidth();
|
||||
int h = img.getHeight();
|
||||
int[] pixels;
|
||||
if ((img.getType() == BufferedImage.TYPE_INT_ARGB || img.getType() == BufferedImage.TYPE_INT_RGB)
|
||||
&& img.getRaster().getDataBuffer() instanceof DataBufferInt) {
|
||||
pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
|
||||
} else {
|
||||
pixels = new int[w * h];
|
||||
img.getRGB(0, 0, w, h, pixels, 0, w);
|
||||
}
|
||||
return new DefaultPixelBuffer(w, h, pixels);
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,18 @@ public class ConnectDialog extends JDialog {
|
||||
private JTextField hostField;
|
||||
private JTextField portField;
|
||||
private JComboBox<TerminalModel> modelCombo;
|
||||
private JLabel dynamicDimLabel;
|
||||
private JPanel dynamicDimPanel;
|
||||
private JSpinner dynamicRowsSpinner;
|
||||
private JSpinner dynamicColsSpinner;
|
||||
private JComboBox<haus.nightmare.lib3270j.graphics.GraphicsMode> graphicsCombo;
|
||||
private JComboBox<String> codePageCombo;
|
||||
private JTextField luField;
|
||||
private JCheckBox tlsCheckBox;
|
||||
private JCheckBox verifyCertCheckBox;
|
||||
private JCheckBox tn3270eCheckBox;
|
||||
private JCheckBox keepAliveCheckBox;
|
||||
private JCheckBox autoReconnectCheckBox;
|
||||
private boolean confirmed;
|
||||
private ConnectionConfig result;
|
||||
|
||||
@@ -79,10 +85,49 @@ public class ConnectDialog extends JDialog {
|
||||
ThemeManager.styleComboBox(modelCombo);
|
||||
mainPanel.add(modelCombo, gbc);
|
||||
|
||||
// LU Name
|
||||
// Dynamic Dimensions (shown when IBM-DYNAMIC is selected)
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 0;
|
||||
dynamicDimLabel = new JLabel("Screen Size:");
|
||||
dynamicDimLabel.setFont(labelFont);
|
||||
mainPanel.add(dynamicDimLabel, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1.0;
|
||||
dynamicDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
|
||||
dynamicDimPanel.setOpaque(false);
|
||||
|
||||
JLabel rowsLabel = new JLabel("Rows:");
|
||||
rowsLabel.setFont(labelFont);
|
||||
dynamicRowsSpinner = new JSpinner(new SpinnerNumberModel(haus.nightmare.j3270.config.Settings.getDynamicRows(), 24, 255, 1));
|
||||
ThemeManager.styleSpinner(dynamicRowsSpinner);
|
||||
|
||||
JLabel colsLabel = new JLabel("Cols:");
|
||||
colsLabel.setFont(labelFont);
|
||||
dynamicColsSpinner = new JSpinner(new SpinnerNumberModel(haus.nightmare.j3270.config.Settings.getDynamicCols(), 80, 255, 1));
|
||||
ThemeManager.styleSpinner(dynamicColsSpinner);
|
||||
|
||||
dynamicDimPanel.add(rowsLabel);
|
||||
dynamicDimPanel.add(dynamicRowsSpinner);
|
||||
dynamicDimPanel.add(colsLabel);
|
||||
dynamicDimPanel.add(dynamicColsSpinner);
|
||||
mainPanel.add(dynamicDimPanel, gbc);
|
||||
|
||||
Runnable updateDynamicVisibility = () -> {
|
||||
TerminalModel m = (TerminalModel) modelCombo.getSelectedItem();
|
||||
boolean isDyn = (m != null && m.isDynamic());
|
||||
dynamicDimLabel.setVisible(isDyn);
|
||||
dynamicDimPanel.setVisible(isDyn);
|
||||
pack();
|
||||
};
|
||||
modelCombo.addActionListener(e -> updateDynamicVisibility.run());
|
||||
updateDynamicVisibility.run();
|
||||
|
||||
// LU Name
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 4;
|
||||
gbc.weightx = 0;
|
||||
JLabel luLabel = new JLabel("LU Name:");
|
||||
luLabel.setFont(labelFont);
|
||||
mainPanel.add(luLabel, gbc);
|
||||
@@ -93,7 +138,7 @@ public class ConnectDialog extends JDialog {
|
||||
|
||||
// Graphics Mode
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 4;
|
||||
gbc.gridy = 5;
|
||||
gbc.weightx = 0;
|
||||
JLabel graphicsLabel = new JLabel("Graphics:");
|
||||
graphicsLabel.setFont(labelFont);
|
||||
@@ -108,7 +153,7 @@ public class ConnectDialog extends JDialog {
|
||||
|
||||
// Code Page
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 5;
|
||||
gbc.gridy = 6;
|
||||
gbc.weightx = 0;
|
||||
JLabel cpLabel = new JLabel("Code Page:");
|
||||
cpLabel.setFont(labelFont);
|
||||
@@ -167,7 +212,7 @@ public class ConnectDialog extends JDialog {
|
||||
|
||||
// TLS / SSL Checkbox
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 6;
|
||||
gbc.gridy = 7;
|
||||
gbc.weightx = 1.0;
|
||||
tlsCheckBox = new JCheckBox("Enable TLS/SSL");
|
||||
ThemeManager.styleCheckBox(tlsCheckBox);
|
||||
@@ -186,7 +231,7 @@ public class ConnectDialog extends JDialog {
|
||||
|
||||
// Verify Certificate Checkbox
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 7;
|
||||
gbc.gridy = 8;
|
||||
verifyCertCheckBox = new JCheckBox("Verify Server Certificate");
|
||||
ThemeManager.styleCheckBox(verifyCertCheckBox);
|
||||
verifyCertCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
|
||||
@@ -196,13 +241,31 @@ public class ConnectDialog extends JDialog {
|
||||
|
||||
// TN3270E Checkbox
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 8;
|
||||
gbc.gridy = 9;
|
||||
tn3270eCheckBox = new JCheckBox("Enable TN3270E (Extended 3270)");
|
||||
ThemeManager.styleCheckBox(tn3270eCheckBox);
|
||||
tn3270eCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
|
||||
tn3270eCheckBox.setSelected(haus.nightmare.j3270.config.Settings.getAutoConnectTn3270e());
|
||||
mainPanel.add(tn3270eCheckBox, gbc);
|
||||
|
||||
// Keep-Alive Checkbox
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 10;
|
||||
keepAliveCheckBox = new JCheckBox("Enable Keep-Alive Heartbeat (NOP)");
|
||||
ThemeManager.styleCheckBox(keepAliveCheckBox);
|
||||
keepAliveCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
|
||||
keepAliveCheckBox.setSelected(haus.nightmare.j3270.config.Settings.getAutoConnectKeepAlive());
|
||||
mainPanel.add(keepAliveCheckBox, gbc);
|
||||
|
||||
// Auto-Reconnect Checkbox
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 11;
|
||||
autoReconnectCheckBox = new JCheckBox("Auto-Reconnect on Disconnect");
|
||||
ThemeManager.styleCheckBox(autoReconnectCheckBox);
|
||||
autoReconnectCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
|
||||
autoReconnectCheckBox.setSelected(haus.nightmare.j3270.config.Settings.getAutoConnectAutoReconnect());
|
||||
mainPanel.add(autoReconnectCheckBox, gbc);
|
||||
|
||||
// Buttons
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 4));
|
||||
|
||||
@@ -223,7 +286,7 @@ public class ConnectDialog extends JDialog {
|
||||
buttonPanel.add(connectBtn);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 9;
|
||||
gbc.gridy = 12;
|
||||
gbc.gridwidth = 2;
|
||||
mainPanel.add(buttonPanel, gbc);
|
||||
|
||||
@@ -256,7 +319,15 @@ public class ConnectDialog extends JDialog {
|
||||
return;
|
||||
}
|
||||
|
||||
result = new ConnectionConfig(host, port, (TerminalModel) modelCombo.getSelectedItem());
|
||||
TerminalModel selectedModel = (TerminalModel) modelCombo.getSelectedItem();
|
||||
result = new ConnectionConfig(host, port, selectedModel);
|
||||
if (selectedModel != null && selectedModel.isDynamic()) {
|
||||
int dRows = (Integer) dynamicRowsSpinner.getValue();
|
||||
int dCols = (Integer) dynamicColsSpinner.getValue();
|
||||
result.setDynamicDimensions(dRows, dCols);
|
||||
haus.nightmare.j3270.config.Settings.setDynamicRows(dRows);
|
||||
haus.nightmare.j3270.config.Settings.setDynamicCols(dCols);
|
||||
}
|
||||
String lu = luField.getText().trim();
|
||||
if (!lu.isEmpty()) {
|
||||
result.setLuName(lu);
|
||||
@@ -277,6 +348,18 @@ public class ConnectDialog extends JDialog {
|
||||
result.setUseTls(tlsCheckBox.isSelected());
|
||||
result.setTlsVerifyCert(verifyCertCheckBox.isSelected());
|
||||
result.setTn3270eEnabled(tn3270eCheckBox.isSelected());
|
||||
result.setAutoSysUnlock(haus.nightmare.j3270.config.Settings.getAutoSysUnlock());
|
||||
|
||||
boolean ka = keepAliveCheckBox.isSelected();
|
||||
result.setKeepAliveEnabled(ka);
|
||||
result.setKeepAliveIntervalSeconds(haus.nightmare.j3270.config.Settings.getAutoConnectKeepAliveInterval());
|
||||
haus.nightmare.j3270.config.Settings.setAutoConnectKeepAlive(ka);
|
||||
|
||||
boolean ar = autoReconnectCheckBox.isSelected();
|
||||
result.setAutoReconnect(ar);
|
||||
result.setReconnectMaxRetries(haus.nightmare.j3270.config.Settings.getAutoConnectReconnectMaxRetries());
|
||||
haus.nightmare.j3270.config.Settings.setAutoConnectAutoReconnect(ar);
|
||||
|
||||
confirmed = true;
|
||||
dispose();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Keyboard mapping profile (.kmp) file importer and keybinding utility.
|
||||
* Parses keyboard mapping profile files, translates key scan codes and mnemonics
|
||||
* to j3270 action handlers.
|
||||
*/
|
||||
public class KeyBindings {
|
||||
|
||||
private static final Logger log = Logger.getLogger(KeyBindings.class.getName());
|
||||
|
||||
// IBM scan code to standard Java KeyStroke key name mapping
|
||||
private static final Map<Integer, String> SCAN_CODE_MAP = new HashMap<>();
|
||||
|
||||
// Mnemonic to j3270 action mapping
|
||||
private static final Map<String, String> MNEMONIC_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
// Alphanumeric and symbol keys
|
||||
SCAN_CODE_MAP.put(1, "BACK_QUOTE");
|
||||
SCAN_CODE_MAP.put(2, "1");
|
||||
SCAN_CODE_MAP.put(3, "2");
|
||||
SCAN_CODE_MAP.put(4, "3");
|
||||
SCAN_CODE_MAP.put(5, "4");
|
||||
SCAN_CODE_MAP.put(6, "5");
|
||||
SCAN_CODE_MAP.put(7, "6");
|
||||
SCAN_CODE_MAP.put(8, "7");
|
||||
SCAN_CODE_MAP.put(9, "8");
|
||||
SCAN_CODE_MAP.put(10, "9");
|
||||
SCAN_CODE_MAP.put(11, "0");
|
||||
SCAN_CODE_MAP.put(12, "MINUS");
|
||||
SCAN_CODE_MAP.put(13, "EQUALS");
|
||||
SCAN_CODE_MAP.put(14, "BACK_SPACE");
|
||||
SCAN_CODE_MAP.put(15, "TAB");
|
||||
SCAN_CODE_MAP.put(16, "Q");
|
||||
SCAN_CODE_MAP.put(17, "W");
|
||||
SCAN_CODE_MAP.put(18, "E");
|
||||
SCAN_CODE_MAP.put(19, "R");
|
||||
SCAN_CODE_MAP.put(20, "T");
|
||||
SCAN_CODE_MAP.put(21, "Y");
|
||||
SCAN_CODE_MAP.put(22, "U");
|
||||
SCAN_CODE_MAP.put(23, "I");
|
||||
SCAN_CODE_MAP.put(24, "O");
|
||||
SCAN_CODE_MAP.put(25, "P");
|
||||
SCAN_CODE_MAP.put(26, "OPEN_BRACKET");
|
||||
SCAN_CODE_MAP.put(27, "CLOSE_BRACKET");
|
||||
SCAN_CODE_MAP.put(28, "BACK_SLASH");
|
||||
SCAN_CODE_MAP.put(29, "CAPS_LOCK");
|
||||
SCAN_CODE_MAP.put(30, "A");
|
||||
SCAN_CODE_MAP.put(31, "S");
|
||||
SCAN_CODE_MAP.put(32, "D");
|
||||
SCAN_CODE_MAP.put(33, "F");
|
||||
SCAN_CODE_MAP.put(34, "G");
|
||||
SCAN_CODE_MAP.put(35, "H");
|
||||
SCAN_CODE_MAP.put(36, "J");
|
||||
SCAN_CODE_MAP.put(37, "K");
|
||||
SCAN_CODE_MAP.put(38, "L");
|
||||
SCAN_CODE_MAP.put(39, "SEMICOLON");
|
||||
SCAN_CODE_MAP.put(40, "QUOTE");
|
||||
SCAN_CODE_MAP.put(41, "BACK_QUOTE");
|
||||
SCAN_CODE_MAP.put(42, "ENTER");
|
||||
SCAN_CODE_MAP.put(43, "ENTER");
|
||||
SCAN_CODE_MAP.put(45, "Z");
|
||||
SCAN_CODE_MAP.put(46, "X");
|
||||
SCAN_CODE_MAP.put(47, "C");
|
||||
SCAN_CODE_MAP.put(48, "V");
|
||||
SCAN_CODE_MAP.put(49, "B");
|
||||
SCAN_CODE_MAP.put(50, "N");
|
||||
SCAN_CODE_MAP.put(51, "M");
|
||||
SCAN_CODE_MAP.put(52, "COMMA");
|
||||
SCAN_CODE_MAP.put(53, "PERIOD");
|
||||
SCAN_CODE_MAP.put(54, "SLASH");
|
||||
SCAN_CODE_MAP.put(57, "SPACE");
|
||||
|
||||
// Editing & Navigation keys
|
||||
SCAN_CODE_MAP.put(75, "INSERT");
|
||||
SCAN_CODE_MAP.put(76, "DELETE");
|
||||
SCAN_CODE_MAP.put(79, "LEFT");
|
||||
SCAN_CODE_MAP.put(80, "HOME");
|
||||
SCAN_CODE_MAP.put(81, "END");
|
||||
SCAN_CODE_MAP.put(83, "UP");
|
||||
SCAN_CODE_MAP.put(84, "DOWN");
|
||||
SCAN_CODE_MAP.put(85, "PAGE_UP");
|
||||
SCAN_CODE_MAP.put(86, "PAGE_DOWN");
|
||||
SCAN_CODE_MAP.put(89, "RIGHT");
|
||||
|
||||
// Numeric Keypad
|
||||
SCAN_CODE_MAP.put(90, "NUM_LOCK");
|
||||
SCAN_CODE_MAP.put(91, "NUMPAD7");
|
||||
SCAN_CODE_MAP.put(92, "NUMPAD4");
|
||||
SCAN_CODE_MAP.put(93, "NUMPAD1");
|
||||
SCAN_CODE_MAP.put(95, "DIVIDE");
|
||||
SCAN_CODE_MAP.put(96, "NUMPAD8");
|
||||
SCAN_CODE_MAP.put(97, "NUMPAD5");
|
||||
SCAN_CODE_MAP.put(98, "NUMPAD2");
|
||||
SCAN_CODE_MAP.put(99, "NUMPAD0");
|
||||
SCAN_CODE_MAP.put(100, "MULTIPLY");
|
||||
SCAN_CODE_MAP.put(101, "NUMPAD9");
|
||||
SCAN_CODE_MAP.put(102, "NUMPAD6");
|
||||
SCAN_CODE_MAP.put(103, "NUMPAD3");
|
||||
SCAN_CODE_MAP.put(104, "DECIMAL");
|
||||
SCAN_CODE_MAP.put(105, "SUBTRACT");
|
||||
SCAN_CODE_MAP.put(106, "ADD");
|
||||
SCAN_CODE_MAP.put(108, "ENTER");
|
||||
|
||||
// Function keys & Escape
|
||||
SCAN_CODE_MAP.put(110, "ESCAPE");
|
||||
SCAN_CODE_MAP.put(112, "F1");
|
||||
SCAN_CODE_MAP.put(113, "F2");
|
||||
SCAN_CODE_MAP.put(114, "F3");
|
||||
SCAN_CODE_MAP.put(115, "F4");
|
||||
SCAN_CODE_MAP.put(116, "F5");
|
||||
SCAN_CODE_MAP.put(117, "F6");
|
||||
SCAN_CODE_MAP.put(118, "F7");
|
||||
SCAN_CODE_MAP.put(119, "F8");
|
||||
SCAN_CODE_MAP.put(120, "F9");
|
||||
SCAN_CODE_MAP.put(121, "F10");
|
||||
SCAN_CODE_MAP.put(122, "F11");
|
||||
SCAN_CODE_MAP.put(123, "F12");
|
||||
|
||||
// Mnemonics mapping
|
||||
MNEMONIC_MAP.put("enter", "ENTER");
|
||||
MNEMONIC_MAP.put("enterreset", "ENTER");
|
||||
MNEMONIC_MAP.put("newline", "NEWLINE");
|
||||
MNEMONIC_MAP.put("tab", "TAB");
|
||||
MNEMONIC_MAP.put("backtab", "shift TAB");
|
||||
MNEMONIC_MAP.put("reset", "ESCAPE");
|
||||
MNEMONIC_MAP.put("clear", "CLEAR");
|
||||
MNEMONIC_MAP.put("eraseeof", "END");
|
||||
MNEMONIC_MAP.put("eof", "END");
|
||||
MNEMONIC_MAP.put("erasefld", "ERASE_INPUT");
|
||||
MNEMONIC_MAP.put("erinp", "ERASE_INPUT");
|
||||
MNEMONIC_MAP.put("eraseinput", "ERASE_INPUT");
|
||||
MNEMONIC_MAP.put("dup", "DUP");
|
||||
MNEMONIC_MAP.put("fieldmark", "FIELD_MARK");
|
||||
MNEMONIC_MAP.put("fldmark", "FIELD_MARK");
|
||||
MNEMONIC_MAP.put("fldext", "NEWLINE");
|
||||
MNEMONIC_MAP.put("field-exit", "NEWLINE");
|
||||
MNEMONIC_MAP.put("field+", "TAB");
|
||||
MNEMONIC_MAP.put("field-", "TAB");
|
||||
MNEMONIC_MAP.put("attn", "ATTN");
|
||||
MNEMONIC_MAP.put("sysreq", "SYSREQ");
|
||||
MNEMONIC_MAP.put("cursel", "CURSEL");
|
||||
MNEMONIC_MAP.put("copy", "COPY");
|
||||
MNEMONIC_MAP.put("paste", "PASTE");
|
||||
MNEMONIC_MAP.put("selectall", "SELECTALL");
|
||||
MNEMONIC_MAP.put("insert", "INSERT");
|
||||
MNEMONIC_MAP.put("delete", "DELETE");
|
||||
MNEMONIC_MAP.put("backspace", "BACK_SPACE");
|
||||
MNEMONIC_MAP.put("home", "HOME");
|
||||
MNEMONIC_MAP.put("end", "END");
|
||||
MNEMONIC_MAP.put("up", "UP");
|
||||
MNEMONIC_MAP.put("down", "DOWN");
|
||||
MNEMONIC_MAP.put("left", "LEFT");
|
||||
MNEMONIC_MAP.put("right", "RIGHT");
|
||||
MNEMONIC_MAP.put("pageup", "PAGE_UP");
|
||||
MNEMONIC_MAP.put("pagedn", "PAGE_DOWN");
|
||||
MNEMONIC_MAP.put("pagedown", "PAGE_DOWN");
|
||||
MNEMONIC_MAP.put("docmode", "DOCMODE");
|
||||
MNEMONIC_MAP.put("wordwrap", "WORDWRAP");
|
||||
MNEMONIC_MAP.put("apl", "APL");
|
||||
MNEMONIC_MAP.put("rule", "CROSSHAIR_RULER");
|
||||
MNEMONIC_MAP.put("statusbar", "STATUS_BAR");
|
||||
|
||||
for (int i = 1; i <= 24; i++) {
|
||||
MNEMONIC_MAP.put("pf" + i, "PF" + i);
|
||||
}
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
MNEMONIC_MAP.put("pa" + i, "PA" + i);
|
||||
}
|
||||
// Shifted PF keys 1-12 = PF13-PF24
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
MNEMONIC_MAP.put("spf" + i, "PF" + (i + 12));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a .kmp file from a File object.
|
||||
*
|
||||
* @param file the .kmp file to parse
|
||||
* @return Map of j3270 action names to key stroke bindings
|
||||
* @throws IOException on I/O error
|
||||
*/
|
||||
public static Map<String, String> parseKmp(File file) throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
return parseKmp(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a .kmp file from an InputStream.
|
||||
*
|
||||
* @param in the InputStream to parse
|
||||
* @return Map of j3270 action names to key stroke bindings
|
||||
* @throws IOException on I/O error
|
||||
*/
|
||||
public static Map<String, String> parseKmp(InputStream in) throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
|
||||
return parseKmp(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a .kmp file from a Reader.
|
||||
* Supports both INI-style KEY<n>=action formats and bind statements.
|
||||
*
|
||||
* @param reader the reader to parse from
|
||||
* @return Map of j3270 action names to key stroke bindings
|
||||
* @throws IOException on I/O error
|
||||
*/
|
||||
public static Map<String, String> parseKmp(Reader reader) throws IOException {
|
||||
BufferedReader br = (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader);
|
||||
Map<String, List<String>> actionToBindings = new LinkedHashMap<>();
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
line = line.trim();
|
||||
|
||||
// Strip comments
|
||||
int commentIdx = line.indexOf(';');
|
||||
if (commentIdx >= 0) {
|
||||
line = line.substring(0, commentIdx).trim();
|
||||
}
|
||||
commentIdx = line.indexOf('#');
|
||||
if (commentIdx >= 0) {
|
||||
line = line.substring(0, commentIdx).trim();
|
||||
}
|
||||
|
||||
if (line.isEmpty() || line.startsWith("[")) {
|
||||
continue; // Skip section headers and blank lines
|
||||
}
|
||||
|
||||
// Syntax 1: bind [mnemonic] KeyCombination OR bind action KeyCombination
|
||||
if (line.toLowerCase().startsWith("bind ")) {
|
||||
parseBindStatement(line.substring(5).trim(), actionToBindings);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Syntax 2: KEY<n>=action OR Modifier-KEY<n>=action OR KeyStroke=[mnemonic]
|
||||
int eq = line.indexOf('=');
|
||||
if (eq > 0) {
|
||||
String left = line.substring(0, eq).trim();
|
||||
String right = line.substring(eq + 1).trim();
|
||||
parseKeyAssignment(left, right, actionToBindings);
|
||||
}
|
||||
}
|
||||
|
||||
// Format into combined comma-separated bindings map
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, List<String>> entry : actionToBindings.entrySet()) {
|
||||
String action = entry.getKey();
|
||||
List<String> bindings = entry.getValue();
|
||||
if (!bindings.isEmpty()) {
|
||||
result.put(action, String.join(", ", bindings));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void parseBindStatement(String stmt, Map<String, List<String>> actionToBindings) {
|
||||
String[] parts = stmt.split("\\s+", 2);
|
||||
if (parts.length < 2) return;
|
||||
|
||||
String target = parts[0].trim();
|
||||
String keyStrokeStr = parts[1].trim();
|
||||
|
||||
String action = resolveMnemonic(target);
|
||||
if (action == null) {
|
||||
// Check if parts[1] was the mnemonic instead (e.g. "bind KeyCombination [mnemonic]")
|
||||
String altAction = resolveMnemonic(keyStrokeStr);
|
||||
if (altAction != null) {
|
||||
action = altAction;
|
||||
keyStrokeStr = target;
|
||||
}
|
||||
}
|
||||
|
||||
if (action != null) {
|
||||
String normKeyStroke = normalizeKeyStroke(keyStrokeStr);
|
||||
if (normKeyStroke != null && !normKeyStroke.isEmpty()) {
|
||||
addBinding(actionToBindings, action, normKeyStroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseKeyAssignment(String left, String right, Map<String, List<String>> actionToBindings) {
|
||||
// Case A: left is KEY<n> or Modifier-KEY<n>, right is mnemonic
|
||||
String action = resolveMnemonic(right);
|
||||
String keyStroke = null;
|
||||
|
||||
if (action != null) {
|
||||
keyStroke = parseScanCodeEntry(left);
|
||||
} else {
|
||||
// Case B: left is mnemonic, right is KeyStroke
|
||||
action = resolveMnemonic(left);
|
||||
if (action != null) {
|
||||
keyStroke = normalizeKeyStroke(right);
|
||||
} else {
|
||||
// Case C: left is KeyStroke, right is mnemonic
|
||||
action = resolveMnemonic(right);
|
||||
if (action != null) {
|
||||
keyStroke = normalizeKeyStroke(left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (action != null && keyStroke != null && !keyStroke.isEmpty()) {
|
||||
addBinding(actionToBindings, action, keyStroke);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse scan code entry like "KEY43", "S-KEY112", "C-KEY43", "CS-KEY85", etc.
|
||||
*/
|
||||
public static String parseScanCodeEntry(String entry) {
|
||||
if (entry == null || entry.isEmpty()) return null;
|
||||
|
||||
String upper = entry.toUpperCase().trim();
|
||||
int keyPos = upper.indexOf("KEY");
|
||||
if (keyPos < 0) {
|
||||
return normalizeKeyStroke(entry);
|
||||
}
|
||||
|
||||
String prefix = upper.substring(0, keyPos);
|
||||
if (prefix.endsWith("-")) {
|
||||
prefix = prefix.substring(0, prefix.length() - 1);
|
||||
}
|
||||
|
||||
String numPart = upper.substring(keyPos + 3);
|
||||
int scanCode;
|
||||
try {
|
||||
scanCode = Integer.parseInt(numPart.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String baseKey = SCAN_CODE_MAP.get(scanCode);
|
||||
if (baseKey == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (prefix.contains("C")) sb.append("ctrl ");
|
||||
if (prefix.contains("A") || prefix.contains("2")) sb.append("alt ");
|
||||
if (prefix.contains("S")) sb.append("shift ");
|
||||
if (prefix.contains("M")) sb.append("meta ");
|
||||
|
||||
sb.append(baseKey);
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize key stroke expression (e.g. "Ctrl+Shift+C" -> "ctrl shift C").
|
||||
*/
|
||||
public static String normalizeKeyStroke(String stroke) {
|
||||
if (stroke == null || stroke.trim().isEmpty()) return null;
|
||||
String s = stroke.trim();
|
||||
|
||||
// Check if it is an IBM scan code
|
||||
if (s.toUpperCase().contains("KEY")) {
|
||||
String fromScan = parseScanCodeEntry(s);
|
||||
if (fromScan != null) return fromScan;
|
||||
}
|
||||
|
||||
// Replace '+' with space
|
||||
s = s.replace("+", " ");
|
||||
String[] parts = s.split("\\s+");
|
||||
|
||||
StringBuilder mods = new StringBuilder();
|
||||
String mainKey = null;
|
||||
|
||||
for (String p : parts) {
|
||||
String lp = p.toLowerCase();
|
||||
if ("ctrl".equals(lp) || "control".equals(lp)) {
|
||||
mods.append("ctrl ");
|
||||
} else if ("shift".equals(lp)) {
|
||||
mods.append("shift ");
|
||||
} else if ("alt".equals(lp)) {
|
||||
mods.append("alt ");
|
||||
} else if ("meta".equals(lp) || "cmd".equals(lp) || "command".equals(lp)) {
|
||||
mods.append("meta ");
|
||||
} else {
|
||||
mainKey = p.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (mainKey == null) return null;
|
||||
return (mods.toString() + mainKey).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a mnemonic token (e.g. "[enter]", "enter", "[pf12]", "eraseeof")
|
||||
* into a j3270 action name.
|
||||
*/
|
||||
public static String resolveMnemonic(String token) {
|
||||
if (token == null) return null;
|
||||
String clean = token.trim();
|
||||
if (clean.startsWith("[") && clean.endsWith("]")) {
|
||||
clean = clean.substring(1, clean.length() - 1);
|
||||
}
|
||||
clean = clean.toLowerCase();
|
||||
|
||||
String direct = MNEMONIC_MAP.get(clean);
|
||||
if (direct != null) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
// Case-insensitive match on existing action names
|
||||
String upper = clean.toUpperCase();
|
||||
if (MNEMONIC_MAP.containsValue(upper)) {
|
||||
return upper;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void addBinding(Map<String, List<String>> map, String action, String keyStroke) {
|
||||
List<String> list = map.computeIfAbsent(action, k -> new ArrayList<>());
|
||||
if (!list.contains(keyStroke)) {
|
||||
list.add(keyStroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,19 +98,21 @@ public class ScreenExporter {
|
||||
writer.write("<style>\n");
|
||||
writer.write("body { background-color: #0a0a0a; color: #32cd32; font-family: 'Courier New', Courier, monospace; font-size: 14px; margin: 20px; }\n");
|
||||
writer.write(".screen { background-color: #000; padding: 15px; border-radius: 4px; display: inline-block; box-shadow: 0 0 10px rgba(0,0,0,0.8); line-height: 1.2; }\n");
|
||||
writer.write(".c-blue { color: #5078ff; }\n");
|
||||
writer.write(".c-red { color: #ff3232; }\n");
|
||||
writer.write(".c-pink { color: #ff82b4; }\n");
|
||||
writer.write(".c-green { color: #32cd32; }\n");
|
||||
writer.write(".c-turq { color: #40e0d0; }\n");
|
||||
writer.write(".c-yellow { color: #ffff50; }\n");
|
||||
writer.write(".c-blue { color: #7890f0; }\n");
|
||||
writer.write(".c-red { color: #ff0000; }\n");
|
||||
writer.write(".c-pink { color: #ff00ff; }\n");
|
||||
writer.write(".c-green { color: #00ff00; }\n");
|
||||
writer.write(".c-turq { color: #00ffff; }\n");
|
||||
writer.write(".c-yellow { color: #ffff00; }\n");
|
||||
writer.write(".c-white { color: #ffffff; }\n");
|
||||
writer.write(".c-black { color: #000000; }\n");
|
||||
writer.write(".c-orange { color: #ffa500; }\n");
|
||||
writer.write(".c-purple { color: #b482ff; }\n");
|
||||
writer.write(".c-palegreen { color: #90ee90; }\n");
|
||||
writer.write(".c-paleturq { color: #afeeee; }\n");
|
||||
writer.write(".c-grey { color: #aaaaaa; }\n");
|
||||
writer.write(".c-deepblue { color: #000080; }\n");
|
||||
writer.write(".c-orange { color: #ffa200; }\n");
|
||||
writer.write(".c-purple { color: #800080; }\n");
|
||||
writer.write(".c-palegreen { color: #008000; }\n");
|
||||
writer.write(".c-paleturq { color: #008080; }\n");
|
||||
writer.write(".c-mustard { color: #a0a000; }\n");
|
||||
writer.write(".c-grey { color: #c0c0c0; }\n");
|
||||
writer.write(".bold { font-weight: bold; }\n");
|
||||
writer.write(".underline { text-decoration: underline; }\n");
|
||||
writer.write("</style>\n</head>\n<body>\n<div class=\"screen\"><pre>");
|
||||
@@ -209,17 +211,17 @@ public class ScreenExporter {
|
||||
case 6: return "c-yellow";
|
||||
case 7: return "c-white";
|
||||
case 8: return "c-black";
|
||||
case 9: return "c-blue";
|
||||
case 9: return "c-deepblue";
|
||||
case 10: return "c-orange";
|
||||
case 11: return "c-purple";
|
||||
case 12: return "c-palegreen";
|
||||
case 13: return "c-paleturq";
|
||||
case 14: return "c-grey";
|
||||
case 15: return "c-white";
|
||||
case 14: return "c-mustard";
|
||||
case 15: return "c-grey";
|
||||
}
|
||||
}
|
||||
if (faIsProtected(currentFA & 0xFF)) {
|
||||
return faIsHigh(currentFA & 0xFF) ? "c-white" : "c-blue";
|
||||
return faIsHigh(currentFA & 0xFF) ? "c-white" : "c-turq";
|
||||
}
|
||||
return faIsHigh(currentFA & 0xFF) ? "c-red" : "c-green";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import haus.nightmare.j3270.config.Settings;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
@@ -30,7 +31,27 @@ public class SettingsDialog extends JDialog {
|
||||
private JPanel autoConnectPanel;
|
||||
private JTextField hostField;
|
||||
private JTextField portField;
|
||||
private JCheckBox autoReconnectCheck;
|
||||
private JCheckBox inputMaskCheck;
|
||||
private JTextField inputMaskCharField;
|
||||
private JCheckBox blockSelectCheck;
|
||||
private JSpinner dynamicRowsSpinner;
|
||||
private JSpinner dynamicColsSpinner;
|
||||
private JCheckBox enablePasteFromExcelCheck;
|
||||
private JCheckBox pasteStopAtProtectedCheck;
|
||||
|
||||
// Entry Assist & Modes tab
|
||||
private JCheckBox docModeCheck;
|
||||
private JCheckBox wordWrapCheck;
|
||||
private JSpinner startColSpinner;
|
||||
private JSpinner endColSpinner;
|
||||
private JCheckBox bellCheck;
|
||||
private JSpinner bellColSpinner;
|
||||
private JTextField tabStopsField;
|
||||
private JCheckBox insertOffOnAidCheck;
|
||||
private JCheckBox fourColorOverrideCheck;
|
||||
private JCheckBox numericFieldLockCheck;
|
||||
private JCheckBox autoSkipCheck;
|
||||
|
||||
// Advanced tab state tracking
|
||||
private final Color[] tempHostColors = new Color[16];
|
||||
@@ -43,7 +64,7 @@ public class SettingsDialog extends JDialog {
|
||||
this.parentApp = parent;
|
||||
|
||||
initComponents();
|
||||
setSize(560, 480);
|
||||
setSize(600, 520);
|
||||
setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
@@ -53,6 +74,7 @@ public class SettingsDialog extends JDialog {
|
||||
|
||||
tabbedPane.addTab("Appearance", createAppearancePanel());
|
||||
tabbedPane.addTab("Behavior", createBehaviorPanel());
|
||||
tabbedPane.addTab("Entry Assist & Modes", createEntryAssistPanel());
|
||||
tabbedPane.addTab("Advanced", createAdvancedPanel());
|
||||
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 8));
|
||||
@@ -131,11 +153,31 @@ public class SettingsDialog extends JDialog {
|
||||
panel.add(fontLabel, gbc);
|
||||
|
||||
String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
|
||||
fontBox = new JComboBox<>(fonts);
|
||||
// Find default
|
||||
java.util.List<String> fontList = new java.util.ArrayList<>();
|
||||
boolean hasMonospaced = false;
|
||||
String currentFont = Settings.getFontFamily();
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
if (fonts[i].equalsIgnoreCase(currentFont)) {
|
||||
for (String f : fonts) {
|
||||
if ("Monospaced".equalsIgnoreCase(f)) {
|
||||
hasMonospaced = true;
|
||||
}
|
||||
fontList.add(f);
|
||||
}
|
||||
if (!hasMonospaced) {
|
||||
fontList.add(0, "Monospaced");
|
||||
}
|
||||
boolean hasCurrent = false;
|
||||
for (String f : fontList) {
|
||||
if (f.equalsIgnoreCase(currentFont)) {
|
||||
hasCurrent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasCurrent && currentFont != null && !currentFont.trim().isEmpty()) {
|
||||
fontList.add(0, currentFont);
|
||||
}
|
||||
fontBox = new JComboBox<>(fontList.toArray(new String[0]));
|
||||
for (int i = 0; i < fontBox.getItemCount(); i++) {
|
||||
if (fontBox.getItemAt(i).equalsIgnoreCase(currentFont)) {
|
||||
fontBox.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
@@ -229,20 +271,180 @@ public class SettingsDialog extends JDialog {
|
||||
});
|
||||
autoConnectPanel.setVisible(Settings.getStartupBehavior() == Settings.StartupBehavior.AUTO_CONNECT);
|
||||
|
||||
// Block select mode checkbox
|
||||
// Auto-Reconnect checkbox
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 2;
|
||||
gbc.gridwidth = 2;
|
||||
autoReconnectCheck = new JCheckBox("Auto-Reconnect on Disconnect", Settings.getAutoConnectAutoReconnect());
|
||||
ThemeManager.styleCheckBox(autoReconnectCheck);
|
||||
panel.add(autoReconnectCheck, gbc);
|
||||
|
||||
// Input Mask feature control
|
||||
gbc.gridy = 3;
|
||||
gbc.gridwidth = 2;
|
||||
JPanel inputMaskPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0));
|
||||
inputMaskPanel.setOpaque(false);
|
||||
inputMaskCheck = new JCheckBox("Enable Input Mask (Password Masking)", Settings.getInputMask());
|
||||
ThemeManager.styleCheckBox(inputMaskCheck);
|
||||
inputMaskPanel.add(inputMaskCheck);
|
||||
|
||||
JLabel maskCharLabel = new JLabel("Mask Character:");
|
||||
inputMaskCharField = new JTextField(Settings.getInputMaskChar(), 2);
|
||||
ThemeManager.styleTextField(inputMaskCharField);
|
||||
inputMaskCharField.setEnabled(inputMaskCheck.isSelected());
|
||||
maskCharLabel.setEnabled(inputMaskCheck.isSelected());
|
||||
inputMaskCheck.addActionListener(e -> {
|
||||
boolean sel = inputMaskCheck.isSelected();
|
||||
inputMaskCharField.setEnabled(sel);
|
||||
maskCharLabel.setEnabled(sel);
|
||||
});
|
||||
inputMaskPanel.add(maskCharLabel);
|
||||
inputMaskPanel.add(inputMaskCharField);
|
||||
panel.add(inputMaskPanel, gbc);
|
||||
|
||||
// Block select mode checkbox
|
||||
gbc.gridy = 4;
|
||||
gbc.gridwidth = 2;
|
||||
blockSelectCheck = new JCheckBox("Block selection mode (rectangular select)", Settings.getBlockSelectMode());
|
||||
panel.add(blockSelectCheck, gbc);
|
||||
|
||||
// Placeholder for potentially more behavior options below
|
||||
gbc.gridy = 3;
|
||||
// Default Dynamic Screen Size
|
||||
gbc.gridy = 5;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridx = 0;
|
||||
panel.add(new JLabel("Default Dynamic Screen:"), gbc);
|
||||
|
||||
JPanel dynDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
|
||||
dynDimPanel.setOpaque(false);
|
||||
dynDimPanel.add(new JLabel("Rows:"));
|
||||
dynamicRowsSpinner = new JSpinner(new SpinnerNumberModel(Settings.getDynamicRows(), 24, 255, 1));
|
||||
ThemeManager.styleSpinner(dynamicRowsSpinner);
|
||||
dynDimPanel.add(dynamicRowsSpinner);
|
||||
dynDimPanel.add(new JLabel("Cols:"));
|
||||
dynamicColsSpinner = new JSpinner(new SpinnerNumberModel(Settings.getDynamicCols(), 80, 255, 1));
|
||||
ThemeManager.styleSpinner(dynamicColsSpinner);
|
||||
dynDimPanel.add(dynamicColsSpinner);
|
||||
|
||||
gbc.gridx = 1;
|
||||
panel.add(dynDimPanel, gbc);
|
||||
|
||||
// Clipboard & Tabular Paste options
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 6;
|
||||
gbc.gridwidth = 2;
|
||||
enablePasteFromExcelCheck = new JCheckBox("Enable Excel / Tabular Paste (advance with tabs & newlines)", Settings.getEnablePasteFromExcel());
|
||||
panel.add(enablePasteFromExcelCheck, gbc);
|
||||
|
||||
gbc.gridy = 7;
|
||||
pasteStopAtProtectedCheck = new JCheckBox("Stop Paste at Protected Boundary", Settings.getPasteStopAtProtectedLine());
|
||||
panel.add(pasteStopAtProtectedCheck, gbc);
|
||||
|
||||
gbc.gridy = 8;
|
||||
gbc.weighty = 1.0;
|
||||
panel.add(Box.createGlue(), gbc);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createEntryAssistPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
// Group 1: Entry Assist / Document Mode
|
||||
JPanel eaGroup = new JPanel(new GridBagLayout());
|
||||
eaGroup.setBorder(BorderFactory.createTitledBorder("Entry Assist (Document Mode)"));
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.insets = new Insets(4, 6, 4, 6);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
|
||||
docModeCheck = new JCheckBox("Enable Document Mode (DOC)", Settings.getEntryAssistDocMode());
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridwidth = 2;
|
||||
eaGroup.add(docModeCheck, gbc);
|
||||
|
||||
wordWrapCheck = new JCheckBox("Enable Word Wrap (V)", Settings.getEntryAssistWordWrap());
|
||||
gbc.gridy = 1;
|
||||
eaGroup.add(wordWrapCheck, gbc);
|
||||
|
||||
// Margins
|
||||
gbc.gridy = 2;
|
||||
gbc.gridwidth = 1;
|
||||
eaGroup.add(new JLabel("Margins:"), gbc);
|
||||
|
||||
JPanel marginPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
|
||||
marginPanel.setOpaque(false);
|
||||
marginPanel.add(new JLabel("Left:"));
|
||||
startColSpinner = new JSpinner(new SpinnerNumberModel(Settings.getEntryAssistStartCol(), 1, 80, 1));
|
||||
ThemeManager.styleSpinner(startColSpinner);
|
||||
marginPanel.add(startColSpinner);
|
||||
|
||||
marginPanel.add(new JLabel("Right:"));
|
||||
endColSpinner = new JSpinner(new SpinnerNumberModel(Settings.getEntryAssistEndCol(), 1, 80, 1));
|
||||
ThemeManager.styleSpinner(endColSpinner);
|
||||
marginPanel.add(endColSpinner);
|
||||
|
||||
gbc.gridx = 1;
|
||||
eaGroup.add(marginPanel, gbc);
|
||||
|
||||
// End-of-Line Bell
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
bellCheck = new JCheckBox("Audible EOL Bell at Col:", Settings.getEntryAssistBell());
|
||||
eaGroup.add(bellCheck, gbc);
|
||||
|
||||
bellColSpinner = new JSpinner(new SpinnerNumberModel(Settings.getEntryAssistBellCol(), 1, 80, 1));
|
||||
ThemeManager.styleSpinner(bellColSpinner);
|
||||
gbc.gridx = 1;
|
||||
eaGroup.add(bellColSpinner, gbc);
|
||||
|
||||
// Tab Stops
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 4;
|
||||
eaGroup.add(new JLabel("Tab Stops:"), gbc);
|
||||
|
||||
tabStopsField = new JTextField(Settings.getEntryAssistTabStops(), 20);
|
||||
tabStopsField.setToolTipText("Comma-separated column numbers (1-80, e.g. 1,9,17,25,33,41,49,57,65,73)");
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
eaGroup.add(tabStopsField, gbc);
|
||||
|
||||
panel.add(eaGroup);
|
||||
panel.add(Box.createVerticalStrut(10));
|
||||
|
||||
// Group 2: Terminal Operational Modes
|
||||
JPanel modesGroup = new JPanel(new GridBagLayout());
|
||||
modesGroup.setBorder(BorderFactory.createTitledBorder("Terminal Operational Modes"));
|
||||
GridBagConstraints gbcM = new GridBagConstraints();
|
||||
gbcM.insets = new Insets(4, 6, 4, 6);
|
||||
gbcM.anchor = GridBagConstraints.WEST;
|
||||
gbcM.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbcM.gridx = 0;
|
||||
gbcM.weightx = 1.0;
|
||||
|
||||
insertOffOnAidCheck = new JCheckBox("Reset Insert mode on AID key (Enter, PF, PA, Clear)", Settings.getInsertOffOnAid());
|
||||
gbcM.gridy = 0;
|
||||
modesGroup.add(insertOffOnAidCheck, gbcM);
|
||||
|
||||
fourColorOverrideCheck = new JCheckBox("Base 4-Color Override mode (3279 green/white/red/turquoise)", Settings.getFourColorOverride());
|
||||
gbcM.gridy = 1;
|
||||
modesGroup.add(fourColorOverrideCheck, gbcM);
|
||||
|
||||
numericFieldLockCheck = new JCheckBox("Lock keyboard on non-numeric input in numeric fields (-NUMERIC)", Settings.getNumericFieldLock());
|
||||
gbcM.gridy = 2;
|
||||
modesGroup.add(numericFieldLockCheck, gbcM);
|
||||
|
||||
autoSkipCheck = new JCheckBox("Auto-Skip to next unprotected field when field is filled", Settings.getAutoSkipEnabled());
|
||||
gbcM.gridy = 3;
|
||||
modesGroup.add(autoSkipCheck, gbcM);
|
||||
|
||||
panel.add(modesGroup);
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createAdvancedPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
@@ -345,7 +547,9 @@ public class SettingsDialog extends JDialog {
|
||||
|
||||
String[] actions = {"ENTER", "TAB", "shift TAB", "UP", "DOWN", "LEFT", "RIGHT",
|
||||
"HOME", "END", "PAGE_UP", "PAGE_DOWN", "ESCAPE", "INSERT", "DELETE", "BACK_SPACE", "CLEAR",
|
||||
"ERASE_INPUT", "NEWLINE", "DUP", "FIELD_MARK", "ATTN", "SYSREQ", "CURSEL"};
|
||||
"STATUS_BAR",
|
||||
"ERASE_INPUT", "NEWLINE", "DUP", "FIELD_MARK", "ATTN", "SYSREQ", "CURSEL",
|
||||
"COPY", "PASTE", "SELECTALL"};
|
||||
|
||||
keymapModel = new DefaultTableModel(new Object[]{"Action", "Key Binding"}, 0) {
|
||||
@Override
|
||||
@@ -356,15 +560,7 @@ public class SettingsDialog extends JDialog {
|
||||
|
||||
// Populate table from Settings or Defaults
|
||||
for(String act : actions) {
|
||||
String def = act;
|
||||
if (def.equals("ERASE_INPUT")) def = "alt E";
|
||||
else if (def.equals("NEWLINE")) def = "shift ENTER";
|
||||
else if (def.equals("DUP")) def = "alt D";
|
||||
else if (def.equals("FIELD_MARK")) def = "alt M";
|
||||
else if (def.equals("ATTN")) def = "alt A";
|
||||
else if (def.equals("SYSREQ")) def = "alt S";
|
||||
else if (def.equals("CURSEL")) def = "alt Q";
|
||||
else if (def.equals("CLEAR")) def = "alt C";
|
||||
String def = getDefaultBinding(act);
|
||||
String current = haus.nightmare.j3270.config.Settings.getKeyBinding(act, def);
|
||||
tempKeyBindings.put(act, current);
|
||||
keymapModel.addRow(new Object[]{act, current});
|
||||
@@ -502,6 +698,45 @@ public class SettingsDialog extends JDialog {
|
||||
});
|
||||
btnPanel.add(btnReset);
|
||||
|
||||
// Import Keymap — import from .kmp file
|
||||
JButton btnImportKmp = new JButton("Import Keymap...");
|
||||
ThemeManager.styleButton(btnImportKmp, ThemeManager.ButtonVariant.DEFAULT);
|
||||
btnImportKmp.addActionListener(e -> {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setDialogTitle("Import Keymap Profile");
|
||||
chooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter("Keyboard Map Profile (*.kmp)", "kmp"));
|
||||
int ret = chooser.showOpenDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File f = chooser.getSelectedFile();
|
||||
try {
|
||||
Map<String, String> imported = KeyBindings.parseKmp(f);
|
||||
int updatedCount = 0;
|
||||
for (Map.Entry<String, String> entry : imported.entrySet()) {
|
||||
String action = entry.getKey();
|
||||
String binding = entry.getValue();
|
||||
tempKeyBindings.put(action, binding);
|
||||
for (int row = 0; row < keymapModel.getRowCount(); row++) {
|
||||
if (action.equalsIgnoreCase((String) keymapModel.getValueAt(row, 0))) {
|
||||
keymapModel.setValueAt(binding, row, 1);
|
||||
updatedCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"Successfully imported " + updatedCount + " key bindings from " + f.getName(),
|
||||
"Keymap Imported",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"Failed to import keymap: " + ex.getMessage(),
|
||||
"Import Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnPanel.add(btnImportKmp);
|
||||
|
||||
main.add(new JScrollPane(table), BorderLayout.CENTER);
|
||||
main.add(btnPanel, BorderLayout.SOUTH);
|
||||
|
||||
@@ -510,13 +745,12 @@ public class SettingsDialog extends JDialog {
|
||||
|
||||
/** Returns the factory-default binding for a given action name. */
|
||||
private String getDefaultBinding(String action) {
|
||||
if (action.startsWith("PF")) {
|
||||
if (action.matches("PF[0-9]+")) {
|
||||
int n = Integer.parseInt(action.substring(2));
|
||||
return n <= 12 ? "F" + n : "shift F" + (n - 12);
|
||||
}
|
||||
if (action.startsWith("PA")) return "alt " + action.substring(2);
|
||||
if (action.equals("CLEAR")) return "alt C";
|
||||
return action; // nav keys default to their own name
|
||||
if (action.matches("PA[1-3]")) return "alt " + action.substring(2);
|
||||
return haus.nightmare.j3270.config.Settings.getDefaultBinding(action);
|
||||
}
|
||||
|
||||
// ========== Apply Settings ==========
|
||||
@@ -552,9 +786,57 @@ public class SettingsDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-Reconnect
|
||||
if (autoReconnectCheck != null) {
|
||||
boolean ar = autoReconnectCheck.isSelected();
|
||||
Settings.setAutoConnectAutoReconnect(ar);
|
||||
if (parentApp != null && parentApp.getClient() != null && parentApp.getClient().getConfig() != null) {
|
||||
parentApp.getClient().getConfig().setAutoReconnect(ar);
|
||||
}
|
||||
}
|
||||
|
||||
// Input Mask
|
||||
if (inputMaskCheck != null) {
|
||||
Settings.setInputMask(inputMaskCheck.isSelected());
|
||||
}
|
||||
if (inputMaskCharField != null) {
|
||||
String charText = inputMaskCharField.getText().trim();
|
||||
Settings.setInputMaskChar(charText.isEmpty() ? "*" : charText.substring(0, 1));
|
||||
}
|
||||
|
||||
// Block select mode
|
||||
Settings.setBlockSelectMode(blockSelectCheck.isSelected());
|
||||
|
||||
// Clipboard & Tabular Paste options
|
||||
if (enablePasteFromExcelCheck != null) {
|
||||
Settings.setEnablePasteFromExcel(enablePasteFromExcelCheck.isSelected());
|
||||
}
|
||||
if (pasteStopAtProtectedCheck != null) {
|
||||
Settings.setPasteStopAtProtectedLine(pasteStopAtProtectedCheck.isSelected());
|
||||
}
|
||||
|
||||
// Default Dynamic screen dimensions
|
||||
if (dynamicRowsSpinner != null && dynamicColsSpinner != null) {
|
||||
Settings.setDynamicRows((Integer) dynamicRowsSpinner.getValue());
|
||||
Settings.setDynamicCols((Integer) dynamicColsSpinner.getValue());
|
||||
}
|
||||
|
||||
// Entry Assist & Modes
|
||||
if (docModeCheck != null) {
|
||||
Settings.setEntryAssistDocMode(docModeCheck.isSelected());
|
||||
Settings.setEntryAssistWordWrap(wordWrapCheck.isSelected());
|
||||
Settings.setEntryAssistStartCol((Integer) startColSpinner.getValue());
|
||||
Settings.setEntryAssistEndCol((Integer) endColSpinner.getValue());
|
||||
Settings.setEntryAssistBell(bellCheck.isSelected());
|
||||
Settings.setEntryAssistBellCol((Integer) bellColSpinner.getValue());
|
||||
Settings.setEntryAssistTabStops(tabStopsField.getText().trim());
|
||||
|
||||
Settings.setInsertOffOnAid(insertOffOnAidCheck.isSelected());
|
||||
Settings.setFourColorOverride(fourColorOverrideCheck.isSelected());
|
||||
Settings.setNumericFieldLock(numericFieldLockCheck.isSelected());
|
||||
Settings.setAutoSkipEnabled(autoSkipCheck.isSelected());
|
||||
}
|
||||
|
||||
// Propagate visual changes to the app
|
||||
// Save Colors
|
||||
for (int i=0; i<16; i++) {
|
||||
@@ -570,6 +852,9 @@ public class SettingsDialog extends JDialog {
|
||||
}
|
||||
|
||||
parentApp.getTerminalPanel().reloadSettings();
|
||||
if (parentApp != null && (parentApp.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
|
||||
parentApp.getTerminalPanel().guardedPack();
|
||||
}
|
||||
ThemeManager.applyThemeToWindow(this);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -18,7 +18,11 @@ public class StatusBar extends JPanel {
|
||||
private final JLabel tlsStatus;
|
||||
private final JLabel luName;
|
||||
private final JLabel lockStatus;
|
||||
private final JLabel insertStatus;
|
||||
private final JLabel aplStatus;
|
||||
private final JLabel fieldTypeStatus;
|
||||
private final JLabel docModeStatus;
|
||||
private final JLabel wordWrapStatus;
|
||||
private final JLabel codePageInfo;
|
||||
private final JLabel modelInfo;
|
||||
private final JLabel cursorPosition;
|
||||
@@ -37,8 +41,40 @@ public class StatusBar extends JPanel {
|
||||
connectionStatus = createLabel("Not Connected", oiaFont, ThemeManager.getOiaFgDim());
|
||||
tlsStatus = createLabel("", oiaFont, ThemeManager.getOiaFgNormal());
|
||||
luName = createLabel("", oiaFont, ThemeManager.getOiaFgNormal());
|
||||
lockStatus = createLabel("", oiaFont, ThemeManager.getOiaFgAlert());
|
||||
lockStatus = createLabel("", oiaFont, ThemeManager.getOiaInputInhibited());
|
||||
insertStatus = createClickableLabel("", oiaFont, ThemeManager.getOiaStatusSysAvail(), "Insert Mode (^ / Insert key) - Click to toggle", () -> {
|
||||
if (terminalPanel != null) {
|
||||
terminalPanel.toggleInsertMode();
|
||||
} else if (client != null) {
|
||||
client.toggleInsert();
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
aplStatus = createClickableLabel("", oiaFont, ThemeManager.getOiaFgAlert(), "APL Keyboard Mode (Alt+F3) - Click to toggle", () -> {
|
||||
if (terminalPanel != null) {
|
||||
terminalPanel.toggleAplMode();
|
||||
} else if (client != null) {
|
||||
client.toggleAplMode();
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
fieldTypeStatus = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
|
||||
docModeStatus = createClickableLabel("", oiaFont, ThemeManager.getOiaStatusSysAvail(), "Entry Assist Document Mode (Alt+F1) - Click to toggle", () -> {
|
||||
if (terminalPanel != null) {
|
||||
terminalPanel.toggleDocMode();
|
||||
} else if (client != null) {
|
||||
client.toggleDocMode();
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
wordWrapStatus = createClickableLabel("", oiaFont, ThemeManager.getOiaStatusSysAvail(), "Entry Assist Word Wrap (Alt+F2) - Click to toggle", () -> {
|
||||
if (terminalPanel != null) {
|
||||
terminalPanel.toggleWordWrap();
|
||||
} else if (client != null) {
|
||||
client.toggleWordWrap();
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
codePageInfo = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
|
||||
modelInfo = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
|
||||
cursorPosition = createLabel("001/001 [0000]", oiaFont, ThemeManager.getOiaFgNormal());
|
||||
@@ -51,9 +87,17 @@ public class StatusBar extends JPanel {
|
||||
add(luName);
|
||||
add(Box.createHorizontalStrut(12));
|
||||
add(lockStatus);
|
||||
add(Box.createHorizontalStrut(8));
|
||||
add(insertStatus);
|
||||
add(Box.createHorizontalStrut(8));
|
||||
add(aplStatus);
|
||||
add(Box.createHorizontalStrut(10));
|
||||
add(fieldTypeStatus);
|
||||
add(Box.createHorizontalGlue());
|
||||
add(docModeStatus);
|
||||
add(Box.createHorizontalStrut(8));
|
||||
add(wordWrapStatus);
|
||||
add(Box.createHorizontalStrut(12));
|
||||
add(codePageInfo);
|
||||
add(Box.createHorizontalStrut(12));
|
||||
add(modelInfo);
|
||||
@@ -69,6 +113,23 @@ public class StatusBar extends JPanel {
|
||||
return label;
|
||||
}
|
||||
|
||||
private JLabel createClickableLabel(String text, Font font, Color fg, String tooltip, Runnable onClick) {
|
||||
JLabel label = new JLabel(text);
|
||||
label.setFont(font);
|
||||
label.setForeground(fg);
|
||||
label.setToolTipText(tooltip);
|
||||
label.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
|
||||
label.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(java.awt.event.MouseEvent e) {
|
||||
if (onClick != null) {
|
||||
onClick.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setClient(Telnet3270Client client, TerminalPanel terminalPanel) {
|
||||
this.client = client;
|
||||
this.terminalPanel = terminalPanel;
|
||||
@@ -76,12 +137,20 @@ public class StatusBar extends JPanel {
|
||||
}
|
||||
|
||||
public void applyTheme(UITheme theme) {
|
||||
if (isDisplayable() && !SwingUtilities.isEventDispatchThread()) {
|
||||
SwingUtilities.invokeLater(() -> applyTheme(theme));
|
||||
return;
|
||||
}
|
||||
setBackground(ThemeManager.getStatusBarBg(theme));
|
||||
setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, ThemeManager.getStatusBarBorder(theme)));
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
if (isDisplayable() && !SwingUtilities.isEventDispatchThread()) {
|
||||
SwingUtilities.invokeLater(this::updateStatus);
|
||||
return;
|
||||
}
|
||||
UITheme theme = ThemeManager.getTheme();
|
||||
if (client == null) {
|
||||
connectionStatus.setText("Not Connected");
|
||||
@@ -89,10 +158,16 @@ public class StatusBar extends JPanel {
|
||||
tlsStatus.setText("");
|
||||
luName.setText("");
|
||||
lockStatus.setText("");
|
||||
lockStatus.setForeground(ThemeManager.getOiaInputInhibited(theme));
|
||||
insertStatus.setText("");
|
||||
aplStatus.setText("");
|
||||
fieldTypeStatus.setText("");
|
||||
docModeStatus.setText("");
|
||||
wordWrapStatus.setText("");
|
||||
codePageInfo.setText("");
|
||||
modelInfo.setText("");
|
||||
cursorPosition.setText("001/001");
|
||||
cursorPosition.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,6 +178,10 @@ public class StatusBar extends JPanel {
|
||||
connectionStatus.setText("Not Connected");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgDim(theme));
|
||||
break;
|
||||
case RECONNECTING:
|
||||
connectionStatus.setText("Reconnecting...");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgAlert(theme));
|
||||
break;
|
||||
case TCP_PENDING:
|
||||
case TELNET_PENDING:
|
||||
connectionStatus.setText("Connecting...");
|
||||
@@ -110,25 +189,25 @@ public class StatusBar extends JPanel {
|
||||
break;
|
||||
case CONNECTED_3270:
|
||||
connectionStatus.setText("TN3270");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
break;
|
||||
case CONNECTED_TN3270E:
|
||||
connectionStatus.setText("TN3270E");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
break;
|
||||
case CONNECTED_SSCP:
|
||||
connectionStatus.setText("SSCP-LU");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
break;
|
||||
case CONNECTED_NVT:
|
||||
case CONNECTED_NVT_CHAR:
|
||||
case CONNECTED_E_NVT:
|
||||
connectionStatus.setText("NVT");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
break;
|
||||
case CONNECTED_UNBOUND:
|
||||
connectionStatus.setText("Unbound");
|
||||
connectionStatus.setForeground(ThemeManager.getOiaFgWarn(theme));
|
||||
connectionStatus.setForeground(ThemeManager.getOiaAttention(theme));
|
||||
break;
|
||||
default:
|
||||
connectionStatus.setText(state.name());
|
||||
@@ -144,11 +223,11 @@ public class StatusBar extends JPanel {
|
||||
String protocol = session != null ? session.getProtocol() : "TLS";
|
||||
if (verified) {
|
||||
tlsStatus.setText("🔒 TLS");
|
||||
tlsStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
tlsStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verified)");
|
||||
} else {
|
||||
tlsStatus.setText("🔓 TLS (Unverified)");
|
||||
tlsStatus.setForeground(ThemeManager.getOiaFgWarn(theme));
|
||||
tlsStatus.setForeground(ThemeManager.getOiaAttention(theme));
|
||||
tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verification Bypassed)");
|
||||
}
|
||||
} else {
|
||||
@@ -164,42 +243,85 @@ public class StatusBar extends JPanel {
|
||||
lu = "LU:" + client.getConfig().getLuName();
|
||||
}
|
||||
luName.setText(lu);
|
||||
luName.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
luName.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
|
||||
// Lock / Inhibit status
|
||||
int inhibit = client.getOIA().getInputInhibited();
|
||||
if (inhibit != ECLConstants.INHIBIT_NOT_INHIBITED) {
|
||||
Color lockFg = ThemeManager.getOiaInputInhibited(theme);
|
||||
switch (inhibit) {
|
||||
case ECLConstants.INHIBIT_SYSTEM_LOCK:
|
||||
lockStatus.setText("X SYSTEM");
|
||||
lockFg = ThemeManager.getOiaInputInhibited(theme);
|
||||
break;
|
||||
case ECLConstants.INHIBIT_COMM_CHECK:
|
||||
lockStatus.setText("X COMM");
|
||||
lockFg = ThemeManager.getOiaCommCheck(theme);
|
||||
break;
|
||||
case ECLConstants.INHIBIT_NUMERIC_ONLY:
|
||||
lockStatus.setText("X NUM");
|
||||
lockFg = ThemeManager.getOiaAttention(theme);
|
||||
break;
|
||||
case ECLConstants.INHIBIT_PROTECTED_FIELD:
|
||||
lockStatus.setText("X PROT");
|
||||
lockFg = ThemeManager.getOiaInputInhibited(theme);
|
||||
break;
|
||||
case ECLConstants.INHIBIT_OVERFLOW:
|
||||
lockStatus.setText("X >");
|
||||
lockFg = ThemeManager.getOiaAttention(theme);
|
||||
break;
|
||||
case ECLConstants.INHIBIT_OPERATOR_DUE:
|
||||
lockStatus.setText("X OP");
|
||||
lockFg = ThemeManager.getOiaAttention(theme);
|
||||
break;
|
||||
default:
|
||||
lockStatus.setText("X LOCKED");
|
||||
lockFg = ThemeManager.getOiaInputInhibited(theme);
|
||||
break;
|
||||
}
|
||||
lockStatus.setForeground(ThemeManager.getOiaFgAlert(theme));
|
||||
} else if (client.getInputProcessor().isInsertMode()) {
|
||||
lockStatus.setText("INSERT");
|
||||
lockStatus.setForeground(ThemeManager.getOiaFgNormal(theme));
|
||||
lockStatus.setForeground(lockFg);
|
||||
} else {
|
||||
lockStatus.setText("");
|
||||
}
|
||||
|
||||
// Insert Mode Indicator
|
||||
boolean isInsert = false;
|
||||
if (terminalPanel != null) {
|
||||
isInsert = terminalPanel.isInsertMode();
|
||||
} else if (client.getInputProcessor() != null) {
|
||||
isInsert = client.getInputProcessor().isInsertMode();
|
||||
}
|
||||
if (isInsert) {
|
||||
insertStatus.setText("^ INS");
|
||||
insertStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
} else {
|
||||
insertStatus.setText("");
|
||||
}
|
||||
|
||||
// APL Keyboard Mode Indicator
|
||||
if (client.getInputProcessor() != null && client.getInputProcessor().isAplKeyboardMode()) {
|
||||
aplStatus.setText("APL");
|
||||
aplStatus.setForeground(ThemeManager.getOiaFgAlert(theme));
|
||||
} else {
|
||||
aplStatus.setText("");
|
||||
}
|
||||
|
||||
// Entry Assist DOC Mode Indicator
|
||||
if (client.getScreenBuffer() != null && client.getScreenBuffer().isEntryAssistDOCmode()) {
|
||||
docModeStatus.setText("DOC");
|
||||
docModeStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
} else {
|
||||
docModeStatus.setText("");
|
||||
}
|
||||
|
||||
// Entry Assist Word Wrap Indicator
|
||||
if (client.getScreenBuffer() != null && client.getScreenBuffer().isEntryAssistWordWrap()) {
|
||||
wordWrapStatus.setText("V");
|
||||
wordWrapStatus.setForeground(ThemeManager.getOiaStatusSysAvail(theme));
|
||||
} else {
|
||||
wordWrapStatus.setText("");
|
||||
}
|
||||
|
||||
// Field status: Numeric vs Alphanumeric
|
||||
if (state.isFullSession() && client.getScreenBuffer().isFormatted()) {
|
||||
if (client.getOIA().isNumeric()) {
|
||||
@@ -223,7 +345,13 @@ public class StatusBar extends JPanel {
|
||||
ScreenBuffer sb = client.getScreenBuffer();
|
||||
int rows = sb.getDisplayRows();
|
||||
int cols = sb.getDisplayCols();
|
||||
modelInfo.setText(client.getConfig().getModel().name().replace('_', '-') + " [" + rows + "x" + cols + "]");
|
||||
String modelName;
|
||||
if (client.getConfig().isDynamicModel() || (client.getConfig().getModel() != null && client.getConfig().getModel().isDynamic())) {
|
||||
modelName = "IBM-DYNAMIC [" + rows + "x" + cols + "]";
|
||||
} else {
|
||||
modelName = client.getConfig().getModel().name().replace('_', '-') + " [" + rows + "x" + cols + "]";
|
||||
}
|
||||
modelInfo.setText(modelName);
|
||||
modelInfo.setForeground(ThemeManager.getOiaFgDim(theme));
|
||||
|
||||
// Cursor position and buffer address
|
||||
|
||||
@@ -57,11 +57,24 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
CHAR_STRINGS[i] = String.valueOf((char) i);
|
||||
}
|
||||
}
|
||||
public enum CursorStyle {
|
||||
BLOCK,
|
||||
UNDERLINE
|
||||
}
|
||||
private CursorStyle cursorStyle = CursorStyle.BLOCK;
|
||||
private static final Color CURSOR_COLOR = new Color(255, 255, 255, 180);
|
||||
private boolean crosshairRulerEnabled = false;
|
||||
private static final Color CROSSHAIR_RULER_COLOR = new Color(0, 255, 0, 102); // 40% alpha (cRC)
|
||||
private boolean inputMaskEnabled = haus.nightmare.j3270.config.Settings.getInputMask();
|
||||
private String inputMaskChar = haus.nightmare.j3270.config.Settings.getInputMaskChar();
|
||||
private boolean textBlinkVisible = true;
|
||||
private Image wallpaperImage = null;
|
||||
private haus.nightmare.lib3270j.graphics.HODWallpaper hodWallpaper = null;
|
||||
|
||||
private int selectionStartRow = -1, selectionStartCol = -1;
|
||||
private int selectionEndRow = -1, selectionEndCol = -1;
|
||||
private boolean isDragging = false;
|
||||
private static final Color SELECTION_COLOR = new Color(75, 110, 175, 100);
|
||||
private static final Color SELECTION_COLOR = new Color(75, 110, 175, 102); // 40% alpha blend
|
||||
|
||||
// ========== Search Highlight state ==========
|
||||
private int searchHighlightAddr = -1;
|
||||
@@ -73,6 +86,33 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
private long lastGraphicsUpdateCount = -1;
|
||||
private java.awt.image.BufferedImage cachedGraphicsImage = null;
|
||||
private boolean resizeGuard = false;
|
||||
private StatusBar statusBar = null;
|
||||
|
||||
// ========== Mode and Listener State ==========
|
||||
private boolean insertMode = false;
|
||||
|
||||
public interface ModeChangeListener {
|
||||
void onModeChanged();
|
||||
}
|
||||
private final java.util.List<ModeChangeListener> modeChangeListeners = new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||
|
||||
public void addModeChangeListener(ModeChangeListener listener) {
|
||||
if (listener != null && !modeChangeListeners.contains(listener)) {
|
||||
modeChangeListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeModeChangeListener(ModeChangeListener listener) {
|
||||
modeChangeListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void fireModeChanged() {
|
||||
for (ModeChangeListener l : modeChangeListeners) {
|
||||
try {
|
||||
l.onModeChanged();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the horizontal render offset to center the grid within the panel.
|
||||
@@ -96,31 +136,31 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
return Math.max(padding, extra / 2);
|
||||
}
|
||||
|
||||
// Default Host color mapping
|
||||
// Default Host color mapping aligned 1:1 with IBM Host On-Demand ColorRemapModel3270
|
||||
public static final Color[] DEFAULT_HOST_COLORS = {
|
||||
new Color(0, 0, 0), // 0: Neutral Black
|
||||
new Color(80, 120, 255), // 1: Blue
|
||||
new Color(255, 50, 50), // 2: Red
|
||||
new Color(255, 130, 180), // 3: Pink
|
||||
new Color(50, 205, 50), // 4: Green
|
||||
new Color(64, 224, 208), // 5: Turquoise
|
||||
new Color(255, 255, 80), // 6: Yellow
|
||||
new Color(120, 144, 240), // 1: Blue (0x7890F0 CUSTOMBLUE)
|
||||
new Color(255, 0, 0), // 2: Red
|
||||
new Color(255, 0, 255), // 3: Pink
|
||||
new Color(0, 255, 0), // 4: Green
|
||||
new Color(0, 255, 255), // 5: Turquoise / Cyan
|
||||
new Color(255, 255, 0), // 6: Yellow
|
||||
new Color(255, 255, 255), // 7: Neutral White
|
||||
new Color(0, 0, 0), // 8: Black
|
||||
new Color(30, 60, 180), // 9: Deep Blue
|
||||
new Color(255, 165, 0), // 10: Orange
|
||||
new Color(180, 130, 255), // 11: Purple
|
||||
new Color(144, 238, 144), // 12: Pale Green
|
||||
new Color(175, 238, 238), // 13: Pale Turquoise
|
||||
new Color(170, 170, 170), // 14: Grey
|
||||
new Color(255, 255, 255), // 15: White
|
||||
new Color(0, 0, 128), // 9: Deep Blue
|
||||
new Color(255, 162, 0), // 10: Orange (0xFFFFA200)
|
||||
new Color(128, 0, 128), // 11: Purple
|
||||
new Color(0, 128, 0), // 12: Pale Green
|
||||
new Color(0, 128, 128), // 13: Pale Turquoise
|
||||
new Color(160, 160, 0), // 14: Mustard (0xFFA0A000)
|
||||
new Color(192, 192, 192), // 15: Grey (0xFFC0C0C0)
|
||||
};
|
||||
|
||||
// Default 3278 monochrome colors
|
||||
public static final Color DEFAULT_MONO_NORMAL = new Color(50, 205, 50);
|
||||
public static final Color DEFAULT_MONO_INTENSIFY = new Color(255, 255, 255);
|
||||
public static final Color DEFAULT_MONO_PROTECTED = new Color(80, 120, 255);
|
||||
public static final Color DEFAULT_MONO_PROTECTED_HIGH = new Color(255, 255, 255);
|
||||
// Default 3278 / base monochrome colors aligned with HoD
|
||||
public static final Color DEFAULT_MONO_NORMAL = new Color(0, 255, 0); // Green
|
||||
public static final Color DEFAULT_MONO_INTENSIFY = new Color(255, 0, 0); // Red
|
||||
public static final Color DEFAULT_MONO_PROTECTED = new Color(0, 255, 255); // Cyan / Turquoise
|
||||
public static final Color DEFAULT_MONO_PROTECTED_HIGH = new Color(255, 255, 255); // White
|
||||
|
||||
// Default Background
|
||||
public static final Color DEFAULT_BG_COLOR = Color.BLACK;
|
||||
@@ -138,6 +178,9 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
setupCursorBlink();
|
||||
|
||||
blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode();
|
||||
crosshairRulerEnabled = haus.nightmare.j3270.config.Settings.getCrosshairRuler();
|
||||
String cStyle = haus.nightmare.j3270.config.Settings.getCursorStyle();
|
||||
cursorStyle = "UNDERLINE".equalsIgnoreCase(cStyle) ? CursorStyle.UNDERLINE : CursorStyle.BLOCK;
|
||||
|
||||
// Handle mouse clicks to position cursor, selection, and grab focus
|
||||
MouseAdapter mouseHandler = new MouseAdapter() {
|
||||
@@ -317,12 +360,12 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
addMouseListener(mouseHandler);
|
||||
addMouseMotionListener(mouseHandler);
|
||||
|
||||
// Handle resize: auto-fit font to window size
|
||||
// Handle resize: keep user configured font persistent without auto-fit reset
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (resizeGuard) return;
|
||||
autoFitFont();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -447,13 +490,27 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
try {
|
||||
String text = (String) Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
.getData(DataFlavor.stringFlavor);
|
||||
if (text != null) {
|
||||
for (char ch : text.toCharArray()) {
|
||||
if (ch == '\n' || ch == '\r') {
|
||||
continue;
|
||||
}
|
||||
if (ch >= 0x20 && ch != 0x7F) {
|
||||
client.typeCharacter(ch);
|
||||
if (text != null && !text.isEmpty()) {
|
||||
ScreenBuffer sb = client.getScreenBuffer();
|
||||
int curPos = sb != null ? sb.getDisplayCursorAddress() : 0;
|
||||
int cols = sb != null ? sb.getDisplayCols() : 80;
|
||||
int curRow = cols > 0 ? curPos / cols : 0;
|
||||
int curCol = cols > 0 ? curPos % cols : 0;
|
||||
boolean excelPaste = haus.nightmare.j3270.config.Settings.getEnablePasteFromExcel();
|
||||
boolean stopAtProtected = haus.nightmare.j3270.config.Settings.getPasteStopAtProtectedLine();
|
||||
|
||||
if (client.getInputProcessor() != null && (excelPaste || stopAtProtected || text.contains("\t") || text.contains("\n") || text.contains("\r"))) {
|
||||
client.getInputProcessor().pasteText(text, excelPaste, stopAtProtected);
|
||||
} else if (client.getPS() != null) {
|
||||
client.getPS().pasteString(text, curRow, curCol);
|
||||
} else {
|
||||
for (char ch : text.toCharArray()) {
|
||||
if (ch == '\n' || ch == '\r') {
|
||||
continue;
|
||||
}
|
||||
if (ch >= 0x20 && ch != 0x7F) {
|
||||
client.typeCharacter(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshScreen();
|
||||
@@ -550,53 +607,20 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Font auto-resize ==========
|
||||
|
||||
private void autoFitFont() {
|
||||
int panelW = getWidth();
|
||||
int panelH = getHeight();
|
||||
if (panelW <= 0 || panelH <= 0) return;
|
||||
|
||||
int termCols = 80;
|
||||
int termRows = 24;
|
||||
if (client != null) {
|
||||
ScreenBuffer sb = client.getScreenBuffer();
|
||||
termCols = sb.getDisplayCols();
|
||||
termRows = sb.getDisplayRows();
|
||||
}
|
||||
|
||||
int availW = panelW - 2 * padding;
|
||||
int availH = panelH - 2 * padding;
|
||||
if (availW <= 0 || availH <= 0) return;
|
||||
|
||||
int bestSize = 8;
|
||||
for (int testSize = 8; testSize <= 72; testSize++) {
|
||||
Font testFont = new Font(terminalFont.getFamily(), Font.PLAIN, testSize);
|
||||
FontMetrics fm = getFontMetrics(testFont);
|
||||
int testCellW = fm.charWidth('M');
|
||||
int testCellH = fm.getHeight();
|
||||
|
||||
if (testCellW * termCols <= availW && testCellH * termRows <= availH) {
|
||||
bestSize = testSize;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestSize != currentFontSize) {
|
||||
currentFontSize = bestSize;
|
||||
haus.nightmare.j3270.config.Settings.setFontSize(bestSize);
|
||||
terminalFont = new Font(terminalFont.getFamily(), Font.PLAIN, bestSize);
|
||||
updateCellSize();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void guardedPack() {
|
||||
if (isDisplayable() && !SwingUtilities.isEventDispatchThread()) {
|
||||
SwingUtilities.invokeLater(this::guardedPack);
|
||||
return;
|
||||
}
|
||||
resizeGuard = true;
|
||||
revalidate();
|
||||
Container top = getTopLevelAncestor();
|
||||
if (top instanceof java.awt.Window) {
|
||||
if (top instanceof java.awt.Frame) {
|
||||
if ((((java.awt.Frame) top).getExtendedState() & java.awt.Frame.MAXIMIZED_BOTH) == 0) {
|
||||
((java.awt.Window) top).pack();
|
||||
}
|
||||
} else if (top instanceof java.awt.Window) {
|
||||
((java.awt.Window) top).pack();
|
||||
}
|
||||
SwingUtilities.invokeLater(() -> resizeGuard = false);
|
||||
@@ -629,7 +653,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
"PAGE_UP", "PAGE_DOWN", "HOME", "END", "ENTER",
|
||||
"ESCAPE", "INSERT", "DELETE", "BACK_SPACE" };
|
||||
for (String key : navKeys) {
|
||||
String binding = haus.nightmare.j3270.config.Settings.getKeyBinding(key, key);
|
||||
String defBinding = haus.nightmare.j3270.config.Settings.getDefaultBinding(key);
|
||||
String binding = haus.nightmare.j3270.config.Settings.getKeyBinding(key, defBinding);
|
||||
bindKeyToMap(im, key, binding);
|
||||
}
|
||||
|
||||
@@ -657,18 +682,31 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
bindKeyToMap(im, "SYSREQ", haus.nightmare.j3270.config.Settings.getKeyBinding("SYSREQ", "alt S"));
|
||||
bindKeyToMap(im, "CURSEL", haus.nightmare.j3270.config.Settings.getKeyBinding("CURSEL", "alt Q"));
|
||||
|
||||
// Operational Mode keybindings
|
||||
bindKeyToMap(im, "DOCMODE", haus.nightmare.j3270.config.Settings.getKeyBinding("DOCMODE", "alt F1"));
|
||||
bindKeyToMap(im, "WORDWRAP", haus.nightmare.j3270.config.Settings.getKeyBinding("WORDWRAP", "alt F2"));
|
||||
bindKeyToMap(im, "APL", haus.nightmare.j3270.config.Settings.getKeyBinding("APL", "alt F3"));
|
||||
|
||||
// Copy/Paste/Lightpen bindings
|
||||
int shortcutMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, shortcutMask), "j3270-COPY");
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, shortcutMask), "j3270-PASTE");
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, shortcutMask), "j3270-SELECTALL");
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, java.awt.event.InputEvent.ALT_DOWN_MASK), "j3270-LIGHTPEN");
|
||||
String defCopy = haus.nightmare.j3270.config.Settings.getDefaultBinding("COPY");
|
||||
String defPaste = haus.nightmare.j3270.config.Settings.getDefaultBinding("PASTE");
|
||||
String defSelectAll = haus.nightmare.j3270.config.Settings.getDefaultBinding("SELECTALL");
|
||||
bindKeyToMap(im, "COPY", haus.nightmare.j3270.config.Settings.getKeyBinding("COPY", defCopy));
|
||||
bindKeyToMap(im, "PASTE", haus.nightmare.j3270.config.Settings.getKeyBinding("PASTE", defPaste));
|
||||
bindKeyToMap(im, "SELECTALL", haus.nightmare.j3270.config.Settings.getKeyBinding("SELECTALL", defSelectAll));
|
||||
bindKeyToMap(im, "LIGHTPEN", haus.nightmare.j3270.config.Settings.getKeyBinding("LIGHTPEN", "alt L"));
|
||||
|
||||
String defStatusBar = haus.nightmare.j3270.config.Settings.getDefaultBinding("STATUS_BAR");
|
||||
bindKeyToMap(im, "STATUS_BAR", haus.nightmare.j3270.config.Settings.getKeyBinding("STATUS_BAR", defStatusBar));
|
||||
|
||||
// Action map implementations
|
||||
am.put("j3270-ENTER", createAction(this::handleEnter));
|
||||
am.put("j3270-ESCAPE", createAction(this::handleReset));
|
||||
am.put("j3270-TAB", createAction(() -> handleTab(false)));
|
||||
am.put("j3270-shift TAB", createAction(() -> handleTab(true)));
|
||||
am.put("j3270-DOCMODE", createAction(this::toggleDocMode));
|
||||
am.put("j3270-WORDWRAP", createAction(this::toggleWordWrap));
|
||||
am.put("j3270-APL", createAction(this::toggleAplMode));
|
||||
am.put("j3270-UP", createAction(() -> handleCursor("up")));
|
||||
am.put("j3270-DOWN", createAction(() -> handleCursor("down")));
|
||||
am.put("j3270-LEFT", createAction(() -> handleCursor("left")));
|
||||
@@ -679,7 +717,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
am.put("j3270-END", createAction(this::handleEraseEOF));
|
||||
am.put("j3270-DELETE", createAction(this::handleDelete));
|
||||
am.put("j3270-BACK_SPACE", createAction(this::handleBackspace));
|
||||
am.put("j3270-INSERT", createAction(this::handleInsert));
|
||||
am.put("j3270-INSERT", createAction(this::toggleInsertMode));
|
||||
am.put("j3270-CLEAR", createAction(this::handleClear));
|
||||
am.put("j3270-ERASE_INPUT", createAction(this::handleEraseInput));
|
||||
am.put("j3270-NEWLINE", createAction(this::handleNewline));
|
||||
@@ -693,6 +731,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
am.put("j3270-PASTE", createAction(this::pasteClipboard));
|
||||
am.put("j3270-SELECTALL", createAction(this::selectAll));
|
||||
am.put("j3270-LIGHTPEN", createAction(this::toggleLightPen));
|
||||
am.put("j3270-STATUS_BAR", createAction(this::toggleStatusBar));
|
||||
|
||||
for (int i = 1; i <= 24; i++) {
|
||||
final int pf = i;
|
||||
@@ -807,6 +846,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
} else if (state.isFullSession()) {
|
||||
client.sendEnter();
|
||||
refreshScreen();
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,6 +864,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
clearSelection();
|
||||
client.reset();
|
||||
refreshScreen();
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,6 +934,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
client.sendPF(n);
|
||||
refreshScreen();
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,6 +961,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
if (client != null && client.getConnectionState().isFullSession()) {
|
||||
client.sendPA(n);
|
||||
refreshScreen();
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,12 +1006,65 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInsert() {
|
||||
if (client != null) {
|
||||
public void toggleInsertMode() {
|
||||
if (client != null && client.getInputProcessor() != null) {
|
||||
var ip = client.getInputProcessor();
|
||||
ip.setInsertMode(!ip.isInsertMode());
|
||||
refreshScreen();
|
||||
insertMode = ip.isInsertMode();
|
||||
} else {
|
||||
insertMode = !insertMode;
|
||||
}
|
||||
refreshScreen();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
fireModeChanged();
|
||||
}
|
||||
|
||||
public boolean isInsertMode() {
|
||||
if (client != null && client.getInputProcessor() != null) {
|
||||
return client.getInputProcessor().isInsertMode();
|
||||
}
|
||||
return insertMode;
|
||||
}
|
||||
|
||||
public void toggleDocMode() {
|
||||
if (client != null) {
|
||||
client.toggleDocMode();
|
||||
haus.nightmare.j3270.config.Settings.setEntryAssistDocMode(client.isDocMode());
|
||||
refreshScreen();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
fireModeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleWordWrap() {
|
||||
if (client != null) {
|
||||
client.toggleWordWrap();
|
||||
haus.nightmare.j3270.config.Settings.setEntryAssistWordWrap(client.isWordWrap());
|
||||
refreshScreen();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
fireModeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleAplMode() {
|
||||
if (client != null) {
|
||||
client.toggleAplMode();
|
||||
refreshScreen();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
fireModeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDocMode() {
|
||||
return client != null && client.isDocMode();
|
||||
}
|
||||
|
||||
public boolean isWordWrap() {
|
||||
return client != null && client.isWordWrap();
|
||||
}
|
||||
|
||||
public boolean isAplMode() {
|
||||
return client != null && client.isAplMode();
|
||||
}
|
||||
|
||||
private void handleClear() {
|
||||
@@ -977,6 +1077,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
client.sendClear();
|
||||
refreshScreen();
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,11 +1134,73 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatusBar(StatusBar statusBar) {
|
||||
this.statusBar = statusBar;
|
||||
}
|
||||
|
||||
public StatusBar getStatusBar() {
|
||||
return statusBar;
|
||||
}
|
||||
|
||||
private Runnable statusBarToggleCallback;
|
||||
|
||||
public void setStatusBarToggleCallback(Runnable callback) {
|
||||
this.statusBarToggleCallback = callback;
|
||||
}
|
||||
|
||||
public void toggleStatusBar() {
|
||||
if (statusBarToggleCallback != null) {
|
||||
statusBarToggleCallback.run();
|
||||
} else if (statusBar != null) {
|
||||
boolean visible = !statusBar.isVisible();
|
||||
statusBar.setVisible(visible);
|
||||
haus.nightmare.j3270.config.Settings.setStatusBarVisible(visible);
|
||||
guardedPack();
|
||||
}
|
||||
}
|
||||
|
||||
public void applyModeSettings() {
|
||||
if (client != null) {
|
||||
ScreenBuffer sb = client.getScreenBuffer();
|
||||
if (sb != null) {
|
||||
sb.setEntryAssistDOCmode(haus.nightmare.j3270.config.Settings.getEntryAssistDocMode());
|
||||
sb.setEntryAssistWordWrap(haus.nightmare.j3270.config.Settings.getEntryAssistWordWrap());
|
||||
sb.setLeftMargin(Math.max(0, haus.nightmare.j3270.config.Settings.getEntryAssistStartCol() - 1));
|
||||
sb.setRightMargin(Math.max(0, haus.nightmare.j3270.config.Settings.getEntryAssistEndCol() - 1));
|
||||
sb.setWordTabPositions(haus.nightmare.j3270.config.Settings.getEntryAssistTabStopsArray());
|
||||
}
|
||||
haus.nightmare.lib3270j.input.InputProcessor ip = client.getInputProcessor();
|
||||
if (ip != null) {
|
||||
ip.setBellEnabled(haus.nightmare.j3270.config.Settings.getEntryAssistBell());
|
||||
ip.setBellColumn(Math.max(0, haus.nightmare.j3270.config.Settings.getEntryAssistBellCol() - 1));
|
||||
if (ip.getBellListener() == null) {
|
||||
ip.setBellListener(() -> {
|
||||
SwingUtilities.invokeLater(() -> Toolkit.getDefaultToolkit().beep());
|
||||
});
|
||||
}
|
||||
ip.setInsertOffOnAid(haus.nightmare.j3270.config.Settings.getInsertOffOnAid());
|
||||
ip.setNumericFieldLock(haus.nightmare.j3270.config.Settings.getNumericFieldLock());
|
||||
ip.setAutoSkipEnabled(haus.nightmare.j3270.config.Settings.getAutoSkipEnabled());
|
||||
}
|
||||
if (client.getPS() != null) {
|
||||
client.getPS().setEnablePasteFromExcel(haus.nightmare.j3270.config.Settings.getEnablePasteFromExcel());
|
||||
client.getPS().setPasteStopAtProtectedLine(haus.nightmare.j3270.config.Settings.getPasteStopAtProtectedLine());
|
||||
}
|
||||
}
|
||||
if (statusBar != null) {
|
||||
statusBar.updateStatus();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void refreshScreen() {
|
||||
if (client != null) {
|
||||
client.getScreenBuffer().updateDisplaySnapshot();
|
||||
}
|
||||
repaint();
|
||||
if (statusBar != null) {
|
||||
statusBar.updateStatus();
|
||||
}
|
||||
Container parent = getParent();
|
||||
while (parent != null) {
|
||||
if (parent instanceof JFrame) {
|
||||
@@ -1074,11 +1238,35 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
setupColors();
|
||||
setupKeyBindings();
|
||||
setupFont();
|
||||
applyModeSettings();
|
||||
blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode();
|
||||
crosshairRulerEnabled = haus.nightmare.j3270.config.Settings.getCrosshairRuler();
|
||||
inputMaskEnabled = haus.nightmare.j3270.config.Settings.getInputMask();
|
||||
inputMaskChar = haus.nightmare.j3270.config.Settings.getInputMaskChar();
|
||||
String cStyle = haus.nightmare.j3270.config.Settings.getCursorStyle();
|
||||
cursorStyle = "UNDERLINE".equalsIgnoreCase(cStyle) ? CursorStyle.UNDERLINE : CursorStyle.BLOCK;
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public boolean isInputMaskEnabled() {
|
||||
return inputMaskEnabled;
|
||||
}
|
||||
|
||||
public void setInputMaskEnabled(boolean enabled) {
|
||||
this.inputMaskEnabled = enabled;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public String getInputMaskChar() {
|
||||
return inputMaskChar;
|
||||
}
|
||||
|
||||
public void setInputMaskChar(String maskChar) {
|
||||
this.inputMaskChar = maskChar;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setFontSize(int size) {
|
||||
currentFontSize = size;
|
||||
haus.nightmare.j3270.config.Settings.setFontSize(size);
|
||||
@@ -1103,18 +1291,31 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
|
||||
private void setupCursorBlink() {
|
||||
blinkTimer = new Timer(530, e -> {
|
||||
blinkTimer = new Timer(500, e -> {
|
||||
cursorVisible = !cursorVisible;
|
||||
textBlinkVisible = !textBlinkVisible;
|
||||
repaint();
|
||||
});
|
||||
blinkTimer.start();
|
||||
}
|
||||
|
||||
public Telnet3270Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setClient(Telnet3270Client client) {
|
||||
this.client = client;
|
||||
if (client != null) {
|
||||
setupGraphicsPlaneRenderer();
|
||||
updateCellSize();
|
||||
applyModeSettings();
|
||||
|
||||
if (client.getInputProcessor() != null) {
|
||||
client.getInputProcessor().setInsertMode(insertMode);
|
||||
client.getInputProcessor().setBellListener(() -> {
|
||||
SwingUtilities.invokeLater(() -> Toolkit.getDefaultToolkit().beep());
|
||||
});
|
||||
}
|
||||
|
||||
client.setNvtClipboardHandler(new haus.nightmare.lib3270j.nvt.NvtProcessor.ClipboardHandler() {
|
||||
@Override
|
||||
@@ -1147,6 +1348,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
});
|
||||
});
|
||||
}
|
||||
fireModeChanged();
|
||||
if (statusBar != null) statusBar.updateStatus();
|
||||
}
|
||||
|
||||
private void setupGraphicsPlaneRenderer() {
|
||||
@@ -1247,7 +1450,18 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
int cols = sb.getDisplayCols();
|
||||
boolean isColorModel = client.getConfig().getModel().isColor();
|
||||
|
||||
// Draw Vector Graphics Plane under text if present
|
||||
// Layer 0: Optional Wallpaper / Background Image
|
||||
if (hodWallpaper != null) {
|
||||
int gridW = cols * cellWidth;
|
||||
int gridH = rows * cellHeight;
|
||||
hodWallpaper.paint(this, g2, ox, oy, gridW, gridH);
|
||||
} else if (wallpaperImage != null) {
|
||||
int gridW = cols * cellWidth;
|
||||
int gridH = rows * cellHeight;
|
||||
g2.drawImage(wallpaperImage, ox, oy, gridW, gridH, null);
|
||||
}
|
||||
|
||||
// Layer 1: Draw Vector Graphics Plane under text if present
|
||||
if (client.getGraphicsPlane() != null && client.getGraphicsPlane().hasContent()) {
|
||||
int gridW = cols * cellWidth;
|
||||
int gridH = rows * cellHeight;
|
||||
@@ -1257,8 +1471,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
if (rgb != null && gWidth > 0 && gHeight > 0) {
|
||||
long currentUpdateCount = client.getGraphicsPlane().getUpdateCount();
|
||||
if (cachedGraphicsImage == null || currentUpdateCount != lastGraphicsUpdateCount || cachedGraphicsImage.getWidth() != gWidth || cachedGraphicsImage.getHeight() != gHeight) {
|
||||
cachedGraphicsImage = new java.awt.image.BufferedImage(gWidth, gHeight, java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
cachedGraphicsImage.setRGB(0, 0, gWidth, gHeight, rgb, 0, gWidth);
|
||||
cachedGraphicsImage = AwtPixelBufferBridge.toBufferedImage(client.getGraphicsPlane());
|
||||
lastGraphicsUpdateCount = currentUpdateCount;
|
||||
}
|
||||
if (gWidth == gridW && gHeight == gridH) {
|
||||
@@ -1269,6 +1482,22 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
}
|
||||
|
||||
// Layer 2: Optional Crosshair Ruler under character glyphs
|
||||
if (crosshairRulerEnabled && client.getConnectionState().isFullSession()) {
|
||||
int curAddr = sb.getDisplayCursorAddress();
|
||||
int curRow = curAddr / cols;
|
||||
int curCol = curAddr % cols;
|
||||
int cx = ox + curCol * cellWidth;
|
||||
int cy = oy + curRow * cellHeight;
|
||||
int gridW = cols * cellWidth;
|
||||
int gridH = rows * cellHeight;
|
||||
|
||||
g2.setColor(CROSSHAIR_RULER_COLOR);
|
||||
g2.fillRect(ox, cy, gridW, cellHeight);
|
||||
g2.fillRect(cx, oy, cellWidth, gridH);
|
||||
}
|
||||
|
||||
// Layer 3: Character / Text Plane
|
||||
byte currentFA = 0;
|
||||
ExtendedAttribute currentFieldEa = null;
|
||||
|
||||
@@ -1296,7 +1525,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine foreground color
|
||||
// Determine foreground and background colors
|
||||
if (isColorModel) {
|
||||
fgColor = getColorForAttribute(ea, currentFieldEa, currentFA);
|
||||
bgColor = getBackgroundForAttribute(ea, currentFieldEa);
|
||||
@@ -1305,6 +1534,9 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
bgColor = this.bgColor;
|
||||
}
|
||||
|
||||
int rawBg = ea.bg != 0 ? (ea.bg & 0xFF) : (currentFieldEa != null ? (currentFieldEa.bg & 0xFF) : 0);
|
||||
boolean bgIsExplicit = (rawBg >= 0xF0 && rawBg <= 0xFF && rawBg != HOST_COLOR_NEUTRAL_BLACK && rawBg != HOST_COLOR_BLACK);
|
||||
|
||||
// Graphics rendition
|
||||
byte gr = ea.gr != 0 ? ea.gr : (currentFieldEa != null ? currentFieldEa.gr : 0);
|
||||
if (gr != 0) {
|
||||
@@ -1317,12 +1549,15 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
|
||||
// Password fields
|
||||
if (faIsZero(currentFA & 0xFF)) {
|
||||
char ch = ea.ucs4;
|
||||
if (ch > 0x20 && ch != 0xFF) {
|
||||
Font f = bold ? boldTerminalFont : terminalFont;
|
||||
g2.setFont(f);
|
||||
g2.setColor(fgColor);
|
||||
g2.drawString("*", x, y + fontAscent);
|
||||
if (inputMaskEnabled) {
|
||||
char ch = ea.ucs4;
|
||||
if (ch > 0x20 && ch != 0xFF) {
|
||||
Font f = bold ? boldTerminalFont : terminalFont;
|
||||
g2.setFont(f);
|
||||
g2.setColor(fgColor);
|
||||
String mask = (inputMaskChar != null && !inputMaskChar.isEmpty()) ? inputMaskChar : "*";
|
||||
g2.drawString(mask, x, y + fontAscent);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCellSelected(row, col)) {
|
||||
@@ -1334,23 +1569,28 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
|
||||
if (reverse) {
|
||||
Color tmp = fgColor;
|
||||
fgColor = bgColor;
|
||||
fgColor = (rawBg == 0) ? this.bgColor : bgColor;
|
||||
bgColor = tmp;
|
||||
}
|
||||
|
||||
if (!bgColor.equals(this.bgColor) || reverse) {
|
||||
g2.setColor(bgColor);
|
||||
g2.fillRect(x, y, cellWidth, cellHeight);
|
||||
} else if (bgIsExplicit || !bgColor.equals(this.bgColor)) {
|
||||
g2.setColor(bgColor);
|
||||
g2.fillRect(x, y, cellWidth, cellHeight);
|
||||
}
|
||||
|
||||
// Check text blink (500ms cycle)
|
||||
boolean blink = (gr & GR_BLINK) != 0;
|
||||
boolean suppressGlyph = blink && !textBlinkVisible;
|
||||
|
||||
// Draw character or Programmed Symbol
|
||||
int cs = (ea.cs != 0) ? (ea.cs & 0xFF) : (currentFieldEa != null ? (currentFieldEa.cs & 0xFF) : 0);
|
||||
boolean drawnAsPs = false;
|
||||
if (cs >= 0x40 && client.getProgramSymbolManager() != null) {
|
||||
if (cs >= 0x40 && client.getProgramSymbolManager() != null && !suppressGlyph) {
|
||||
haus.nightmare.lib3270j.graphics.ProgramSymbolSet.SymbolSlot slot = client.getProgramSymbolManager().getSymbol(cs, ea.ec & 0xFF);
|
||||
if (slot != null) {
|
||||
int symBg = (!bgColor.equals(this.bgColor) || reverse) ? bgColor.getRGB() : 0;
|
||||
java.awt.image.BufferedImage img = slot.getScaledImage(cellWidth, cellHeight, fgColor.getRGB(), symBg);
|
||||
int symBg = (bgIsExplicit || reverse) ? bgColor.getRGB() : 0;
|
||||
haus.nightmare.lib3270j.graphics.PixelBuffer symPb = slot.getScaledPixelBuffer(cellWidth, cellHeight, fgColor.getRGB(), symBg);
|
||||
java.awt.image.BufferedImage img = AwtPixelBufferBridge.toBufferedImage(symPb);
|
||||
if (img != null) {
|
||||
g2.drawImage(img, x, y, null);
|
||||
drawnAsPs = true;
|
||||
@@ -1358,7 +1598,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
}
|
||||
|
||||
if (!drawnAsPs) {
|
||||
if (!drawnAsPs && !suppressGlyph) {
|
||||
char ch = ea.ucs4;
|
||||
if (ch > 0x20 && ch != 0xFF) {
|
||||
Font f = bold ? boldTerminalFont : terminalFont;
|
||||
@@ -1385,7 +1625,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
g2.fillRect(x, y, cellWidth, cellHeight);
|
||||
}
|
||||
|
||||
// Draw selection highlight
|
||||
// Draw selection highlight (40% alpha blend over cell)
|
||||
if (isCellSelected(row, col)) {
|
||||
g2.setColor(SELECTION_COLOR);
|
||||
g2.fillRect(x, y, cellWidth, cellHeight);
|
||||
@@ -1394,9 +1634,15 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
}
|
||||
|
||||
// Draw Graphic Cursor if active
|
||||
if (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive() && client.getGraphicsPlane() != null) {
|
||||
int gocaX = client.getGocaDecoder().getGraphicCursorX();
|
||||
int gocaY = client.getGocaDecoder().getGraphicCursorY();
|
||||
boolean isGraphicCursor = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
|
||||
|| (client.getGraphicsPlane() != null && client.getGraphicsPlane().isGraphicCursorAttached());
|
||||
if (isGraphicCursor && client.getGraphicsPlane() != null) {
|
||||
int gocaX = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
|
||||
? client.getGocaDecoder().getGraphicCursorX()
|
||||
: client.getGraphicsPlane().getGraphicCursorX();
|
||||
int gocaY = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
|
||||
? client.getGocaDecoder().getGraphicCursorY()
|
||||
: client.getGraphicsPlane().getGraphicCursorY();
|
||||
int canvasPx = client.getGraphicsPlane().mapX(gocaX);
|
||||
int canvasPy = client.getGraphicsPlane().mapY(gocaY);
|
||||
int gridW = cols * cellWidth;
|
||||
@@ -1408,12 +1654,19 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.setXORMode(Color.BLACK);
|
||||
g2.drawLine(px - 6, py, px + 6, py);
|
||||
g2.drawLine(px, py - 6, px, py + 6);
|
||||
int shape = client.getGraphicsPlane().getHodCursorShape();
|
||||
if (shape == 2) {
|
||||
// Shape 2: Box cursor per HoD
|
||||
g2.drawRect(px - 3, py - 3, 6, 6);
|
||||
} else {
|
||||
// Shape 1 (default): Crosshair per HoD
|
||||
g2.drawLine(px - 8, py, px + 8, py);
|
||||
g2.drawLine(px, py - 8, px, py + 8);
|
||||
}
|
||||
g2.setPaintMode();
|
||||
}
|
||||
|
||||
// Draw 3270 text cursor
|
||||
// Draw 3270 text cursor with alpha blending (Block / Underline)
|
||||
if (cursorVisible && client.getConnectionState().isFullSession()) {
|
||||
int curAddr = sb.getDisplayCursorAddress();
|
||||
int curRow = curAddr / cols;
|
||||
@@ -1421,21 +1674,94 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
|
||||
int cx = ox + curCol * cellWidth;
|
||||
int cy = oy + curRow * cellHeight;
|
||||
|
||||
boolean isUnderline = (cursorStyle == CursorStyle.UNDERLINE) ||
|
||||
(client.getInputProcessor() != null && client.getInputProcessor().isInsertMode());
|
||||
g2.setColor(CURSOR_COLOR);
|
||||
g2.setXORMode(bgColor);
|
||||
g2.fillRect(cx, cy, cellWidth, cellHeight);
|
||||
g2.setPaintMode();
|
||||
if (isUnderline) {
|
||||
int ulH = Math.max(2, cellHeight / 6);
|
||||
g2.fillRect(cx, cy + cellHeight - ulH, cellWidth, ulH);
|
||||
} else {
|
||||
g2.fillRect(cx, cy, cellWidth, cellHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCrosshairRulerEnabled() {
|
||||
return crosshairRulerEnabled;
|
||||
}
|
||||
|
||||
public void setCrosshairRulerEnabled(boolean enabled) {
|
||||
this.crosshairRulerEnabled = enabled;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void toggleCrosshairRuler() {
|
||||
setCrosshairRulerEnabled(!crosshairRulerEnabled);
|
||||
}
|
||||
|
||||
public CursorStyle getCursorStyle() {
|
||||
return cursorStyle;
|
||||
}
|
||||
|
||||
public void setCursorStyle(CursorStyle style) {
|
||||
this.cursorStyle = (style != null) ? style : CursorStyle.BLOCK;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Image getWallpaperImage() {
|
||||
return wallpaperImage;
|
||||
}
|
||||
|
||||
public void setWallpaperImage(Image wallpaperImage) {
|
||||
this.wallpaperImage = wallpaperImage;
|
||||
if (wallpaperImage != null) {
|
||||
if (this.hodWallpaper == null) {
|
||||
this.hodWallpaper = new haus.nightmare.lib3270j.graphics.HODWallpaper(wallpaperImage, haus.nightmare.lib3270j.graphics.HODWallpaper.HOD_STRETCH);
|
||||
} else {
|
||||
this.hodWallpaper.setImage(wallpaperImage);
|
||||
}
|
||||
} else {
|
||||
this.hodWallpaper = null;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public haus.nightmare.lib3270j.graphics.HODWallpaper getHodWallpaper() {
|
||||
return hodWallpaper;
|
||||
}
|
||||
|
||||
public void setHodWallpaper(haus.nightmare.lib3270j.graphics.HODWallpaper wallpaper) {
|
||||
this.hodWallpaper = wallpaper;
|
||||
if (wallpaper != null) {
|
||||
Object hodImg = wallpaper.getHODImage();
|
||||
if (hodImg instanceof Image) {
|
||||
this.wallpaperImage = (Image) hodImg;
|
||||
} else if (hodImg instanceof haus.nightmare.lib3270j.graphics.PixelBuffer) {
|
||||
this.wallpaperImage = AwtPixelBufferBridge.toBufferedImage((haus.nightmare.lib3270j.graphics.PixelBuffer) hodImg);
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setWallpaperMode(int displayMode) {
|
||||
if (this.hodWallpaper == null && this.wallpaperImage != null) {
|
||||
this.hodWallpaper = new haus.nightmare.lib3270j.graphics.HODWallpaper(this.wallpaperImage, displayMode);
|
||||
} else if (this.hodWallpaper != null) {
|
||||
this.hodWallpaper.setDisplay(displayMode);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
private Color getColorForAttribute(ExtendedAttribute ea, ExtendedAttribute currentFieldEa, byte currentFA) {
|
||||
int fg = ea.fg != 0 ? (ea.fg & 0xFF)
|
||||
: (currentFieldEa != null && currentFieldEa.fg != 0 ? (currentFieldEa.fg & 0xFF) : 0);
|
||||
if (fg >= 0xf0 && fg <= 0xff) {
|
||||
return hostColors[fg - 0xf0];
|
||||
if (!haus.nightmare.j3270.config.Settings.getFourColorOverride()) {
|
||||
int fg = ea.fg != 0 ? (ea.fg & 0xFF)
|
||||
: (currentFieldEa != null && currentFieldEa.fg != 0 ? (currentFieldEa.fg & 0xFF) : 0);
|
||||
if (fg >= 0xf0 && fg <= 0xff) {
|
||||
return hostColors[fg - 0xf0];
|
||||
}
|
||||
}
|
||||
if (faIsProtected(currentFA & 0xFF)) {
|
||||
return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_WHITE] : hostColors[HOST_COLOR_BLUE];
|
||||
return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_WHITE] : hostColors[HOST_COLOR_TURQUOISE];
|
||||
}
|
||||
return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_RED] : hostColors[HOST_COLOR_GREEN];
|
||||
}
|
||||
|
||||
@@ -244,6 +244,38 @@ public final class ThemeManager {
|
||||
return t == UITheme.DARK ? new Color(255, 190, 70) : new Color(180, 100, 0);
|
||||
}
|
||||
|
||||
// Host On-Demand OIA Category Colors (oSI, oII, oAI, oEI, oOB)
|
||||
public static final Color HOD_OIA_STATUS_SYS_AVAIL = new Color(120, 144, 240); // oSI: CUSTOMBLUE
|
||||
public static final Color HOD_OIA_INPUT_INHIBITED = new Color(255, 255, 255); // oII: White
|
||||
public static final Color HOD_OIA_ATTENTION_WARN = new Color(255, 255, 0); // oAI: Yellow
|
||||
public static final Color HOD_OIA_COMM_CHECK_ERROR = new Color(255, 0, 0); // oEI: Red
|
||||
public static final Color HOD_OIA_BG_BLACK = new Color(0, 0, 0); // oOB: Black
|
||||
|
||||
public static Color getOiaStatusSysAvail() { return getOiaStatusSysAvail(currentTheme); }
|
||||
public static Color getOiaStatusSysAvail(UITheme t) {
|
||||
return t == UITheme.DARK ? HOD_OIA_STATUS_SYS_AVAIL : new Color(0, 90, 200);
|
||||
}
|
||||
|
||||
public static Color getOiaInputInhibited() { return getOiaInputInhibited(currentTheme); }
|
||||
public static Color getOiaInputInhibited(UITheme t) {
|
||||
return t == UITheme.DARK ? HOD_OIA_INPUT_INHIBITED : new Color(20, 20, 20);
|
||||
}
|
||||
|
||||
public static Color getOiaAttention() { return getOiaAttention(currentTheme); }
|
||||
public static Color getOiaAttention(UITheme t) {
|
||||
return t == UITheme.DARK ? HOD_OIA_ATTENTION_WARN : new Color(180, 100, 0);
|
||||
}
|
||||
|
||||
public static Color getOiaCommCheck() { return getOiaCommCheck(currentTheme); }
|
||||
public static Color getOiaCommCheck(UITheme t) {
|
||||
return t == UITheme.DARK ? HOD_OIA_COMM_CHECK_ERROR : new Color(190, 20, 20);
|
||||
}
|
||||
|
||||
public static Color getOiaBackground() { return getOiaBackground(currentTheme); }
|
||||
public static Color getOiaBackground(UITheme t) {
|
||||
return t == UITheme.DARK ? HOD_OIA_BG_BLACK : getStatusBarBg(t);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Button Variants & Color helpers
|
||||
// =========================================================================
|
||||
@@ -634,6 +666,16 @@ public final class ThemeManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (comp instanceof StatusBar) {
|
||||
((StatusBar) comp).applyTheme(theme);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comp instanceof TerminalPanel) {
|
||||
comp.repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
if (comp instanceof JMenuBar) {
|
||||
styleMenuBar((JMenuBar) comp);
|
||||
for (int i = 0; i < ((JMenuBar) comp).getMenuCount(); i++) {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package haus.nightmare.j3270;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class LoggingConfigurationTest {
|
||||
|
||||
private PrintStream originalOut;
|
||||
private PrintStream originalErr;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
originalOut = System.out;
|
||||
originalErr = System.err;
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
System.setOut(originalOut);
|
||||
System.setErr(originalErr);
|
||||
// Ensure all handlers are closed and logging reset
|
||||
J3270App.configureLogging(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoggingDisabledWhenDebugFalse() {
|
||||
File logFile = new File("j3270.log");
|
||||
if (logFile.exists()) {
|
||||
logFile.delete();
|
||||
}
|
||||
|
||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(outContent));
|
||||
System.setErr(new PrintStream(errContent));
|
||||
|
||||
J3270App.configureLogging(false);
|
||||
|
||||
// Root logger should have no handlers attached
|
||||
Logger rootLogger = Logger.getLogger("");
|
||||
assertEquals(0, rootLogger.getHandlers().length, "Root logger should have no handlers when debug is disabled");
|
||||
assertEquals(Level.OFF, rootLogger.getLevel(), "Root logger level should be OFF when debug is disabled");
|
||||
|
||||
// Application loggers should be OFF
|
||||
assertEquals(Level.OFF, Logger.getLogger("haus.nightmare").getLevel());
|
||||
assertEquals(Level.OFF, Logger.getLogger("haus.nightmare.j3270").getLevel());
|
||||
assertEquals(Level.OFF, Logger.getLogger("haus.nightmare.lib3270j").getLevel());
|
||||
|
||||
// Emit log records at all levels
|
||||
Logger appLogger = Logger.getLogger("haus.nightmare.j3270.J3270App");
|
||||
appLogger.severe("Test SEVERE message");
|
||||
appLogger.warning("Test WARNING message");
|
||||
appLogger.info("Test INFO message");
|
||||
appLogger.fine("Test FINE message");
|
||||
|
||||
// Verify nothing was written to stdout or stderr
|
||||
assertEquals(0, outContent.size(), "Standard output should be empty when debug is disabled");
|
||||
assertEquals(0, errContent.size(), "Standard error should be empty when debug is disabled");
|
||||
|
||||
// Verify j3270.log was NOT created
|
||||
assertFalse(logFile.exists(), "j3270.log should NOT be created when debug is disabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoggingEnabledWhenDebugTrue() {
|
||||
J3270App.configureLogging(true);
|
||||
|
||||
Logger rootLogger = Logger.getLogger("");
|
||||
Handler[] handlers = rootLogger.getHandlers();
|
||||
assertTrue(handlers.length >= 2, "Root logger should have at least ConsoleHandler and FileHandler when debug is enabled");
|
||||
|
||||
assertEquals(Level.ALL, rootLogger.getLevel());
|
||||
assertEquals(Level.ALL, Logger.getLogger("haus.nightmare").getLevel());
|
||||
assertEquals(Level.ALL, Logger.getLogger("haus.nightmare.j3270").getLevel());
|
||||
assertEquals(Level.ALL, Logger.getLogger("haus.nightmare.lib3270j").getLevel());
|
||||
|
||||
File logFile = new File("j3270.log");
|
||||
assertTrue(logFile.exists(), "j3270.log should be created when debug is enabled");
|
||||
|
||||
// Clean up
|
||||
J3270App.configureLogging(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package haus.nightmare.j3270.ft;
|
||||
|
||||
import haus.nightmare.lib3270j.ft.FTConfig;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.HeadlessException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class FileTransferSessionAndCmsTest {
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void cleanup() {
|
||||
FileTransferDialog.resetSessionState();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCmsFilenamePeriodReplacement() {
|
||||
// Test replacing periods with spaces for CMS
|
||||
assertEquals("fscms exec", FileTransferDialog.formatHostFilename("fscms.exec", FTConfig.HostType.CMS));
|
||||
assertEquals("fscms exec", FileTransferDialog.formatHostFilename("/var/tmp/fscms.exec", FTConfig.HostType.CMS));
|
||||
assertEquals("test script exec", FileTransferDialog.formatHostFilename("test.script.exec", FTConfig.HostType.CMS));
|
||||
assertEquals("noextension", FileTransferDialog.formatHostFilename("noextension", FTConfig.HostType.CMS));
|
||||
|
||||
// TSO and CICS should retain periods
|
||||
assertEquals("fscms.exec", FileTransferDialog.formatHostFilename("fscms.exec", FTConfig.HostType.TSO));
|
||||
assertEquals("my.dataset.name", FileTransferDialog.formatHostFilename("/path/to/my.dataset.name", FTConfig.HostType.TSO));
|
||||
assertEquals("cics.file", FileTransferDialog.formatHostFilename("cics.file", FTConfig.HostType.CICS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionStateRememberedInMemory() {
|
||||
assertNull(FileTransferDialog.getLastTransferState());
|
||||
|
||||
FileTransferDialog.TransferSessionState state = new FileTransferDialog.TransferSessionState();
|
||||
state.hostType = FTConfig.HostType.CMS;
|
||||
state.isSend = true;
|
||||
state.localFile = "/tmp/fscms.exec";
|
||||
state.hostFile = "fscms exec";
|
||||
state.isAscii = true;
|
||||
state.mtu = 8192;
|
||||
state.crFlag = false;
|
||||
state.remapFlag = false;
|
||||
state.append = true;
|
||||
state.overwrite = true;
|
||||
state.options = "CLEAR";
|
||||
|
||||
FileTransferDialog.setLastTransferState(state);
|
||||
|
||||
FileTransferDialog.TransferSessionState retrieved = FileTransferDialog.getLastTransferState();
|
||||
assertNotNull(retrieved);
|
||||
assertEquals(FTConfig.HostType.CMS, retrieved.hostType);
|
||||
assertTrue(retrieved.isSend);
|
||||
assertEquals("/tmp/fscms.exec", retrieved.localFile);
|
||||
assertEquals("fscms exec", retrieved.hostFile);
|
||||
assertTrue(retrieved.isAscii);
|
||||
assertEquals(8192, retrieved.mtu);
|
||||
assertFalse(retrieved.crFlag);
|
||||
assertFalse(retrieved.remapFlag);
|
||||
assertTrue(retrieved.append);
|
||||
assertTrue(retrieved.overwrite);
|
||||
assertEquals("CLEAR", retrieved.options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDialogPrefillingFromSessionState() {
|
||||
FileTransferDialog.TransferSessionState state = new FileTransferDialog.TransferSessionState();
|
||||
state.hostType = FTConfig.HostType.CMS;
|
||||
state.isSend = true;
|
||||
state.localFile = "/tmp/fscms.exec";
|
||||
state.hostFile = "fscms exec";
|
||||
state.isAscii = false; // Binary
|
||||
state.mtu = 4096;
|
||||
state.crFlag = true;
|
||||
state.remapFlag = true;
|
||||
state.append = false;
|
||||
state.overwrite = true;
|
||||
state.options = "ASCII";
|
||||
|
||||
FileTransferDialog.setLastTransferState(state);
|
||||
|
||||
try {
|
||||
FileTransferDialog dialog = new FileTransferDialog(null, null);
|
||||
assertEquals(FTConfig.HostType.CMS, dialog.getHostTypeCombo().getSelectedItem());
|
||||
assertTrue(dialog.getSendRadio().isSelected());
|
||||
assertFalse(dialog.getReceiveRadio().isSelected());
|
||||
assertEquals("/tmp/fscms.exec", dialog.getLocalFileField().getText());
|
||||
assertEquals("fscms exec", dialog.getHostFileField().getText());
|
||||
assertFalse(dialog.getAsciiRadio().isSelected());
|
||||
assertTrue(dialog.getBinaryRadio().isSelected());
|
||||
assertEquals(4096, dialog.getMtuCombo().getSelectedItem());
|
||||
assertTrue(dialog.getOverwriteCheck().isSelected());
|
||||
assertEquals("ASCII", dialog.getOptionsField().getText());
|
||||
dialog.dispose();
|
||||
} catch (HeadlessException e) {
|
||||
// Headless environment; verified through state retention
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.j3270.J3270App;
|
||||
import haus.nightmare.j3270.config.Settings;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class BehaviorSettingsTest {
|
||||
|
||||
private boolean origAutoReconnect;
|
||||
private int origReconnectMaxRetries;
|
||||
private boolean origInputMask;
|
||||
private String origInputMaskChar;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
origAutoReconnect = Settings.getAutoConnectAutoReconnect();
|
||||
origReconnectMaxRetries = Settings.getAutoConnectReconnectMaxRetries();
|
||||
origInputMask = Settings.getInputMask();
|
||||
origInputMaskChar = Settings.getInputMaskChar();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
Settings.setAutoConnectAutoReconnect(origAutoReconnect);
|
||||
Settings.setAutoConnectReconnectMaxRetries(origReconnectMaxRetries);
|
||||
Settings.setInputMask(origInputMask);
|
||||
Settings.setInputMaskChar(origInputMaskChar);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Auto-reconnect settings get/set and alias consistency")
|
||||
public void testAutoReconnectSettingsPersistence() {
|
||||
Settings.setAutoConnectAutoReconnect(true);
|
||||
assertTrue(Settings.getAutoConnectAutoReconnect());
|
||||
assertTrue(Settings.getAutoReconnect());
|
||||
|
||||
Settings.setAutoReconnect(false);
|
||||
assertFalse(Settings.getAutoConnectAutoReconnect());
|
||||
assertFalse(Settings.getAutoReconnect());
|
||||
|
||||
Settings.setAutoConnectReconnectMaxRetries(8);
|
||||
assertEquals(8, Settings.getAutoConnectReconnectMaxRetries());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Input mask settings get/set and defaults")
|
||||
public void testInputMaskSettingsPersistence() {
|
||||
Settings.setInputMask(false);
|
||||
assertFalse(Settings.getInputMask());
|
||||
assertFalse(Settings.getInputMaskEnabled());
|
||||
|
||||
Settings.setInputMaskEnabled(true);
|
||||
assertTrue(Settings.getInputMask());
|
||||
assertTrue(Settings.getInputMaskEnabled());
|
||||
|
||||
Settings.setInputMaskChar("#");
|
||||
assertEquals("#", Settings.getInputMaskChar());
|
||||
|
||||
Settings.setInputMaskChar("*");
|
||||
assertEquals("*", Settings.getInputMaskChar());
|
||||
|
||||
// Empty string should fall back to '*'
|
||||
Settings.setInputMaskChar("");
|
||||
assertEquals("*", Settings.getInputMaskChar());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("INI export and load preserves autoReconnect and inputMask")
|
||||
public void testIniExportAndLoad() throws Exception {
|
||||
Settings.setAutoConnectAutoReconnect(true);
|
||||
Settings.setAutoConnectReconnectMaxRetries(12);
|
||||
Settings.setInputMask(false);
|
||||
Settings.setInputMaskChar("@");
|
||||
|
||||
File tempFile = File.createTempFile("j3270_behavior_test", ".ini");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Settings.exportToIniFile(tempFile.getAbsolutePath());
|
||||
|
||||
// Reset to different values
|
||||
Settings.setAutoConnectAutoReconnect(false);
|
||||
Settings.setAutoConnectReconnectMaxRetries(3);
|
||||
Settings.setInputMask(true);
|
||||
Settings.setInputMaskChar("*");
|
||||
|
||||
// Load back from INI
|
||||
Settings.loadFromIniFile(tempFile.getAbsolutePath());
|
||||
|
||||
assertTrue(Settings.getAutoConnectAutoReconnect());
|
||||
assertEquals(12, Settings.getAutoConnectReconnectMaxRetries());
|
||||
assertFalse(Settings.getInputMask());
|
||||
assertEquals("@", Settings.getInputMaskChar());
|
||||
|
||||
tempFile.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("TerminalPanel reloads input mask settings correctly")
|
||||
public void testTerminalPanelInputMaskReload() {
|
||||
try {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
Settings.setInputMask(false);
|
||||
Settings.setInputMaskChar("$");
|
||||
panel.reloadSettings();
|
||||
|
||||
assertFalse(panel.isInputMaskEnabled());
|
||||
assertEquals("$", panel.getInputMaskChar());
|
||||
|
||||
panel.setInputMaskEnabled(true);
|
||||
assertTrue(panel.isInputMaskEnabled());
|
||||
|
||||
panel.setInputMaskChar("#");
|
||||
assertEquals("#", panel.getInputMaskChar());
|
||||
} catch (HeadlessException ignored) {
|
||||
// Safe fallback for headless runner
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("SettingsDialog contains Auto-Reconnect checkbox and Input Mask controls in Behavior panel")
|
||||
public void testSettingsDialogBehaviorControls() throws Exception {
|
||||
J3270App app;
|
||||
try {
|
||||
app = new J3270App();
|
||||
} catch (HeadlessException e) {
|
||||
// In automated/headless environments, JFrame cannot be initialized
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
SettingsDialog dialog = new SettingsDialog(app);
|
||||
|
||||
// Access private fields in SettingsDialog to verify component bindings
|
||||
Field autoRecField = SettingsDialog.class.getDeclaredField("autoReconnectCheck");
|
||||
autoRecField.setAccessible(true);
|
||||
JCheckBox autoReconnectCheck = (JCheckBox) autoRecField.get(dialog);
|
||||
assertNotNull(autoReconnectCheck, "autoReconnectCheck must exist in SettingsDialog");
|
||||
assertEquals("Auto-Reconnect on Disconnect", autoReconnectCheck.getText());
|
||||
assertEquals(Settings.getAutoConnectAutoReconnect(), autoReconnectCheck.isSelected());
|
||||
|
||||
Field inputMaskCheckField = SettingsDialog.class.getDeclaredField("inputMaskCheck");
|
||||
inputMaskCheckField.setAccessible(true);
|
||||
JCheckBox inputMaskCheck = (JCheckBox) inputMaskCheckField.get(dialog);
|
||||
assertNotNull(inputMaskCheck, "inputMaskCheck must exist in SettingsDialog");
|
||||
assertEquals(Settings.getInputMask(), inputMaskCheck.isSelected());
|
||||
|
||||
Field inputMaskCharField = SettingsDialog.class.getDeclaredField("inputMaskCharField");
|
||||
inputMaskCharField.setAccessible(true);
|
||||
JTextField maskCharField = (JTextField) inputMaskCharField.get(dialog);
|
||||
assertNotNull(maskCharField, "inputMaskCharField must exist in SettingsDialog");
|
||||
assertEquals(Settings.getInputMaskChar(), maskCharField.getText());
|
||||
assertEquals(inputMaskCheck.isSelected(), maskCharField.isEnabled());
|
||||
|
||||
// Test interaction: unchecking inputMask disables character field
|
||||
inputMaskCheck.setSelected(false);
|
||||
for (java.awt.event.ActionListener al : inputMaskCheck.getActionListeners()) {
|
||||
al.actionPerformed(new java.awt.event.ActionEvent(inputMaskCheck, java.awt.event.ActionEvent.ACTION_PERFORMED, ""));
|
||||
}
|
||||
assertFalse(maskCharField.isEnabled());
|
||||
|
||||
dialog.dispose();
|
||||
app.dispose();
|
||||
} catch (HeadlessException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.j3270.config.Settings;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class FontSettingsPersistenceTest {
|
||||
|
||||
private int originalFontSize;
|
||||
private String originalFontFamily;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
originalFontSize = Settings.getFontSize();
|
||||
originalFontFamily = Settings.getFontFamily();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
Settings.setFontSize(originalFontSize);
|
||||
Settings.setFontFamily(originalFontFamily);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingsPersistence() {
|
||||
Settings.setFontSize(22);
|
||||
Settings.setFontFamily("Monospaced");
|
||||
assertEquals(22, Settings.getFontSize());
|
||||
assertEquals("Monospaced", Settings.getFontFamily());
|
||||
|
||||
Settings.setFontSize(18);
|
||||
assertEquals(18, Settings.getFontSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminalPanelResizeDoesNotResetFontSize() {
|
||||
try {
|
||||
Settings.setFontSize(24);
|
||||
Settings.setFontFamily("Monospaced");
|
||||
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
assertEquals(24, panel.getFontSize());
|
||||
assertEquals(24, Settings.getFontSize());
|
||||
|
||||
// Simulate window / component resize events
|
||||
panel.setSize(new Dimension(800, 600));
|
||||
ComponentEvent resizeEvent1 = new ComponentEvent(panel, ComponentEvent.COMPONENT_RESIZED);
|
||||
for (java.awt.event.ComponentListener cl : panel.getComponentListeners()) {
|
||||
cl.componentResized(resizeEvent1);
|
||||
}
|
||||
|
||||
// Verify font size and family did NOT reset
|
||||
assertEquals(24, panel.getFontSize());
|
||||
assertEquals(24, Settings.getFontSize());
|
||||
assertEquals("Monospaced", Settings.getFontFamily());
|
||||
|
||||
// Simulate another resize to smaller dimension
|
||||
panel.setSize(new Dimension(400, 300));
|
||||
ComponentEvent resizeEvent2 = new ComponentEvent(panel, ComponentEvent.COMPONENT_RESIZED);
|
||||
for (java.awt.event.ComponentListener cl : panel.getComponentListeners()) {
|
||||
cl.componentResized(resizeEvent2);
|
||||
}
|
||||
|
||||
assertEquals(24, panel.getFontSize());
|
||||
assertEquals(24, Settings.getFontSize());
|
||||
assertEquals("Monospaced", Settings.getFontFamily());
|
||||
|
||||
panel.dispose();
|
||||
} catch (HeadlessException e) {
|
||||
// In headless environment without display, Settings persistence is verified above
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.j3270.J3270App;
|
||||
import haus.nightmare.j3270.config.Settings;
|
||||
import haus.nightmare.lib3270j.ConnectionConfig;
|
||||
import haus.nightmare.lib3270j.Telnet3270Client;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class KeyBindingsTest {
|
||||
|
||||
@Test
|
||||
public void testDefaultBindingsContainRequiredKeys() {
|
||||
String insertBindings = Settings.getDefaultBinding("INSERT");
|
||||
assertNotNull(insertBindings);
|
||||
assertTrue(insertBindings.contains("INSERT"), "Default INSERT binding should contain INSERT key");
|
||||
if (Settings.isMac()) {
|
||||
assertTrue(insertBindings.contains("HELP"), "macOS INSERT binding should contain HELP key");
|
||||
assertTrue(insertBindings.contains("alt I"), "macOS INSERT binding should contain alt I fallback");
|
||||
} else {
|
||||
assertTrue(insertBindings.contains("ctrl I"), "Non-macOS INSERT binding should contain ctrl I fallback");
|
||||
}
|
||||
|
||||
String copyBindings = Settings.getDefaultBinding("COPY");
|
||||
assertNotNull(copyBindings);
|
||||
assertTrue(copyBindings.contains("ctrl INSERT"), "Default COPY binding should support 3270 Ctrl+Insert");
|
||||
assertTrue(copyBindings.contains("ctrl C"), "Default COPY binding should support Ctrl+C");
|
||||
assertTrue(copyBindings.contains("ctrl shift C"), "Default COPY binding should support Ctrl+Shift+C");
|
||||
if (Settings.isMac()) {
|
||||
assertTrue(copyBindings.contains("meta C"), "macOS COPY binding should support Cmd+C");
|
||||
}
|
||||
|
||||
String pasteBindings = Settings.getDefaultBinding("PASTE");
|
||||
assertNotNull(pasteBindings);
|
||||
assertTrue(pasteBindings.contains("shift INSERT"), "Default PASTE binding should support 3270 Shift+Insert");
|
||||
assertTrue(pasteBindings.contains("ctrl V"), "Default PASTE binding should support Ctrl+V");
|
||||
assertTrue(pasteBindings.contains("ctrl shift V"), "Default PASTE binding should support Ctrl+Shift+V");
|
||||
if (Settings.isMac()) {
|
||||
assertTrue(pasteBindings.contains("meta V"), "macOS PASTE binding should support Cmd+V");
|
||||
}
|
||||
|
||||
String selectAllBindings = Settings.getDefaultBinding("SELECTALL");
|
||||
assertNotNull(selectAllBindings);
|
||||
assertTrue(selectAllBindings.contains("ctrl A"), "Default SELECTALL binding should support Ctrl+A");
|
||||
if (Settings.isMac()) {
|
||||
assertTrue(selectAllBindings.contains("meta A"), "macOS SELECTALL binding should support Cmd+A");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminalPanelInputMapAndAction() {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
InputMap im = panel.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
ActionMap am = panel.getActionMap();
|
||||
|
||||
// Check INSERT key mappings
|
||||
KeyStroke ksInsert = KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0);
|
||||
assertEquals("j3270-INSERT", im.get(ksInsert), "VK_INSERT must map to j3270-INSERT");
|
||||
|
||||
if (Settings.isMac()) {
|
||||
KeyStroke ksHelp = KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0);
|
||||
assertEquals("j3270-INSERT", im.get(ksHelp), "VK_HELP must map to j3270-INSERT on Mac");
|
||||
KeyStroke ksAltI = KeyStroke.getKeyStroke("alt I");
|
||||
assertEquals("j3270-INSERT", im.get(ksAltI), "alt I must map to j3270-INSERT on Mac");
|
||||
}
|
||||
|
||||
// Check COPY key mappings
|
||||
KeyStroke ksCtrlIns = KeyStroke.getKeyStroke("ctrl INSERT");
|
||||
assertEquals("j3270-COPY", im.get(ksCtrlIns), "ctrl INSERT must map to j3270-COPY");
|
||||
KeyStroke ksCtrlC = KeyStroke.getKeyStroke("ctrl C");
|
||||
assertEquals("j3270-COPY", im.get(ksCtrlC), "ctrl C must map to j3270-COPY");
|
||||
if (Settings.isMac()) {
|
||||
KeyStroke ksMetaC = KeyStroke.getKeyStroke("meta C");
|
||||
assertEquals("j3270-COPY", im.get(ksMetaC), "meta C must map to j3270-COPY on Mac");
|
||||
}
|
||||
|
||||
// Check PASTE key mappings
|
||||
KeyStroke ksShiftIns = KeyStroke.getKeyStroke("shift INSERT");
|
||||
assertEquals("j3270-PASTE", im.get(ksShiftIns), "shift INSERT must map to j3270-PASTE");
|
||||
KeyStroke ksCtrlV = KeyStroke.getKeyStroke("ctrl V");
|
||||
assertEquals("j3270-PASTE", im.get(ksCtrlV), "ctrl V must map to j3270-PASTE");
|
||||
if (Settings.isMac()) {
|
||||
KeyStroke ksMetaV = KeyStroke.getKeyStroke("meta V");
|
||||
assertEquals("j3270-PASTE", im.get(ksMetaV), "meta V must map to j3270-PASTE on Mac");
|
||||
}
|
||||
|
||||
// Check SELECTALL key mappings
|
||||
KeyStroke ksCtrlA = KeyStroke.getKeyStroke("ctrl A");
|
||||
assertEquals("j3270-SELECTALL", im.get(ksCtrlA), "ctrl A must map to j3270-SELECTALL");
|
||||
if (Settings.isMac()) {
|
||||
KeyStroke ksMetaA = KeyStroke.getKeyStroke("meta A");
|
||||
assertEquals("j3270-SELECTALL", im.get(ksMetaA), "meta A must map to j3270-SELECTALL on Mac");
|
||||
}
|
||||
|
||||
// Test insert mode toggle action
|
||||
assertFalse(panel.isInsertMode(), "Initial insertMode should be false");
|
||||
Action insertAction = am.get("j3270-INSERT");
|
||||
assertNotNull(insertAction, "j3270-INSERT action must exist");
|
||||
|
||||
AtomicBoolean modeChangedFired = new AtomicBoolean(false);
|
||||
panel.addModeChangeListener(() -> modeChangedFired.set(true));
|
||||
|
||||
insertAction.actionPerformed(new ActionEvent(panel, ActionEvent.ACTION_PERFORMED, ""));
|
||||
assertTrue(panel.isInsertMode(), "insertMode should be true after invoking action");
|
||||
assertTrue(modeChangedFired.get(), "ModeChangeListener should have fired");
|
||||
|
||||
modeChangedFired.set(false);
|
||||
insertAction.actionPerformed(new ActionEvent(panel, ActionEvent.ACTION_PERFORMED, ""));
|
||||
assertFalse(panel.isInsertMode(), "insertMode should be false after invoking action again");
|
||||
assertTrue(modeChangedFired.get(), "ModeChangeListener should have fired again");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertModeSyncWithClient() {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
panel.toggleInsertMode();
|
||||
assertTrue(panel.isInsertMode());
|
||||
|
||||
Telnet3270Client client = new Telnet3270Client(new ConnectionConfig("localhost", 23));
|
||||
panel.setClient(client);
|
||||
|
||||
// When client is attached, client's inputProcessor should receive current insertMode
|
||||
assertNotNull(client.getInputProcessor());
|
||||
assertTrue(client.getInputProcessor().isInsertMode(), "Client inputProcessor should inherit insertMode");
|
||||
assertTrue(panel.isInsertMode());
|
||||
|
||||
// Toggling on panel updates client
|
||||
panel.toggleInsertMode();
|
||||
assertFalse(client.getInputProcessor().isInsertMode());
|
||||
assertFalse(panel.isInsertMode());
|
||||
|
||||
panel.toggleInsertMode();
|
||||
assertTrue(client.getInputProcessor().isInsertMode());
|
||||
assertTrue(panel.isInsertMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJ3270AppModesMenuSync() {
|
||||
J3270App app;
|
||||
try {
|
||||
app = new J3270App();
|
||||
} catch (HeadlessException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
JMenuBar mb = app.getJMenuBar();
|
||||
assertNotNull(mb);
|
||||
|
||||
JMenu modesMenu = null;
|
||||
for (int i = 0; i < mb.getMenuCount(); i++) {
|
||||
JMenu m = mb.getMenu(i);
|
||||
if (m != null && "Modes".equals(m.getText())) {
|
||||
modesMenu = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(modesMenu, "Modes menu should exist");
|
||||
|
||||
JCheckBoxMenuItem insertItem = null;
|
||||
for (int i = 0; i < modesMenu.getItemCount(); i++) {
|
||||
JMenuItem item = modesMenu.getItem(i);
|
||||
if (item instanceof JCheckBoxMenuItem && "Insert Mode".equals(item.getText())) {
|
||||
insertItem = (JCheckBoxMenuItem) item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(insertItem, "Insert Mode menu item should exist");
|
||||
assertFalse(insertItem.isSelected(), "Initial Insert Mode item should not be selected");
|
||||
|
||||
// Find terminal panel and toggle
|
||||
TerminalPanel panel = null;
|
||||
for (java.awt.Component c : app.getContentPane().getComponents()) {
|
||||
if (c instanceof TerminalPanel) {
|
||||
panel = (TerminalPanel) c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(panel, "TerminalPanel should be found");
|
||||
|
||||
// Toggling via panel updates menu item
|
||||
panel.toggleInsertMode();
|
||||
assertTrue(panel.isInsertMode());
|
||||
assertTrue(insertItem.isSelected(), "Menu item should reflect true insert mode");
|
||||
|
||||
panel.toggleInsertMode();
|
||||
assertFalse(panel.isInsertMode());
|
||||
assertFalse(insertItem.isSelected(), "Menu item should reflect false insert mode");
|
||||
|
||||
// Clicking menu item toggles insert mode on panel
|
||||
insertItem.doClick();
|
||||
assertTrue(panel.isInsertMode(), "Panel should be in insert mode after clicking menu item");
|
||||
assertTrue(insertItem.isSelected(), "Menu item should be selected after click");
|
||||
|
||||
insertItem.doClick();
|
||||
assertFalse(panel.isInsertMode(), "Panel should exit insert mode after clicking menu item");
|
||||
assertFalse(insertItem.isSelected(), "Menu item should be deselected after click");
|
||||
} finally {
|
||||
app.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyAndPasteActions() {
|
||||
try {
|
||||
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
} catch (HeadlessException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
Telnet3270Client client = new Telnet3270Client(new ConnectionConfig("localhost", 23));
|
||||
panel.setClient(client);
|
||||
|
||||
var sb = client.getScreenBuffer();
|
||||
sb.setChar(0, 0, 'J');
|
||||
sb.setChar(0, 1, '3');
|
||||
sb.setChar(0, 2, '2');
|
||||
sb.setChar(0, 3, '7');
|
||||
sb.setChar(0, 4, '0');
|
||||
|
||||
panel.setSelectionRange(0, 4);
|
||||
assertTrue(panel.hasSelection());
|
||||
assertEquals("J3270", panel.getSelectedText());
|
||||
|
||||
Action copyAction = panel.getActionMap().get("j3270-COPY");
|
||||
assertNotNull(copyAction);
|
||||
copyAction.actionPerformed(new ActionEvent(panel, ActionEvent.ACTION_PERFORMED, ""));
|
||||
|
||||
try {
|
||||
String clip = (String) java.awt.Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
.getData(java.awt.datatransfer.DataFlavor.stringFlavor);
|
||||
assertEquals("J3270", clip);
|
||||
} catch (Exception e) {
|
||||
fail("Clipboard read failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
// Test multiline paste handling
|
||||
try {
|
||||
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
|
||||
new java.awt.datatransfer.StringSelection("LINE1\nLINE2"), null);
|
||||
Action pasteAction = panel.getActionMap().get("j3270-PASTE");
|
||||
assertNotNull(pasteAction);
|
||||
pasteAction.actionPerformed(new ActionEvent(panel, ActionEvent.ACTION_PERFORMED, ""));
|
||||
// Shouldn't throw any exceptions
|
||||
} catch (Exception e) {
|
||||
fail("Paste action failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToggleStatusBar() {
|
||||
assertEquals("alt B", Settings.getDefaultBinding("STATUS_BAR"));
|
||||
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
InputMap im = panel.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
ActionMap am = panel.getActionMap();
|
||||
|
||||
KeyStroke ksAltB = KeyStroke.getKeyStroke("alt B");
|
||||
assertEquals("j3270-STATUS_BAR", im.get(ksAltB), "alt B must map to j3270-STATUS_BAR");
|
||||
assertNotNull(am.get("j3270-STATUS_BAR"), "j3270-STATUS_BAR action must exist");
|
||||
|
||||
J3270App app;
|
||||
try {
|
||||
app = new J3270App();
|
||||
} catch (HeadlessException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
JMenuBar mb = app.getJMenuBar();
|
||||
assertNotNull(mb);
|
||||
|
||||
JMenu viewMenu = null;
|
||||
for (int i = 0; i < mb.getMenuCount(); i++) {
|
||||
JMenu m = mb.getMenu(i);
|
||||
if (m != null && "View".equals(m.getText())) {
|
||||
viewMenu = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(viewMenu);
|
||||
|
||||
JCheckBoxMenuItem statusBarItem = null;
|
||||
for (int i = 0; i < viewMenu.getItemCount(); i++) {
|
||||
JMenuItem item = viewMenu.getItem(i);
|
||||
if (item instanceof JCheckBoxMenuItem && "Status Bar".equals(item.getText())) {
|
||||
statusBarItem = (JCheckBoxMenuItem) item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(statusBarItem, "Status Bar menu item must exist in View menu");
|
||||
assertTrue(statusBarItem.isSelected(), "Status bar should be selected by default");
|
||||
|
||||
StatusBar bar = null;
|
||||
for (java.awt.Component c : app.getContentPane().getComponents()) {
|
||||
if (c instanceof StatusBar) {
|
||||
bar = (StatusBar) c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(bar, "StatusBar component should exist in content pane");
|
||||
assertTrue(bar.isVisible(), "StatusBar should be visible by default");
|
||||
|
||||
// Test toggling via toggleStatusBar()
|
||||
app.toggleStatusBar();
|
||||
assertFalse(bar.isVisible(), "StatusBar should be hidden after toggle");
|
||||
assertFalse(statusBarItem.isSelected(), "Menu item should be unchecked");
|
||||
assertFalse(Settings.getStatusBarVisible());
|
||||
|
||||
app.toggleStatusBar();
|
||||
assertTrue(bar.isVisible(), "StatusBar should be shown after second toggle");
|
||||
assertTrue(statusBarItem.isSelected(), "Menu item should be checked");
|
||||
assertTrue(Settings.getStatusBarVisible());
|
||||
|
||||
// Test toggling via menu item click
|
||||
statusBarItem.doClick();
|
||||
assertFalse(bar.isVisible(), "StatusBar should be hidden after menu click");
|
||||
assertFalse(statusBarItem.isSelected(), "Menu item should be unchecked");
|
||||
|
||||
statusBarItem.doClick();
|
||||
assertTrue(bar.isVisible(), "StatusBar should be shown after menu click");
|
||||
assertTrue(statusBarItem.isSelected(), "Menu item should be checked");
|
||||
} finally {
|
||||
app.dispose();
|
||||
Settings.setStatusBarVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Unit tests for Phase 13.3: Keyboard Remap (.kmp) File Importer.
|
||||
* Tests parsing of scan codes, modifier combinations, bind statements,
|
||||
* mnemonic actions, and comments.
|
||||
*/
|
||||
public class KmpKeymapImportTest {
|
||||
|
||||
@Test
|
||||
public void testParseScanCodeAssignments() throws Exception {
|
||||
String kmpContent =
|
||||
"# Sample keyboard profile mapping\n" +
|
||||
"; IBM scan code mappings\n" +
|
||||
"KEY43=[enter]\n" +
|
||||
"S-KEY112=[pf13]\n" +
|
||||
"C-KEY43=[newline]\n" +
|
||||
"A-KEY110=[reset]\n" +
|
||||
"KEY15=[tab]\n" +
|
||||
"S-KEY15=[backtab]\n";
|
||||
|
||||
Map<String, String> imported = KeyBindings.parseKmp(new StringReader(kmpContent));
|
||||
assertNotNull(imported);
|
||||
|
||||
// KEY43 is ENTER -> ENTER
|
||||
assertEquals("ENTER", imported.get("ENTER"));
|
||||
// S-KEY112 is Shift+F1 -> PF13
|
||||
assertEquals("shift F1", imported.get("PF13"));
|
||||
// C-KEY43 is Ctrl+ENTER -> NEWLINE
|
||||
assertEquals("ctrl ENTER", imported.get("NEWLINE"));
|
||||
// A-KEY110 is Alt+ESCAPE -> ESCAPE
|
||||
assertEquals("alt ESCAPE", imported.get("ESCAPE"));
|
||||
// KEY15 is TAB -> TAB
|
||||
assertEquals("TAB", imported.get("TAB"));
|
||||
// S-KEY15 is Shift+TAB -> shift TAB
|
||||
assertEquals("shift TAB", imported.get("shift TAB"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseBindStatements() throws Exception {
|
||||
String kmpContent =
|
||||
"bind [enter] Ctrl+Enter\n" +
|
||||
"bind [pf1] F1\n" +
|
||||
"bind [pf24] Shift+F12\n" +
|
||||
"bind [eraseeof] End\n" +
|
||||
"bind [clear] Pause\n";
|
||||
|
||||
Map<String, String> imported = KeyBindings.parseKmp(new StringReader(kmpContent));
|
||||
assertNotNull(imported);
|
||||
|
||||
assertEquals("ctrl ENTER", imported.get("ENTER"));
|
||||
assertEquals("F1", imported.get("PF1"));
|
||||
assertEquals("shift F12", imported.get("PF24"));
|
||||
assertEquals("END", imported.get("END"));
|
||||
assertEquals("PAUSE", imported.get("CLEAR"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScanCodeWithMultipleModifiers() {
|
||||
// C-S-KEY85 -> Ctrl+Shift+PAGE_UP
|
||||
String res = KeyBindings.parseScanCodeEntry("CS-KEY85");
|
||||
assertEquals("ctrl shift PAGE_UP", res);
|
||||
|
||||
// 2-KEY80 -> Alt+HOME (2- prefix is Alt in scan code syntax)
|
||||
String altRes = KeyBindings.parseScanCodeEntry("2-KEY80");
|
||||
assertEquals("alt HOME", altRes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMnemonicResolution() {
|
||||
assertEquals("ENTER", KeyBindings.resolveMnemonic("[enter]"));
|
||||
assertEquals("ENTER", KeyBindings.resolveMnemonic("enterreset"));
|
||||
assertEquals("NEWLINE", KeyBindings.resolveMnemonic("[newline]"));
|
||||
assertEquals("NEWLINE", KeyBindings.resolveMnemonic("[field-exit]"));
|
||||
assertEquals("PF1", KeyBindings.resolveMnemonic("[pf1]"));
|
||||
assertEquals("PF12", KeyBindings.resolveMnemonic("[pf12]"));
|
||||
assertEquals("PF13", KeyBindings.resolveMnemonic("[spf1]"));
|
||||
assertEquals("ESCAPE", KeyBindings.resolveMnemonic("[reset]"));
|
||||
assertEquals("ERASE_INPUT", KeyBindings.resolveMnemonic("[erasefld]"));
|
||||
assertEquals("DOCMODE", KeyBindings.resolveMnemonic("[docmode]"));
|
||||
assertEquals("WORDWRAP", KeyBindings.resolveMnemonic("[wordwrap]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommentsAndBlankLinesIgnored() throws Exception {
|
||||
String kmpContent =
|
||||
"[ProfileHeader]\n" +
|
||||
" \n" +
|
||||
"# Full line comment\n" +
|
||||
"; Another comment\n" +
|
||||
"KEY42=[enter] ; inline comment\n" +
|
||||
" \n";
|
||||
|
||||
Map<String, String> imported = KeyBindings.parseKmp(new StringReader(kmpContent));
|
||||
assertEquals(1, imported.size());
|
||||
assertEquals("ENTER", imported.get("ENTER"));
|
||||
}
|
||||
}
|
||||
@@ -58,11 +58,26 @@ public class MenuBarShortcutsTest {
|
||||
assertNotNull(fileMenu, "File menu should exist");
|
||||
assertNotNull(editMenu, "Edit menu should exist");
|
||||
|
||||
// Verify View Menu items use ALT_DOWN_MASK
|
||||
// Verify View Menu items
|
||||
Map<String, JMenuItem> viewItems = collectMenuItems(viewMenu);
|
||||
assertAcceleratorUsesAlt(viewItems.get("Font Size +"), KeyEvent.VK_EQUALS);
|
||||
assertAcceleratorUsesAlt(viewItems.get("Font Size -"), KeyEvent.VK_MINUS);
|
||||
assertAcceleratorUsesAlt(viewItems.get("Reset Font"), KeyEvent.VK_0);
|
||||
assertAcceleratorUsesAlt(viewItems.get("Status Bar"), KeyEvent.VK_B);
|
||||
|
||||
// Crosshair Ruler must use Alt+Shift+R
|
||||
JMenuItem rulerItem = viewItems.get("Crosshair Ruler");
|
||||
assertNotNull(rulerItem, "Crosshair Ruler menu item must exist");
|
||||
KeyStroke rulerKs = rulerItem.getAccelerator();
|
||||
assertNotNull(rulerKs, "Crosshair Ruler should have an accelerator");
|
||||
assertEquals(KeyEvent.VK_R, rulerKs.getKeyCode(), "Key code mismatch for Crosshair Ruler");
|
||||
int rulerMods = rulerKs.getModifiers();
|
||||
assertTrue((rulerMods & (KeyEvent.ALT_DOWN_MASK | KeyEvent.ALT_MASK)) != 0,
|
||||
"Crosshair Ruler accelerator must have ALT modifier");
|
||||
assertTrue((rulerMods & (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.SHIFT_MASK)) != 0,
|
||||
"Crosshair Ruler accelerator must have SHIFT modifier");
|
||||
assertEquals(0, rulerMods & (KeyEvent.CTRL_DOWN_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK),
|
||||
"Crosshair Ruler accelerator must NOT have CTRL or META modifiers");
|
||||
|
||||
// Verify Actions Menu items use ALT_DOWN_MASK
|
||||
Map<String, JMenuItem> actionItems = collectMenuItems(actionsMenu);
|
||||
@@ -75,6 +90,10 @@ public class MenuBarShortcutsTest {
|
||||
assertAcceleratorUsesAlt(actionItems.get("Cursor Select"), KeyEvent.VK_Q);
|
||||
assertAcceleratorUsesAlt(actionItems.get("Toggle Light Pen (Alt+L)"), KeyEvent.VK_L);
|
||||
assertAcceleratorUsesAlt(actionItems.get("File Transfer..."), KeyEvent.VK_T);
|
||||
|
||||
// Ensure Crosshair Ruler and Reset do not collide
|
||||
assertNotEquals(rulerKs, actionItems.get("Reset").getAccelerator(),
|
||||
"Crosshair Ruler and Reset accelerators must not collide");
|
||||
} finally {
|
||||
// Dispose frame
|
||||
app.dispose();
|
||||
@@ -89,6 +108,8 @@ public class MenuBarShortcutsTest {
|
||||
int mods = ks.getModifiers();
|
||||
assertTrue((mods & (KeyEvent.ALT_DOWN_MASK | KeyEvent.ALT_MASK)) != 0,
|
||||
"Menu item " + item.getText() + " accelerator must have ALT modifier");
|
||||
assertEquals(0, mods & (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.SHIFT_MASK),
|
||||
"Menu item " + item.getText() + " accelerator must NOT have SHIFT modifier");
|
||||
assertEquals(0, mods & (KeyEvent.CTRL_DOWN_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK),
|
||||
"Menu item " + item.getText() + " accelerator must NOT have CTRL or META modifiers");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.j3270.config.Settings;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.HeadlessException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Verification test suite for Phase 1 UI Overlays and Color Alignment.
|
||||
* Covers items 1.1, 1.2, and 1.5 of the PhasedUpdates specification.
|
||||
*/
|
||||
public class Phase1UiOverlayTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Item 1.1 & 1.2: TerminalPanel host and mono colors match IBM Host On-Demand specs")
|
||||
public void testTerminalPanelColorAlignment() {
|
||||
// Index 10: Orange (255, 162, 0)
|
||||
assertEquals(new Color(255, 162, 0), TerminalPanel.DEFAULT_HOST_COLORS[10]);
|
||||
|
||||
// Index 14: Mustard (160, 160, 0)
|
||||
assertEquals(new Color(160, 160, 0), TerminalPanel.DEFAULT_HOST_COLORS[14]);
|
||||
|
||||
// Index 1: Blue (120, 144, 240)
|
||||
assertEquals(new Color(120, 144, 240), TerminalPanel.DEFAULT_HOST_COLORS[1]);
|
||||
|
||||
// Base 4-Color mono defaults
|
||||
assertEquals(new Color(0, 255, 0), TerminalPanel.DEFAULT_MONO_NORMAL);
|
||||
assertEquals(new Color(255, 0, 0), TerminalPanel.DEFAULT_MONO_INTENSIFY);
|
||||
assertEquals(new Color(0, 255, 255), TerminalPanel.DEFAULT_MONO_PROTECTED);
|
||||
assertEquals(new Color(255, 255, 255), TerminalPanel.DEFAULT_MONO_PROTECTED_HIGH);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Item 1.5: ThemeManager HoD OIA category colors match specification")
|
||||
public void testThemeManagerOiaColors() {
|
||||
ThemeManager.setTheme(UITheme.DARK);
|
||||
// oSI: Status / System Available -> CUSTOMBLUE (120, 144, 240)
|
||||
assertEquals(new Color(120, 144, 240), ThemeManager.getOiaStatusSysAvail());
|
||||
|
||||
// oII: Input Inhibited / X SYSTEM -> White (255, 255, 255)
|
||||
assertEquals(new Color(255, 255, 255), ThemeManager.getOiaInputInhibited());
|
||||
|
||||
// oAI: Attention / Reminders / Message Waiting -> Yellow (255, 255, 0)
|
||||
assertEquals(new Color(255, 255, 0), ThemeManager.getOiaAttention());
|
||||
|
||||
// oEI: Error Checks / Comm Check -> Red (255, 0, 0)
|
||||
assertEquals(new Color(255, 0, 0), ThemeManager.getOiaCommCheck());
|
||||
|
||||
// oOB: OIA Separator / Background -> Black (0, 0, 0)
|
||||
assertEquals(new Color(0, 0, 0), ThemeManager.getOiaBackground());
|
||||
|
||||
// Light mode OIA colors should be legible and not white on grey
|
||||
ThemeManager.setTheme(UITheme.LIGHT);
|
||||
assertNotEquals(Color.WHITE, ThemeManager.getOiaInputInhibited());
|
||||
assertEquals(new Color(20, 20, 20), ThemeManager.getOiaInputInhibited());
|
||||
assertEquals(new Color(0, 90, 200), ThemeManager.getOiaStatusSysAvail());
|
||||
assertEquals(new Color(180, 100, 0), ThemeManager.getOiaAttention());
|
||||
assertEquals(new Color(190, 20, 20), ThemeManager.getOiaCommCheck());
|
||||
assertEquals(ThemeManager.getStatusBarBg(UITheme.LIGHT), ThemeManager.getOiaBackground());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Item 1.5: TerminalPanel Crosshair Ruler and Cursor Style controls")
|
||||
public void testTerminalPanelRulerAndCursorStyle() {
|
||||
try {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
|
||||
// Default cursor style is BLOCK
|
||||
assertEquals(TerminalPanel.CursorStyle.BLOCK, panel.getCursorStyle());
|
||||
panel.setCursorStyle(TerminalPanel.CursorStyle.UNDERLINE);
|
||||
assertEquals(TerminalPanel.CursorStyle.UNDERLINE, panel.getCursorStyle());
|
||||
|
||||
// Crosshair ruler toggling
|
||||
assertFalse(panel.isCrosshairRulerEnabled());
|
||||
panel.setCrosshairRulerEnabled(true);
|
||||
assertTrue(panel.isCrosshairRulerEnabled());
|
||||
panel.toggleCrosshairRuler();
|
||||
assertFalse(panel.isCrosshairRulerEnabled());
|
||||
|
||||
// Wallpaper image setter
|
||||
assertNull(panel.getWallpaperImage());
|
||||
} catch (HeadlessException e) {
|
||||
// Handled gracefully in headless CI environments
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Settings persistence for Crosshair Ruler and Cursor Style")
|
||||
public void testSettingsPersistence() {
|
||||
boolean originalRuler = Settings.getCrosshairRuler();
|
||||
String originalCursor = Settings.getCursorStyle();
|
||||
|
||||
try {
|
||||
Settings.setCrosshairRuler(true);
|
||||
assertTrue(Settings.getCrosshairRuler());
|
||||
|
||||
Settings.setCrosshairRuler(false);
|
||||
assertFalse(Settings.getCrosshairRuler());
|
||||
|
||||
Settings.setCursorStyle("UNDERLINE");
|
||||
assertEquals("UNDERLINE", Settings.getCursorStyle());
|
||||
|
||||
Settings.setCursorStyle("BLOCK");
|
||||
assertEquals("BLOCK", Settings.getCursorStyle());
|
||||
} finally {
|
||||
Settings.setCrosshairRuler(originalRuler);
|
||||
Settings.setCursorStyle(originalCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package haus.nightmare.j3270.ui;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.GocaConstants;
|
||||
import haus.nightmare.lib3270j.graphics.GraphicsPlane;
|
||||
import haus.nightmare.lib3270j.graphics.HODWallpaper;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Verification test suite for Phase 2 UI Vector Graphics, Wallpaper, and Cursor Overlays.
|
||||
*/
|
||||
public class Phase2UiGraphicsTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Test TerminalPanel Wallpaper Integration (Tile, Center, Stretch)")
|
||||
public void testTerminalPanelWallpaperModes() {
|
||||
try {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
assertNull(panel.getHodWallpaper());
|
||||
assertNull(panel.getWallpaperImage());
|
||||
|
||||
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
|
||||
panel.setWallpaperImage(img);
|
||||
assertNotNull(panel.getWallpaperImage());
|
||||
assertNotNull(panel.getHodWallpaper());
|
||||
assertEquals(HODWallpaper.HOD_STRETCH, panel.getHodWallpaper().getDisplay());
|
||||
|
||||
panel.setWallpaperMode(HODWallpaper.HOD_TILE);
|
||||
assertEquals(HODWallpaper.HOD_TILE, panel.getHodWallpaper().getDisplay());
|
||||
|
||||
panel.setWallpaperMode(HODWallpaper.HOD_CENTER);
|
||||
assertEquals(HODWallpaper.HOD_CENTER, panel.getHodWallpaper().getDisplay());
|
||||
|
||||
HODWallpaper customWp = new HODWallpaper(img, HODWallpaper.HOD_TILE);
|
||||
panel.setHodWallpaper(customWp);
|
||||
assertSame(customWp, panel.getHodWallpaper());
|
||||
|
||||
// Clear wallpaper
|
||||
panel.setWallpaperImage(null);
|
||||
assertNull(panel.getHodWallpaper());
|
||||
assertNull(panel.getWallpaperImage());
|
||||
} catch (HeadlessException e) {
|
||||
// Handled gracefully in headless environments
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test Graphics Plane Cursor Synchronization and Rendering")
|
||||
public void testGraphicsCursorOverlay() {
|
||||
try {
|
||||
TerminalPanel panel = new TerminalPanel();
|
||||
panel.setSize(new Dimension(800, 600));
|
||||
panel.setClient(new haus.nightmare.lib3270j.Telnet3270Client(new haus.nightmare.lib3270j.ConnectionConfig("localhost", 23)));
|
||||
|
||||
GraphicsPlane plane = panel.getClient() != null ? panel.getClient().getGraphicsPlane() : null;
|
||||
if (plane != null) {
|
||||
// Attach graphics cursor
|
||||
plane.attachGraphicCursor(100, 100);
|
||||
plane.setHodCursorShape(GocaConstants.GCURSOR_SHAPE_CROSSHAIR);
|
||||
assertTrue(plane.isGraphicCursorAttached());
|
||||
assertEquals(100, plane.getGraphicCursorX());
|
||||
assertEquals(100, plane.getGraphicCursorY());
|
||||
assertEquals(1, plane.getHodCursorShape());
|
||||
|
||||
// Paint component to verify no exceptions during rendering
|
||||
BufferedImage offscreen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = offscreen.createGraphics();
|
||||
panel.paint(g2);
|
||||
g2.dispose();
|
||||
|
||||
// Change cursor shape to box
|
||||
plane.setHodCursorShape(GocaConstants.GCURSOR_SHAPE_BOX);
|
||||
assertEquals(2, plane.getHodCursorShape());
|
||||
offscreen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
|
||||
g2 = offscreen.createGraphics();
|
||||
panel.paint(g2);
|
||||
g2.dispose();
|
||||
|
||||
// Detach graphics cursor
|
||||
plane.detachGraphicCursor();
|
||||
assertFalse(plane.isGraphicCursorAttached());
|
||||
}
|
||||
} catch (HeadlessException e) {
|
||||
// Handled gracefully in headless environments
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,8 +62,33 @@ public class ThemeManagerTest {
|
||||
// Verify Status Bar colors
|
||||
Color sbBg = ThemeManager.getStatusBarBg(theme);
|
||||
Color sbNormal = ThemeManager.getOiaFgNormal(theme);
|
||||
Color sbInhibited = ThemeManager.getOiaInputInhibited(theme);
|
||||
Color sbSysAvail = ThemeManager.getOiaStatusSysAvail(theme);
|
||||
Color sbAttention = ThemeManager.getOiaAttention(theme);
|
||||
Color sbCommCheck = ThemeManager.getOiaCommCheck(theme);
|
||||
assertNotNull(sbBg);
|
||||
assertNotNull(sbNormal);
|
||||
assertNotNull(sbInhibited);
|
||||
assertNotNull(sbSysAvail);
|
||||
assertNotNull(sbAttention);
|
||||
assertNotNull(sbCommCheck);
|
||||
|
||||
// Verify status bar contrast: ensure NO white on grey in light mode
|
||||
double sbBgLum = (0.299 * sbBg.getRed() + 0.587 * sbBg.getGreen() + 0.114 * sbBg.getBlue());
|
||||
double sbInhibitedLum = (0.299 * sbInhibited.getRed() + 0.587 * sbInhibited.getGreen() + 0.114 * sbInhibited.getBlue());
|
||||
double sbInhibitedDiff = Math.abs(sbBgLum - sbInhibitedLum);
|
||||
assertTrue(sbInhibitedDiff > 120, "Status bar input inhibited (X PROT) contrast in " + theme + " must be > 120 (was " + sbInhibitedDiff + ")");
|
||||
|
||||
double sbSysAvailLum = (0.299 * sbSysAvail.getRed() + 0.587 * sbSysAvail.getGreen() + 0.114 * sbSysAvail.getBlue());
|
||||
assertTrue(Math.abs(sbBgLum - sbSysAvailLum) > 100, "Status bar sys avail contrast in " + theme + " must be > 100");
|
||||
|
||||
double sbAttentionLum = (0.299 * sbAttention.getRed() + 0.587 * sbAttention.getGreen() + 0.114 * sbAttention.getBlue());
|
||||
assertTrue(Math.abs(sbBgLum - sbAttentionLum) > 100, "Status bar attention contrast in " + theme + " must be > 100");
|
||||
|
||||
if (theme == UITheme.LIGHT) {
|
||||
assertNotEquals(Color.WHITE, sbInhibited, "Status bar input inhibited text must not be pure white in light mode");
|
||||
assertNotEquals(Color.WHITE, sbNormal, "Status bar normal text must not be pure white in light mode");
|
||||
}
|
||||
|
||||
// Verify Button colors
|
||||
Color btnDefBg = ThemeManager.getButtonBg(ThemeManager.ButtonVariant.DEFAULT, theme);
|
||||
@@ -218,4 +243,23 @@ public class ThemeManagerTest {
|
||||
tmpIni.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusBarLightModeLegibility() {
|
||||
try {
|
||||
ThemeManager.setTheme(UITheme.LIGHT);
|
||||
StatusBar sb = new StatusBar();
|
||||
sb.applyTheme(UITheme.LIGHT);
|
||||
|
||||
assertEquals(ThemeManager.getStatusBarBg(UITheme.LIGHT), sb.getBackground());
|
||||
assertNotEquals(Color.WHITE, ThemeManager.getOiaInputInhibited());
|
||||
assertNotEquals(Color.WHITE, ThemeManager.getOiaInputInhibited(UITheme.LIGHT));
|
||||
|
||||
// Verify recursive applyTheme does not break StatusBar background
|
||||
ThemeManager.applyTheme(sb, UITheme.LIGHT);
|
||||
assertEquals(ThemeManager.getStatusBarBg(UITheme.LIGHT), sb.getBackground());
|
||||
} catch (HeadlessException e) {
|
||||
// Handled in headless CI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,16 @@ public class ConnectionConfig {
|
||||
private boolean tlsVerifyCert = true;
|
||||
private haus.nightmare.lib3270j.tls.TlsCertificateVerifier certificateVerifier = null;
|
||||
private String sslProtocol = "TLS";
|
||||
private String keyStorePath = null;
|
||||
private String keyStorePassword = null;
|
||||
private String keyStoreType = null;
|
||||
private String keyStoreAlias = null;
|
||||
private String trustStorePath = null;
|
||||
private String trustStorePassword = null;
|
||||
private String trustStoreType = null;
|
||||
private ClassLoader customizedCAsClassLoader = null;
|
||||
private java.util.List<String> enabledProtocols = new java.util.ArrayList<>();
|
||||
private java.util.List<String> enabledCipherSuites = new java.util.ArrayList<>();
|
||||
private int connectTimeoutMs = 15000;
|
||||
private int nopIntervalSeconds = 0;
|
||||
private String terminalName = null; // override terminal type string
|
||||
@@ -27,8 +37,8 @@ public class ConnectionConfig {
|
||||
private int soTimeoutMs = 0;
|
||||
private java.util.List<String> luNames = new java.util.ArrayList<>();
|
||||
private boolean dynamicModel = false;
|
||||
private int dynamicRows = 24;
|
||||
private int dynamicCols = 80;
|
||||
private int dynamicRows = 62;
|
||||
private int dynamicCols = 160;
|
||||
private haus.nightmare.lib3270j.graphics.GraphicsMode graphicsMode = haus.nightmare.lib3270j.graphics.GraphicsMode.BOTH;
|
||||
private String codePage = "037";
|
||||
private String associatedPrinterLu = null;
|
||||
@@ -48,6 +58,17 @@ public class ConnectionConfig {
|
||||
private java.util.Map<String, String> environmentVariables = new java.util.LinkedHashMap<>();
|
||||
private java.util.Map<String, String> userVariables = new java.util.LinkedHashMap<>();
|
||||
|
||||
// IBM HoD autoSysUnlock parity
|
||||
private boolean autoSysUnlock = true;
|
||||
|
||||
// Phase 11: Enterprise Connection Resilience & Heartbeat
|
||||
private boolean keepAliveEnabled = true;
|
||||
private int keepAliveIntervalSeconds = 120;
|
||||
private String keepAliveType = "NOP";
|
||||
private boolean autoReconnect = false;
|
||||
private int reconnectMaxRetries = 5;
|
||||
private int tcpUserTimeoutMs = 0;
|
||||
|
||||
public ConnectionConfig() {}
|
||||
|
||||
public ConnectionConfig(String host, int port) {
|
||||
@@ -81,7 +102,12 @@ public class ConnectionConfig {
|
||||
public void setPort(int port) { this.port = port; }
|
||||
|
||||
public TerminalModel getModel() { return model; }
|
||||
public void setModel(TerminalModel model) { this.model = model; }
|
||||
public void setModel(TerminalModel model) {
|
||||
this.model = model;
|
||||
if (model != null && model.isDynamic()) {
|
||||
this.dynamicModel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLuName() { return luName; }
|
||||
public void setLuName(String luName) { this.luName = luName; }
|
||||
@@ -104,6 +130,52 @@ public class ConnectionConfig {
|
||||
public String getSslProtocol() { return sslProtocol; }
|
||||
public void setSslProtocol(String protocol) { this.sslProtocol = protocol; }
|
||||
|
||||
public String getKeyStorePath() { return keyStorePath; }
|
||||
public void setKeyStorePath(String path) { this.keyStorePath = path; }
|
||||
|
||||
public String getKeyStorePassword() { return keyStorePassword; }
|
||||
public void setKeyStorePassword(String password) { this.keyStorePassword = password; }
|
||||
|
||||
public String getKeyStoreType() { return keyStoreType; }
|
||||
public void setKeyStoreType(String type) { this.keyStoreType = type; }
|
||||
|
||||
public String getKeyStoreAlias() { return keyStoreAlias; }
|
||||
public void setKeyStoreAlias(String alias) { this.keyStoreAlias = alias; }
|
||||
|
||||
public String getTrustStorePath() { return trustStorePath; }
|
||||
public void setTrustStorePath(String path) { this.trustStorePath = path; }
|
||||
|
||||
public String getTrustStorePassword() { return trustStorePassword; }
|
||||
public void setTrustStorePassword(String password) { this.trustStorePassword = password; }
|
||||
|
||||
public String getTrustStoreType() { return trustStoreType; }
|
||||
public void setTrustStoreType(String type) { this.trustStoreType = type; }
|
||||
|
||||
public ClassLoader getCustomizedCAsClassLoader() { return customizedCAsClassLoader; }
|
||||
public void setCustomizedCAsClassLoader(ClassLoader cl) { this.customizedCAsClassLoader = cl; }
|
||||
|
||||
public java.util.List<String> getEnabledProtocols() { return enabledProtocols; }
|
||||
public void setEnabledProtocols(java.util.List<String> protocols) {
|
||||
this.enabledProtocols = protocols != null ? new java.util.ArrayList<>(protocols) : new java.util.ArrayList<>();
|
||||
}
|
||||
public void setEnabledProtocols(String... protocols) {
|
||||
this.enabledProtocols = new java.util.ArrayList<>();
|
||||
if (protocols != null) {
|
||||
for (String p : protocols) if (p != null) this.enabledProtocols.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.List<String> getEnabledCipherSuites() { return enabledCipherSuites; }
|
||||
public void setEnabledCipherSuites(java.util.List<String> cipherSuites) {
|
||||
this.enabledCipherSuites = cipherSuites != null ? new java.util.ArrayList<>(cipherSuites) : new java.util.ArrayList<>();
|
||||
}
|
||||
public void setEnabledCipherSuites(String... cipherSuites) {
|
||||
this.enabledCipherSuites = new java.util.ArrayList<>();
|
||||
if (cipherSuites != null) {
|
||||
for (String c : cipherSuites) if (c != null) this.enabledCipherSuites.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMs() { return connectTimeoutMs; }
|
||||
public void setConnectTimeoutMs(int ms) { this.connectTimeoutMs = ms; }
|
||||
|
||||
@@ -145,15 +217,30 @@ public class ConnectionConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDynamicModel() { return dynamicModel; }
|
||||
public void setDynamicModel(boolean dynamicModel) { this.dynamicModel = dynamicModel; }
|
||||
public boolean isDynamicModel() {
|
||||
return dynamicModel || (model != null && model.isDynamic());
|
||||
}
|
||||
|
||||
public void setDynamicModel(boolean dynamicModel) {
|
||||
this.dynamicModel = dynamicModel;
|
||||
if (dynamicModel && (model == null || !model.isDynamic())) {
|
||||
this.model = TerminalModel.IBM_DYNAMIC;
|
||||
} else if (!dynamicModel && model != null && model.isDynamic()) {
|
||||
this.model = TerminalModel.IBM_3279_4;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDynamic(boolean dynamic) {
|
||||
setDynamicModel(dynamic);
|
||||
}
|
||||
|
||||
public int getDynamicRows() { return dynamicRows; }
|
||||
public int getDynamicCols() { return dynamicCols; }
|
||||
public void setDynamicDimensions(int rows, int cols) {
|
||||
this.dynamicModel = true;
|
||||
this.dynamicRows = rows;
|
||||
this.dynamicCols = cols;
|
||||
this.dynamicRows = Math.max(1, rows);
|
||||
this.dynamicCols = Math.max(1, cols);
|
||||
this.model = TerminalModel.IBM_DYNAMIC;
|
||||
}
|
||||
|
||||
public ProxyType getProxyType() { return proxyType; }
|
||||
@@ -204,6 +291,27 @@ public class ConnectionConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAutoSysUnlock() { return autoSysUnlock; }
|
||||
public void setAutoSysUnlock(boolean autoSysUnlock) { this.autoSysUnlock = autoSysUnlock; }
|
||||
|
||||
public boolean isKeepAliveEnabled() { return keepAliveEnabled; }
|
||||
public void setKeepAliveEnabled(boolean enabled) { this.keepAliveEnabled = enabled; }
|
||||
|
||||
public int getKeepAliveIntervalSeconds() { return keepAliveIntervalSeconds; }
|
||||
public void setKeepAliveIntervalSeconds(int seconds) { this.keepAliveIntervalSeconds = seconds; }
|
||||
|
||||
public String getKeepAliveType() { return keepAliveType; }
|
||||
public void setKeepAliveType(String type) { this.keepAliveType = (type != null) ? type.trim().toUpperCase() : "NOP"; }
|
||||
|
||||
public boolean isAutoReconnect() { return autoReconnect; }
|
||||
public void setAutoReconnect(boolean autoReconnect) { this.autoReconnect = autoReconnect; }
|
||||
|
||||
public int getReconnectMaxRetries() { return reconnectMaxRetries; }
|
||||
public void setReconnectMaxRetries(int retries) { this.reconnectMaxRetries = Math.max(0, retries); }
|
||||
|
||||
public int getTcpUserTimeoutMs() { return tcpUserTimeoutMs; }
|
||||
public void setTcpUserTimeoutMs(int timeoutMs) { this.tcpUserTimeoutMs = Math.max(0, timeoutMs); }
|
||||
|
||||
/**
|
||||
* Parse a host connection string which may include prefixes for TLS (e.g. "L:host:port", "ssl:host:port", "y:host:port"),
|
||||
* plain TN3270 (e.g. "P:host:port", "plain:host:port", "non-e:host:port"), proxy flags (e.g. "--proxy=http://proxy:8080 host:23"),
|
||||
@@ -216,6 +324,9 @@ public class ConnectionConfig {
|
||||
String s = hostStr.trim();
|
||||
boolean tls = false;
|
||||
boolean tn3270e = true;
|
||||
boolean dynamic = false;
|
||||
int dynRows = 62;
|
||||
int dynCols = 160;
|
||||
|
||||
// Parse --proxy=<url> or -proxy=<url> flags
|
||||
ProxyType pType = ProxyType.NONE;
|
||||
@@ -224,10 +335,21 @@ public class ConnectionConfig {
|
||||
String pUser = null;
|
||||
String pPass = null;
|
||||
|
||||
boolean keepAlive = true;
|
||||
boolean autoReconnect = false;
|
||||
|
||||
String[] tokens = s.split("\\s+");
|
||||
StringBuilder remaining = new StringBuilder();
|
||||
for (String tok : tokens) {
|
||||
if (tok.startsWith("--proxy=") || tok.startsWith("-proxy=")) {
|
||||
if (tok.equalsIgnoreCase("--keepalive") || tok.equalsIgnoreCase("-keepalive")) {
|
||||
keepAlive = true;
|
||||
} else if (tok.equalsIgnoreCase("--no-keepalive") || tok.equalsIgnoreCase("-no-keepalive")) {
|
||||
keepAlive = false;
|
||||
} else if (tok.equalsIgnoreCase("--autoreconnect") || tok.equalsIgnoreCase("-autoreconnect")) {
|
||||
autoReconnect = true;
|
||||
} else if (tok.equalsIgnoreCase("--no-autoreconnect") || tok.equalsIgnoreCase("-no-autoreconnect")) {
|
||||
autoReconnect = false;
|
||||
} else if (tok.startsWith("--proxy=") || tok.startsWith("-proxy=")) {
|
||||
String proxyUrl = tok.substring(tok.indexOf('=') + 1).trim();
|
||||
try {
|
||||
java.net.URI uri = new java.net.URI(proxyUrl);
|
||||
@@ -287,9 +409,40 @@ public class ConnectionConfig {
|
||||
int colon = s.indexOf(':');
|
||||
s = s.substring(colon + 1);
|
||||
prefixFound = true;
|
||||
} else if (s.startsWith("D:") || s.startsWith("d:")) {
|
||||
dynamic = true;
|
||||
s = s.substring(2);
|
||||
prefixFound = true;
|
||||
} else if (s.toLowerCase().startsWith("dyn:") || s.toLowerCase().startsWith("dynamic:") ||
|
||||
s.toLowerCase().startsWith("dyn[") || s.toLowerCase().startsWith("dynamic[")) {
|
||||
int colon = s.indexOf(':');
|
||||
if (colon > 0) {
|
||||
String prefix = s.substring(0, colon);
|
||||
s = s.substring(colon + 1);
|
||||
prefixFound = true;
|
||||
dynamic = true;
|
||||
if (prefix.contains("[") && prefix.contains("]")) {
|
||||
String dim = prefix.substring(prefix.indexOf('[') + 1, prefix.indexOf(']'));
|
||||
String[] parts = dim.toLowerCase().split("x");
|
||||
if (parts.length == 2) {
|
||||
try {
|
||||
dynRows = Integer.parseInt(parts[0].trim());
|
||||
dynCols = Integer.parseInt(parts[1].trim());
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse [lu@]host[:port] (e.g. "00C2@mvs.host.com:1023")
|
||||
String parsedLu = null;
|
||||
int atIdx = s.indexOf('@');
|
||||
if (atIdx > 0 && atIdx < s.length() - 1) {
|
||||
parsedLu = s.substring(0, atIdx).trim();
|
||||
s = s.substring(atIdx + 1).trim();
|
||||
}
|
||||
|
||||
String host = s;
|
||||
int port = (defaultPort > 0) ? defaultPort : (tls ? 992 : 23);
|
||||
|
||||
@@ -313,8 +466,16 @@ public class ConnectionConfig {
|
||||
}
|
||||
|
||||
ConnectionConfig config = new ConnectionConfig(host, port, defaultModel != null ? defaultModel : TerminalModel.IBM_3279_4);
|
||||
if (parsedLu != null && !parsedLu.isEmpty()) {
|
||||
config.setLuName(parsedLu);
|
||||
}
|
||||
config.setUseTls(tls);
|
||||
config.setTn3270eEnabled(tn3270e);
|
||||
config.setKeepAliveEnabled(keepAlive);
|
||||
config.setAutoReconnect(autoReconnect);
|
||||
if (dynamic) {
|
||||
config.setDynamicDimensions(dynRows, dynCols);
|
||||
}
|
||||
if (pType != ProxyType.NONE && pHost != null) {
|
||||
config.setProxy(pType, pHost, pPort, pUser, pPass);
|
||||
}
|
||||
@@ -328,8 +489,8 @@ public class ConnectionConfig {
|
||||
if (terminalName != null) {
|
||||
return terminalName;
|
||||
}
|
||||
if (dynamicModel) {
|
||||
return extendedDataStream ? "IBM-DYNAMIC-E" : "IBM-DYNAMIC";
|
||||
if (isDynamicModel()) {
|
||||
return "IBM-DYNAMIC";
|
||||
}
|
||||
return extendedDataStream ? model.getTerminalType() : model.getBaseTerminalType();
|
||||
}
|
||||
|
||||
@@ -44,11 +44,24 @@ public class Telnet3270Client {
|
||||
private final haus.nightmare.lib3270j.ecl.ECLXfer xfer;
|
||||
private TelnetConnection connection;
|
||||
|
||||
private final java.util.concurrent.atomic.AtomicBoolean reconnecting = new java.util.concurrent.atomic.AtomicBoolean(false);
|
||||
private volatile Thread reconnectThread;
|
||||
|
||||
public Telnet3270Client(ConnectionConfig config) {
|
||||
this.config = config;
|
||||
this.translator = new EbcdicTranslator(config.getCodePage());
|
||||
this.screenBuffer = new ScreenBuffer(config.getModel(), translator);
|
||||
if (config.isDynamicModel() || (config.getModel() != null && config.getModel().isDynamic())) {
|
||||
this.screenBuffer = new ScreenBuffer(
|
||||
haus.nightmare.lib3270j.protocol.DS3270Constants.MODEL_2_ROWS,
|
||||
haus.nightmare.lib3270j.protocol.DS3270Constants.MODEL_2_COLS,
|
||||
config.getDynamicRows(),
|
||||
config.getDynamicCols(),
|
||||
translator);
|
||||
} else {
|
||||
this.screenBuffer = new ScreenBuffer(config.getModel(), translator);
|
||||
}
|
||||
this.dsProcessor = new DataStreamProcessor(screenBuffer, translator);
|
||||
this.dsProcessor.setAutoSysUnlock(config.isAutoSysUnlock());
|
||||
this.dsProcessor.getQueryReplyBuilder().setGraphicsMode(config.getGraphicsMode());
|
||||
this.fsm = new TelnetFSM(config, screenBuffer, dsProcessor);
|
||||
this.inputProcessor = new InputProcessor(screenBuffer, translator, fsm);
|
||||
@@ -78,6 +91,33 @@ public class Telnet3270Client {
|
||||
@Override public void onSoundAlarm() {
|
||||
ps.notifyAlarm();
|
||||
}
|
||||
@Override public void onKeyboardUnlocked() {
|
||||
ps.notifyKeyUnlocked();
|
||||
}
|
||||
});
|
||||
|
||||
// Phase 11: Auto-reconnection and OIA status coordinator
|
||||
fsm.addConnectionListener(new ConnectionListener() {
|
||||
@Override
|
||||
public void onConnectionStateChanged(ConnectionState oldState, ConnectionState newState) {
|
||||
if (newState == ConnectionState.RECONNECTING) {
|
||||
if (oia != null) {
|
||||
oia.writeToOIA("X RECONNECT");
|
||||
}
|
||||
initiateAutoReconnect();
|
||||
} else if (newState == ConnectionState.NOT_CONNECTED) {
|
||||
if (oia != null) {
|
||||
oia.setInputInhibited(haus.nightmare.lib3270j.ecl.ECLOIA.INHIBIT_COMMCHECK);
|
||||
}
|
||||
} else if (newState.isFullSession()) {
|
||||
if (oia != null) {
|
||||
oia.setInputInhibited(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionError(String message) {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -150,11 +190,146 @@ public class Telnet3270Client {
|
||||
* Disconnect from the host.
|
||||
*/
|
||||
public void disconnect() {
|
||||
cancelAutoReconnect();
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
connection = null;
|
||||
}
|
||||
fsm.onDisconnect();
|
||||
fsm.onDisconnect(false);
|
||||
}
|
||||
|
||||
public void cancelAutoReconnect() {
|
||||
reconnecting.set(false);
|
||||
if (reconnectThread != null) {
|
||||
reconnectThread.interrupt();
|
||||
reconnectThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void initiateAutoReconnect() {
|
||||
if (config == null || !config.isAutoReconnect()) {
|
||||
return;
|
||||
}
|
||||
if (!reconnecting.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
reconnectThread = new Thread(this::runAutoReconnect, "TN3270-AutoReconnect");
|
||||
reconnectThread.setDaemon(true);
|
||||
reconnectThread.start();
|
||||
}
|
||||
|
||||
private void runAutoReconnect() {
|
||||
int maxRetries = (config != null) ? config.getReconnectMaxRetries() : 5;
|
||||
log.info("Starting automatic reconnection loop (maxRetries=" + maxRetries + ")");
|
||||
try {
|
||||
for (int attempt = 1; attempt <= maxRetries && reconnecting.get(); attempt++) {
|
||||
// Exponential backoff: 1s, 2s, 4s, 8s, 16s, capped at 30s
|
||||
long delaySeconds = Math.min(30, (long) Math.pow(2, attempt - 1));
|
||||
log.info("Auto-reconnect attempt " + attempt + "/" + maxRetries + " scheduled in " + delaySeconds + "s");
|
||||
|
||||
for (int s = 0; s < delaySeconds * 10; s++) {
|
||||
if (!reconnecting.get() || Thread.currentThread().isInterrupted()) {
|
||||
log.info("Auto-reconnect cancelled during backoff delay");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
log.info("Auto-reconnect thread interrupted");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!reconnecting.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("Executing auto-reconnect attempt " + attempt + "/" + maxRetries + " to " + config.getHost() + ":" + config.getPort());
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
connection = null;
|
||||
}
|
||||
fsm.resetSessionState();
|
||||
screenBuffer.erase(false);
|
||||
|
||||
connection = new TelnetConnection(config, fsm);
|
||||
fsm.setConnection(connection);
|
||||
connection.connect();
|
||||
fsm.onConnected();
|
||||
|
||||
log.info("Auto-reconnect successful on attempt " + attempt);
|
||||
reconnecting.set(false);
|
||||
fsm.notifyScreenUpdate();
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
log.warning("Auto-reconnect attempt " + attempt + " failed: " + e.getMessage());
|
||||
if (attempt < maxRetries && reconnecting.get()) {
|
||||
fsm.setConnectionState(ConnectionState.RECONNECTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All retries failed
|
||||
log.warning("All " + maxRetries + " automatic reconnection attempts failed");
|
||||
reconnecting.set(false);
|
||||
fsm.onDisconnect(false);
|
||||
fsm.onError("Automatic reconnection failed after " + maxRetries + " attempts");
|
||||
} finally {
|
||||
reconnecting.set(false);
|
||||
reconnectThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAutoReconnect() {
|
||||
return (config != null) && config.isAutoReconnect();
|
||||
}
|
||||
|
||||
public void setAutoReconnect(boolean autoReconnect) {
|
||||
if (config != null) {
|
||||
config.setAutoReconnect(autoReconnect);
|
||||
}
|
||||
}
|
||||
|
||||
public int getReconnectMaxRetries() {
|
||||
return (config != null) ? config.getReconnectMaxRetries() : 5;
|
||||
}
|
||||
|
||||
public void setReconnectMaxRetries(int retries) {
|
||||
if (config != null) {
|
||||
config.setReconnectMaxRetries(retries);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReconnecting() {
|
||||
return reconnecting.get() || fsm.getConnectionState() == ConnectionState.RECONNECTING;
|
||||
}
|
||||
|
||||
public boolean isKeepAliveEnabled() {
|
||||
return (config != null) && config.isKeepAliveEnabled();
|
||||
}
|
||||
|
||||
public void setKeepAliveEnabled(boolean enabled) {
|
||||
if (config != null) {
|
||||
config.setKeepAliveEnabled(enabled);
|
||||
}
|
||||
if (connection != null) {
|
||||
if (enabled) connection.startKeepAlive();
|
||||
else connection.stopKeepAlive();
|
||||
}
|
||||
}
|
||||
|
||||
public int getKeepAliveIntervalSeconds() {
|
||||
return (config != null) ? config.getKeepAliveIntervalSeconds() : 120;
|
||||
}
|
||||
|
||||
public void setKeepAliveIntervalSeconds(int seconds) {
|
||||
if (config != null) {
|
||||
config.setKeepAliveIntervalSeconds(seconds);
|
||||
}
|
||||
if (connection != null && config != null && config.isKeepAliveEnabled()) {
|
||||
connection.startKeepAlive();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,6 +419,9 @@ public class Telnet3270Client {
|
||||
/** Get the data stream processor. */
|
||||
public DataStreamProcessor getDataStreamProcessor() { return dsProcessor; }
|
||||
|
||||
/** Get the underlying telnet connection. */
|
||||
public TelnetConnection getConnection() { return connection; }
|
||||
|
||||
/** Get the connection config. */
|
||||
public ConnectionConfig getConfig() { return config; }
|
||||
|
||||
@@ -282,6 +460,23 @@ public class Telnet3270Client {
|
||||
return fsm;
|
||||
}
|
||||
|
||||
public boolean isAutoSysUnlock() {
|
||||
return (config != null) ? config.isAutoSysUnlock() : true;
|
||||
}
|
||||
|
||||
public void setAutoSysUnlock(boolean autoSysUnlock) {
|
||||
if (config != null) {
|
||||
config.setAutoSysUnlock(autoSysUnlock);
|
||||
}
|
||||
if (dsProcessor != null) {
|
||||
dsProcessor.setAutoSysUnlock(autoSysUnlock);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isContentionResolution() {
|
||||
return fsm != null && fsm.isContentionResolutionNegotiated();
|
||||
}
|
||||
|
||||
/** Send an NVT ASCII character in NVT mode. */
|
||||
public void sendNVTChar(char c) throws IOException {
|
||||
fsm.sendNVTChar(c);
|
||||
@@ -450,8 +645,23 @@ public class Telnet3270Client {
|
||||
public void processFieldMark() { inputProcessor.processFieldMark(); }
|
||||
|
||||
/** Toggle Insert Mode. */
|
||||
public void toggleInsert() { inputProcessor.setInsertMode(!inputProcessor.isInsertMode()); }
|
||||
public void processToggleInsert() { inputProcessor.processToggleInsert(); }
|
||||
public boolean isInsertMode() { return inputProcessor != null && inputProcessor.isInsertMode(); }
|
||||
public void toggleInsert() { if (inputProcessor != null) inputProcessor.setInsertMode(!inputProcessor.isInsertMode()); }
|
||||
public void processToggleInsert() { if (inputProcessor != null) inputProcessor.processToggleInsert(); }
|
||||
|
||||
/** Document Mode (Entry Assist) operations. */
|
||||
public boolean isDocMode() { return screenBuffer != null && screenBuffer.isEntryAssistDOCmode(); }
|
||||
public void setDocMode(boolean b) { if (screenBuffer != null) screenBuffer.setEntryAssistDOCmode(b); if (oia != null) oia.notifyOIAChanged(); }
|
||||
public void toggleDocMode() { setDocMode(!isDocMode()); }
|
||||
|
||||
public boolean isWordWrap() { return screenBuffer != null && screenBuffer.isEntryAssistWordWrap(); }
|
||||
public void setWordWrap(boolean b) { if (screenBuffer != null) screenBuffer.setEntryAssistWordWrap(b); if (oia != null) oia.notifyOIAChanged(); }
|
||||
public void toggleWordWrap() { setWordWrap(!isWordWrap()); }
|
||||
|
||||
/** APL Keyboard Mode operations. */
|
||||
public boolean isAplMode() { return inputProcessor != null && inputProcessor.isAplKeyboardMode(); }
|
||||
public void setAplMode(boolean b) { if (inputProcessor != null) inputProcessor.setAplKeyboardMode(b); }
|
||||
public void toggleAplMode() { if (inputProcessor != null) inputProcessor.toggleAplKeyboardMode(); }
|
||||
|
||||
/** Move word left. */
|
||||
public void processWordLeft() { inputProcessor.processWordLeft(); }
|
||||
|
||||
@@ -14,7 +14,8 @@ public enum TerminalModel {
|
||||
IBM_3279_2(2, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_2_ROWS, MODEL_2_COLS),
|
||||
IBM_3279_3(3, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_3_ROWS, MODEL_3_COLS),
|
||||
IBM_3279_4(4, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_4_ROWS, MODEL_4_COLS),
|
||||
IBM_3279_5(5, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_5_ROWS, MODEL_5_COLS);
|
||||
IBM_3279_5(5, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_5_ROWS, MODEL_5_COLS),
|
||||
IBM_DYNAMIC(0, true, MODEL_2_ROWS, MODEL_2_COLS, 62, 160);
|
||||
|
||||
private final int modelNumber;
|
||||
private final boolean color;
|
||||
@@ -40,12 +41,17 @@ public enum TerminalModel {
|
||||
public int getDefaultCols() { return defaultCols; }
|
||||
public int getAlternateRows() { return alternateRows; }
|
||||
public int getAlternateCols() { return alternateCols; }
|
||||
public boolean isDynamic() { return modelNumber == 0; }
|
||||
|
||||
/**
|
||||
* Returns the terminal type string for TN3270E negotiation.
|
||||
* e.g., "IBM-3279-4-E" for a color model 4 with extended data stream.
|
||||
* e.g., "IBM-3279-4-E" for a color model 4 with extended data stream,
|
||||
* or "IBM-DYNAMIC" for dynamic model.
|
||||
*/
|
||||
public String getTerminalType() {
|
||||
if (modelNumber == 0) {
|
||||
return "IBM-DYNAMIC";
|
||||
}
|
||||
return String.format("IBM-327%c-%d-E", color ? '9' : '8', modelNumber);
|
||||
}
|
||||
|
||||
@@ -53,6 +59,9 @@ public enum TerminalModel {
|
||||
* Returns the base terminal type without "-E" suffix (for non-extended mode).
|
||||
*/
|
||||
public String getBaseTerminalType() {
|
||||
if (modelNumber == 0) {
|
||||
return "IBM-DYNAMIC";
|
||||
}
|
||||
return String.format("IBM-327%c-%d", color ? '9' : '8', modelNumber);
|
||||
}
|
||||
|
||||
@@ -60,6 +69,9 @@ public enum TerminalModel {
|
||||
* Look up a model by number and color mode.
|
||||
*/
|
||||
public static TerminalModel forModel(int number, boolean isColor) {
|
||||
if (number == 0) {
|
||||
return IBM_DYNAMIC;
|
||||
}
|
||||
for (TerminalModel m : values()) {
|
||||
if (m.modelNumber == number && m.color == isColor) {
|
||||
return m;
|
||||
|
||||
@@ -69,4 +69,88 @@ public interface CodePage {
|
||||
* Returns -1 if unmappable.
|
||||
*/
|
||||
int unicodeToDbcs(char unicode);
|
||||
|
||||
/**
|
||||
* Convert an EBCDIC byte buffer to a char array matching IBM HoD conversion.
|
||||
*/
|
||||
default char[] convBuffByte2Char(byte[] buf, int offset, int length) {
|
||||
if (buf == null || length <= 0) return new char[0];
|
||||
char[] out = new char[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
out[i] = ebcdicToUnicode(buf[offset + i] & 0xFF);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a char array to an EBCDIC byte array matching IBM HoD conversion.
|
||||
*/
|
||||
default byte[] convBuffChar2Byte(char[] buf, int offset, int length) {
|
||||
if (buf == null || length <= 0) return new byte[0];
|
||||
byte[] out = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
out[i] = unicodeToEbcdicSafe(buf[offset + i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a HODByteToCharConverter instance backed by this CodePage.
|
||||
*/
|
||||
default haus.nightmare.lib3270j.converters.HODByteToCharConverter getByteToCharConverter() {
|
||||
if (isDBCS()) {
|
||||
return new haus.nightmare.lib3270j.converters.ByteToCharDBCS_EBCDIC(this);
|
||||
} else {
|
||||
return new haus.nightmare.lib3270j.converters.ByteToCharSingleByte(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a HODCharToByteConverter instance backed by this CodePage.
|
||||
*/
|
||||
default haus.nightmare.lib3270j.converters.HODCharToByteConverter getCharToByteConverter() {
|
||||
if (isDBCS()) {
|
||||
return new haus.nightmare.lib3270j.converters.CharToByteDBCS_EBCDIC(this);
|
||||
} else {
|
||||
return new haus.nightmare.lib3270j.converters.CharToByteSingleByte(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to test if a pair of characters forms a Unicode surrogate pair.
|
||||
*/
|
||||
static boolean isSurrogate(char high, char low) {
|
||||
return Character.isSurrogatePair(high, low);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to test if a character is a high surrogate.
|
||||
*/
|
||||
static boolean isHighSurrogate(char c) {
|
||||
return Character.isHighSurrogate(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to test if a character is a low surrogate.
|
||||
*/
|
||||
static boolean isLowSurrogate(char c) {
|
||||
return Character.isLowSurrogate(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper matching IBM HoD CodePage.ComposeChar to combine characters.
|
||||
*/
|
||||
static boolean ComposeChar(char[] chars) {
|
||||
if (chars == null || chars.length < 2) return false;
|
||||
if (chars[1] >= '\u0300' && chars[1] <= '\u036F') {
|
||||
String decomposed = new String(chars, 0, 2);
|
||||
String normalized = java.text.Normalizer.normalize(decomposed, java.text.Normalizer.Form.NFC);
|
||||
if (normalized.length() == 1) {
|
||||
chars[0] = normalized.charAt(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,25 @@ public class CodePageRegistry {
|
||||
|
||||
public static String normalizeKey(String name) {
|
||||
if (name == null) return "";
|
||||
String s = name.trim().toLowerCase();
|
||||
String s = name.trim();
|
||||
// Strip package qualifiers if present (e.g. com.ibm.eNetwork.HOD.converters.onea.ByteToCharCp273)
|
||||
int lastDot = Math.max(s.lastIndexOf('.'), s.lastIndexOf('/'));
|
||||
if (lastDot >= 0 && lastDot < s.length() - 1) {
|
||||
s = s.substring(lastDot + 1);
|
||||
}
|
||||
|
||||
// Strip HoD converter class prefixes
|
||||
for (String pfx : new String[]{
|
||||
"HODByteToChar", "HODCharToByte", "ByteToChar", "CharToByte",
|
||||
"ConverterBIDIPrinter", "ConverterFT", "ConverterJDK", "ConverterVT", "PrtConverter"
|
||||
}) {
|
||||
if (s.startsWith(pfx)) {
|
||||
s = s.substring(pfx.length());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s = s.toLowerCase();
|
||||
s = s.replace("_", "").replace("-", "");
|
||||
if (s.startsWith("ebcdiccp")) {
|
||||
s = s.substring(8);
|
||||
@@ -174,13 +192,12 @@ public class CodePageRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a code page by ID or alias.
|
||||
* If not found in built-ins, attempts to load via java.nio.charset.Charset.
|
||||
* Falls back to CP037 if completely unresolvable.
|
||||
* Look up a code page by ID, alias, or converter name without fallback to CP037.
|
||||
* Returns null if unresolvable.
|
||||
*/
|
||||
public static CodePage getCodePage(String name) {
|
||||
public static CodePage resolveCodePage(String name) {
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
return CODE_PAGES.get("037");
|
||||
return null;
|
||||
}
|
||||
|
||||
String raw = name.trim();
|
||||
@@ -198,6 +215,9 @@ public class CodePageRegistry {
|
||||
if (targetId != null) {
|
||||
cp = CODE_PAGES.get(targetId);
|
||||
if (cp != null) return cp;
|
||||
String normTarget = normalizeKey(targetId);
|
||||
cp = CODE_PAGES.get(normTarget);
|
||||
if (cp != null) return cp;
|
||||
}
|
||||
|
||||
// Try standard NIO Charset dynamic adapter
|
||||
@@ -205,18 +225,55 @@ public class CodePageRegistry {
|
||||
if (Charset.isSupported(raw)) {
|
||||
return new NioCodePageAdapter(raw);
|
||||
}
|
||||
if (Charset.isSupported(norm)) {
|
||||
return new NioCodePageAdapter(norm);
|
||||
}
|
||||
String ibmName = "IBM" + norm;
|
||||
if (Charset.isSupported(ibmName)) {
|
||||
return new NioCodePageAdapter(ibmName);
|
||||
}
|
||||
String ibmDashName = "IBM-" + norm;
|
||||
if (Charset.isSupported(ibmDashName)) {
|
||||
return new NioCodePageAdapter(ibmDashName);
|
||||
}
|
||||
String cpName = "Cp" + norm;
|
||||
if (Charset.isSupported(cpName)) {
|
||||
return new NioCodePageAdapter(cpName);
|
||||
}
|
||||
String isoName = "ISO-8859-" + norm.replace("8859", "");
|
||||
if (Charset.isSupported(isoName)) {
|
||||
return new NioCodePageAdapter(isoName);
|
||||
}
|
||||
String winName = "windows-" + norm;
|
||||
if (Charset.isSupported(winName)) {
|
||||
return new NioCodePageAdapter(winName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.fine("Dynamic charset loading failed for " + name + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a code page by ID or alias.
|
||||
* If not found in built-ins, attempts to load via java.nio.charset.Charset.
|
||||
* Falls back to CP037 if completely unresolvable.
|
||||
*/
|
||||
public static CodePage get(String name) {
|
||||
return getCodePage(name);
|
||||
}
|
||||
|
||||
public static CodePage getDefault() {
|
||||
return getCodePage("037");
|
||||
}
|
||||
|
||||
public static CodePage getCodePage(String name) {
|
||||
CodePage cp = resolveCodePage(name);
|
||||
if (cp != null) {
|
||||
return cp;
|
||||
}
|
||||
|
||||
log.warning("CodePage not recognized: '" + name + "'; falling back to CP037");
|
||||
return CODE_PAGES.get("037");
|
||||
}
|
||||
@@ -301,18 +358,82 @@ public class CodePageRegistry {
|
||||
addAlias("chinese-ext-traditional", "1371");
|
||||
addAlias("zh-traditional-ext", "1371");
|
||||
addAlias("zh-tw-ext", "1371");
|
||||
|
||||
// HoD Converter aliases mapping all HoD converter names to CodePage / Charset
|
||||
addAlias("1390", "930");
|
||||
addAlias("1390jis2004", "930");
|
||||
addAlias("1399", "939");
|
||||
addAlias("1399jis2004", "939");
|
||||
addAlias("937macau", "937");
|
||||
addAlias("1364", "933");
|
||||
addAlias("1379", "937");
|
||||
addAlias("274", "500");
|
||||
addAlias("275", "037");
|
||||
addAlias("924", "1047");
|
||||
addAlias("1153", "870");
|
||||
addAlias("1156", "1025");
|
||||
addAlias("1157", "1025");
|
||||
addAlias("1158", "1025");
|
||||
addAlias("1166", "1025");
|
||||
addAlias("1112", "1025");
|
||||
addAlias("1122", "1025");
|
||||
addAlias("1137", "037");
|
||||
addAlias("1008", "420");
|
||||
addAlias("449", "420");
|
||||
addAlias("1089", "420");
|
||||
addAlias("1134", "424");
|
||||
addAlias("1349", "424");
|
||||
addAlias("8585", "875");
|
||||
addAlias("8586", "875");
|
||||
addAlias("220", "284");
|
||||
addAlias("big5550", "937");
|
||||
addAlias("cns", "937");
|
||||
addAlias("tca", "937");
|
||||
addAlias("ks25550", "933");
|
||||
addAlias("jis", "930");
|
||||
addAlias("euc", "937");
|
||||
addAlias("singlebyte", "037");
|
||||
addAlias("dbcsebcdic", "930");
|
||||
addAlias("dbcsebcdicnibm", "930");
|
||||
addAlias("dbcsebcdicibm", "930");
|
||||
addAlias("dbcsascii", "930");
|
||||
addAlias("encodings", "037");
|
||||
addAlias("1011", "037");
|
||||
addAlias("1012", "037");
|
||||
addAlias("1020", "037");
|
||||
addAlias("1021", "037");
|
||||
addAlias("1023", "037");
|
||||
addAlias("1090", "037");
|
||||
addAlias("1101", "037");
|
||||
addAlias("1102", "037");
|
||||
addAlias("1103", "037");
|
||||
addAlias("1104", "037");
|
||||
addAlias("1105", "037");
|
||||
addAlias("1106", "037");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a code page is registered.
|
||||
* Check if a code page or converter is registered or resolvable.
|
||||
*/
|
||||
public static boolean hasCodePage(String name) {
|
||||
if (name == null || name.trim().isEmpty()) return false;
|
||||
String raw = name.trim();
|
||||
if (CODE_PAGES.containsKey(raw)) return true;
|
||||
String norm = normalizeKey(raw);
|
||||
if (CODE_PAGES.containsKey(norm)) return true;
|
||||
return ALIASES.containsKey(norm);
|
||||
return resolveCodePage(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience factory method to get a HODByteToCharConverter by name or alias.
|
||||
*/
|
||||
public static haus.nightmare.lib3270j.converters.HODByteToCharConverter getByteToCharConverter(String name)
|
||||
throws haus.nightmare.lib3270j.converters.HODUnsupportedCodepageException {
|
||||
return haus.nightmare.lib3270j.converters.HODByteToCharConverter.getHODConverter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience factory method to get a HODCharToByteConverter by name or alias.
|
||||
*/
|
||||
public static haus.nightmare.lib3270j.converters.HODCharToByteConverter getCharToByteConverter(String name)
|
||||
throws haus.nightmare.lib3270j.converters.HODUnsupportedCodepageException {
|
||||
return haus.nightmare.lib3270j.converters.HODCharToByteConverter.getHODConverter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* EBCDIC ↔ Unicode character translator conforming to IBM Host On-Demand (HoD v14).
|
||||
* EBCDIC ↔ Unicode character translator conforming to Host On-Demand (HoD v14).
|
||||
* Modular architecture delegating to pluggable CodePage implementations (SBCS and DBCS).
|
||||
* Supports custom per-instance character translation override tables and complete
|
||||
* IBM 3270 APL / Graphic Escape (GA23-0059) character mappings.
|
||||
* 3270 APL / Graphic Escape (GA23-0059) character mappings.
|
||||
* Default: Code Page 037 (US/Canada EBCDIC).
|
||||
*/
|
||||
public class EbcdicTranslator {
|
||||
@@ -210,9 +210,11 @@ public class EbcdicTranslator {
|
||||
*/
|
||||
public char ebcdicToUnicode(int ebc) {
|
||||
int b = ebc & 0xFF;
|
||||
Character custom = customEbcdicToUnicode.get(b);
|
||||
if (custom != null) {
|
||||
return custom;
|
||||
if (!customEbcdicToUnicode.isEmpty()) {
|
||||
Character custom = customEbcdicToUnicode.get(b);
|
||||
if (custom != null) {
|
||||
return custom;
|
||||
}
|
||||
}
|
||||
return activeCodePage.ebcdicToUnicode(b);
|
||||
}
|
||||
@@ -236,9 +238,11 @@ public class EbcdicTranslator {
|
||||
* Returns -1 if the character cannot be mapped.
|
||||
*/
|
||||
public int unicodeToEbcdic(char unicode) {
|
||||
Integer custom = customUnicodeToEbcdic.get(unicode);
|
||||
if (custom != null) {
|
||||
return custom;
|
||||
if (!customUnicodeToEbcdic.isEmpty()) {
|
||||
Integer custom = customUnicodeToEbcdic.get(unicode);
|
||||
if (custom != null) {
|
||||
return custom;
|
||||
}
|
||||
}
|
||||
return activeCodePage.unicodeToEbcdic(unicode);
|
||||
}
|
||||
@@ -296,8 +300,8 @@ public class EbcdicTranslator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Map an IBM 3270 APL / Graphic Escape (GE) EBCDIC code point to its Unicode glyph.
|
||||
* Conforms to IBM 3270 APL / Text character set and GA23-0059 specification.
|
||||
* Map a 3270 APL / Graphic Escape (GE) EBCDIC code point to its Unicode glyph.
|
||||
* Conforms to 3270 APL / Text character set and GA23-0059 specification.
|
||||
*/
|
||||
public char mapAPL(int ebcdicCodePoint) {
|
||||
switch (ebcdicCodePoint & 0xFF) {
|
||||
@@ -331,7 +335,7 @@ public class EbcdicTranslator {
|
||||
case 0xBF: return '\u00B5'; // Micro 'µ'
|
||||
case 0x5F: return '\u00AC'; // Not sign '¬'
|
||||
|
||||
// IBM 3270 APL Operational & Structural Glyphs
|
||||
// 3270 APL Operational & Structural Glyphs
|
||||
case 0x80: return '\u22C4'; // Diamond '⋄'
|
||||
case 0x81: return '\u237A'; // APL Alpha '⍺'
|
||||
case 0x82: return '\u22A5'; // Up Tack / Decode '⊥'
|
||||
@@ -383,7 +387,7 @@ public class EbcdicTranslator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an IBM 3270 Graphic Escape (GE) / APL character code to Unicode.
|
||||
* Translate a 3270 Graphic Escape (GE) / APL character code to Unicode.
|
||||
*/
|
||||
public char getAplGraphic(int ec) {
|
||||
return mapAPL(ec);
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
/**
|
||||
* Concrete converter implementing mixed SBCS/DBCS byte-to-char conversion with transparent
|
||||
* Shift-Out (0x0E) and Shift-In (0x0F) state management.
|
||||
* Conforms to com.ibm.eNetwork.HOD.converters.ByteToCharDBCS_EBCDIC.
|
||||
*/
|
||||
public class ByteToCharDBCS_EBCDIC extends HODByteToCharConverter {
|
||||
|
||||
public ByteToCharDBCS_EBCDIC() {
|
||||
this(CodePageRegistry.getCodePage("930"));
|
||||
}
|
||||
|
||||
public ByteToCharDBCS_EBCDIC(CodePage codePage) {
|
||||
super(codePage != null ? codePage : CodePageRegistry.getCodePage("930"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException {
|
||||
if (in == null || inEnd <= inOff) {
|
||||
return 0;
|
||||
}
|
||||
if (out == null) {
|
||||
throw new HODCharConversionException("Output buffer cannot be null");
|
||||
}
|
||||
|
||||
this.byteOff = inOff;
|
||||
this.charOff = outOff;
|
||||
|
||||
while (this.byteOff < inEnd || this.savedBytePresent) {
|
||||
int b;
|
||||
boolean isSaved = false;
|
||||
if (this.savedBytePresent) {
|
||||
b = this.savedByte & 0xFF;
|
||||
this.savedBytePresent = false;
|
||||
isSaved = true;
|
||||
} else {
|
||||
b = in[this.byteOff] & 0xFF;
|
||||
}
|
||||
|
||||
// Handle Shift-Out (0x0E) -> DBCS mode
|
||||
if (b == SO) {
|
||||
this.currentState = 1;
|
||||
if (this.preserveSOSI) {
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing SO at " + this.charOff);
|
||||
}
|
||||
out[this.charOff++] = (char) SO;
|
||||
}
|
||||
if (!isSaved) this.byteOff++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle Shift-In (0x0F) -> SBCS mode
|
||||
if (b == SI) {
|
||||
this.currentState = 0;
|
||||
if (this.preserveSOSI) {
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing SI at " + this.charOff);
|
||||
}
|
||||
out[this.charOff++] = (char) SI;
|
||||
}
|
||||
if (!isSaved) this.byteOff++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// SBCS mode conversion
|
||||
if (this.currentState == 0) {
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
|
||||
}
|
||||
char c = this.codePage.ebcdicToUnicode(b);
|
||||
if (c == '\uFFFD') {
|
||||
if (this.subMode) {
|
||||
c = this.subChars[0];
|
||||
} else {
|
||||
this.badInputLength = 1;
|
||||
throw new HODCharConversionException("Unmappable byte 0x" + Integer.toHexString(b) + " at index " + this.byteOff);
|
||||
}
|
||||
}
|
||||
out[this.charOff++] = c;
|
||||
if (!isSaved) this.byteOff++;
|
||||
} else {
|
||||
// DBCS mode conversion (requires 2 bytes)
|
||||
int b2;
|
||||
if (isSaved) {
|
||||
if (this.byteOff >= inEnd) {
|
||||
// Incomplete DBCS pair at end of buffer
|
||||
this.savedByte = (byte) b;
|
||||
this.savedBytePresent = true;
|
||||
break;
|
||||
}
|
||||
b2 = in[this.byteOff++] & 0xFF;
|
||||
} else {
|
||||
if (this.byteOff + 1 >= inEnd) {
|
||||
// Trailing single byte inside DBCS shift
|
||||
this.savedByte = (byte) b;
|
||||
this.savedBytePresent = true;
|
||||
this.byteOff++;
|
||||
break;
|
||||
}
|
||||
b2 = in[this.byteOff + 1] & 0xFF;
|
||||
this.byteOff += 2;
|
||||
}
|
||||
|
||||
// Check for premature Shift-In
|
||||
if (b2 == SI) {
|
||||
this.currentState = 0;
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
|
||||
}
|
||||
out[this.charOff++] = this.codePage.ebcdicToUnicode(b);
|
||||
if (this.preserveSOSI) {
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
|
||||
}
|
||||
out[this.charOff++] = (char) SI;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
char c = this.codePage.dbcsToUnicode(b, b2);
|
||||
if (c == '?' || c == '\uFFFD') {
|
||||
if (this.subMode) {
|
||||
c = this.subChars[0];
|
||||
} else {
|
||||
this.badInputLength = 2;
|
||||
throw new HODCharConversionException("Unmappable DBCS pair 0x" + Integer.toHexString(b) + ", 0x" + Integer.toHexString(b2));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
|
||||
}
|
||||
out[this.charOff++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
return this.charOff - outOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int flush(char[] out, int outOff, int outEnd) throws HODCharConversionException {
|
||||
int count = 0;
|
||||
if (this.savedBytePresent) {
|
||||
if (!this.subMode) {
|
||||
reset();
|
||||
this.badInputLength = 1;
|
||||
throw new HODCharConversionException("Unclosed trailing DBCS byte at end of input");
|
||||
}
|
||||
if (outOff < outEnd) {
|
||||
out[outOff] = this.subChars[0];
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
reset();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.byteOff = 0;
|
||||
this.charOff = 0;
|
||||
this.currentState = 0;
|
||||
this.savedBytePresent = false;
|
||||
this.savedByte = 0;
|
||||
this.badInputLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "DBCS_EBCDIC";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
/**
|
||||
* Concrete converter implementing single-byte character set (SBCS) byte-to-char conversion.
|
||||
* Conforms to com.ibm.eNetwork.HOD.converters.ByteToCharSingleByte.
|
||||
*/
|
||||
public class ByteToCharSingleByte extends HODByteToCharConverter {
|
||||
|
||||
public ByteToCharSingleByte() {
|
||||
this(CodePageRegistry.getDefault());
|
||||
}
|
||||
|
||||
public ByteToCharSingleByte(CodePage codePage) {
|
||||
super(codePage != null ? codePage : CodePageRegistry.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException {
|
||||
if (in == null || inEnd <= inOff) {
|
||||
return 0;
|
||||
}
|
||||
if (out == null) {
|
||||
throw new HODCharConversionException("Output buffer cannot be null");
|
||||
}
|
||||
|
||||
this.byteOff = inOff;
|
||||
this.charOff = outOff;
|
||||
|
||||
while (this.byteOff < inEnd) {
|
||||
if (this.charOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output char buffer overflow at position " + this.charOff);
|
||||
}
|
||||
|
||||
int b = in[this.byteOff] & 0xFF;
|
||||
char c = this.codePage.ebcdicToUnicode(b);
|
||||
|
||||
if (c == '\uFFFD') {
|
||||
if (this.subMode) {
|
||||
c = this.subChars[0];
|
||||
} else {
|
||||
this.badInputLength = 1;
|
||||
throw new HODCharConversionException("Unmappable byte 0x" + Integer.toHexString(b) + " at input index " + this.byteOff);
|
||||
}
|
||||
}
|
||||
|
||||
out[this.charOff++] = c;
|
||||
this.byteOff++;
|
||||
}
|
||||
|
||||
return this.charOff - outOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int flush(char[] out, int outOff, int outEnd) {
|
||||
reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.byteOff = 0;
|
||||
this.charOff = 0;
|
||||
this.badInputLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "SingleByte";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
/**
|
||||
* Concrete converter implementing mixed SBCS/DBCS char-to-byte conversion with transparent
|
||||
* Shift-Out (0x0E) and Shift-In (0x0F) state generation.
|
||||
* Conforms to com.ibm.eNetwork.HOD.converters.CharToByteDBCS_EBCDIC.
|
||||
*/
|
||||
public class CharToByteDBCS_EBCDIC extends HODCharToByteConverter {
|
||||
|
||||
public CharToByteDBCS_EBCDIC() {
|
||||
this(CodePageRegistry.getCodePage("930"));
|
||||
}
|
||||
|
||||
public CharToByteDBCS_EBCDIC(CodePage codePage) {
|
||||
super(codePage != null ? codePage : CodePageRegistry.getCodePage("930"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException {
|
||||
if (in == null || inEnd <= inOff) {
|
||||
return 0;
|
||||
}
|
||||
if (out == null) {
|
||||
throw new HODCharConversionException("Output buffer cannot be null");
|
||||
}
|
||||
|
||||
this.charOff = inOff;
|
||||
this.byteOff = outOff;
|
||||
|
||||
while (this.charOff < inEnd) {
|
||||
char c = in[this.charOff];
|
||||
|
||||
// Explicit Shift-Out control character handling
|
||||
if (c == (char) SO) {
|
||||
if (this.currentState == 0) {
|
||||
if (this.byteOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing SO at " + this.byteOff);
|
||||
}
|
||||
out[this.byteOff++] = SO;
|
||||
this.currentState = 1;
|
||||
}
|
||||
this.charOff++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Explicit Shift-In control character handling
|
||||
if (c == (char) SI) {
|
||||
if (this.currentState == 1) {
|
||||
if (this.byteOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing SI at " + this.byteOff);
|
||||
}
|
||||
out[this.byteOff++] = SI;
|
||||
this.currentState = 0;
|
||||
}
|
||||
this.charOff++;
|
||||
continue;
|
||||
}
|
||||
|
||||
int dbcs = this.codePage.unicodeToDbcs(c);
|
||||
|
||||
if (dbcs >= 0) {
|
||||
// Character is DBCS: ensure in DBCS mode
|
||||
int needed = (this.currentState == 0) ? 3 : 2;
|
||||
if (this.byteOff + needed > outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing DBCS character at " + this.byteOff);
|
||||
}
|
||||
|
||||
if (this.currentState == 0) {
|
||||
out[this.byteOff++] = SO;
|
||||
this.currentState = 1;
|
||||
}
|
||||
|
||||
out[this.byteOff++] = (byte) ((dbcs >> 8) & 0xFF);
|
||||
out[this.byteOff++] = (byte) (dbcs & 0xFF);
|
||||
} else {
|
||||
// Character is SBCS: ensure in SBCS mode
|
||||
int needed = (this.currentState == 1) ? 2 : 1;
|
||||
if (this.byteOff + needed > outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow writing SBCS character at " + this.byteOff);
|
||||
}
|
||||
|
||||
if (this.currentState == 1) {
|
||||
out[this.byteOff++] = SI;
|
||||
this.currentState = 0;
|
||||
}
|
||||
|
||||
int ebc = this.codePage.unicodeToEbcdic(c);
|
||||
if (ebc < 0) {
|
||||
if (this.subMode) {
|
||||
out[this.byteOff++] = this.subBytes[0];
|
||||
} else {
|
||||
this.badInputLength = 1;
|
||||
throw new HODCharConversionException("Unmappable character '\\u" + Integer.toHexString(c) + "' at input index " + this.charOff);
|
||||
}
|
||||
} else {
|
||||
out[this.byteOff++] = (byte) (ebc & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
this.charOff++;
|
||||
}
|
||||
|
||||
return this.byteOff - outOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int flush(byte[] out, int outOff, int outEnd) throws HODCharConversionException {
|
||||
int flushed = 0;
|
||||
if (this.currentState == 1) {
|
||||
if (outOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output buffer overflow during flush at " + outOff);
|
||||
}
|
||||
out[outOff] = SI;
|
||||
flushed = 1;
|
||||
this.currentState = 0;
|
||||
}
|
||||
reset();
|
||||
return flushed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.charOff = 0;
|
||||
this.byteOff = 0;
|
||||
this.currentState = 0;
|
||||
this.badInputLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "DBCS_EBCDIC";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
/**
|
||||
* Concrete converter implementing single-byte character set (SBCS) char-to-byte conversion.
|
||||
* Conforms to com.ibm.eNetwork.HOD.converters.CharToByteSingleByte.
|
||||
*/
|
||||
public class CharToByteSingleByte extends HODCharToByteConverter {
|
||||
|
||||
public CharToByteSingleByte() {
|
||||
this(CodePageRegistry.getDefault());
|
||||
}
|
||||
|
||||
public CharToByteSingleByte(CodePage codePage) {
|
||||
super(codePage != null ? codePage : CodePageRegistry.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException {
|
||||
if (in == null || inEnd <= inOff) {
|
||||
return 0;
|
||||
}
|
||||
if (out == null) {
|
||||
throw new HODCharConversionException("Output buffer cannot be null");
|
||||
}
|
||||
|
||||
this.charOff = inOff;
|
||||
this.byteOff = outOff;
|
||||
|
||||
while (this.charOff < inEnd) {
|
||||
if (this.byteOff >= outEnd) {
|
||||
throw new HODCharConversionException("Output byte buffer overflow at position " + this.byteOff);
|
||||
}
|
||||
|
||||
char c = in[this.charOff];
|
||||
int ebc = this.codePage.unicodeToEbcdic(c);
|
||||
|
||||
if (ebc < 0) {
|
||||
if (this.subMode) {
|
||||
out[this.byteOff++] = this.subBytes[0];
|
||||
} else {
|
||||
this.badInputLength = 1;
|
||||
throw new HODCharConversionException("Unmappable character '\\u" + Integer.toHexString(c) + "' at input index " + this.charOff);
|
||||
}
|
||||
} else {
|
||||
out[this.byteOff++] = (byte) (ebc & 0xFF);
|
||||
}
|
||||
|
||||
this.charOff++;
|
||||
}
|
||||
|
||||
return this.byteOff - outOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int flush(byte[] out, int outOff, int outEnd) {
|
||||
reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.charOff = 0;
|
||||
this.byteOff = 0;
|
||||
this.badInputLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "SingleByte";
|
||||
}
|
||||
}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* High-performance adapter and bridge converting byte streams (EBCDIC, ASCII, ISO, UTF)
|
||||
* to Unicode characters conforming to IBM Host On-Demand (HoD) converter specifications.
|
||||
* <p>
|
||||
* Supports dynamic factory resolution for all 275 HoD converter class names and transparent
|
||||
* Shift-In (0x0F) / Shift-Out (0x0E) DBCS transitions.
|
||||
*/
|
||||
public abstract class HODByteToCharConverter {
|
||||
|
||||
public static final int SO = 0x0E;
|
||||
public static final int SI = 0x0F;
|
||||
|
||||
protected int byteOff = 0;
|
||||
protected int charOff = 0;
|
||||
protected int badInputLength = 0;
|
||||
protected boolean subMode = true;
|
||||
protected char[] subChars = new char[]{'\uFFFD'};
|
||||
protected CodePage codePage;
|
||||
|
||||
// DBCS State
|
||||
protected int currentState = 0; // 0 = SBCS, 1 = DBCS
|
||||
protected boolean savedBytePresent = false;
|
||||
protected byte savedByte = 0;
|
||||
protected boolean preserveSOSI = false;
|
||||
|
||||
public HODByteToCharConverter() {
|
||||
}
|
||||
|
||||
public HODByteToCharConverter(CodePage codePage) {
|
||||
this.codePage = Objects.requireNonNull(codePage, "codePage cannot be null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up and instantiate a ByteToChar converter matching the given encoding,
|
||||
* codepage ID, alias, or HoD converter class name (e.g. "Cp037", "037", "ByteToCharCp1047", "ConverterFT1047").
|
||||
*
|
||||
* @param encoding encoding identifier or class name
|
||||
* @return initialized HODByteToCharConverter instance
|
||||
* @throws HODUnsupportedCodepageException if the codepage cannot be resolved
|
||||
*/
|
||||
public static HODByteToCharConverter getHODConverter(String encoding) throws HODUnsupportedCodepageException {
|
||||
if (encoding == null || encoding.trim().isEmpty()) {
|
||||
throw new HODUnsupportedCodepageException("Encoding name cannot be null or empty");
|
||||
}
|
||||
|
||||
CodePage cp = CodePageRegistry.resolveCodePage(encoding);
|
||||
if (cp == null) {
|
||||
throw new HODUnsupportedCodepageException("Unsupported codepage / converter: " + encoding);
|
||||
}
|
||||
|
||||
if (cp.isDBCS()) {
|
||||
return new ByteToCharDBCS_EBCDIC(cp);
|
||||
} else {
|
||||
return new ByteToCharSingleByte(cp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard converter lookup alias conforming to Java/HoD converter factory patterns.
|
||||
*/
|
||||
public static HODByteToCharConverter getConverter(String encoding) throws HODUnsupportedCodepageException {
|
||||
return getHODConverter(encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array of bytes into an array of characters.
|
||||
*
|
||||
* @param in source byte buffer
|
||||
* @param inOff start offset in input buffer
|
||||
* @param inEnd end offset in input buffer (exclusive)
|
||||
* @param out destination char buffer
|
||||
* @param outOff start offset in output buffer
|
||||
* @param outEnd end offset in output buffer (exclusive)
|
||||
* @return number of characters converted and written into out
|
||||
* @throws HODCharConversionException if an unmappable byte is encountered with substitution disabled,
|
||||
* or if the output buffer overflows
|
||||
*/
|
||||
public abstract int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException;
|
||||
|
||||
/**
|
||||
* Overload supporting an extra boolean flag matching HoD CFR decompiled signature.
|
||||
*/
|
||||
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd, boolean bl)
|
||||
throws HODCharConversionException {
|
||||
return convert(in, inOff, inEnd, out, outOff, outEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any buffered / trailing state into the output char buffer.
|
||||
*
|
||||
* @param out destination char buffer
|
||||
* @param outOff start offset
|
||||
* @param outEnd end offset
|
||||
* @return number of characters flushed
|
||||
* @throws HODCharConversionException if flush fails or trailing incomplete sequence cannot be converted
|
||||
*/
|
||||
public abstract int flush(char[] out, int outOff, int outEnd) throws HODCharConversionException;
|
||||
|
||||
/**
|
||||
* Reset converter state and offsets to defaults.
|
||||
*/
|
||||
public abstract void reset();
|
||||
|
||||
/**
|
||||
* Get the canonical character encoding name (e.g. "Cp037", "Cp930").
|
||||
*/
|
||||
public abstract String getCharacterEncoding();
|
||||
|
||||
/**
|
||||
* Convert an entire byte array to a char array matching IBM HoD's hodConvertAll API.
|
||||
*/
|
||||
public char[] hodConvertAll(byte[] in) throws HODCharConversionException {
|
||||
if (in == null) return new char[0];
|
||||
reset();
|
||||
char[] buf = new char[Math.max(16, in.length * 2 + 16)];
|
||||
int converted = convert(in, 0, in.length, buf, 0, buf.length);
|
||||
int flushed = flush(buf, converted, buf.length);
|
||||
int total = converted + flushed;
|
||||
char[] result = new char[total];
|
||||
System.arraycopy(buf, 0, result, 0, total);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience alias for hodConvertAll.
|
||||
*/
|
||||
public char[] convertAll(byte[] in) throws HODCharConversionException {
|
||||
return hodConvertAll(in);
|
||||
}
|
||||
|
||||
public void setSubstitutionMode(boolean mode) {
|
||||
this.subMode = mode;
|
||||
}
|
||||
|
||||
public boolean getSubstitutionMode() {
|
||||
return this.subMode;
|
||||
}
|
||||
|
||||
public void setSubstitutionChars(char[] subChars) {
|
||||
if (subChars != null && subChars.length > 0) {
|
||||
this.subChars = subChars;
|
||||
}
|
||||
}
|
||||
|
||||
public char[] getSubstitutionChars() {
|
||||
return this.subChars;
|
||||
}
|
||||
|
||||
public int getBadInputLength() {
|
||||
return this.badInputLength;
|
||||
}
|
||||
|
||||
public int nextByteIndex() {
|
||||
return this.byteOff;
|
||||
}
|
||||
|
||||
public int nextCharIndex() {
|
||||
return this.charOff;
|
||||
}
|
||||
|
||||
public CodePage getCodePage() {
|
||||
return this.codePage;
|
||||
}
|
||||
|
||||
public void setPreserveSOSI(boolean preserve) {
|
||||
this.preserveSOSI = preserve;
|
||||
}
|
||||
|
||||
public boolean isPreserveSOSI() {
|
||||
return this.preserveSOSI;
|
||||
}
|
||||
|
||||
public int getCurrentState() {
|
||||
return this.currentState;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import java.io.CharConversionException;
|
||||
|
||||
/**
|
||||
* Exception thrown when character conversion fails during Host On-Demand converter processing.
|
||||
* Conforms to com.ibm.eNetwork.HOD.common.HODCharConversionException.
|
||||
*/
|
||||
public class HODCharConversionException extends CharConversionException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HODCharConversionException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODCharConversionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.CodePage;
|
||||
import haus.nightmare.lib3270j.charset.CodePageRegistry;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* High-performance adapter and bridge converting Unicode characters to byte streams
|
||||
* (EBCDIC, ASCII, ISO, UTF) conforming to IBM Host On-Demand (HoD) converter specifications.
|
||||
* <p>
|
||||
* Supports dynamic factory resolution for all 275 HoD converter class names and transparent
|
||||
* Shift-In (0x0F) / Shift-Out (0x0E) DBCS transitions.
|
||||
*/
|
||||
public abstract class HODCharToByteConverter {
|
||||
|
||||
public static final byte SO = 0x0E;
|
||||
public static final byte SI = 0x0F;
|
||||
|
||||
protected int byteOff = 0;
|
||||
protected int charOff = 0;
|
||||
protected int badInputLength = 0;
|
||||
protected boolean subMode = true;
|
||||
protected byte[] subBytes = new byte[]{(byte) 0x6F}; // 0x6F '?' in EBCDIC (or safe fallback)
|
||||
protected CodePage codePage;
|
||||
|
||||
// DBCS State
|
||||
protected int currentState = 0; // 0 = SBCS, 1 = DBCS
|
||||
|
||||
public HODCharToByteConverter() {
|
||||
}
|
||||
|
||||
public HODCharToByteConverter(CodePage codePage) {
|
||||
this.codePage = Objects.requireNonNull(codePage, "codePage cannot be null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up and instantiate a CharToByte converter matching the given encoding,
|
||||
* codepage ID, alias, or HoD converter class name (e.g. "Cp037", "037", "CharToByteCp1047", "ConverterFT1047").
|
||||
*
|
||||
* @param encoding encoding identifier or class name
|
||||
* @return initialized HODCharToByteConverter instance
|
||||
* @throws HODUnsupportedCodepageException if the codepage cannot be resolved
|
||||
*/
|
||||
public static HODCharToByteConverter getHODConverter(String encoding) throws HODUnsupportedCodepageException {
|
||||
if (encoding == null || encoding.trim().isEmpty()) {
|
||||
throw new HODUnsupportedCodepageException("Encoding name cannot be null or empty");
|
||||
}
|
||||
|
||||
CodePage cp = CodePageRegistry.resolveCodePage(encoding);
|
||||
if (cp == null) {
|
||||
throw new HODUnsupportedCodepageException("Unsupported codepage / converter: " + encoding);
|
||||
}
|
||||
|
||||
if (cp.isDBCS()) {
|
||||
return new CharToByteDBCS_EBCDIC(cp);
|
||||
} else {
|
||||
return new CharToByteSingleByte(cp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard converter lookup alias conforming to Java/HoD converter factory patterns.
|
||||
*/
|
||||
public static HODCharToByteConverter getConverter(String encoding) throws HODUnsupportedCodepageException {
|
||||
return getHODConverter(encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array of characters into an array of bytes.
|
||||
*
|
||||
* @param in source char buffer
|
||||
* @param inOff start offset in input buffer
|
||||
* @param inEnd end offset in input buffer (exclusive)
|
||||
* @param out destination byte buffer
|
||||
* @param outOff start offset in output buffer
|
||||
* @param outEnd end offset in output buffer (exclusive)
|
||||
* @return number of bytes converted and written into out
|
||||
* @throws HODCharConversionException if an unmappable char is encountered with substitution disabled,
|
||||
* or if the output buffer overflows
|
||||
*/
|
||||
public abstract int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
|
||||
throws HODCharConversionException;
|
||||
|
||||
/**
|
||||
* Flush any buffered / trailing shift state into the output byte buffer.
|
||||
*
|
||||
* @param out destination byte buffer
|
||||
* @param outOff start offset
|
||||
* @param outEnd end offset
|
||||
* @return number of bytes flushed
|
||||
* @throws HODCharConversionException if output buffer overflows
|
||||
*/
|
||||
public abstract int flush(byte[] out, int outOff, int outEnd) throws HODCharConversionException;
|
||||
|
||||
/**
|
||||
* Reset converter state and offsets to defaults.
|
||||
*/
|
||||
public abstract void reset();
|
||||
|
||||
/**
|
||||
* Get the canonical character encoding name (e.g. "Cp037", "Cp930").
|
||||
*/
|
||||
public abstract String getCharacterEncoding();
|
||||
|
||||
/**
|
||||
* Convert an entire char array to a byte array matching IBM HoD's hodConvertAll API.
|
||||
*/
|
||||
public byte[] hodConvertAll(char[] in) throws HODCharConversionException {
|
||||
if (in == null) return new byte[0];
|
||||
reset();
|
||||
byte[] buf = new byte[Math.max(16, in.length * 3 + 16)];
|
||||
int converted = convert(in, 0, in.length, buf, 0, buf.length);
|
||||
int flushed = flush(buf, converted, buf.length);
|
||||
int total = converted + flushed;
|
||||
byte[] result = new byte[total];
|
||||
System.arraycopy(buf, 0, result, 0, total);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience alias for hodConvertAll.
|
||||
*/
|
||||
public byte[] convertAll(char[] in) throws HODCharConversionException {
|
||||
return hodConvertAll(in);
|
||||
}
|
||||
|
||||
public void setSubstitutionMode(boolean mode) {
|
||||
this.subMode = mode;
|
||||
}
|
||||
|
||||
public boolean getSubstitutionMode() {
|
||||
return this.subMode;
|
||||
}
|
||||
|
||||
public void setSubstitutionBytes(byte[] subBytes) {
|
||||
if (subBytes != null && subBytes.length > 0) {
|
||||
this.subBytes = subBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getSubstitutionBytes() {
|
||||
return this.subBytes;
|
||||
}
|
||||
|
||||
public int getBadInputLength() {
|
||||
return this.badInputLength;
|
||||
}
|
||||
|
||||
public int nextByteIndex() {
|
||||
return this.byteOff;
|
||||
}
|
||||
|
||||
public int nextCharIndex() {
|
||||
return this.charOff;
|
||||
}
|
||||
|
||||
public int getMaxBytesPerChar() {
|
||||
return (codePage != null && codePage.isDBCS()) ? 3 : 1; // At most 3 bytes (SO + 2-byte DBCS)
|
||||
}
|
||||
|
||||
public CodePage getCodePage() {
|
||||
return this.codePage;
|
||||
}
|
||||
|
||||
public int getCurrentState() {
|
||||
return this.currentState;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package haus.nightmare.lib3270j.converters;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* Exception thrown when a requested character encoding or codepage identifier cannot be resolved.
|
||||
* Conforms to com.ibm.eNetwork.HOD.common.HODUnsupportedCodepageException.
|
||||
*/
|
||||
public class HODUnsupportedCodepageException extends UnsupportedEncodingException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HODUnsupportedCodepageException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODUnsupportedCodepageException(String encoding) {
|
||||
super(encoding);
|
||||
}
|
||||
}
|
||||
+326
-18
@@ -47,6 +47,19 @@ public class DataStreamProcessor {
|
||||
private final java.io.ByteArrayOutputStream gocaAccumulator = new java.io.ByteArrayOutputStream();
|
||||
private int currentGocaSubtype = 0;
|
||||
|
||||
// Phase 10: Auto-Unlock & Contention Resolution State
|
||||
private boolean autoSysUnlock = true;
|
||||
private boolean contentionResolution = false;
|
||||
private boolean unlockPending = false;
|
||||
private boolean unlockSysPending = false;
|
||||
private boolean rcvdRead = false;
|
||||
|
||||
// Modal SA (set attribute) character attributes
|
||||
private byte currentFg = 0;
|
||||
private byte currentBg = 0;
|
||||
private byte currentGr = 0;
|
||||
private byte currentCs = 0;
|
||||
|
||||
/** Functional interface for sending output back through the telnet stack. */
|
||||
@FunctionalInterface
|
||||
public interface OutputSender {
|
||||
@@ -63,6 +76,14 @@ public class DataStreamProcessor {
|
||||
this.graphicsPlane.setProgramSymbolManager(programSymbolManager);
|
||||
}
|
||||
|
||||
public ScreenBuffer getScreen() {
|
||||
return screen;
|
||||
}
|
||||
|
||||
public ScreenBuffer getScreenBuffer() {
|
||||
return screen;
|
||||
}
|
||||
|
||||
public QueryReplyBuilder getQueryReplyBuilder() {
|
||||
return qrBuilder;
|
||||
}
|
||||
@@ -81,6 +102,13 @@ public class DataStreamProcessor {
|
||||
|
||||
public void setOutputSender(OutputSender sender) {
|
||||
this.outputSender = sender;
|
||||
if (inputProcessor != null) {
|
||||
inputProcessor.setOutputSender(sender);
|
||||
}
|
||||
}
|
||||
|
||||
public OutputSender getOutputSender() {
|
||||
return outputSender;
|
||||
}
|
||||
|
||||
public void setFTDft(haus.nightmare.lib3270j.ft.FTDft ftDft) {
|
||||
@@ -99,6 +127,9 @@ public class DataStreamProcessor {
|
||||
|
||||
public void setInputProcessor(haus.nightmare.lib3270j.input.InputProcessor inputProcessor) {
|
||||
this.inputProcessor = inputProcessor;
|
||||
if (inputProcessor != null && outputSender != null) {
|
||||
inputProcessor.setOutputSender(outputSender);
|
||||
}
|
||||
}
|
||||
|
||||
public haus.nightmare.lib3270j.input.InputProcessor getInputProcessor() {
|
||||
@@ -113,6 +144,21 @@ public class DataStreamProcessor {
|
||||
screenListeners.remove(l);
|
||||
}
|
||||
|
||||
public boolean isAutoSysUnlock() { return autoSysUnlock; }
|
||||
public void setAutoSysUnlock(boolean autoSysUnlock) { this.autoSysUnlock = autoSysUnlock; }
|
||||
|
||||
public boolean isContentionResolution() { return contentionResolution; }
|
||||
public void setContentionResolution(boolean cr) { this.contentionResolution = cr; }
|
||||
|
||||
public boolean isUnlockPending() { return unlockPending; }
|
||||
public void setUnlockPending(boolean pending) { this.unlockPending = pending; }
|
||||
|
||||
public boolean isUnlockSysPending() { return unlockSysPending; }
|
||||
public void setUnlockSysPending(boolean pending) { this.unlockSysPending = pending; }
|
||||
|
||||
public boolean isRcvdRead() { return rcvdRead; }
|
||||
public void setRcvdRead(boolean rcvdRead) { this.rcvdRead = rcvdRead; }
|
||||
|
||||
/**
|
||||
* Process a 3270 data stream record.
|
||||
*
|
||||
@@ -179,16 +225,19 @@ public class DataStreamProcessor {
|
||||
break;
|
||||
case CMD_RB:
|
||||
case SNA_CMD_RB:
|
||||
rcvdRead = true;
|
||||
programSymbolManager.commitStagedSymbols();
|
||||
processReadBuffer();
|
||||
break;
|
||||
case CMD_RM:
|
||||
case SNA_CMD_RM:
|
||||
rcvdRead = true;
|
||||
programSymbolManager.commitStagedSymbols();
|
||||
processReadModified(false);
|
||||
break;
|
||||
case CMD_RMA:
|
||||
case SNA_CMD_RMA:
|
||||
rcvdRead = true;
|
||||
programSymbolManager.commitStagedSymbols();
|
||||
processReadModified(true);
|
||||
break;
|
||||
@@ -197,6 +246,10 @@ public class DataStreamProcessor {
|
||||
programSymbolManager.commitStagedSymbols();
|
||||
log.info(">>> EAU: erasing all unprotected fields");
|
||||
screen.eraseAllUnprotected();
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
break;
|
||||
case CMD_WSF:
|
||||
case SNA_CMD_WSF:
|
||||
@@ -217,7 +270,10 @@ public class DataStreamProcessor {
|
||||
screen.updateDisplaySnapshot();
|
||||
}
|
||||
|
||||
if (keyboardRestore && inputProcessor != null) {
|
||||
boolean isWriteCmd = (cmd == CMD_W || cmd == SNA_CMD_W ||
|
||||
cmd == CMD_EW || cmd == SNA_CMD_EW ||
|
||||
cmd == CMD_EWA || cmd == SNA_CMD_EWA);
|
||||
if (!isWriteCmd && keyboardRestore && inputProcessor != null && !contentionResolution) {
|
||||
inputProcessor.setKeyboardLocked(false);
|
||||
}
|
||||
|
||||
@@ -315,10 +371,13 @@ public class DataStreamProcessor {
|
||||
log.fine("WCC: " + String.format("0x%02x", wcc) +
|
||||
" reset=" + wccReset(wcc) + " alarm=" + alarm + " kbdRestore=" + kbdRestore + " resetMdt=" + resetMdt);
|
||||
|
||||
if (kbdRestore || inputProcessor != null) {
|
||||
if (inputProcessor != null) {
|
||||
inputProcessor.setKeyboardLocked(false);
|
||||
}
|
||||
if (kbdRestore) {
|
||||
unlockPending = true;
|
||||
unlockSysPending = true;
|
||||
}
|
||||
|
||||
if (!contentionResolution && kbdRestore && inputProcessor != null) {
|
||||
inputProcessor.setKeyboardLocked(false);
|
||||
}
|
||||
|
||||
if (resetMdt) {
|
||||
@@ -329,11 +388,19 @@ public class DataStreamProcessor {
|
||||
if (wccReset(wcc)) {
|
||||
// Reset all character attributes to defaults
|
||||
log.fine("WCC reset: clearing default attributes");
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
}
|
||||
|
||||
if (eraseFirst) {
|
||||
screen.clear();
|
||||
log.fine("Cleared screen for Erase/Write");
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
}
|
||||
|
||||
// Process orders and data starting at byte 2
|
||||
@@ -341,9 +408,6 @@ public class DataStreamProcessor {
|
||||
int end = offset + length;
|
||||
int baddr = screen.getBufferAddress();
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
|
||||
// Current SA (set attribute) values for character-mode
|
||||
byte currentFg = 0, currentBg = 0, currentGr = 0, currentCs = 0;
|
||||
boolean lastWasOrder = false;
|
||||
|
||||
while (pos < end) {
|
||||
@@ -378,10 +442,6 @@ public class DataStreamProcessor {
|
||||
// FA position is a display position that shows as blank
|
||||
ea.ec = 0;
|
||||
ea.ucs4 = ' ';
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
screen.setFormatted(true);
|
||||
baddr = (baddr + 1) % size;
|
||||
screen.setBufferAddress(baddr);
|
||||
@@ -406,10 +466,6 @@ public class DataStreamProcessor {
|
||||
ea.clear();
|
||||
ea.ec = 0;
|
||||
ea.ucs4 = ' ';
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
|
||||
for (int i = 0; i < nPairs; i++) {
|
||||
int attrType = data[pos + 2 + i * 2] & 0xFF;
|
||||
@@ -436,6 +492,12 @@ public class DataStreamProcessor {
|
||||
int attrType = data[pos + 1] & 0xFF;
|
||||
int attrValue = data[pos + 2] & 0xFF;
|
||||
switch (attrType) {
|
||||
case XA_ALL:
|
||||
currentFg = 0;
|
||||
currentBg = 0;
|
||||
currentGr = 0;
|
||||
currentCs = 0;
|
||||
break;
|
||||
case XA_FOREGROUND:
|
||||
currentFg = (byte) attrValue;
|
||||
break;
|
||||
@@ -935,7 +997,13 @@ public class DataStreamProcessor {
|
||||
break;
|
||||
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJDATA: // 0x85: Graphics Object Data / GOCA
|
||||
if (fieldLen > 3) {
|
||||
graphicsPlane.setCharDimensions(qrBuilder.getCharWidth(), qrBuilder.getCharHeight());
|
||||
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
|
||||
int targetW = screen.getCols() * qrBuilder.getCharWidth();
|
||||
int targetH = screen.getRows() * qrBuilder.getCharHeight();
|
||||
if (graphicsPlane.getCanvasWidth() != targetW || graphicsPlane.getCanvasHeight() != targetH) {
|
||||
graphicsPlane.resize(targetW, targetH);
|
||||
}
|
||||
gocaDecoder.decodeStream(data, pos + 3, fieldLen - 3);
|
||||
notifyScreenUpdated();
|
||||
}
|
||||
@@ -1083,6 +1151,9 @@ public class DataStreamProcessor {
|
||||
}
|
||||
|
||||
private void notifyScreenUpdated() {
|
||||
if (screen != null) {
|
||||
screen.notifyScreenUpdate();
|
||||
}
|
||||
for (ScreenUpdateListener l : screenListeners) {
|
||||
l.onScreenUpdated();
|
||||
}
|
||||
@@ -1246,9 +1317,10 @@ public class DataStreamProcessor {
|
||||
int orderOffset = (fieldLen >= 7) ? (offset + 7) : (offset + 4);
|
||||
int orderLen = Math.max(0, fieldLen - (orderOffset - offset));
|
||||
|
||||
graphicsPlane.setCharDimensions(qrBuilder.getCharWidth(), qrBuilder.getCharHeight());
|
||||
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
|
||||
int targetW = screen.getCols() * 9;
|
||||
int targetH = screen.getRows() * 16;
|
||||
int targetW = screen.getCols() * qrBuilder.getCharWidth();
|
||||
int targetH = screen.getRows() * qrBuilder.getCharHeight();
|
||||
if (graphicsPlane.getCanvasWidth() != targetW || graphicsPlane.getCanvasHeight() != targetH) {
|
||||
graphicsPlane.resize(targetW, targetH);
|
||||
}
|
||||
@@ -1270,6 +1342,9 @@ public class DataStreamProcessor {
|
||||
byte[] fullStream = gocaAccumulator.toByteArray();
|
||||
gocaAccumulator.reset();
|
||||
log.info(String.format("GOCA stream SPAN_LAST assembled: %d bytes", fullStream.length));
|
||||
try {
|
||||
java.nio.file.Files.write(java.nio.file.Paths.get("/Users/rudi/Projects/j3270/captured_goca.bin"), fullStream);
|
||||
} catch (Exception ignored) {}
|
||||
if (currentGocaSubtype == haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB) {
|
||||
gocaDecoder.processProcedureOrders(fullStream, 0, fullStream.length);
|
||||
} else {
|
||||
@@ -1516,4 +1591,237 @@ public class DataStreamProcessor {
|
||||
public void processNullStructuredField() {
|
||||
log.fine("Processed null structured field");
|
||||
}
|
||||
|
||||
// ========== Phase 3: HoD DS3270 Order & Data Stream Functions ==========
|
||||
|
||||
/** Process Write Control Character (WCC). */
|
||||
public void processWCC(int wcc) {
|
||||
boolean alarm = wccSoundAlarm(wcc);
|
||||
boolean kbdRestore = wccKeyboardRestore(wcc);
|
||||
boolean resetMdt = wccResetMDT(wcc);
|
||||
|
||||
log.fine("processWCC: " + String.format("0x%02x", wcc) +
|
||||
" reset=" + wccReset(wcc) + " alarm=" + alarm + " kbdRestore=" + kbdRestore + " resetMdt=" + resetMdt);
|
||||
|
||||
if (kbdRestore) {
|
||||
unlockPending = true;
|
||||
unlockSysPending = true;
|
||||
}
|
||||
if (!contentionResolution && kbdRestore && inputProcessor != null) {
|
||||
inputProcessor.setKeyboardLocked(false);
|
||||
}
|
||||
if (resetMdt) {
|
||||
resetAllMDT();
|
||||
}
|
||||
if (wccReset(wcc)) {
|
||||
log.fine("WCC reset: clearing default attributes");
|
||||
}
|
||||
}
|
||||
|
||||
public void processWCC(short wcc) {
|
||||
processWCC(wcc & 0xFFFF);
|
||||
}
|
||||
|
||||
/** Process Set Buffer Address (SBA) order. */
|
||||
public void processSBA(int baddr) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size > 0) {
|
||||
screen.setBufferAddress(baddr % size);
|
||||
}
|
||||
}
|
||||
|
||||
public void processSBA(int b1, int b2) {
|
||||
processSBA(decodeAddress(b1, b2));
|
||||
}
|
||||
|
||||
public void processSBA() {
|
||||
// No-op or maintains current buffer address
|
||||
}
|
||||
|
||||
/** Process Start Field (SF) order. */
|
||||
public void processSF(byte fa) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size <= 0) return;
|
||||
int baddr = screen.getBufferAddress();
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
ea.clear();
|
||||
ea.fa = (byte) (fa & FA_MASK);
|
||||
ea.ec = 0;
|
||||
ea.ucs4 = ' ';
|
||||
screen.setFormatted(true);
|
||||
screen.setBufferAddress((baddr + 1) % size);
|
||||
}
|
||||
|
||||
public void processSF() {
|
||||
processSF((byte) FA_PRINTABLE);
|
||||
}
|
||||
|
||||
/** Process Start Field Extended (SFE) order. */
|
||||
public void processSFE(byte[] pairs) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size <= 0) return;
|
||||
int baddr = screen.getBufferAddress();
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
ea.clear();
|
||||
ea.ec = 0;
|
||||
ea.ucs4 = ' ';
|
||||
if (pairs != null) {
|
||||
for (int i = 0; i + 1 < pairs.length; i += 2) {
|
||||
int attrType = pairs[i] & 0xFF;
|
||||
int attrValue = pairs[i + 1] & 0xFF;
|
||||
applyExtendedAttribute(ea, attrType, attrValue);
|
||||
}
|
||||
}
|
||||
if (ea.fa == 0) {
|
||||
ea.fa = (byte) FA_PRINTABLE;
|
||||
}
|
||||
screen.setFormatted(true);
|
||||
screen.setBufferAddress((baddr + 1) % size);
|
||||
}
|
||||
|
||||
public void processSFE() {
|
||||
processSFE(new byte[0]);
|
||||
}
|
||||
|
||||
/** Process Set Attribute (SA) order. */
|
||||
public void processSA(int attrType, int attrValue) {
|
||||
int baddr = screen.getBufferAddress();
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
applyExtendedAttribute(ea, attrType, attrValue);
|
||||
}
|
||||
|
||||
public void processSA() {
|
||||
// Default attributes
|
||||
}
|
||||
|
||||
/** Process Modify Field (MF) order. */
|
||||
public void processMF(byte[] pairs) {
|
||||
int baddr = screen.getBufferAddress();
|
||||
int faAddr = screen.findFieldAttribute(baddr);
|
||||
if (faAddr >= 0 && pairs != null) {
|
||||
ExtendedAttribute ea = screen.getCell(faAddr);
|
||||
for (int i = 0; i + 1 < pairs.length; i += 2) {
|
||||
int attrType = pairs[i] & 0xFF;
|
||||
int attrValue = pairs[i + 1] & 0xFF;
|
||||
applyExtendedAttribute(ea, attrType, attrValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processMF() {
|
||||
processMF(new byte[0]);
|
||||
}
|
||||
|
||||
/** Process Insert Cursor (IC) order. */
|
||||
public void processIC() {
|
||||
screen.setCursorAddress(screen.getBufferAddress());
|
||||
}
|
||||
|
||||
/** Process Program Tab (PT) order. */
|
||||
public void processPT() {
|
||||
int baddr = screen.findNextUnprotected(screen.getBufferAddress());
|
||||
screen.setBufferAddress(baddr);
|
||||
}
|
||||
|
||||
/** Process Repeat to Address (RA) order. */
|
||||
public void processRA(int toAddr, int fillChar) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size <= 0) return;
|
||||
toAddr = ((toAddr % size) + size) % size;
|
||||
int baddr = screen.getBufferAddress();
|
||||
char ucs4 = (translator != null) ? translator.ebcdicToUnicode(fillChar & 0xFF) : (char) fillChar;
|
||||
do {
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
ea.fa = 0;
|
||||
ea.ec = (byte) fillChar;
|
||||
ea.ucs4 = ucs4;
|
||||
baddr = (baddr + 1) % size;
|
||||
} while (baddr != toAddr);
|
||||
screen.setBufferAddress(baddr);
|
||||
}
|
||||
|
||||
public void processRA() {
|
||||
processRA(0, 0);
|
||||
}
|
||||
|
||||
/** Process Erase Unprotected to Address (EUA) order. */
|
||||
public void processEUA(int toAddr) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size <= 0) return;
|
||||
toAddr = ((toAddr % size) + size) % size;
|
||||
int baddr = screen.getBufferAddress();
|
||||
do {
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
if (!ea.isFieldAttribute()) {
|
||||
int faAddr = screen.findFieldAttribute(baddr);
|
||||
byte faVal = faAddr >= 0 ? screen.getCell(faAddr).fa : 0;
|
||||
if (!faIsProtected(faVal & 0xFF)) {
|
||||
ea.ec = 0;
|
||||
ea.ucs4 = 0;
|
||||
ea.fg = 0;
|
||||
ea.bg = 0;
|
||||
ea.gr = 0;
|
||||
ea.cs = 0;
|
||||
}
|
||||
}
|
||||
baddr = (baddr + 1) % size;
|
||||
} while (baddr != toAddr);
|
||||
screen.setBufferAddress(baddr);
|
||||
}
|
||||
|
||||
public void processEUA() {
|
||||
processEUA(0);
|
||||
}
|
||||
|
||||
/** Process Graphic Escape (GE) order. */
|
||||
public void processGE(int geChar) {
|
||||
int size = screen.getRows() * screen.getCols();
|
||||
if (size <= 0) return;
|
||||
int baddr = screen.getBufferAddress();
|
||||
ExtendedAttribute ea = screen.getCell(baddr);
|
||||
ea.fa = 0;
|
||||
ea.ec = (byte) geChar;
|
||||
ea.cs = CS_GE;
|
||||
ea.ucs4 = (translator != null) ? translator.mapAPL(geChar) : (char) geChar;
|
||||
screen.setBufferAddress((baddr + 1) % size);
|
||||
}
|
||||
|
||||
public void processGE() {
|
||||
processGE(0);
|
||||
}
|
||||
|
||||
/** Process Write Structured Field (WSF) from short buffer. */
|
||||
public void processWSF(short[] data, int off, int len) {
|
||||
if (data == null || len <= 0) return;
|
||||
byte[] bdata = new byte[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
bdata[i] = (byte) (data[off + i] & 0xFF);
|
||||
}
|
||||
processWriteStructuredField(bdata, 0, len);
|
||||
}
|
||||
|
||||
public void processWSF(byte[] data, int off, int len) {
|
||||
processWriteStructuredField(data, off, len);
|
||||
}
|
||||
|
||||
/** Process raw inbound data stream chunk (short[] representation). */
|
||||
public void processData(short[] data, int off, int len) {
|
||||
if (data == null || len <= 0) return;
|
||||
byte[] bdata = new byte[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
bdata[i] = (byte) (data[off + i] & 0xFF);
|
||||
}
|
||||
processRecord(bdata, 0, len, true);
|
||||
}
|
||||
|
||||
public void processData(byte[] data, int off, int len) {
|
||||
processRecord(data, off, len, true);
|
||||
}
|
||||
|
||||
/** Send AID key with explicit cursor address. */
|
||||
public void sendAid(short aid, int cursorAddress) {
|
||||
if (inputProcessor != null) {
|
||||
inputProcessor.sendAid(aid & 0xFFFF, cursorAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package haus.nightmare.lib3270j.datastream;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Reusable, resizable byte buffer that provides zero-copy access to its internal
|
||||
* array and supports ByteBuffer slicing to minimize heap allocations during
|
||||
* network stream processing.
|
||||
*/
|
||||
public class FastByteBuffer extends OutputStream {
|
||||
|
||||
private byte[] buf;
|
||||
private int count;
|
||||
|
||||
public FastByteBuffer() {
|
||||
this(32768);
|
||||
}
|
||||
|
||||
public FastByteBuffer(int initialCapacity) {
|
||||
this.buf = new byte[Math.max(32, initialCapacity)];
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
private void ensureCapacity(int minCapacity) {
|
||||
if (minCapacity > buf.length) {
|
||||
int newCap = Math.max(buf.length << 1, minCapacity);
|
||||
buf = Arrays.copyOf(buf, newCap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void write(int b) {
|
||||
ensureCapacity(count + 1);
|
||||
buf[count++] = (byte) b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void write(byte[] b, int off, int len) {
|
||||
if (b == null || len <= 0) return;
|
||||
ensureCapacity(count + len);
|
||||
System.arraycopy(b, off, buf, count, len);
|
||||
count += len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct reference to internal buffer array.
|
||||
* Use {@link #size()} to determine active length.
|
||||
*/
|
||||
public synchronized byte[] buffer() {
|
||||
return buf;
|
||||
}
|
||||
|
||||
public synchronized int size() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public synchronized void reset() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a read-only ByteBuffer view wrapping active bytes without copying.
|
||||
*/
|
||||
public synchronized ByteBuffer asByteBuffer() {
|
||||
return ByteBuffer.wrap(buf, 0, count).asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a read-only ByteBuffer slice for a sub-range without copying.
|
||||
*/
|
||||
public synchronized ByteBuffer slice(int offset, int length) {
|
||||
if (offset < 0 || length < 0 || offset + length > count) {
|
||||
throw new IndexOutOfBoundsException("offset=" + offset + " length=" + length + " size=" + count);
|
||||
}
|
||||
return ByteBuffer.wrap(buf, offset, length).slice().asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a copied byte array if an isolated copy is explicitly required.
|
||||
*/
|
||||
public synchronized byte[] toByteArray() {
|
||||
return Arrays.copyOf(buf, count);
|
||||
}
|
||||
}
|
||||
+154
-138
@@ -9,7 +9,7 @@ import static haus.nightmare.lib3270j.protocol.DS3270Constants.*;
|
||||
|
||||
/**
|
||||
* Builds Query Reply structured fields in response to host Read Partition queries.
|
||||
* Matches IBM 3270 Architecture (GA23-0059) and x3270 sf.c exact binary layout.
|
||||
* Matches 3270 Architecture (GA23-0059) and x3270 sf.c exact binary layout.
|
||||
*/
|
||||
public class QueryReplyBuilder {
|
||||
|
||||
@@ -18,10 +18,102 @@ public class QueryReplyBuilder {
|
||||
private static final int SW_3279_2 = 0x09;
|
||||
private static final int SH_3279_2 = 0x0c;
|
||||
|
||||
// Usable Area physical dimensions matching IBM Host On-Demand DS3270.java (Inches, 96 dpi: 0x00010060)
|
||||
// Usable Area physical dimensions matching HOD DS3270.java (Inches, 96 dpi: 0x00010060)
|
||||
private static final int Xr_HOD = 0x00010060;
|
||||
private static final int Yr_HOD = 0x00010060;
|
||||
|
||||
// Pre-computed static query reply payloads to eliminate allocation churn
|
||||
private static final byte[] STATIC_QR_COLOR = new byte[] {
|
||||
0x00, 0x08, 0x00, (byte) 0xF4,
|
||||
(byte) 0xF1, (byte) 0xF1, // Blue
|
||||
(byte) 0xF2, (byte) 0xF2, // Red
|
||||
(byte) 0xF3, (byte) 0xF3, // Pink
|
||||
(byte) 0xF4, (byte) 0xF4, // Green
|
||||
(byte) 0xF5, (byte) 0xF5, // Turquoise
|
||||
(byte) 0xF6, (byte) 0xF6, // Yellow
|
||||
(byte) 0xF7, (byte) 0xF7 // Neutral/White
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_HIGHLIGHTING = new byte[] {
|
||||
0x04, 0x00, (byte) 0xF0,
|
||||
(byte) 0xF1, (byte) 0xF1,
|
||||
(byte) 0xF2, (byte) 0xF2,
|
||||
(byte) 0xF4, (byte) 0xF4
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_REPLY_MODES = new byte[] {
|
||||
SF_SRM_FIELD, SF_SRM_XFIELD, SF_SRM_CHAR
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_OUTLINING = new byte[] {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_DBCS_ASIA = new byte[] {
|
||||
0x00, 0x03, 0x01, (byte) 0x80, 0x03, 0x02, 0x01
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_AUXDA = new byte[] {
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_TRANSPARENCY = new byte[] {
|
||||
0x02, 0x00, (byte) 0xF0, (byte) 0xFF, (byte) 0xFF
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_SEGMENT = new byte[] {
|
||||
(byte) 0x80, 0x02, 0x00, 0x00, 0x00, (byte) 0xFC, 0x00
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_PROCEDURE = new byte[] {
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, (byte) 0xFC, 0x00,
|
||||
0x06, 0x40, 0x06, 0x40, 0x06, 0x01,
|
||||
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_QR_LINETYPE = new byte[] {
|
||||
0x00, 0x09, 0x00, 0x07,
|
||||
0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04,
|
||||
0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x08, 0x08
|
||||
};
|
||||
|
||||
private static final byte[] STATIC_PORT_BLOCKS;
|
||||
static {
|
||||
ByteArrayOutputStream pOut = new ByteArrayOutputStream(64);
|
||||
byte[][] data = {
|
||||
{ 0x00, 0x03, 0x02, (byte) 0x90, 0x09, 0x01, 0x00, 0x03, 0x02, (byte) 0x80, 0x00, 0x7F, (byte) 0xFF },
|
||||
{ 0x00, 0x04, 0x08, 0x40, 0x07, 0x03, 0x00, 0x03, (byte) 0x80, 0x00, 0x02 },
|
||||
{ 0x00, 0x05, 0x02, (byte) 0x80, 0x09, 0x01, 0x00, 0x01, 0x02, (byte) 0x80, 0x00, 0x7F, (byte) 0xFF },
|
||||
{ 0x00, 0x07, 0x08, 0x40, 0x07, 0x03, 0x00, 0x01, 0x00, 0x00, 0x1C }
|
||||
};
|
||||
for (byte[] d : data) {
|
||||
int len = 4 + d.length;
|
||||
pOut.write((len >> 8) & 0xFF);
|
||||
pOut.write(len & 0xFF);
|
||||
pOut.write(SFID_QREPLY);
|
||||
pOut.write(QR_PORT);
|
||||
pOut.write(d, 0, d.length);
|
||||
}
|
||||
STATIC_PORT_BLOCKS = pOut.toByteArray();
|
||||
}
|
||||
|
||||
private static final byte[] STATIC_QR_GRCOLOR;
|
||||
static {
|
||||
ByteArrayOutputStream gOut = new ByteArrayOutputStream(110);
|
||||
gOut.write(0x00); gOut.write(0x04); gOut.write(0x00); gOut.write(0xFF); gOut.write(0xFF);
|
||||
gOut.write(0x00); gOut.write(0x10); gOut.write(0x00); gOut.write(0x10);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
gOut.write(0x00);
|
||||
gOut.write(i);
|
||||
int argb = haus.nightmare.lib3270j.graphics.GocaConstants.GOCA_COLORS[i];
|
||||
gOut.write((argb >> 16) & 0xFF);
|
||||
gOut.write((argb >> 8) & 0xFF);
|
||||
gOut.write(argb & 0xFF);
|
||||
gOut.write(0x00);
|
||||
}
|
||||
STATIC_QR_GRCOLOR = gOut.toByteArray();
|
||||
}
|
||||
|
||||
private final ScreenBuffer screen;
|
||||
private GraphicsMode graphicsMode = GraphicsMode.BOTH;
|
||||
|
||||
@@ -101,27 +193,27 @@ public class QueryReplyBuilder {
|
||||
appendQueryReply(out, QR_CHARSETS, buildCharsets());
|
||||
|
||||
// Color (0x86)
|
||||
appendQueryReply(out, QR_COLOR, buildColor());
|
||||
appendQueryReply(out, QR_COLOR, STATIC_QR_COLOR);
|
||||
|
||||
// Highlighting (0x87)
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, buildHighlighting());
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, STATIC_QR_HIGHLIGHTING);
|
||||
|
||||
// Reply Modes (0x88)
|
||||
appendQueryReply(out, QR_REPLY_MODES, buildReplyModes());
|
||||
appendQueryReply(out, QR_REPLY_MODES, STATIC_QR_REPLY_MODES);
|
||||
|
||||
boolean isDbcs = (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS());
|
||||
if (isDbcs) {
|
||||
// Outlining (0x8C)
|
||||
appendQueryReply(out, QR_OUTLINING, buildOutlining());
|
||||
appendQueryReply(out, QR_OUTLINING, STATIC_QR_OUTLINING);
|
||||
// DBCS Asia (0x91)
|
||||
appendQueryReply(out, QR_DBCS_ASIA, buildDbcsAsia());
|
||||
appendQueryReply(out, QR_DBCS_ASIA, STATIC_QR_DBCS_ASIA);
|
||||
}
|
||||
|
||||
// Distributed Data Management (0x95)
|
||||
appendQueryReply(out, QR_DDM, buildDdm(4096));
|
||||
|
||||
// Auxiliary Devices (0x99)
|
||||
appendQueryReply(out, QR_AUXDA, buildAuxDa());
|
||||
appendQueryReply(out, QR_AUXDA, STATIC_QR_AUXDA);
|
||||
|
||||
// Implicit Partition (0xA6)
|
||||
appendQueryReply(out, QR_IMP_PART, buildImplicitPartition(maxCols, maxRows));
|
||||
@@ -141,27 +233,27 @@ public class QueryReplyBuilder {
|
||||
appendQueryReply(out, QR_USABLE_AREA, buildUsableArea(maxCols, maxRows, bufferSize));
|
||||
appendQueryReply(out, QR_ALPHA_PART, buildAlphaPartitions(maxRows));
|
||||
appendQueryReply(out, QR_CHARSETS, buildCharsets());
|
||||
appendQueryReply(out, QR_COLOR, buildColor());
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, buildHighlighting());
|
||||
appendQueryReply(out, QR_REPLY_MODES, buildReplyModes());
|
||||
appendQueryReply(out, QR_COLOR, STATIC_QR_COLOR);
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, STATIC_QR_HIGHLIGHTING);
|
||||
appendQueryReply(out, QR_REPLY_MODES, STATIC_QR_REPLY_MODES);
|
||||
|
||||
appendQueryReply(out, QR_OUTLINING, buildOutlining());
|
||||
appendQueryReply(out, QR_OUTLINING, STATIC_QR_OUTLINING);
|
||||
boolean isDbcs = (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS());
|
||||
if (isDbcs) {
|
||||
appendQueryReply(out, QR_DBCS_ASIA, buildDbcsAsia());
|
||||
appendQueryReply(out, QR_DBCS_ASIA, STATIC_QR_DBCS_ASIA);
|
||||
}
|
||||
appendQueryReply(out, QR_DDM, buildDdm(4096));
|
||||
appendQueryReply(out, QR_AUXDA, buildAuxDa());
|
||||
appendQueryReply(out, QR_AUXDA, STATIC_QR_AUXDA);
|
||||
appendQueryReply(out, QR_IMP_PART, buildImplicitPartition(maxCols, maxRows));
|
||||
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_TRANSPARENCY, buildTransparency()); // 0xA8
|
||||
appendQueryReply(out, QR_SEGMENT, buildSegment(maxCols, maxRows)); // 0xB0
|
||||
appendQueryReply(out, QR_PROCEDURE, buildProcedure(maxCols, maxRows)); // 0xB1
|
||||
appendQueryReply(out, QR_LINETYPE, buildLineType()); // 0xB2
|
||||
appendPort(out); // 0xB3
|
||||
appendQueryReply(out, QR_GRCOLOR, buildGrColor()); // 0xB4
|
||||
appendQueryReply(out, QR_GRSYMBOLSET, buildGrSymbolSet()); // 0xB6
|
||||
appendQueryReply(out, QR_TRANSPARENCY, STATIC_QR_TRANSPARENCY); // 0xA8
|
||||
appendQueryReply(out, QR_SEGMENT, STATIC_QR_SEGMENT); // 0xB0
|
||||
appendQueryReply(out, QR_PROCEDURE, STATIC_QR_PROCEDURE); // 0xB1
|
||||
appendQueryReply(out, QR_LINETYPE, STATIC_QR_LINETYPE); // 0xB2
|
||||
appendPort(out); // 0xB3
|
||||
appendQueryReply(out, QR_GRCOLOR, STATIC_QR_GRCOLOR); // 0xB4
|
||||
appendQueryReply(out, QR_GRSYMBOLSET, buildGrSymbolSet()); // 0xB6
|
||||
}
|
||||
|
||||
log.info("Built " + out.size() + " bytes of complete query replies (graphicsMode=" + graphicsMode + ")");
|
||||
@@ -197,20 +289,20 @@ public class QueryReplyBuilder {
|
||||
appendQueryReply(out, QR_CHARSETS, buildCharsets());
|
||||
break;
|
||||
case QR_COLOR:
|
||||
appendQueryReply(out, QR_COLOR, buildColor());
|
||||
appendQueryReply(out, QR_COLOR, STATIC_QR_COLOR);
|
||||
break;
|
||||
case QR_HIGHLIGHTING:
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, buildHighlighting());
|
||||
appendQueryReply(out, QR_HIGHLIGHTING, STATIC_QR_HIGHLIGHTING);
|
||||
break;
|
||||
case QR_REPLY_MODES:
|
||||
appendQueryReply(out, QR_REPLY_MODES, buildReplyModes());
|
||||
appendQueryReply(out, QR_REPLY_MODES, STATIC_QR_REPLY_MODES);
|
||||
break;
|
||||
case QR_OUTLINING: // 0x8C
|
||||
appendQueryReply(out, QR_OUTLINING, buildOutlining());
|
||||
appendQueryReply(out, QR_OUTLINING, STATIC_QR_OUTLINING);
|
||||
break;
|
||||
case QR_DBCS_ASIA: // 0x91
|
||||
if (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS()) {
|
||||
appendQueryReply(out, QR_DBCS_ASIA, buildDbcsAsia());
|
||||
appendQueryReply(out, QR_DBCS_ASIA, STATIC_QR_DBCS_ASIA);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
@@ -219,35 +311,35 @@ public class QueryReplyBuilder {
|
||||
appendQueryReply(out, QR_DDM, buildDdm(4096));
|
||||
break;
|
||||
case QR_AUXDA: // 0x99
|
||||
appendQueryReply(out, QR_AUXDA, buildAuxDa());
|
||||
appendQueryReply(out, QR_AUXDA, STATIC_QR_AUXDA);
|
||||
break;
|
||||
case QR_IMP_PART: // 0xA6
|
||||
appendQueryReply(out, QR_IMP_PART, buildImplicitPartition(maxCols, maxRows));
|
||||
break;
|
||||
case QR_TRANSPARENCY: // 0xA8
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_TRANSPARENCY, buildTransparency());
|
||||
appendQueryReply(out, QR_TRANSPARENCY, STATIC_QR_TRANSPARENCY);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
break;
|
||||
case QR_SEGMENT: // 0xB0
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_SEGMENT, buildSegment(maxCols, maxRows));
|
||||
appendQueryReply(out, QR_SEGMENT, STATIC_QR_SEGMENT);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
break;
|
||||
case QR_PROCEDURE: // 0xB1
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_PROCEDURE, buildProcedure(maxCols, maxRows));
|
||||
appendQueryReply(out, QR_PROCEDURE, STATIC_QR_PROCEDURE);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
break;
|
||||
case QR_LINETYPE: // 0xB2
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_LINETYPE, buildLineType());
|
||||
appendQueryReply(out, QR_LINETYPE, STATIC_QR_LINETYPE);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
@@ -261,7 +353,7 @@ public class QueryReplyBuilder {
|
||||
break;
|
||||
case QR_GRCOLOR: // 0xB4
|
||||
if (graphicsMode.isVectorGraphicsEnabled()) {
|
||||
appendQueryReply(out, QR_GRCOLOR, buildGrColor());
|
||||
appendQueryReply(out, QR_GRCOLOR, STATIC_QR_GRCOLOR);
|
||||
} else {
|
||||
appendQueryReply(out, QR_NULL, new byte[0]);
|
||||
}
|
||||
@@ -321,19 +413,19 @@ public class QueryReplyBuilder {
|
||||
out.write(maxCols & 0xFF); // usable width low
|
||||
out.write((maxRows >> 8) & 0xFF); // usable height high
|
||||
out.write(maxRows & 0xFF); // usable height low
|
||||
out.write(0x00); // units (0x00 = inches, matching IBM Host On-Demand QR_USEAREA_STRING)
|
||||
// Xr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING (96 DPI)
|
||||
out.write(0x00); // units (0x00 = inches, matching HOD QR_USEAREA_STRING)
|
||||
// Xr (4 bytes) - matching HOD QR_USEAREA_STRING (96 DPI)
|
||||
out.write((Xr_HOD >> 24) & 0xFF);
|
||||
out.write((Xr_HOD >> 16) & 0xFF);
|
||||
out.write((Xr_HOD >> 8) & 0xFF);
|
||||
out.write(Xr_HOD & 0xFF);
|
||||
// Yr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING (96 DPI)
|
||||
// Yr (4 bytes) - matching HOD QR_USEAREA_STRING (96 DPI)
|
||||
out.write((Yr_HOD >> 24) & 0xFF);
|
||||
out.write((Yr_HOD >> 16) & 0xFF);
|
||||
out.write((Yr_HOD >> 8) & 0xFF);
|
||||
out.write(Yr_HOD & 0xFF);
|
||||
int charW = getCharWidth();
|
||||
int charH = getCharHeight();
|
||||
int charW = getCharWidth(maxRows);
|
||||
int charH = getCharHeight(maxRows);
|
||||
out.write(charW); // AW
|
||||
out.write(charH); // AH
|
||||
int buf = maxCols * maxRows;
|
||||
@@ -343,6 +435,11 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public int getCharWidth() {
|
||||
int rows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
|
||||
return getCharWidth(rows);
|
||||
}
|
||||
|
||||
public int getCharWidth(int rows) {
|
||||
if (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS()) {
|
||||
return 12;
|
||||
}
|
||||
@@ -350,18 +447,11 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public int getCharHeight() {
|
||||
// ARCHITECTURAL NOTE ON 3179G GOCA VERTICAL ALIGNMENT & QUERY REPLIES:
|
||||
// Why hardcoding SH = 12 (0x0C) in Character Sets & Usable Area failed in past iterations:
|
||||
// When SDH/AH is declared as 12 (0x0C) in Query Reply, the mainframe host GDDM engine computes
|
||||
// total presentation space as rows * 12 (e.g. 43 * 12 = 516 units, yMax = 257).
|
||||
// GDDM then places the top menu bar at Row 1 (gy = 187..200).
|
||||
// Meanwhile, the client emulator rendered into a 16-pitch grid (43 * 16 = 688 units, yMax = 343).
|
||||
// On a 688-unit canvas, gy = 200 mapped to Row 9.2 (middle of the screen), leaving a massive void above.
|
||||
// When the user clicked on the visual menu drawn at Row 9, the client emitted gy = 189 with cursor at Row 9,
|
||||
// which GDDM rejected as outside its menu hit box (causing terminal alarm beeps).
|
||||
//
|
||||
// Solution: Declare SDH = 16 (0x10) when Vector Graphics is enabled (3179G standard), ensuring host GDDM
|
||||
// and client GraphicsPlane share the exact same 16-pitch presentation space (720x688, yMax = 343).
|
||||
int rows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
|
||||
return getCharHeight(rows);
|
||||
}
|
||||
|
||||
public int getCharHeight(int rows) {
|
||||
return graphicsMode.isVectorGraphicsEnabled() ? 0x10 : SH_3279_2;
|
||||
}
|
||||
|
||||
@@ -442,31 +532,15 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildColor() {
|
||||
// Alphanumeric Color (matches HOD: 8 pairs, F1..F7 + default F4 green, 18 bytes payload / 22 bytes total)
|
||||
return new byte[] {
|
||||
0x00, 0x08, 0x00, (byte) 0xF4,
|
||||
(byte) 0xF1, (byte) 0xF1, // Blue
|
||||
(byte) 0xF2, (byte) 0xF2, // Red
|
||||
(byte) 0xF3, (byte) 0xF3, // Pink
|
||||
(byte) 0xF4, (byte) 0xF4, // Green
|
||||
(byte) 0xF5, (byte) 0xF5, // Turquoise
|
||||
(byte) 0xF6, (byte) 0xF6, // Yellow
|
||||
(byte) 0xF7, (byte) 0xF7 // Neutral/White
|
||||
};
|
||||
return STATIC_QR_COLOR.clone();
|
||||
}
|
||||
|
||||
public byte[] buildHighlighting() {
|
||||
// Highlighting (matches HOD: 4 pairs: default F0, Blink F1, Reverse F2, Underscore F4, 9 bytes payload / 13 bytes total)
|
||||
return new byte[] {
|
||||
0x04, 0x00, (byte) 0xF0,
|
||||
(byte) 0xF1, (byte) 0xF1,
|
||||
(byte) 0xF2, (byte) 0xF2,
|
||||
(byte) 0xF4, (byte) 0xF4
|
||||
};
|
||||
return STATIC_QR_HIGHLIGHTING.clone();
|
||||
}
|
||||
|
||||
public byte[] buildReplyModes() {
|
||||
return new byte[] { SF_SRM_FIELD, SF_SRM_XFIELD, SF_SRM_CHAR };
|
||||
return STATIC_QR_REPLY_MODES.clone();
|
||||
}
|
||||
|
||||
public byte[] buildDdm() {
|
||||
@@ -517,39 +591,27 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildOutlining() {
|
||||
// HOD QueryReply3270Constants.java QR_OUTLINING_STRING ("\u0000\n\u0081\u008c\u0000\u0000\u0000\u0000\u0000\u0000")
|
||||
return new byte[]{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
return STATIC_QR_OUTLINING.clone();
|
||||
}
|
||||
|
||||
public byte[] buildDbcsAsia() {
|
||||
// HOD QueryReply3270Constants.java QR_DBCS_ASIA_STRING ("\u0000\u000b\u0081\u0091\u0000\u0003\u0001\u0080\u0003\u0002\u0001")
|
||||
return new byte[]{ 0x00, 0x03, 0x01, (byte) 0x80, 0x03, 0x02, 0x01 };
|
||||
return STATIC_QR_DBCS_ASIA.clone();
|
||||
}
|
||||
|
||||
public byte[] buildAuxDa() {
|
||||
// HOD QueryReply3270Constants.java QR_AUXDA_STRING ("\u0000\u0006\u0081\u0099\u0000\u0000")
|
||||
return new byte[]{ 0x00, 0x00 };
|
||||
return STATIC_QR_AUXDA.clone();
|
||||
}
|
||||
|
||||
public byte[] buildTransparency() {
|
||||
// HOD QueryReply3270Constants.java QR_TRANSPARENCY_STRING ("\u0000\t\u0081\u00a8\u0002\u0000\u00f0\u00ff\u00ff")
|
||||
return new byte[]{ 0x02, 0x00, (byte) 0xF0, (byte) 0xFF, (byte) 0xFF };
|
||||
return STATIC_QR_TRANSPARENCY.clone();
|
||||
}
|
||||
|
||||
public byte[] buildSegment() {
|
||||
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
|
||||
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
|
||||
return buildSegment(maxCols, maxRows);
|
||||
return STATIC_QR_SEGMENT.clone();
|
||||
}
|
||||
|
||||
public byte[] buildSegment(int maxCols, int maxRows) {
|
||||
// HOD QueryReply3270Constants.java QR_SEGMENT_STRING ("\u0000\u000b\u0081\u00b0\u0080\u0002\u0000\u0000\u0000\u00fc\u0000")
|
||||
return new byte[]{
|
||||
(byte) 0x80, 0x02,
|
||||
0x00, 0x00,
|
||||
0x00, (byte) 0xFC,
|
||||
0x00
|
||||
};
|
||||
return STATIC_QR_SEGMENT.clone();
|
||||
}
|
||||
|
||||
public byte[] buildGraphics() {
|
||||
@@ -561,21 +623,11 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildProcedure() {
|
||||
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
|
||||
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
|
||||
return buildProcedure(maxCols, maxRows);
|
||||
return STATIC_QR_PROCEDURE.clone();
|
||||
}
|
||||
|
||||
public byte[] buildProcedure(int maxCols, int maxRows) {
|
||||
// HOD QueryReply3270Constants.java QR_PROCEDURE_STRING ("\u0000\u0015\u0081\u00b1\u0000\u0001\u0000\u0000\u0000\u00fc\u0000\u0006@\u0006@\u0006\u0001\u00ff\u00ff\u00ff\u00f0")
|
||||
return new byte[]{
|
||||
0x00, 0x01,
|
||||
0x00, 0x00,
|
||||
0x00, (byte) 0xFC,
|
||||
0x00,
|
||||
0x06, 0x40, 0x06, 0x40, 0x06, 0x01,
|
||||
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0
|
||||
};
|
||||
return STATIC_QR_PROCEDURE.clone();
|
||||
}
|
||||
|
||||
public byte[] buildGImage() {
|
||||
@@ -587,12 +639,7 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildLineType() {
|
||||
// HOD QueryReply3270Constants.java QR_LINETYPE_STRING ("\u0000\u0018\u0081\u00b2\u0000\t\u0000\u0007\u0001\u0001\u0002\u0002\u0003\u0003\u0004\u0004\u0005\u0005\u0006\u0006\u0007\u0007\b\b")
|
||||
return new byte[]{
|
||||
0x00, 0x09, 0x00, 0x07,
|
||||
0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04,
|
||||
0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x08, 0x08
|
||||
};
|
||||
return STATIC_QR_LINETYPE.clone();
|
||||
}
|
||||
|
||||
public byte[] buildAuxDev() {
|
||||
@@ -604,19 +651,7 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public void appendPort(ByteArrayOutputStream out) {
|
||||
// HOD QueryReply3270Constants.java QR_PORT_STRING (4 OEM format sub-fields, 64 bytes total)
|
||||
appendQueryReply(out, QR_PORT, new byte[]{
|
||||
0x00, 0x03, 0x02, (byte) 0x90, 0x09, 0x01, 0x00, 0x03, 0x02, (byte) 0x80, 0x00, 0x7F, (byte) 0xFF
|
||||
});
|
||||
appendQueryReply(out, QR_PORT, new byte[]{
|
||||
0x00, 0x04, 0x08, 0x40, 0x07, 0x03, 0x00, 0x03, (byte) 0x80, 0x00, 0x02
|
||||
});
|
||||
appendQueryReply(out, QR_PORT, new byte[]{
|
||||
0x00, 0x05, 0x02, (byte) 0x80, 0x09, 0x01, 0x00, 0x01, 0x02, (byte) 0x80, 0x00, 0x7F, (byte) 0xFF
|
||||
});
|
||||
appendQueryReply(out, QR_PORT, new byte[]{
|
||||
0x00, 0x07, 0x08, 0x40, 0x07, 0x03, 0x00, 0x01, 0x00, 0x00, 0x1C
|
||||
});
|
||||
out.write(STATIC_PORT_BLOCKS, 0, STATIC_PORT_BLOCKS.length);
|
||||
}
|
||||
|
||||
public void appendOemFmt(ByteArrayOutputStream out) {
|
||||
@@ -624,9 +659,7 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildPort() {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(70);
|
||||
appendPort(out);
|
||||
return out.toByteArray();
|
||||
return STATIC_PORT_BLOCKS.clone();
|
||||
}
|
||||
|
||||
public byte[] buildOemFormat() {
|
||||
@@ -634,24 +667,7 @@ public class QueryReplyBuilder {
|
||||
}
|
||||
|
||||
public byte[] buildGrColor() {
|
||||
// HOD QueryReply3270Constants.java QR_GRCOLOR_STRING (109 bytes total)
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(110);
|
||||
out.write(0x00); out.write(0x04); out.write(0x00); out.write(0xFF); out.write(0xFF);
|
||||
out.write(0x00); out.write(0x10); out.write(0x00); out.write(0x10);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
out.write(0x00);
|
||||
out.write(i);
|
||||
int argb = haus.nightmare.lib3270j.graphics.GocaConstants.GOCA_COLORS[i];
|
||||
int r = (argb >> 16) & 0xFF;
|
||||
int g = (argb >> 8) & 0xFF;
|
||||
int b = argb & 0xFF;
|
||||
out.write(r);
|
||||
out.write(g);
|
||||
out.write(b);
|
||||
out.write(0x00); // 6th byte in HOD color table
|
||||
}
|
||||
return out.toByteArray();
|
||||
return STATIC_QR_GRCOLOR.clone();
|
||||
}
|
||||
|
||||
public byte[] buildGraphicColor() {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package haus.nightmare.lib3270j.datastream;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* Thread-safe memory pool providing reusable byte buffers for high-throughput
|
||||
* 3270 stream operations, minimizing garbage collector pressure.
|
||||
*/
|
||||
public final class ReusableByteBufferPool {
|
||||
|
||||
public static final int SIZE_SMALL = 512;
|
||||
public static final int SIZE_MEDIUM = 4096;
|
||||
public static final int SIZE_LARGE = 32768;
|
||||
|
||||
private static final int MAX_POOLED_PER_TIER = 32;
|
||||
|
||||
private static final Queue<byte[]> smallPool = new ConcurrentLinkedQueue<>();
|
||||
private static final Queue<byte[]> mediumPool = new ConcurrentLinkedQueue<>();
|
||||
private static final Queue<byte[]> largePool = new ConcurrentLinkedQueue<>();
|
||||
|
||||
private ReusableByteBufferPool() {}
|
||||
|
||||
/**
|
||||
* Acquires a pooled byte array with at least the specified capacity.
|
||||
*/
|
||||
public static byte[] acquire(int minCapacity) {
|
||||
if (minCapacity <= SIZE_SMALL) {
|
||||
byte[] b = smallPool.poll();
|
||||
return (b != null) ? b : new byte[SIZE_SMALL];
|
||||
} else if (minCapacity <= SIZE_MEDIUM) {
|
||||
byte[] b = mediumPool.poll();
|
||||
return (b != null) ? b : new byte[SIZE_MEDIUM];
|
||||
} else if (minCapacity <= SIZE_LARGE) {
|
||||
byte[] b = largePool.poll();
|
||||
return (b != null) ? b : new byte[SIZE_LARGE];
|
||||
}
|
||||
return new byte[minCapacity];
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquires a ByteBuffer wrapping a pooled array up to minCapacity.
|
||||
*/
|
||||
public static ByteBuffer acquireByteBuffer(int minCapacity) {
|
||||
byte[] b = acquire(minCapacity);
|
||||
return ByteBuffer.wrap(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a buffer to the pool for reuse if it matches a standard tier.
|
||||
*/
|
||||
public static void release(byte[] buffer) {
|
||||
if (buffer == null) return;
|
||||
if (buffer.length == SIZE_SMALL && smallPool.size() < MAX_POOLED_PER_TIER) {
|
||||
smallPool.offer(buffer);
|
||||
} else if (buffer.length == SIZE_MEDIUM && mediumPool.size() < MAX_POOLED_PER_TIER) {
|
||||
mediumPool.offer(buffer);
|
||||
} else if (buffer.length == SIZE_LARGE && largePool.size() < MAX_POOLED_PER_TIER) {
|
||||
largePool.offer(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all pools to release held memory.
|
||||
*/
|
||||
public static void clear() {
|
||||
smallPool.clear();
|
||||
mediumPool.clear();
|
||||
largePool.clear();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,22 @@ import haus.nightmare.lib3270j.Telnet3270Client;
|
||||
*/
|
||||
public class ECLConnection extends haus.nightmare.lib3270j.ecl.ECLConnection {
|
||||
|
||||
public ECLConnection() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ECLConnection(haus.nightmare.lib3270j.ecl.ECLSession session) {
|
||||
super((haus.nightmare.lib3270j.ecl.ECLSession) session, session != null ? session.getClient() : null);
|
||||
}
|
||||
|
||||
public ECLConnection(String host, int port) {
|
||||
super(host, port);
|
||||
}
|
||||
|
||||
public ECLConnection(java.util.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public ECLConnection(haus.nightmare.lib3270j.ecl.ECLSession session, Telnet3270Client client) {
|
||||
super(session, client);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLErr.
|
||||
*/
|
||||
public class ECLErr extends haus.nightmare.lib3270j.ecl.ECLErr {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ECLErr() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ECLErr(String text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
public ECLErr(String tag, String id, String text) {
|
||||
super(tag, id, text);
|
||||
}
|
||||
|
||||
public ECLErr(String tag, String id, String text, String extra) {
|
||||
super(tag, id, text, extra);
|
||||
}
|
||||
|
||||
public ECLErr(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ECLErr(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,8 @@ public class ECLOIA extends haus.nightmare.lib3270j.ecl.ECLOIA {
|
||||
public ECLOIA(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
|
||||
super(screen, inputProcessor, fsm);
|
||||
}
|
||||
|
||||
public ECLOIA(haus.nightmare.lib3270j.eNetwork.ECL.ECLSession session) {
|
||||
super(session);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLOIANotify.
|
||||
*/
|
||||
public interface ECLOIANotify extends haus.nightmare.lib3270j.ecl.ECLOIANotify {
|
||||
}
|
||||
@@ -12,4 +12,8 @@ public class ECLPS extends haus.nightmare.lib3270j.ecl.ECLPS {
|
||||
public ECLPS(ScreenBuffer screen, InputProcessor inputProcessor, EbcdicTranslator translator) {
|
||||
super(screen, inputProcessor, translator);
|
||||
}
|
||||
|
||||
public ECLPS(haus.nightmare.lib3270j.eNetwork.ECL.ECLSession session) {
|
||||
super(session);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSBIDIServices.
|
||||
*/
|
||||
public interface ECLPSBIDIServices extends haus.nightmare.lib3270j.ecl.ECLPSBIDIServices {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsServices.
|
||||
*/
|
||||
public interface ECLPSGraphicsServices extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsServices {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSHindiServices.
|
||||
*/
|
||||
public interface ECLPSHindiServices extends haus.nightmare.lib3270j.ecl.ECLPSHindiServices {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSTHAIServices.
|
||||
*/
|
||||
public interface ECLPSTHAIServices extends haus.nightmare.lib3270j.ecl.ECLPSTHAIServices {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSUpdate.
|
||||
*/
|
||||
public class ECLPSUpdate extends haus.nightmare.lib3270j.ecl.ECLPSUpdate {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ECLPSUpdate(haus.nightmare.lib3270j.ecl.ECLPS ps, int startRow, int startCol,
|
||||
int endRow, int endCol, int start, int end, boolean fullUpdate, String text) {
|
||||
super(ps, startRow, startCol, endRow, endCol, start, end, fullUpdate, text);
|
||||
}
|
||||
|
||||
public ECLPSUpdate(int startRow, int startCol, int endRow, int endCol, boolean fullUpdate) {
|
||||
super(startRow, startCol, endRow, endCol, fullUpdate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLScreenNotify.
|
||||
*/
|
||||
public interface ECLScreenNotify extends haus.nightmare.lib3270j.ecl.ECLScreenNotify {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLScreenReco.
|
||||
*/
|
||||
public class ECLScreenReco extends haus.nightmare.lib3270j.ecl.ECLScreenReco {
|
||||
|
||||
public ECLScreenReco() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ECLScreenReco(haus.nightmare.lib3270j.ecl.ECLSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
public ECLScreenReco(haus.nightmare.lib3270j.ecl.ECLPS ps) {
|
||||
super(ps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLScreenRecoEvent.
|
||||
*/
|
||||
public class ECLScreenRecoEvent extends haus.nightmare.lib3270j.ecl.ECLScreenRecoEvent {
|
||||
|
||||
public ECLScreenRecoEvent(haus.nightmare.lib3270j.ecl.ECLScreenReco source,
|
||||
haus.nightmare.lib3270j.ecl.ECLScreenDesc screenDesc,
|
||||
haus.nightmare.lib3270j.ecl.ECLPS ps) {
|
||||
super(source, screenDesc, ps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.bidi;
|
||||
|
||||
import haus.nightmare.lib3270j.input.InputProcessor;
|
||||
import haus.nightmare.lib3270j.screen.ScreenBuffer;
|
||||
import haus.nightmare.lib3270j.telnet.TelnetFSM;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLOIABIDI.
|
||||
*/
|
||||
public class ECLOIABIDI extends haus.nightmare.lib3270j.ecl.ECLOIABIDI {
|
||||
|
||||
public ECLOIABIDI(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
|
||||
super(screen, inputProcessor, fsm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.event;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLOIANotify in event package.
|
||||
*/
|
||||
public interface ECLOIANotify extends haus.nightmare.lib3270j.ecl.ECLOIANotify {
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.event;
|
||||
|
||||
import haus.nightmare.lib3270j.ecl.ECLPSUpdate;
|
||||
|
||||
/**
|
||||
* IBM Host On-Demand ECLPSEvent compatibility class.
|
||||
*/
|
||||
@@ -7,6 +9,15 @@ public class ECLPSEvent extends haus.nightmare.lib3270j.ecl.ECLPSEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ECLPSEvent(Object source, int eventType, int type, int startRow, int startCol,
|
||||
int endRow, int endCol, int oldCursorAddress, int newCursorAddress,
|
||||
int rows, int cols, boolean fullUpdate, boolean cursorVisible,
|
||||
int ringCounter, boolean startPrinterBit, ECLPSUpdate psUpdate) {
|
||||
super(source, eventType, type, startRow, startCol, endRow, endCol,
|
||||
oldCursorAddress, newCursorAddress, rows, cols, fullUpdate,
|
||||
cursorVisible, ringCounter, startPrinterBit, psUpdate);
|
||||
}
|
||||
|
||||
public ECLPSEvent(Object source, int eventType, int startRow, int startCol, int endRow, int endCol,
|
||||
int oldCursorAddress, int newCursorAddress, int rows, int cols, boolean fullUpdate) {
|
||||
super(source, eventType, startRow, startCol, endRow, endCol, oldCursorAddress, newCursorAddress, rows, cols, fullUpdate);
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.event;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.Rectangle;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsEvent.
|
||||
*/
|
||||
public class ECLPSGraphicsEvent extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsEvent {
|
||||
|
||||
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id) {
|
||||
super(source, id);
|
||||
}
|
||||
|
||||
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id, Object image) {
|
||||
super(source, id, image);
|
||||
}
|
||||
|
||||
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id, Object image, Rectangle rectangle) {
|
||||
super(source, id, image, rectangle);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.event;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsListener.
|
||||
*/
|
||||
public interface ECLPSGraphicsListener extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsListener {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hindi;
|
||||
|
||||
import haus.nightmare.lib3270j.input.InputProcessor;
|
||||
import haus.nightmare.lib3270j.screen.ScreenBuffer;
|
||||
import haus.nightmare.lib3270j.telnet.TelnetFSM;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLOIAHindi.
|
||||
*/
|
||||
public class ECLOIAHindi extends haus.nightmare.lib3270j.ecl.ECLOIAHindi {
|
||||
|
||||
public ECLOIAHindi(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
|
||||
super(screen, inputProcessor, fsm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for Edge.
|
||||
*/
|
||||
public class Edge extends haus.nightmare.lib3270j.graphics.Edge {
|
||||
public Edge(int x1, int y1, int x2, int y2) {
|
||||
super(x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.Color;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for FillArea.
|
||||
*/
|
||||
public class FillArea extends haus.nightmare.lib3270j.graphics.FillArea {
|
||||
public FillArea() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FillArea(int fillRule) {
|
||||
super(fillRule);
|
||||
}
|
||||
|
||||
public FillArea(int[] px, int[] py, int[] polyCounts, int numPolys, Color color) {
|
||||
super(px, py, polyCounts, numPolys, color);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for FilletPts.
|
||||
*/
|
||||
public class FilletPts extends haus.nightmare.lib3270j.graphics.FilletPts {
|
||||
public FilletPts() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODBitImage.
|
||||
*/
|
||||
public class HODBitImage extends haus.nightmare.lib3270j.graphics.HODBitImage {
|
||||
public HODBitImage(Object comp, int width, int height, byte[] data, int baseColor, int depth, boolean useGraphicColors) {
|
||||
super(comp, width, height, data, baseColor, depth, useGraphicColors);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODBounds.
|
||||
*/
|
||||
public class HODBounds extends haus.nightmare.lib3270j.graphics.HODBounds {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODColorChangeFilter.
|
||||
*/
|
||||
public class HODColorChangeFilter extends haus.nightmare.lib3270j.graphics.HODColorChangeFilter {
|
||||
public HODColorChangeFilter(int color) {
|
||||
super(color);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.GraphicsPlane;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODGraphicsPlane.
|
||||
*/
|
||||
public class HODGraphicsPlane extends haus.nightmare.lib3270j.graphics.HODGraphicsPlane {
|
||||
public HODGraphicsPlane() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODGraphicsPlane(int width, int height) {
|
||||
super(width, height);
|
||||
}
|
||||
|
||||
public HODGraphicsPlane(GraphicsPlane delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.Dimension;
|
||||
import haus.nightmare.lib3270j.graphics.Rectangle;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODPart.
|
||||
*/
|
||||
public class HODPart extends haus.nightmare.lib3270j.graphics.HODPart {
|
||||
public HODPart() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODPart(Object component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
public HODPart(Object component, Dimension dimension) {
|
||||
super(component, dimension);
|
||||
}
|
||||
|
||||
public HODPart(Object component, Rectangle rectangle) {
|
||||
super(component, rectangle);
|
||||
}
|
||||
|
||||
public HODPart(HODPart hODPart) {
|
||||
super(hODPart);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
import haus.nightmare.lib3270j.graphics.ProgramSymbolManager;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODProgramSymbolManager.
|
||||
*/
|
||||
public class HODProgramSymbolManager extends haus.nightmare.lib3270j.graphics.HODProgramSymbolManager {
|
||||
public HODProgramSymbolManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODProgramSymbolManager(ProgramSymbolManager delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODTransform.
|
||||
*/
|
||||
public class HODTransform extends haus.nightmare.lib3270j.graphics.HODTransform {
|
||||
public HODTransform(int charW, int charH, int defaultCharW, int defaultCharH) {
|
||||
super(charW, charH, defaultCharW, defaultCharH);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODTransparentColorFilter.
|
||||
*/
|
||||
public class HODTransparentColorFilter extends haus.nightmare.lib3270j.graphics.HODTransparentColorFilter {
|
||||
public HODTransparentColorFilter(int transparentColor) {
|
||||
super(transparentColor);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for HODWallpaper.
|
||||
*/
|
||||
public class HODWallpaper extends haus.nightmare.lib3270j.graphics.HODWallpaper {
|
||||
public HODWallpaper() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HODWallpaper(int displayMode) {
|
||||
super(displayMode);
|
||||
}
|
||||
|
||||
public HODWallpaper(Object image, int displayMode) {
|
||||
super(image, displayMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.thai;
|
||||
|
||||
import haus.nightmare.lib3270j.input.InputProcessor;
|
||||
import haus.nightmare.lib3270j.screen.ScreenBuffer;
|
||||
import haus.nightmare.lib3270j.telnet.TelnetFSM;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for ECLOIATHAI.
|
||||
*/
|
||||
public class ECLOIATHAI extends haus.nightmare.lib3270j.ecl.ECLOIATHAI {
|
||||
|
||||
public ECLOIATHAI(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
|
||||
super(screen, inputProcessor, fsm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.datastream.DataStreamProcessor;
|
||||
import haus.nightmare.lib3270j.ecl.ECLPS;
|
||||
import haus.nightmare.lib3270j.ecl.ECLSession;
|
||||
import haus.nightmare.lib3270j.screen.ScreenBuffer;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.DS3270.
|
||||
*/
|
||||
public class DS3270 extends haus.nightmare.lib3270j.tn3270.DS3270 {
|
||||
|
||||
public DS3270() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DS3270(ScreenBuffer screen, EbcdicTranslator translator) {
|
||||
super(screen, translator);
|
||||
}
|
||||
|
||||
public DS3270(DataStreamProcessor delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
public DS3270(ECLSession session, ECLPS ps) {
|
||||
super(session, ps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
|
||||
|
||||
import haus.nightmare.lib3270j.ecl.ECLPS;
|
||||
import haus.nightmare.lib3270j.ecl.ECLSession;
|
||||
import haus.nightmare.lib3270j.nvt.NvtProcessor;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.NVT3270.
|
||||
*/
|
||||
public class NVT3270 extends haus.nightmare.lib3270j.tn3270.NVT3270 {
|
||||
|
||||
public NVT3270() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NVT3270(NvtProcessor nvtProcessor) {
|
||||
super(nvtProcessor);
|
||||
}
|
||||
|
||||
public NVT3270(String host, ECLSession session, ECLPS ps, haus.nightmare.lib3270j.tn3270.DS3270 ds) {
|
||||
super(host, session, ps, ds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.ecl.ECLSession;
|
||||
import haus.nightmare.lib3270j.input.InputProcessor;
|
||||
import haus.nightmare.lib3270j.screen.ScreenBuffer;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.PS3270.
|
||||
*/
|
||||
public class PS3270 extends haus.nightmare.lib3270j.tn3270.PS3270 {
|
||||
|
||||
public PS3270() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PS3270(ECLSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
public PS3270(ScreenBuffer screen, InputProcessor inputProcessor, EbcdicTranslator translator) {
|
||||
super(screen, inputProcessor, translator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
|
||||
|
||||
import haus.nightmare.lib3270j.ecl.ECLPS;
|
||||
import haus.nightmare.lib3270j.ecl.ECLSession;
|
||||
import haus.nightmare.lib3270j.telnet.TelnetConnection;
|
||||
import haus.nightmare.lib3270j.telnet.TelnetFSM;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.Telnet3270E.
|
||||
*/
|
||||
public class Telnet3270E extends haus.nightmare.lib3270j.tn3270.Telnet3270E {
|
||||
|
||||
public Telnet3270E() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Telnet3270E(TelnetFSM fsm, TelnetConnection connection) {
|
||||
super(fsm, connection);
|
||||
}
|
||||
|
||||
public Telnet3270E(String host, ECLSession session, ECLPS ps, haus.nightmare.lib3270j.tn3270.DS3270 ds) {
|
||||
super(host, session, ps, ds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.qr_elem.
|
||||
*/
|
||||
public class qr_elem extends haus.nightmare.lib3270j.tn3270.qr_elem {
|
||||
|
||||
public qr_elem() {
|
||||
super();
|
||||
}
|
||||
|
||||
public qr_elem(int type, int sendFlag) {
|
||||
super(type, sendFlag);
|
||||
}
|
||||
|
||||
public qr_elem(byte type, byte sendFlag) {
|
||||
super(type, sendFlag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrintPS3270;
|
||||
import haus.nightmare.lib3270j.printer.PrintSCS3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
import haus.nightmare.lib3270j.printer.Telnet3270EP;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.DS3270P.
|
||||
*/
|
||||
public class DS3270P extends haus.nightmare.lib3270j.printer.DS3270P {
|
||||
|
||||
public DS3270P() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DS3270P(PrinterConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public DS3270P(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
|
||||
public DS3270P(Telnet3270EP telnet, PrinterConfig config, PD3270 pd,
|
||||
PrintSCS3270 scs, PrintPS3270 printPs, EbcdicTranslator translator) {
|
||||
super(telnet, config, pd, scs, printPs, translator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PD3270.
|
||||
*/
|
||||
public class PD3270 extends haus.nightmare.lib3270j.printer.PD3270 {
|
||||
|
||||
public PD3270() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PD3270(PrinterConfig config) {
|
||||
super(config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PDT.
|
||||
*/
|
||||
public class PDT extends PrinterDefinitionTable {
|
||||
|
||||
public PDT(String name, String description) {
|
||||
super(name, description);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PrintPS3270.
|
||||
*/
|
||||
public class PrintPS3270 extends haus.nightmare.lib3270j.printer.PrintPS3270 {
|
||||
|
||||
public PrintPS3270(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PrintPS3270DB.
|
||||
*/
|
||||
public class PrintPS3270DB extends haus.nightmare.lib3270j.printer.PrintPS3270DB {
|
||||
|
||||
public PrintPS3270DB(PrinterConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public PrintPS3270DB(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PrintSCS3270.
|
||||
*/
|
||||
public class PrintSCS3270 extends haus.nightmare.lib3270j.printer.PrintSCS3270 {
|
||||
|
||||
public PrintSCS3270(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PrintSCS3270DB.
|
||||
*/
|
||||
public class PrintSCS3270DB extends haus.nightmare.lib3270j.printer.PrintSCS3270DB {
|
||||
|
||||
public PrintSCS3270DB(PrinterConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public PrintSCS3270DB(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.PrinterDefinitionTable.
|
||||
*/
|
||||
public class PrinterDefinitionTable extends haus.nightmare.lib3270j.printer.PrinterDefinitionTable {
|
||||
|
||||
public PrinterDefinitionTable(String name, String description) {
|
||||
super(name, description);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
|
||||
import haus.nightmare.lib3270j.printer.PD3270;
|
||||
import haus.nightmare.lib3270j.printer.PrinterConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.Telnet3270EP.
|
||||
*/
|
||||
public class Telnet3270EP extends haus.nightmare.lib3270j.printer.Telnet3270EP {
|
||||
|
||||
public Telnet3270EP(PrinterConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public Telnet3270EP(PrinterConfig config, PD3270 pd, EbcdicTranslator translator) {
|
||||
super(config, pd, translator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
import haus.nightmare.lib3270j.printer.TimerListener;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.Timer.
|
||||
*/
|
||||
public class Timer extends haus.nightmare.lib3270j.printer.Timer {
|
||||
|
||||
public Timer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Timer(long intervalMs) {
|
||||
super(intervalMs);
|
||||
}
|
||||
|
||||
public Timer(long intervalMs, TimerListener listener) {
|
||||
super(intervalMs, listener);
|
||||
}
|
||||
|
||||
public Timer(long intervalMs, TimerListener listener, boolean repeating) {
|
||||
super(intervalMs, listener, repeating);
|
||||
}
|
||||
|
||||
public Timer(long intervalMs, TimerListener listener, boolean repeating, String timerId) {
|
||||
super(intervalMs, listener, repeating, timerId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.TimerEvent.
|
||||
*/
|
||||
public class TimerEvent extends haus.nightmare.lib3270j.printer.TimerEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TimerEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
public TimerEvent(Object source, String timerId) {
|
||||
super(source, timerId);
|
||||
}
|
||||
|
||||
public TimerEvent(Object source, String timerId, long timestamp) {
|
||||
super(source, timerId, timestamp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270p;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270p.TimerListener.
|
||||
*/
|
||||
public interface TimerListener extends haus.nightmare.lib3270j.printer.TimerListener {
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.xfer;
|
||||
|
||||
import haus.nightmare.lib3270j.ft.FTConfig;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatibility class for
|
||||
* com.ibm.eNetwork.ECL.xfer.FileTransferFileObject.
|
||||
*/
|
||||
public class FileTransferFileObject extends haus.nightmare.lib3270j.xfer.FileTransferFileObject {
|
||||
|
||||
public FileTransferFileObject() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FileTransferFileObject(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public FileTransferFileObject(String name, long size) {
|
||||
super(name, size);
|
||||
}
|
||||
|
||||
public FileTransferFileObject(String name, long size, boolean isDirectory) {
|
||||
super(name, size, isDirectory);
|
||||
}
|
||||
|
||||
public FileTransferFileObject(String localFile, String hostDatasetName) {
|
||||
super(localFile, hostDatasetName);
|
||||
}
|
||||
|
||||
public FileTransferFileObject(FTConfig config) {
|
||||
super(config);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package haus.nightmare.lib3270j.eNetwork.ECL.xfer;
|
||||
|
||||
/**
|
||||
* Drop-in IBM Host On-Demand compatibility interface for
|
||||
* com.ibm.eNetwork.ECL.xfer.FileTransferHostDirectoryInterface.
|
||||
*/
|
||||
public interface FileTransferHostDirectoryInterface extends haus.nightmare.lib3270j.xfer.FileTransferHostDirectoryInterface {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user