2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2001-12-17 16:46:08 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2001-12-17 16:46:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2022-01-22 18:37:32 +00:00
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
2001-12-17 16:46:08 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2008-06-24 09:55:08 +00:00
|
|
|
|
2006-03-07 13:46:11 +00:00
|
|
|
#include "gtktextview.h"
|
2022-10-06 02:59:51 +00:00
|
|
|
#include "gtktextutilprivate.h"
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2020-01-27 23:27:36 +00:00
|
|
|
#include "gtkcsscolorvalueprivate.h"
|
2006-03-07 13:46:11 +00:00
|
|
|
#include "gtktextbuffer.h"
|
2019-07-21 01:25:51 +00:00
|
|
|
#include "gtktextlayoutprivate.h"
|
2020-01-27 14:35:09 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
|
|
|
#include "gtkcssstyleprivate.h"
|
|
|
|
#include "gtkcsscolorvalueprivate.h"
|
2022-10-08 20:57:23 +00:00
|
|
|
#include "gtkrenderbackgroundprivate.h"
|
2001-12-17 16:46:08 +00:00
|
|
|
|
2005-07-11 17:51:54 +00:00
|
|
|
#define DRAG_ICON_MAX_WIDTH 250
|
2006-03-07 13:46:11 +00:00
|
|
|
#define DRAG_ICON_MAX_HEIGHT 250
|
2005-07-11 17:51:54 +00:00
|
|
|
#define DRAG_ICON_MAX_LINES 7
|
|
|
|
#define ELLIPSIS_CHARACTER "\xe2\x80\xa6"
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
append_n_lines (GString *str, const char *text, GSList *lines, int n_lines)
|
2005-07-11 17:51:54 +00:00
|
|
|
{
|
|
|
|
PangoLayoutLine *line;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2005-07-11 17:51:54 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n_lines; i++)
|
|
|
|
{
|
|
|
|
line = lines->data;
|
2022-01-23 14:55:46 +00:00
|
|
|
g_string_append_len (str,
|
|
|
|
&text[pango_layout_line_get_start_index (line)],
|
|
|
|
pango_layout_line_get_length (line));
|
2005-07-11 17:51:54 +00:00
|
|
|
lines = lines->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
limit_layout_lines (PangoLayout *layout)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *text;
|
2005-07-11 17:51:54 +00:00
|
|
|
GString *str;
|
|
|
|
GSList *lines, *elem;
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_lines;
|
2005-07-11 17:51:54 +00:00
|
|
|
|
|
|
|
n_lines = pango_layout_get_line_count (layout);
|
2022-01-22 18:37:32 +00:00
|
|
|
|
2005-07-11 17:51:54 +00:00
|
|
|
if (n_lines >= DRAG_ICON_MAX_LINES)
|
|
|
|
{
|
|
|
|
text = pango_layout_get_text (layout);
|
|
|
|
str = g_string_new (NULL);
|
Bug 340141 – Update to Pango 1.16 API
2006-12-24 Behdad Esfahbod <behdad@gnome.org>
Bug 340141 – Update to Pango 1.16 API
* gdk/gdkpango.c (layout_iter_get_line_clip_region),
(gdk_pango_layout_line_get_clip_region):
* gtk/gtkcalendar.c (gtk_calendar_size_request):
* gtk/gtkentry.c (gtk_entry_get_pixel_ranges),
(get_layout_position), (gtk_entry_find_position),
(gtk_entry_adjust_scroll):
* gtk/gtkiconview.c (get_pango_text_offsets):
* gtk/gtklabel.c (get_cursor_direction):
* gtk/gtkstyle.c (get_insensitive_layout):
* gtk/gtktextdisplay.c (render_para):
* gtk/gtktextlayout.c (allocate_child_widgets),
(find_display_line_below), (find_display_line_above),
(gtk_text_layout_move_iter_to_previous_line),
(gtk_text_layout_move_iter_to_next_line),
(gtk_text_layout_move_iter_to_line_end),
(gtk_text_layout_iter_starts_line),
(gtk_text_layout_move_iter_to_x):
* gtk/gtktextutil.c (limit_layout_lines):
Use the _readonly version of pango_layout_iter_get_line(),
pango_layout_iter_get_run(), pango_layout_get_line(), and
pango_layout_get_lines().
* gtk/gtkmain.c (gtk_get_default_language): Use
pango_get_default_language().
2006-12-24 05:29:25 +00:00
|
|
|
lines = pango_layout_get_lines_readonly (layout);
|
2005-07-11 17:51:54 +00:00
|
|
|
|
|
|
|
/* get first lines */
|
|
|
|
elem = lines;
|
|
|
|
append_n_lines (str, text, elem,
|
|
|
|
DRAG_ICON_MAX_LINES / 2);
|
|
|
|
|
|
|
|
g_string_append (str, "\n" ELLIPSIS_CHARACTER "\n");
|
|
|
|
|
|
|
|
/* get last lines */
|
|
|
|
elem = g_slist_nth (lines, n_lines - DRAG_ICON_MAX_LINES / 2);
|
|
|
|
append_n_lines (str, text, elem,
|
|
|
|
DRAG_ICON_MAX_LINES / 2);
|
|
|
|
|
|
|
|
pango_layout_set_text (layout, str->str, -1);
|
|
|
|
g_string_free (str, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 14:21:21 +00:00
|
|
|
/**
|
2018-03-26 02:38:54 +00:00
|
|
|
* gtk_text_util_create_drag_icon:
|
2021-05-20 13:17:04 +00:00
|
|
|
* @widget: `GtkWidget` to extract the pango context
|
2020-07-24 18:40:36 +00:00
|
|
|
* @text: a #char to render the icon
|
2005-07-11 17:51:54 +00:00
|
|
|
* @len: length of @text, or -1 for NUL-terminated text
|
|
|
|
*
|
|
|
|
* Creates a drag and drop icon from @text.
|
2008-12-29 04:50:15 +00:00
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
* Returns: (transfer full): a `GdkPaintable` to use as DND icon
|
2008-12-29 04:50:15 +00:00
|
|
|
*/
|
2018-03-26 02:38:54 +00:00
|
|
|
GdkPaintable *
|
|
|
|
gtk_text_util_create_drag_icon (GtkWidget *widget,
|
2020-07-24 18:40:36 +00:00
|
|
|
char *text,
|
2019-05-01 03:25:02 +00:00
|
|
|
gssize len)
|
2005-07-11 17:51:54 +00:00
|
|
|
{
|
2020-01-27 14:35:09 +00:00
|
|
|
GtkCssStyle *style;
|
2018-03-26 02:38:54 +00:00
|
|
|
GtkSnapshot *snapshot;
|
2005-07-11 17:51:54 +00:00
|
|
|
PangoContext *context;
|
2020-08-08 22:06:12 +00:00
|
|
|
PangoLayout *layout;
|
2018-03-26 02:38:54 +00:00
|
|
|
GdkPaintable *paintable;
|
2020-08-08 22:06:12 +00:00
|
|
|
int layout_width;
|
|
|
|
int layout_height;
|
2020-01-27 14:35:09 +00:00
|
|
|
const GdkRGBA *color;
|
2020-08-08 22:06:12 +00:00
|
|
|
GdkDisplay *display;
|
2005-07-11 17:51:54 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (widget != NULL, NULL);
|
|
|
|
g_return_val_if_fail (text != NULL, NULL);
|
|
|
|
|
|
|
|
context = gtk_widget_get_pango_context (widget);
|
|
|
|
layout = pango_layout_new (context);
|
|
|
|
|
|
|
|
pango_layout_set_text (layout, text, len);
|
|
|
|
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
2018-03-26 02:38:54 +00:00
|
|
|
pango_layout_get_size (layout, &layout_width, NULL);
|
2005-07-11 17:51:54 +00:00
|
|
|
|
|
|
|
layout_width = MIN (layout_width, DRAG_ICON_MAX_WIDTH * PANGO_SCALE);
|
|
|
|
pango_layout_set_width (layout, layout_width);
|
|
|
|
|
|
|
|
limit_layout_lines (layout);
|
|
|
|
|
2018-04-24 01:17:23 +00:00
|
|
|
snapshot = gtk_snapshot_new ();
|
2005-07-11 17:51:54 +00:00
|
|
|
|
2020-01-27 14:35:09 +00:00
|
|
|
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
2020-01-28 07:38:25 +00:00
|
|
|
color = gtk_css_color_value_get_rgba (style->core->color);
|
2020-01-27 14:35:09 +00:00
|
|
|
|
2020-08-08 22:06:12 +00:00
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
if (!gdk_display_is_rgba (display) ||
|
|
|
|
!gdk_display_is_composited (display))
|
|
|
|
{
|
|
|
|
GtkWidget *bg_widget;
|
2022-10-08 20:57:23 +00:00
|
|
|
GtkCssBoxes boxes;
|
2020-08-08 22:06:12 +00:00
|
|
|
|
|
|
|
if (GTK_IS_TEXT (widget))
|
|
|
|
bg_widget = gtk_widget_get_parent (widget);
|
|
|
|
else
|
|
|
|
bg_widget = widget;
|
2022-10-08 20:57:23 +00:00
|
|
|
|
2020-08-08 22:06:12 +00:00
|
|
|
pango_layout_get_size (layout, &layout_width, &layout_height);
|
2022-10-08 20:57:23 +00:00
|
|
|
|
2022-10-09 03:44:01 +00:00
|
|
|
style = gtk_css_node_get_style (gtk_widget_get_css_node (bg_widget));
|
|
|
|
gtk_css_boxes_init_border_box (&boxes, style,
|
2022-10-08 20:57:23 +00:00
|
|
|
0, 0,
|
|
|
|
layout_width / PANGO_SCALE,
|
|
|
|
layout_height / PANGO_SCALE);
|
|
|
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
2020-08-08 22:06:12 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 14:35:09 +00:00
|
|
|
gtk_snapshot_append_layout (snapshot, layout, color);
|
2005-07-11 17:51:54 +00:00
|
|
|
|
2018-04-02 04:15:50 +00:00
|
|
|
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
|
2005-07-11 17:51:54 +00:00
|
|
|
g_object_unref (layout);
|
|
|
|
|
2018-03-26 02:38:54 +00:00
|
|
|
return paintable;
|
2005-07-11 17:51:54 +00:00
|
|
|
}
|
2006-03-07 13:46:11 +00:00
|
|
|
|
|
|
|
static void
|
2020-01-27 14:35:09 +00:00
|
|
|
set_attributes_from_style (GtkWidget *widget,
|
2016-04-27 01:23:08 +00:00
|
|
|
GtkTextAttributes *values)
|
2006-03-07 13:46:11 +00:00
|
|
|
{
|
2020-01-28 07:38:25 +00:00
|
|
|
GtkCssStyle *style;
|
2016-10-28 20:58:12 +00:00
|
|
|
const GdkRGBA black = { 0, };
|
|
|
|
|
|
|
|
if (!values->appearance.bg_rgba)
|
|
|
|
values->appearance.bg_rgba = gdk_rgba_copy (&black);
|
|
|
|
if (!values->appearance.fg_rgba)
|
|
|
|
values->appearance.fg_rgba = gdk_rgba_copy (&black);
|
2011-01-10 19:09:34 +00:00
|
|
|
|
2021-01-28 04:07:55 +00:00
|
|
|
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
2020-01-28 07:38:25 +00:00
|
|
|
|
|
|
|
*values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->background->background_color);
|
|
|
|
*values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->core->color);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
|
|
|
if (values->font)
|
|
|
|
pango_font_description_free (values->font);
|
|
|
|
|
2020-01-28 07:38:25 +00:00
|
|
|
values->font = gtk_css_style_get_pango_font (style);
|
2006-03-07 13:46:11 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2019-10-04 02:21:45 +00:00
|
|
|
get_border_window_size (GtkTextView *text_view,
|
|
|
|
GtkTextWindowType window_type)
|
|
|
|
{
|
|
|
|
GtkWidget *gutter;
|
|
|
|
|
|
|
|
gutter = gtk_text_view_get_gutter (text_view, window_type);
|
|
|
|
if (gutter != NULL)
|
|
|
|
return gtk_widget_get_width (gutter);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-26 04:49:55 +00:00
|
|
|
GdkPaintable *
|
|
|
|
gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
|
|
|
|
GtkTextBuffer *buffer,
|
|
|
|
GtkTextIter *start,
|
|
|
|
GtkTextIter *end)
|
2006-03-07 13:46:11 +00:00
|
|
|
{
|
2010-08-11 20:52:43 +00:00
|
|
|
GtkAllocation allocation;
|
2018-03-26 04:49:55 +00:00
|
|
|
GdkPaintable *paintable;
|
|
|
|
GtkSnapshot *snapshot;
|
2020-07-24 13:54:49 +00:00
|
|
|
int layout_width, layout_height;
|
2006-03-07 13:46:11 +00:00
|
|
|
GtkTextBuffer *new_buffer;
|
|
|
|
GtkTextLayout *layout;
|
|
|
|
GtkTextAttributes *style;
|
|
|
|
PangoContext *ltr_context, *rtl_context;
|
|
|
|
GtkTextIter iter;
|
2020-08-08 22:06:12 +00:00
|
|
|
GdkDisplay *display;
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
|
|
|
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
|
|
|
|
g_return_val_if_fail (start != NULL, NULL);
|
|
|
|
g_return_val_if_fail (end != NULL, NULL);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
new_buffer = gtk_text_buffer_new (gtk_text_buffer_get_tag_table (buffer));
|
|
|
|
gtk_text_buffer_get_start_iter (new_buffer, &iter);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_buffer_insert_range (new_buffer, &iter, start, end);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_buffer_get_start_iter (new_buffer, &iter);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
layout = gtk_text_layout_new ();
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
ltr_context = gtk_widget_create_pango_context (widget);
|
|
|
|
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
|
|
|
|
rtl_context = gtk_widget_create_pango_context (widget);
|
|
|
|
pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_layout_set_contexts (layout, ltr_context, rtl_context);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
g_object_unref (ltr_context);
|
|
|
|
g_object_unref (rtl_context);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
style = gtk_text_attributes_new ();
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
layout_width = allocation.width;
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2020-01-27 14:35:09 +00:00
|
|
|
set_attributes_from_style (widget, style);
|
2016-04-27 01:23:08 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
if (GTK_IS_TEXT_VIEW (widget))
|
|
|
|
{
|
|
|
|
layout_width = layout_width
|
2019-10-04 02:21:45 +00:00
|
|
|
- get_border_window_size (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_LEFT)
|
|
|
|
- get_border_window_size (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_RIGHT);
|
2016-04-27 01:25:02 +00:00
|
|
|
}
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
style->direction = gtk_widget_get_direction (widget);
|
|
|
|
style->wrap_mode = GTK_WRAP_WORD_CHAR;
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_layout_set_default_style (layout, style);
|
|
|
|
gtk_text_attributes_unref (style);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_layout_set_buffer (layout, new_buffer);
|
|
|
|
gtk_text_layout_set_cursor_visible (layout, FALSE);
|
|
|
|
gtk_text_layout_set_screen_width (layout, layout_width);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
gtk_text_layout_validate (layout, DRAG_ICON_MAX_HEIGHT);
|
|
|
|
gtk_text_layout_get_size (layout, &layout_width, &layout_height);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
layout_width = MIN (layout_width, DRAG_ICON_MAX_WIDTH);
|
|
|
|
layout_height = MIN (layout_height, DRAG_ICON_MAX_HEIGHT);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2018-04-24 01:17:23 +00:00
|
|
|
snapshot = gtk_snapshot_new ();
|
2010-07-15 23:45:06 +00:00
|
|
|
|
2020-08-08 22:06:12 +00:00
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
if (!gdk_display_is_rgba (display) ||
|
|
|
|
!gdk_display_is_composited (display))
|
|
|
|
{
|
2022-10-08 20:57:23 +00:00
|
|
|
GtkCssBoxes boxes;
|
2022-10-09 03:44:01 +00:00
|
|
|
GtkCssStyle *css_style;
|
2022-10-08 20:57:23 +00:00
|
|
|
|
2022-10-09 03:44:01 +00:00
|
|
|
css_style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
|
|
|
gtk_css_boxes_init_border_box (&boxes, css_style,
|
2022-10-08 20:57:23 +00:00
|
|
|
0, 0, layout_width, layout_height);
|
|
|
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
2020-08-08 22:06:12 +00:00
|
|
|
}
|
|
|
|
|
2019-07-21 20:06:23 +00:00
|
|
|
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, 1.0);
|
2010-08-15 17:41:51 +00:00
|
|
|
|
2016-04-27 01:25:02 +00:00
|
|
|
g_object_unref (layout);
|
|
|
|
g_object_unref (new_buffer);
|
2006-03-07 13:46:11 +00:00
|
|
|
|
2018-04-02 04:15:50 +00:00
|
|
|
paintable = gtk_snapshot_free_to_paintable (snapshot, &(graphene_size_t) { layout_width, layout_height });
|
2018-03-26 04:49:55 +00:00
|
|
|
|
|
|
|
return paintable;
|
2006-03-07 13:46:11 +00:00
|
|
|
}
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
layout_get_char_width (PangoLayout *layout)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int width;
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
PangoFontMetrics *metrics;
|
|
|
|
const PangoFontDescription *font_desc;
|
|
|
|
PangoContext *context = pango_layout_get_context (layout);
|
|
|
|
|
|
|
|
font_desc = pango_layout_get_font_description (layout);
|
|
|
|
if (!font_desc)
|
|
|
|
font_desc = pango_context_get_font_description (context);
|
|
|
|
|
|
|
|
metrics = pango_context_get_metrics (context, font_desc, NULL);
|
|
|
|
width = pango_font_metrics_get_approximate_char_width (metrics);
|
|
|
|
pango_font_metrics_unref (metrics);
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2008-12-29 04:50:15 +00:00
|
|
|
/*
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
* _gtk_text_util_get_block_cursor_location
|
2021-05-20 13:17:04 +00:00
|
|
|
* @layout: a `PangoLayout`
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
* @index: index at which cursor is located
|
2007-06-28 06:30:21 +00:00
|
|
|
* @pos: cursor location
|
2008-10-03 01:16:48 +00:00
|
|
|
* @at_line_end: whether cursor is drawn at line end, not over some
|
2007-06-28 06:30:21 +00:00
|
|
|
* character
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
*
|
|
|
|
* Returns: whether cursor should actually be drawn as a rectangle.
|
2021-05-18 21:05:26 +00:00
|
|
|
* It may not be the case if character at index is invisible.
|
2008-12-29 04:50:15 +00:00
|
|
|
*/
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
gboolean
|
|
|
|
_gtk_text_util_get_block_cursor_location (PangoLayout *layout,
|
2020-07-24 13:54:49 +00:00
|
|
|
int index,
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
PangoRectangle *pos,
|
|
|
|
gboolean *at_line_end)
|
|
|
|
{
|
|
|
|
PangoRectangle strong_pos, weak_pos;
|
|
|
|
PangoLayoutLine *layout_line;
|
|
|
|
gboolean rtl;
|
2020-07-24 13:54:49 +00:00
|
|
|
int line_no;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *text;
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (layout != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (index >= 0, FALSE);
|
|
|
|
g_return_val_if_fail (pos != NULL, FALSE);
|
|
|
|
|
|
|
|
pango_layout_index_to_pos (layout, index, pos);
|
|
|
|
|
|
|
|
if (pos->width != 0)
|
|
|
|
{
|
|
|
|
/* cursor is at some visible character, good */
|
|
|
|
if (at_line_end)
|
|
|
|
*at_line_end = FALSE;
|
|
|
|
if (pos->width < 0)
|
|
|
|
{
|
|
|
|
pos->x += pos->width;
|
|
|
|
pos->width = -pos->width;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pango_layout_index_to_line_x (layout, index, FALSE, &line_no, NULL);
|
|
|
|
layout_line = pango_layout_get_line_readonly (layout, line_no);
|
|
|
|
g_return_val_if_fail (layout_line != NULL, FALSE);
|
|
|
|
|
2007-06-28 06:30:21 +00:00
|
|
|
text = pango_layout_get_text (layout);
|
|
|
|
|
2022-01-22 18:37:32 +00:00
|
|
|
if (index < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
{
|
2007-06-28 06:30:21 +00:00
|
|
|
/* this may be a zero-width character in the middle of the line,
|
|
|
|
* or it could be a character where line is wrapped, we do want
|
|
|
|
* block cursor in latter case */
|
|
|
|
if (g_utf8_next_char (text + index) - text !=
|
2022-01-22 18:37:32 +00:00
|
|
|
pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
|
2007-06-28 06:30:21 +00:00
|
|
|
{
|
|
|
|
/* zero-width character in the middle of the line, do not
|
|
|
|
* bother with block cursor */
|
|
|
|
return FALSE;
|
|
|
|
}
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cursor is at the line end. It may be an empty line, or it could
|
|
|
|
* be on the left or on the right depending on text direction, or it
|
|
|
|
* even could be in the middle of visual layout in bidi text. */
|
|
|
|
|
|
|
|
pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
|
|
|
|
|
|
|
|
if (strong_pos.x != weak_pos.x)
|
|
|
|
{
|
|
|
|
/* do not show block cursor in this case, since the character typed
|
|
|
|
* in may or may not appear at the cursor position */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In case when index points to the end of line, pos->x is always most right
|
|
|
|
* pixel of the layout line, so we need to correct it for RTL text. */
|
2022-01-22 18:37:32 +00:00
|
|
|
if (pango_layout_line_get_length (layout_line))
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
{
|
2022-01-22 18:37:32 +00:00
|
|
|
if (pango_layout_line_get_resolved_direction (layout_line) == PANGO_DIRECTION_RTL)
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
{
|
|
|
|
PangoLayoutIter *iter;
|
|
|
|
PangoRectangle line_rect;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
|
|
|
int left, right;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *p;
|
2007-06-28 06:30:21 +00:00
|
|
|
|
|
|
|
p = g_utf8_prev_char (text + index);
|
|
|
|
|
|
|
|
pango_layout_line_index_to_x (layout_line, p - text, FALSE, &left);
|
|
|
|
pango_layout_line_index_to_x (layout_line, p - text, TRUE, &right);
|
|
|
|
pos->x = MIN (left, right);
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
|
|
|
|
iter = pango_layout_get_iter (layout);
|
|
|
|
for (i = 0; i < line_no; i++)
|
|
|
|
pango_layout_iter_next_line (iter);
|
|
|
|
pango_layout_iter_get_line_extents (iter, NULL, &line_rect);
|
|
|
|
pango_layout_iter_free (iter);
|
|
|
|
|
|
|
|
rtl = TRUE;
|
2007-06-28 06:30:21 +00:00
|
|
|
pos->x += line_rect.x;
|
Implement block-cursor for overwrite mode. (#80378)
2007-06-12 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtkentry.c (gtk_entry_expose), (gtk_entry_toggle_overwrite),
(gtk_entry_draw_cursor):
* gtk/gtkstyle.c (_gtk_widget_get_cursor_gc),
(_gtk_widget_get_cursor_color):
* gtk/gtkstyle.h:
* gtk/gtktextdisplay.c (gtk_text_renderer_prepare_run),
(gtk_text_renderer_draw_shape), (text_renderer_set_state),
(render_para):
* gtk/gtktextlayout.c (gtk_text_layout_set_overwrite_mode),
(gtk_text_layout_invalidate_cache), (get_block_cursor),
(add_cursor), (gtk_text_layout_get_line_display),
(_gtk_text_layout_get_block_cursor):
* gtk/gtktextlayout.h:
* gtk/gtktextutil.c (layout_get_char_width),
(_gtk_text_util_get_block_cursor_location):
* gtk/gtktextutil.h:
* gtk/gtktextview.c (gtk_text_view_set_editable),
(gtk_text_view_toggle_overwrite), (gtk_text_view_set_overwrite),
(gtk_text_view_ensure_layout), (text_window_invalidate_cursors):
Implement block-cursor for overwrite mode. (#80378)
svn path=/trunk/; revision=18108
2007-06-12 05:32:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rtl = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PangoContext *context = pango_layout_get_context (layout);
|
|
|
|
rtl = pango_context_get_base_dir (context) == PANGO_DIRECTION_RTL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos->width = layout_get_char_width (layout);
|
|
|
|
|
|
|
|
if (rtl)
|
|
|
|
pos->x -= pos->width - 1;
|
|
|
|
|
|
|
|
if (at_line_end)
|
|
|
|
*at_line_end = TRUE;
|
|
|
|
|
|
|
|
return pos->width != 0;
|
|
|
|
}
|