Implemented cursor wrap control codes e[?7h and l
This commit is contained in:
@@ -160,16 +160,25 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// DECTCEM cursor show hide
|
// DECTCEM feature enable / disable
|
||||||
case 'l':
|
|
||||||
if (leadchar == '?' && n1 == 25) {
|
case 'h':
|
||||||
screen_cursor_enable(0);
|
if (leadchar == '?') {
|
||||||
|
if (n1 == 25) {
|
||||||
|
screen_cursor_enable(1);
|
||||||
|
} else if (n1 == 7) {
|
||||||
|
screen_wrap_enable(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'l':
|
||||||
if (leadchar == '?' && n1 == 25) {
|
if (leadchar == '?') {
|
||||||
screen_cursor_enable(1);
|
if (n1 == 25) {
|
||||||
|
screen_cursor_enable(0);
|
||||||
|
} else if (n1 == 7) {
|
||||||
|
screen_wrap_enable(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+25
-8
@@ -31,6 +31,7 @@ static struct {
|
|||||||
int y; //!< Y coordinate
|
int y; //!< Y coordinate
|
||||||
bool visible; //!< Visible
|
bool visible; //!< Visible
|
||||||
bool inverse; //!< Inverse colors
|
bool inverse; //!< Inverse colors
|
||||||
|
bool autowrap; //!< Wrapping when EOL
|
||||||
Color fg; //!< Foreground color for writing
|
Color fg; //!< Foreground color for writing
|
||||||
Color bg; //!< Background color for writing
|
Color bg; //!< Background color for writing
|
||||||
} cursor;
|
} cursor;
|
||||||
@@ -102,6 +103,7 @@ cursor_reset(void)
|
|||||||
cursor.bg = SCREEN_DEF_BG;
|
cursor.bg = SCREEN_DEF_BG;
|
||||||
cursor.visible = 1;
|
cursor.visible = 1;
|
||||||
cursor.inverse = 0;
|
cursor.inverse = 0;
|
||||||
|
cursor.autowrap = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -397,6 +399,17 @@ screen_cursor_enable(bool enable)
|
|||||||
NOTIFY_DONE();
|
NOTIFY_DONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable autowrap
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
screen_wrap_enable(bool enable)
|
||||||
|
{
|
||||||
|
NOTIFY_LOCK();
|
||||||
|
cursor.autowrap = enable;
|
||||||
|
NOTIFY_DONE();
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Colors
|
//region Colors
|
||||||
@@ -492,7 +505,7 @@ screen_putchar(char ch)
|
|||||||
cursor.x--;
|
cursor.x--;
|
||||||
} else {
|
} else {
|
||||||
// wrap around start of line
|
// wrap around start of line
|
||||||
if (cursor.y>0) {
|
if (cursor.autowrap && cursor.y>0) {
|
||||||
cursor.x=W-1;
|
cursor.x=W-1;
|
||||||
cursor.y--;
|
cursor.y--;
|
||||||
}
|
}
|
||||||
@@ -532,13 +545,17 @@ screen_putchar(char ch)
|
|||||||
cursor.x++;
|
cursor.x++;
|
||||||
// X wrap
|
// X wrap
|
||||||
if (cursor.x >= W) {
|
if (cursor.x >= W) {
|
||||||
cursor.x = 0;
|
if (cursor.autowrap) {
|
||||||
cursor.y++;
|
cursor.x = 0;
|
||||||
// Y wrap
|
cursor.y++;
|
||||||
if (cursor.y > H-1) {
|
// Y wrap
|
||||||
// Scroll up, so we have space for writing
|
if (cursor.y > H - 1) {
|
||||||
screen_scroll_up(1);
|
// Scroll up, so we have space for writing
|
||||||
cursor.y = H-1;
|
screen_scroll_up(1);
|
||||||
|
cursor.y = H - 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cursor.x = W - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ void screen_cursor_restore(bool withAttrs);
|
|||||||
/** Enable cursor display */
|
/** Enable cursor display */
|
||||||
void screen_cursor_enable(bool enable);
|
void screen_cursor_enable(bool enable);
|
||||||
|
|
||||||
|
/** Enable auto wrap */
|
||||||
|
void screen_wrap_enable(bool enable);
|
||||||
|
|
||||||
// --- Colors ---
|
// --- Colors ---
|
||||||
|
|
||||||
/** Set cursor foreground color */
|
/** Set cursor foreground color */
|
||||||
|
|||||||
Reference in New Issue
Block a user