Implemented cursor wrap control codes e[?7h and l

pull/30/head
Ondřej Hruška 8 years ago
parent e7c26b3e94
commit 9dd5a1f082
  1. 23
      user/ansi_parser_callbacks.c
  2. 19
      user/screen.c
  3. 3
      user/screen.h

@ -160,16 +160,25 @@ apars_handle_CSI(char leadchar, int *params, char keychar)
}
break;
// DECTCEM cursor show hide
case 'l':
if (leadchar == '?' && n1 == 25) {
screen_cursor_enable(0);
}
break;
// DECTCEM feature enable / disable
case 'h':
if (leadchar == '?' && n1 == 25) {
if (leadchar == '?') {
if (n1 == 25) {
screen_cursor_enable(1);
} else if (n1 == 7) {
screen_wrap_enable(1);
}
}
break;
case 'l':
if (leadchar == '?') {
if (n1 == 25) {
screen_cursor_enable(0);
} else if (n1 == 7) {
screen_wrap_enable(0);
}
}
break;

@ -31,6 +31,7 @@ static struct {
int y; //!< Y coordinate
bool visible; //!< Visible
bool inverse; //!< Inverse colors
bool autowrap; //!< Wrapping when EOL
Color fg; //!< Foreground color for writing
Color bg; //!< Background color for writing
} cursor;
@ -102,6 +103,7 @@ cursor_reset(void)
cursor.bg = SCREEN_DEF_BG;
cursor.visible = 1;
cursor.inverse = 0;
cursor.autowrap = 1;
}
//endregion
@ -397,6 +399,17 @@ screen_cursor_enable(bool enable)
NOTIFY_DONE();
}
/**
* Enable autowrap
*/
void ICACHE_FLASH_ATTR
screen_wrap_enable(bool enable)
{
NOTIFY_LOCK();
cursor.autowrap = enable;
NOTIFY_DONE();
}
//endregion
//region Colors
@ -492,7 +505,7 @@ screen_putchar(char ch)
cursor.x--;
} else {
// wrap around start of line
if (cursor.y>0) {
if (cursor.autowrap && cursor.y>0) {
cursor.x=W-1;
cursor.y--;
}
@ -532,6 +545,7 @@ screen_putchar(char ch)
cursor.x++;
// X wrap
if (cursor.x >= W) {
if (cursor.autowrap) {
cursor.x = 0;
cursor.y++;
// Y wrap
@ -540,6 +554,9 @@ screen_putchar(char ch)
screen_scroll_up(1);
cursor.y = H - 1;
}
} else {
cursor.x = W - 1;
}
}
done:

@ -109,6 +109,9 @@ void screen_cursor_restore(bool withAttrs);
/** Enable cursor display */
void screen_cursor_enable(bool enable);
/** Enable auto wrap */
void screen_wrap_enable(bool enable);
// --- Colors ---
/** Set cursor foreground color */

Loading…
Cancel
Save