From 6fdb23531b7ec89134fd3f3ce1cb3ead1addca1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 6 Sep 2017 21:35:48 +0200 Subject: [PATCH] implemented backindex --- user/apars_csi.c | 8 ++++++++ user/apars_osc.c | 3 +-- user/apars_short.c | 4 ++++ user/screen.c | 15 +++++++++++++++ user/screen.h | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/user/apars_csi.c b/user/apars_csi.c index cbac7de..e0de27d 100644 --- a/user/apars_csi.c +++ b/user/apars_csi.c @@ -562,6 +562,14 @@ do_csi_set_option(CSI_Data *opts) else if (n == 20) { screen_set_newline_mode(yn); } + else if (n == 33) { + ansi_noimpl("Steady cursor"); + // reference https://ttssh2.osdn.jp/manual/en/about/ctrlseq.html + } + else if (n == 34) { + ansi_noimpl("Underline cursor"); + // reference https://ttssh2.osdn.jp/manual/en/about/ctrlseq.html + } else { ansi_noimpl("OPTION %d", n); } diff --git a/user/apars_osc.c b/user/apars_osc.c index 2bf4649..83ac913 100644 --- a/user/apars_osc.c +++ b/user/apars_osc.c @@ -22,7 +22,6 @@ void ICACHE_FLASH_ATTR apars_handle_osc(const char *buffer) { - const char *orig_buff = buffer; int n = 0; char c = 0; while ((c = *buffer++) != 0) { @@ -50,7 +49,7 @@ apars_handle_osc(const char *buffer) } } else { - ansi_warn("BAD OSC: %s", orig_buff); + ansi_warn("BAD OSC: %s", buffer); apars_show_context(); } } diff --git a/user/apars_short.c b/user/apars_short.c index 329c40d..b9bace9 100644 --- a/user/apars_short.c +++ b/user/apars_short.c @@ -121,6 +121,10 @@ void ICACHE_FLASH_ATTR apars_handle_short_cmd(char c) screen_reset(); break; + case '6': // back index + screen_back_index(1); + break; + case '7': // save cursor + attributes screen_cursor_save(true); break; diff --git a/user/screen.c b/user/screen.c index 7848497..7d58287 100644 --- a/user/screen.c +++ b/user/screen.c @@ -919,6 +919,21 @@ screen_cursor_restore(bool withAttrs) NOTIFY_DONE(); } + +void ICACHE_FLASH_ATTR +screen_back_index(int count) +{ + NOTIFY_LOCK(); + int new_x = cursor.x - count; + if (new_x >= 0) { + cursor.x = new_x; + } else { + cursor.x = 0; + screen_insert_characters(-new_x); + } + NOTIFY_DONE(); +} + //endregion //region --- Attribute setting --- diff --git a/user/screen.h b/user/screen.h index a87a113..d89d10a 100644 --- a/user/screen.h +++ b/user/screen.h @@ -254,6 +254,8 @@ void screen_clear_tab(void); void screen_tab_forward(int count); /** Move backward one tab */ void screen_tab_reverse(int count); +/** Move left, shift right if at the boundary */ +void screen_back_index(int count); // --- Printing characters ---