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; break;
// DECTCEM cursor show hide // DECTCEM feature enable / disable
case 'l':
if (leadchar == '?' && n1 == 25) {
screen_cursor_enable(0);
}
break;
case 'h': case 'h':
if (leadchar == '?' && n1 == 25) { if (leadchar == '?') {
if (n1 == 25) {
screen_cursor_enable(1); 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; break;

@ -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,6 +545,7 @@ screen_putchar(char ch)
cursor.x++; cursor.x++;
// X wrap // X wrap
if (cursor.x >= W) { if (cursor.x >= W) {
if (cursor.autowrap) {
cursor.x = 0; cursor.x = 0;
cursor.y++; cursor.y++;
// Y wrap // Y wrap
@ -540,6 +554,9 @@ screen_putchar(char ch)
screen_scroll_up(1); screen_scroll_up(1);
cursor.y = H - 1; cursor.y = H - 1;
} }
} else {
cursor.x = W - 1;
}
} }
done: done:

@ -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 */

Loading…
Cancel
Save