Commit 8adb2183 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

add. Move private VteTerminal stuff which needs to be shared with other

* src/vteint.h: add.  Move private VteTerminal stuff which needs to be shared
	with other modules in the library here.
* src/vtedraw.c, src/vtedraw.h: add get_char_width(), for use in drawing the
	cursor.
* src/vte.c(vte_invalidate_cursor_once): if the character under the cursor
	doesn't fit into its cell, expose the column to the right of it so
	that we can paint into the adjacent cell.
* src/vte.c(vte_terminal_paint): when clearing the area behind the cursor or
	drawing the hollow rectangle to indicate its position when we don't
	have focus, use the visible width of the character instead of just
	assuming it will fit.  This complies better with assertion 2.
parent e4291049
2003-06-16 nalin
* src/vteint.h: add. Move private VteTerminal stuff which needs to be
shared with other modules in the library here.
* src/vtedraw.c, src/vtedraw.h: add get_char_width(), for use in drawing
the cursor.
* src/vte.c(vte_invalidate_cursor_once): if the character under the
cursor doesn't fit into its cell, expose the column to the right of
it so that we can paint into the adjacent cell.
* src/vte.c(vte_terminal_paint): when clearing the area behind the
cursor or drawing the hollow rectangle to indicate its position when
we don't have focus, use the visible width of the character instead
of just assuming it will fit. This complies better with assertion 2.
2003-06-09 nalin
* src/vte.c(vte_terminal_set_encoding): set the encoding for the iso2022
converter (spotted by havill).
......
......@@ -68,6 +68,7 @@ libvte_la_SOURCES = \
vtegl.h \
vteglyph.c \
vteglyph.h \
vteint.h \
vtepango.c \
vtepango.h \
vtepangox.c \
......@@ -86,7 +87,7 @@ libvte_la_SOURCES = \
# Libtool shared library versioning stuffs.
# REVISION gets incremented whenever the source code changes without adding
# an API or ABI change.
VERSION_REVISION=0
VERSION_REVISION=1
# CURRENT must be incremented when an API or ABI change is made, and REVISION
# must be reset to 0 when this happens.
VERSION_CURRENT=5
......
......@@ -61,6 +61,7 @@
#include "vteaccess.h"
#include "vteconv.h"
#include "vtedraw.h"
#include "vteint.h"
#include "vtetc.h"
#include <fontconfig/fontconfig.h>
......@@ -817,6 +818,12 @@ vte_invalidate_cursor_once(gpointer data, gboolean periodic)
}
if (cell != NULL) {
columns = cell->columns;
if (_vte_draw_get_char_width(terminal->pvt->draw,
cell->c,
cell->columns) >
terminal->char_width * columns) {
columns++;
}
}
if (preedit_width > 0) {
columns += preedit_width;
......@@ -9968,6 +9975,11 @@ vte_terminal_focus_in(GtkWidget *widget, GdkEventFocus *event)
GdkModifierType modifiers;
g_return_val_if_fail(GTK_IS_WIDGET(widget), FALSE);
g_return_val_if_fail(VTE_IS_TERMINAL(widget), FALSE);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
fprintf(stderr, "Focus in.\n");
}
#endif
terminal = VTE_TERMINAL(widget);
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
/* Read the keyboard modifiers, though they're probably garbage. */
......@@ -9994,6 +10006,11 @@ vte_terminal_focus_out(GtkWidget *widget, GdkEventFocus *event)
GdkModifierType modifiers;
g_return_val_if_fail(GTK_WIDGET(widget), FALSE);
g_return_val_if_fail(VTE_IS_TERMINAL(widget), FALSE);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
fprintf(stderr, "Focus out.\n");
}
#endif
terminal = VTE_TERMINAL(widget);
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
/* Read the keyboard modifiers, though they're probably garbage. */
......@@ -11442,6 +11459,7 @@ vte_terminal_realize(GtkWidget *widget)
attributes.event_mask = gtk_widget_get_events(widget) |
GDK_EXPOSURE_MASK |
GDK_VISIBILITY_NOTIFY_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
......@@ -12886,7 +12904,7 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
struct _vte_draw_text_request item, *items;
int row, drow, col, row_stop, col_stop, columns;
char *preedit;
long width, height, ascent, descent, delta;
long width, height, ascent, descent, delta, cursor_width;
int i, len, fore, back, x, y;
GdkRectangle all_area;
gboolean blink;
......@@ -12988,6 +13006,13 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
item.columns = cell ? cell->columns : 1;
item.x = col * width;
item.y = row * height;
cursor_width = item.columns * width;
if (cell) {
cursor_width = MAX(cursor_width,
_vte_draw_get_char_width(terminal->pvt->draw,
cell->c,
cell->columns));
}
if (GTK_WIDGET_HAS_FOCUS(GTK_WIDGET(terminal))) {
blink = vte_terminal_get_blink_state(terminal) ^
terminal->pvt->screen->reverse_mode;
......@@ -12996,8 +13021,20 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
_vte_draw_clear(terminal->pvt->draw,
col * width + VTE_PAD_WIDTH,
row * height + VTE_PAD_WIDTH,
width * item.columns,
cursor_width,
height);
if (blink) {
GdkColor color;
color.red = terminal->pvt->palette[back].red;
color.green = terminal->pvt->palette[back].green;
color.blue = terminal->pvt->palette[back].blue;
_vte_draw_fill_rectangle(terminal->pvt->draw,
item.x + VTE_PAD_WIDTH,
item.y + VTE_PAD_WIDTH,
cursor_width, height,
&color,
VTE_DRAW_OPAQUE);
}
if (!vte_unichar_is_local_graphic(item.c) ||
!vte_terminal_draw_graphic(terminal,
item.c,
......@@ -13021,13 +13058,14 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
height);
}
} else {
GdkColor color;
/* Draw it as a hollow rectangle. */
vte_terminal_determine_colors(terminal, cell, FALSE,
&fore, &back);
_vte_draw_clear(terminal->pvt->draw,
col * width + VTE_PAD_WIDTH,
row * height + VTE_PAD_WIDTH,
width * item.columns, height);
cursor_width, height);
vte_terminal_draw_cells(terminal,
&item, 1,
fore, back, TRUE,
......@@ -13035,9 +13073,18 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
cell && cell->underline,
cell && cell->strikethrough,
FALSE,
TRUE,
FALSE,
width,
height);
color.red = terminal->pvt->palette[fore].red;
color.green = terminal->pvt->palette[fore].green;
color.blue = terminal->pvt->palette[fore].blue;
_vte_draw_draw_rectangle(terminal->pvt->draw,
item.x + VTE_PAD_WIDTH,
item.y + VTE_PAD_WIDTH,
cursor_width, height,
&color,
VTE_DRAW_OPAQUE);
}
}
......
......@@ -325,9 +325,6 @@ glong vte_terminal_get_column_count(VteTerminal *terminal);
const char *vte_terminal_get_window_title(VteTerminal *terminal);
const char *vte_terminal_get_icon_title(VteTerminal *terminal);
/* You never saw this. */
void _vte_terminal_accessible_ref(VteTerminal *terminal);
G_END_DECLS
#endif
......@@ -29,6 +29,7 @@
#include "debug.h"
#include "vte.h"
#include "vteaccess.h"
#include "vteint.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
......
......@@ -246,6 +246,14 @@ _vte_draw_get_text_ascent(struct _vte_draw *draw)
return draw->impl->get_text_ascent(draw);
}
int
_vte_draw_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
g_return_val_if_fail(draw->impl != NULL, 1);
g_return_val_if_fail(draw->impl->get_char_width != NULL, 1);
return draw->impl->get_char_width(draw, c, columns);
}
gboolean
_vte_draw_get_using_fontconfig(struct _vte_draw *draw)
{
......
......@@ -70,6 +70,7 @@ struct _vte_draw_impl {
int (*get_text_width)(struct _vte_draw *);
int (*get_text_height)(struct _vte_draw *);
int (*get_text_ascent)(struct _vte_draw *);
int (*get_char_width)(struct _vte_draw *, gunichar c, int columns);
gboolean (*get_using_fontconfig)(struct _vte_draw *);
void (*draw_text)(struct _vte_draw *,
struct _vte_draw_text_request *, gsize,
......@@ -130,6 +131,7 @@ void _vte_draw_set_text_font(struct _vte_draw *draw,
int _vte_draw_get_text_width(struct _vte_draw *draw);
int _vte_draw_get_text_height(struct _vte_draw *draw);
int _vte_draw_get_text_ascent(struct _vte_draw *draw);
int _vte_draw_get_char_width(struct _vte_draw *draw, gunichar c, int columns);
gboolean _vte_draw_get_using_fontconfig(struct _vte_draw *draw);
/* Draw text or rectangles. */
......
......@@ -252,6 +252,22 @@ _vte_ft2_get_text_ascent(struct _vte_draw *draw)
return data->cache->ascent;
}
static int
_vte_ft2_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
struct _vte_ft2_data *data;
const struct _vte_glyph *glyph;
data = (struct _vte_ft2_data*) draw->impl_data;
glyph = _vte_glyph_get(data->cache, c);
if (glyph != NULL) {
return glyph->width;
}
return _vte_ft2_get_text_width(draw) * columns;
}
static gboolean
_vte_ft2_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -365,6 +381,7 @@ struct _vte_draw_impl _vte_draw_ft2 = {
_vte_ft2_get_text_width,
_vte_ft2_get_text_height,
_vte_ft2_get_text_ascent,
_vte_ft2_get_char_width,
_vte_ft2_get_using_fontconfig,
_vte_ft2_draw_text,
_vte_ft2_draw_char,
......
......@@ -428,6 +428,22 @@ _vte_gl_get_text_ascent(struct _vte_draw *draw)
return data->cache->ascent;
}
static int
_vte_gl_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
struct _vte_gl_data *data;
const struct _vte_glyph *glyph;
data = (struct _vte_gl_data*) draw->impl_data;
glyph = _vte_glyph_get(data->cache, c);
if (glyph != NULL) {
return glyph->width;
}
return _vte_gl_get_text_width(draw) * columns;
}
static gboolean
_vte_gl_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -603,6 +619,7 @@ struct _vte_draw_impl _vte_draw_gl = {
_vte_gl_get_text_width,
_vte_gl_get_text_height,
_vte_gl_get_text_ascent,
_vte_gl_get_char_width,
_vte_gl_get_using_fontconfig,
_vte_gl_draw_text,
_vte_gl_draw_char,
......
......@@ -360,6 +360,12 @@ _vte_pango_get_text_ascent(struct _vte_draw *draw)
return draw->ascent;
}
static int
_vte_pango_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
return _vte_pango_get_text_width(draw) * columns;
}
static gboolean
_vte_pango_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -467,6 +473,7 @@ struct _vte_draw_impl _vte_draw_pango = {
_vte_pango_get_text_width,
_vte_pango_get_text_height,
_vte_pango_get_text_ascent,
_vte_pango_get_char_width,
_vte_pango_get_using_fontconfig,
_vte_pango_draw_text,
_vte_pango_draw_char,
......
......@@ -369,6 +369,12 @@ _vte_pango_x_get_text_ascent(struct _vte_draw *draw)
return draw->ascent;
}
static int
_vte_pango_x_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
return _vte_pango_x_get_text_width(draw) * columns;
}
static gboolean
_vte_pango_x_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -481,6 +487,7 @@ struct _vte_draw_impl _vte_draw_pango_x = {
_vte_pango_x_get_text_width,
_vte_pango_x_get_text_height,
_vte_pango_x_get_text_ascent,
_vte_pango_x_get_char_width,
_vte_pango_x_get_using_fontconfig,
_vte_pango_x_draw_text,
_vte_pango_x_draw_char,
......
......@@ -161,6 +161,12 @@ _vte_skel_get_text_ascent(struct _vte_draw *draw)
return draw->ascent;
}
static int
_vte_skel_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
return _vte_skel_get_text_width(draw) * columns;
}
static gboolean
_vte_skel_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -230,6 +236,7 @@ struct _vte_draw_impl _vte_draw_skel = {
_vte_skel_get_text_width,
_vte_skel_get_text_height,
_vte_skel_get_text_ascent,
_vte_skel_get_char_width,
_vte_skel_get_using_fontconfig,
_vte_skel_draw_text,
_vte_skel_draw_char,
......
......@@ -622,6 +622,20 @@ _vte_xft_get_text_ascent(struct _vte_draw *draw)
return draw->ascent;
}
static int
_vte_xft_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
struct _vte_xft_data *data;
XftFont *ftfont;
data = (struct _vte_xft_data*) draw->impl_data;
ftfont = _vte_xft_font_for_char(data->font, c);
if (ftfont == NULL) {
return _vte_xft_get_text_width(draw) * columns;
}
return _vte_xft_char_width(data->font, ftfont, c);
}
static gboolean
_vte_xft_get_using_fontconfig(struct _vte_draw *draw)
{
......@@ -816,6 +830,7 @@ struct _vte_draw_impl _vte_draw_xft = {
_vte_xft_get_text_width,
_vte_xft_get_text_height,
_vte_xft_get_text_ascent,
_vte_xft_get_char_width,
_vte_xft_get_using_fontconfig,
_vte_xft_draw_text,
_vte_xft_draw_char,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment