diff --git a/src/bin/termio.c b/src/bin/termio.c index cc280286..8ca7e0a6 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -44,6 +44,7 @@ struct _Termio struct { Evas_Object *obj; int x, y; + Cursor_Shape shape; } cursor; struct { int cx, cy; @@ -626,15 +627,6 @@ termio_config_update(Evas_Object *obj) termpty_backlog_size_set(sd->pty, sd->config->scrollback); sd->scroll = 0; - if (evas_object_focus_get(obj)) - { - edje_object_signal_emit(sd->cursor.obj, "focus,out", "terminology"); - if (sd->config->disable_cursor_blink) - edje_object_signal_emit(sd->cursor.obj, "focus,in,noblink", "terminology"); - else - edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology"); - } - colors_term_init(sd->grid.obj, sd->theme, sd->config); evas_object_scale_set(sd->grid.obj, elm_config_scale_get()); @@ -647,6 +639,7 @@ termio_config_update(Evas_Object *obj) sd->font.chh = h; evas_object_geometry_get(obj, NULL, NULL, &ow, &oh); + termio_set_cursor_shape(obj, sd->config->cursor_shape); _smart_size(obj, ow / w, oh / h, EINA_TRUE); } @@ -693,10 +686,7 @@ termio_config_set(Evas_Object *obj, Config *config) sd->font.chw = w; sd->font.chh = h; - theme_apply(sd->cursor.obj, config, "terminology/cursor"); - theme_auto_reload_enable(sd->cursor.obj); - evas_object_resize(sd->cursor.obj, sd->font.chw, sd->font.chh); - evas_object_show(sd->cursor.obj); + termio_set_cursor_shape(obj, sd->cursor.shape); theme_apply(sd->sel.theme, config, "terminology/selection"); theme_auto_reload_enable(sd->sel.theme); @@ -704,6 +694,43 @@ termio_config_set(Evas_Object *obj, Config *config) edje_object_part_swallow(sd->sel.theme, "terminology.bottom_right", sd->sel.bottom); } +static const char * +_cursor_shape_to_group_name(Cursor_Shape shape) +{ + switch (shape) + { + case CURSOR_SHAPE_BLOCK: return "terminology/cursor"; + case CURSOR_SHAPE_BAR: return "terminology/cursor_bar"; + case CURSOR_SHAPE_UNDERLINE: return "terminology/cursor_underline"; + } + return NULL; +} + +void +termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape) +{ + Termio *sd = evas_object_smart_data_get(obj); + Config *config; + + EINA_SAFETY_ON_NULL_RETURN(sd); + + config = sd->config; + theme_apply(sd->cursor.obj, config, _cursor_shape_to_group_name(shape)); + theme_auto_reload_enable(sd->cursor.obj); + evas_object_resize(sd->cursor.obj, sd->font.chw, sd->font.chh); + evas_object_show(sd->cursor.obj); + sd->cursor.shape = shape; + + if (evas_object_focus_get(obj)) + { + edje_object_signal_emit(sd->cursor.obj, "focus,out", "terminology"); + if (sd->config->disable_cursor_blink) + edje_object_signal_emit(sd->cursor.obj, "focus,in,noblink", "terminology"); + else + edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology"); + } +} + /* }}} */ /* {{{ Links */ @@ -6020,6 +6047,7 @@ termio_add(Evas_Object *win, Config *config, (config->vidmod < (int)EINA_C_ARRAY_LENGTH(modules))) mod = modules[config->vidmod]; + sd->cursor.shape = config->cursor_shape; termio_config_set(obj, config); sd->term = term; sd->win = win; diff --git a/src/bin/termio.h b/src/bin/termio.h index 199de9e8..0400b9c3 100644 --- a/src/bin/termio.h +++ b/src/bin/termio.h @@ -44,6 +44,7 @@ const char *termio_icon_name_get(const Evas_Object *obj); void termio_media_mute_set(Evas_Object *obj, Eina_Bool mute); void termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize); void termio_config_set(Evas_Object *obj, Config *config); +void termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape); Config *termio_config_get(const Evas_Object *obj); Eina_Bool termio_file_send_ok(const Evas_Object *obj, const char *file); void termio_file_send_cancel(const Evas_Object *obj); diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 436c7d52..85bf1bd1 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -1193,6 +1193,41 @@ _handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b, ty->cursor_state.cy = cy; } +static void +_handle_esc_csi_decscusr(Termpty *ty, Eina_Unicode **b) +{ + int arg = _csi_arg_get(b); + Cursor_Shape shape = CURSOR_SHAPE_BLOCK; + + DBG("DECSCUSR (%d) Set Cursor Shape", arg); + + switch (arg) + { + case 0: + EINA_FALLTHROUGH; + case 1: + EINA_FALLTHROUGH; + case 2: + shape = CURSOR_SHAPE_BLOCK; + break; + case 3: + EINA_FALLTHROUGH; + case 4: + shape = CURSOR_SHAPE_UNDERLINE; + break; + case 5: + EINA_FALLTHROUGH; + case 6: + shape = CURSOR_SHAPE_BAR; + break; + default: + WRN("Invalid DECSCUSR %d", shape); + return; + } + + termio_set_cursor_shape(ty->obj, shape); +} + static int _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) { @@ -1575,6 +1610,18 @@ HVP: goto unhandled; } break; + case 'q': + if (*(cc-1) == ' ') + _handle_esc_csi_decscusr(ty, &b); + else if (*(cc-1) == '"') + { + WRN("TODO: select character protection attribute (DECSCA)"); + } + else + { + WRN("TODO: Load LEDs (DECLL)"); + } + break; case 'r': _handle_esc_csi_decstbm(ty, &b); break; diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c index 5c1465aa..dc66add0 100644 --- a/src/bin/termptyops.c +++ b/src/bin/termptyops.c @@ -427,6 +427,10 @@ void termpty_reset_state(Termpty *ty) { int i; + Config *config = NULL; + + if (ty->obj) + config = termio_config_get(ty->obj); ty->cursor_state.cx = 0; ty->cursor_state.cy = 0; @@ -467,6 +471,8 @@ termpty_reset_state(Termpty *ty) { TAB_SET(ty, i); } + if (config && ty->obj) + termio_set_cursor_shape(ty->obj, config->cursor_shape); } void