X Tutup
Skip to content

Commit 261cf62

Browse files
committed
Handle true color terminal control codes
1 parent a1ac7e7 commit 261cf62

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/src/main/java/de/mud/terminal/VDUBuffer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public class VDUBuffer {
104104
public final static long COLOR_FG = 0x7fffffc0L; /* 0000 0000 0000 0000 0000 0000 0000 0000 0111 1111 1111 1111 1111 1111 1100 0000 */
105105
/** background color mask */
106106
public final static long COLOR_BG = 0xffffff80000000L; /* 0000 0000 1111 1111 1111 1111 1111 1111 1000 0000 0000 0000 0000 0000 0000 0000 */
107+
/** how much to left shift the red component */
108+
public final static int COLOR_RED_SHIFT = 16;
109+
/** how much to left shift the green component */
110+
public final static int COLOR_GREEN_SHIFT = 8;
111+
/** how much to left shift the blue component */
112+
public final static int COLOR_BLUE_SHIFT = 0;
107113

108114
/**
109115
* Create a new video display buffer with the passed width and height in

app/src/main/java/de/mud/terminal/vt320.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,13 @@ else if (R >= height)
29712971
attributes &= ~COLOR_FG;
29722972
attributes |= (long)((DCEvars[i + 2]) + 1) << COLOR_FG_SHIFT;
29732973
i += 2;
2974+
} else if (DCEvars[i+1] == 2) {
2975+
attributes &= ~COLOR_FG;
2976+
int newcolor = DCEvars[i + 2] << COLOR_RED_SHIFT |
2977+
DCEvars[i + 3] << COLOR_GREEN_SHIFT |
2978+
DCEvars[i + 4] << COLOR_BLUE_SHIFT;
2979+
attributes |= (long)(newcolor + 257) << COLOR_FG_SHIFT;
2980+
i += 4;
29742981
}
29752982
break;
29762983
case 39:
@@ -2992,6 +2999,13 @@ else if (R >= height)
29922999
attributes &= ~COLOR_BG;
29933000
attributes |= (long)(DCEvars[i + 2] + 1) << COLOR_BG_SHIFT;
29943001
i += 2;
3002+
} else if (DCEvars[i+1] == 2) {
3003+
attributes &= ~COLOR_BG;
3004+
int newcolor = DCEvars[i + 2] << COLOR_RED_SHIFT |
3005+
DCEvars[i + 3] << COLOR_GREEN_SHIFT |
3006+
DCEvars[i + 4] << COLOR_BLUE_SHIFT;
3007+
attributes |= (long)(newcolor + 257) << COLOR_BG_SHIFT;
3008+
i += 4;
29953009
}
29963010
break;
29973011
case 49:

0 commit comments

Comments
 (0)
X Tutup