Skip to content

Commit

Permalink
Added cursor hide/show ANSI codes
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Mar 19, 2024
1 parent 55e4b2d commit e93da53
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions modules/spin-tools/src/com/maccasoft/propeller/SerialTerminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class SerialTerminal {
public static final int CURSOR_FLASH = 0x01;
public static final int CURSOR_SOLID = 0x00;

public static final int CURSOR_DISPLAY = 0x1000;

public static final int FRAME_TIMER = 16;

Display display;
Expand Down Expand Up @@ -184,7 +186,7 @@ public void run() {
counter++;
if (counter >= 15) {
if ((cursorState & CURSOR_FLASH) != 0) {
if ((cursorState ^= CURSOR_ON) != 0) {
if ((cursorState ^= CURSOR_DISPLAY) != 0) {
redraw(Math.min(cx, screenWidth - 1) * characterWidth, cy * characterHeight, characterWidth, characterHeight);
}
}
Expand Down Expand Up @@ -610,6 +612,24 @@ else if (args[i] >= 100 && args[i] <= 107) {
state = 0;
break;

case 'h':
if (prefix == '?') {
if (args[0] == 25) {
cursorState |= CURSOR_ON;
}
break;
}
break;

case 'l':
if (prefix == '?') {
if (args[0] == 25) {
cursorState &= ~CURSOR_ON;
}
break;
}
break;

default:
state = 0;
break;
Expand Down Expand Up @@ -874,7 +894,7 @@ public void open() {
serialBaudRate = preferences.getTerminalBaudRate();
localEcho = preferences.getTerminalLocalEcho();

cursorState = CURSOR_ON | CURSOR_FLASH | CURSOR_ULINE;
cursorState = CURSOR_DISPLAY | CURSOR_ON | CURSOR_FLASH | CURSOR_ULINE;

Font textFont = JFaceResources.getTextFont();
FontData fontData = textFont.getFontData()[0];
Expand Down Expand Up @@ -1096,7 +1116,7 @@ public void paintControl(PaintEvent e) {
}
}

if ((cursorState & CURSOR_ON) != 0) {
if ((cursorState & (CURSOR_DISPLAY | CURSOR_ON)) == (CURSOR_DISPLAY | CURSOR_ON)) {
int h = characterHeight;
if ((cursorState & CURSOR_ULINE) != 0) {
h = characterHeight / 4;
Expand Down

0 comments on commit e93da53

Please sign in to comment.