[vte] Use the style's cursor-aspect-ratio when drawing the cursor
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] Use the style's cursor-aspect-ratio when drawing the cursor
- Date: Thu, 8 Apr 2010 14:38:47 +0000 (UTC)
commit d00507b9bc4c29248817915225c49c1e8b349fe0
Author: Christian Persch <chpe gnome org>
Date: Thu Dec 3 18:47:13 2009 +0100
Use the style's cursor-aspect-ratio when drawing the cursor
For the ibeam cursor, use the aspect ratio; for the underline, its
inverse (that's the only thing that makes sense here).
Bug #586950.
src/vte-private.h | 1 +
src/vte.c | 29 +++++++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index ba0e432..d605975 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -283,6 +283,7 @@ struct _VteTerminalPrivate {
/* Cursor shape */
VteTerminalCursorShape cursor_shape;
+ float cursor_aspect_ratio;
/* Cursor blinking. */
VteTerminalCursorBlinkMode cursor_blink_mode;
diff --git a/src/vte.c b/src/vte.c
index 884ef4a..ecc5f83 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -4773,6 +4773,7 @@ vte_terminal_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
+ float aspect;
GTK_WIDGET_CLASS (vte_terminal_parent_class)->style_set (widget, prev_style);
@@ -4783,6 +4784,12 @@ vte_terminal_style_set (GtkWidget *widget,
terminal->pvt->fontantialias);
vte_terminal_set_inner_border(terminal);
+
+ gtk_widget_style_get(widget, "cursor-aspect-ratio", &aspect, NULL);
+ if (aspect != terminal->pvt->cursor_aspect_ratio) {
+ terminal->pvt->cursor_aspect_ratio = aspect;
+ _vte_invalidate_cursor_once(terminal, FALSE);
+ }
}
static void
@@ -8112,6 +8119,7 @@ vte_terminal_init(VteTerminal *terminal)
/* Cursor shape. */
pvt->cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
+ pvt->cursor_aspect_ratio = 0.04;
/* Cursor blinking. */
pvt->cursor_visible = TRUE;
@@ -10587,19 +10595,28 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
switch (terminal->pvt->cursor_shape) {
- case VTE_CURSOR_SHAPE_IBEAM:
+ case VTE_CURSOR_SHAPE_IBEAM: {
+ int stem_width;
+
+ stem_width = (int) (((float) height) * terminal->pvt->cursor_aspect_ratio + 0.5);
+ stem_width = CLAMP (stem_width, VTE_LINE_WIDTH, cursor_width);
vte_terminal_fill_rectangle(terminal, &terminal->pvt->palette[back],
- x, y,
- VTE_LINE_WIDTH, height);
+ x, y, stem_width, height);
break;
+ }
+
+ case VTE_CURSOR_SHAPE_UNDERLINE: {
+ int line_height;
- case VTE_CURSOR_SHAPE_UNDERLINE:
+ line_height = (int) (((float) cursor_width) * terminal->pvt->cursor_aspect_ratio + 0.5);
+ line_height = CLAMP (line_height, VTE_LINE_WIDTH, height);
vte_terminal_fill_rectangle(terminal, &terminal->pvt->palette[back],
- x, y + height - VTE_LINE_WIDTH,
- cursor_width, VTE_LINE_WIDTH);
+ x, y + height - line_height,
+ cursor_width, line_height);
break;
+ }
case VTE_CURSOR_SHAPE_BLOCK:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]