Commit 9bec105a authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington
Browse files

Draw the focus, and leave space to do so.

2000-09-25  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextview.c: Draw the focus, and leave space to do so.

	* gtk/gtktexttypes.c: Remove Latin1 conversion stuff

	* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
	Fix a bug when removing node data, we didn't properly
	re-splice the linked list after removing the data.

	* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
	GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget

	* gtk/gtktextbuffer.c (selection_received): fix g_convert usage

	* gtk/gtktextlayout.c (set_para_values): Set tab array
	for the layout from the GtkTextTag.

	* gtk/gtktexttypes.h: delete tab and search cruft,
	remove g_convert() in favor of GLib version

	* gtk/gtktexttypes.c: remove tab implementation from here,
	move to Pango

	* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
	tab stuff using new PangoTabArray from Pango

	* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
	unused border_width stuff
parent f235c3cb
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
Drawables to Pixbufs
<!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
<para>
A function of this type can be used to override the default
......@@ -15,10 +19,6 @@
@pixbuf: The pixbuf that is losing its last reference.
@data: User closure data.
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
Drawables to Pixbufs
<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
<para>
......
......@@ -4724,6 +4724,7 @@ gtk_text_btree_node_remove_data(GtkTextBTreeNode *node, gpointer view_id)
if (nd->view_id == view_id)
break;
prev = nd;
nd = nd->next;
}
......
......@@ -1412,9 +1412,8 @@ clipboard_received (GtkClipboard *clipboard,
else
; /* FIXME Delete selected chars and give up X selection */
}
#endif
#endif
if (request_data->interactive)
gtk_text_buffer_insert_interactive (buffer, &insert_point,
str, -1, request_data->default_editable);
......
......@@ -1039,6 +1039,9 @@ set_para_values (GtkTextLayout *layout,
pango_layout_set_alignment (display->layout, pango_align);
pango_layout_set_spacing (display->layout, style->pixels_inside_wrap * PANGO_SCALE);
if (style->tabs)
pango_layout_set_tabs (display->layout, style->tabs);
display->top_margin = style->pixels_above_lines;
display->height = style->pixels_above_lines + style->pixels_below_lines;
display->bottom_margin = style->pixels_below_lines;
......
......@@ -46,6 +46,14 @@ struct _GtkTextLayout
gint width;
gint height;
/* Pixel offsets from the left and from the top to be used when we
* draw; these allow us to create left/top margins. We don't need
* anything special for bottom/right margins, because those don't
* affect drawing.
*/
/* gint left_edge; */
/* gint top_edge; */
GtkTextBuffer *buffer;
/* Default style used if no tags override it */
......
......@@ -55,6 +55,7 @@
#include "gtkmain.h"
#include <stdlib.h>
#include <string.h>
enum {
EVENT,
......@@ -90,6 +91,7 @@ enum {
ARG_OFFSET,
ARG_BG_FULL_HEIGHT,
ARG_LANGUAGE,
ARG_TABS,
/* Whether-a-style-arg-is-set args */
ARG_BACKGROUND_SET,
......@@ -113,6 +115,7 @@ enum {
ARG_OFFSET_SET,
ARG_BG_FULL_HEIGHT_SET,
ARG_LANGUAGE_SET,
ARG_TABS_SET,
LAST_ARG
};
......@@ -218,6 +221,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_UNDERLINE);
gtk_object_add_arg_type ("GtkTextTag::wrap_mode", GTK_TYPE_ENUM,
GTK_ARG_READWRITE, ARG_WRAP_MODE);
gtk_object_add_arg_type ("GtkTextTag::tabs", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_TABS);
/* Style args are set or not */
gtk_object_add_arg_type ("GtkTextTag::background_set", GTK_TYPE_BOOL,
......@@ -262,6 +267,9 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_UNDERLINE_SET);
gtk_object_add_arg_type ("GtkTextTag::wrap_mode_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_WRAP_MODE_SET);
gtk_object_add_arg_type ("GtkTextTag::tabs_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_TABS_SET);
signals[EVENT] =
gtk_signal_new ("event",
......@@ -580,6 +588,18 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
tkxt_tag->language_set = TRUE;
tkxt_tag->values->language = g_strdup (GTK_VALUE_STRING(*arg));
break;
case ARG_TABS:
tkxt_tag->tabs_set = TRUE;
if (tkxt_tag->values->tabs)
pango_tab_array_free (tkxt_tag->values->tabs);
tkxt_tag->values->tabs =
pango_tab_array_copy (GTK_VALUE_POINTER (*arg));
size_changed = TRUE;
break;
/* Whether the value should be used... */
......@@ -671,6 +691,11 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
tkxt_tag->language_set = GTK_VALUE_BOOL(*arg);
size_changed = TRUE;
break;
case ARG_TABS_SET:
tkxt_tag->tabs_set = GTK_VALUE_BOOL (*arg);
size_changed = TRUE;
break;
default:
g_assert_not_reached();
......@@ -800,6 +825,11 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_LANGUAGE:
GTK_VALUE_STRING(*arg) = g_strdup (tag->values->language);
break;
case ARG_TABS:
GTK_VALUE_POINTER (*arg) = tag->values->tabs ?
pango_tab_array_copy (tag->values->tabs) : NULL;
break;
case ARG_BACKGROUND_SET:
case ARG_BACKGROUND_GDK_SET:
......@@ -878,6 +908,10 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_LANGUAGE_SET:
GTK_VALUE_BOOL(*arg) = tag->language_set;
break;
case ARG_TABS_SET:
GTK_VALUE_BOOL (*arg) = tag->tabs_set;
break;
case ARG_BACKGROUND:
case ARG_FOREGROUND:
......@@ -1050,7 +1084,7 @@ gtk_text_attributes_new(void)
void
gtk_text_attributes_copy(GtkTextAttributes *src,
GtkTextAttributes *dest)
GtkTextAttributes *dest)
{
guint orig_refcount;
......@@ -1067,9 +1101,6 @@ gtk_text_attributes_copy(GtkTextAttributes *src,
if (src->appearance.fg_stipple)
gdk_bitmap_ref(src->appearance.fg_stipple);
if (src->tab_array)
gtk_text_view_tab_array_ref(src->tab_array);
/* Remove refs */
if (dest->appearance.bg_stipple)
......@@ -1078,15 +1109,16 @@ gtk_text_attributes_copy(GtkTextAttributes *src,
if (dest->appearance.fg_stipple)
gdk_bitmap_unref(dest->appearance.fg_stipple);
if (dest->tab_array)
gtk_text_view_tab_array_unref(dest->tab_array);
/* Copy */
orig_refcount = dest->refcount;
*dest = *src;
dest->font_desc = pango_font_description_copy (src->font_desc);
if (src->tabs)
dest->tabs = pango_tab_array_copy (src->tabs);
dest->language = g_strdup (src->language);
dest->refcount = orig_refcount;
......@@ -1122,8 +1154,8 @@ gtk_text_attributes_unref(GtkTextAttributes *values)
if (values->appearance.fg_stipple)
gdk_bitmap_unref(values->appearance.fg_stipple);
if (values->tab_array)
gtk_text_view_tab_array_unref(values->tab_array);
if (values->tabs)
pango_tab_array_free (values->tabs);
if (values->language)
g_free (values->language);
......@@ -1197,10 +1229,7 @@ gtk_text_attributes_fill_from_tags(GtkTextAttributes *dest,
dest->appearance.bg_color = vals->appearance.bg_color;
dest->appearance.draw_bg = TRUE;
}
if (tag->border_width_set)
dest->border_width = vals->border_width;
}
if (tag->relief_set)
dest->relief = vals->relief;
......@@ -1260,12 +1289,11 @@ gtk_text_attributes_fill_from_tags(GtkTextAttributes *dest,
if (tag->pixels_inside_wrap_set)
dest->pixels_inside_wrap = vals->pixels_inside_wrap;
if (tag->tab_array_set)
if (tag->tabs_set)
{
gtk_text_view_tab_array_ref(vals->tab_array);
if (dest->tab_array)
gtk_text_view_tab_array_unref(dest->tab_array);
dest->tab_array = vals->tab_array;
if (dest->tabs)
pango_tab_array_free (dest->tabs);
dest->tabs = pango_tab_array_copy (vals->tabs);
}
if (tag->wrap_mode_set)
......
......@@ -11,9 +11,9 @@ extern "C" {
typedef struct _GtkTextIter GtkTextIter;
typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
typedef struct _GtkTextTagTable GtkTextTagTable;
typedef struct _GtkTextTabArray GtkTextTabArray;
typedef enum {
typedef enum
{
GTK_WRAPMODE_NONE,
GTK_WRAPMODE_CHAR,
GTK_WRAPMODE_WORD
......@@ -54,11 +54,10 @@ struct _GtkTextTag {
GtkTextAttributes *values;
/*
Flags for whether a given value is set; if a value is unset, then
this tag does not affect it. */
/* Flags for whether a given value is set; if a value is unset, then
* this tag does not affect it.
*/
guint bg_color_set : 1;
guint border_width_set : 1;
guint relief_set : 1;
guint bg_stipple_set : 1;
guint fg_color_set : 1;
......@@ -73,7 +72,7 @@ struct _GtkTextTag {
guint pixels_above_lines_set : 1;
guint pixels_below_lines_set : 1;
guint pixels_inside_wrap_set : 1;
guint tab_array_set : 1;
guint tabs_set : 1;
guint underline_set : 1;
guint wrap_mode_set : 1;
guint bg_full_height_set : 1;
......@@ -123,7 +122,8 @@ struct _GtkTextAppearance
/* Whether to use background-related values; this is irrelevant for
* the values struct when in a tag, but is used for the composite
* values struct; it's true if any of the tags being composited
* had background stuff set. */
* had background stuff set.
*/
guint draw_bg : 1;
/* This is only used when we are actually laying out and rendering
......@@ -139,7 +139,6 @@ struct _GtkTextAttributes
GtkTextAppearance appearance;
gint border_width;
GtkShadowType relief;
GtkJustification justify;
GtkTextDirection direction;
......@@ -163,7 +162,7 @@ struct _GtkTextAttributes
gint pixels_inside_wrap;
GtkTextTabArray *tab_array;
PangoTabArray *tabs;
GtkWrapMode wrap_mode; /* How to handle wrap-around for this tag.
* Must be GTK_WRAPMODE_CHAR,
......@@ -176,7 +175,8 @@ struct _GtkTextAttributes
guint invisible : 1;
/* Background is fit to full line height rather than
* baseline +/- ascent/descent (font height) */
* baseline +/- ascent/descent (font height)
*/
guint bg_full_height : 1;
/* can edit this text */
......@@ -197,7 +197,6 @@ void gtk_text_attributes_copy (GtkTextAttributes *src,
void gtk_text_attributes_unref (GtkTextAttributes *values);
void gtk_text_attributes_ref (GtkTextAttributes *values);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
#include "gtktexttypes.h"
/*
* Tab array
*/
GtkTextTabArray*
gtk_text_view_tab_array_new(guint size)
{
GtkTextTabArray *array;
array = g_new0(GtkTextTabArray, 1);
array->refcount = 1;
array->numTabs = size;
array->tabs = g_new0(GtkTextTab, size);
return array;
}
void
gtk_text_view_tab_array_ref(GtkTextTabArray *tab_array)
{
g_return_if_fail(tab_array != NULL);
tab_array->refcount += 1;
}
void
gtk_text_view_tab_array_unref(GtkTextTabArray *tab_array)
{
g_return_if_fail(tab_array != NULL);
g_return_if_fail(tab_array->refcount > 0);
tab_array->refcount -= 1;
if (tab_array->refcount == 0)
{
g_free(tab_array->tabs);
g_free(tab_array);
}
}
/* These are used to represent embedded non-character objects
* if you return a string representation of a text buffer
*/
......@@ -59,4 +17,3 @@ gtk_text_byte_begins_utf8_char(const gchar *byte)
{
return inline_byte_begins_utf8_char(byte);
}
......@@ -15,83 +15,8 @@ typedef struct _GtkTextCounter GtkTextCounter;
typedef struct _GtkTextLineSegment GtkTextLineSegment;
typedef struct _GtkTextLineSegmentClass GtkTextLineSegmentClass;
typedef struct _GtkTextToggleBody GtkTextToggleBody;
typedef struct _GtkTextViewSearch GtkTextViewSearch;
typedef struct _GtkTextTab GtkTextTab;
typedef struct _GtkTextViewStyle GtkTextViewStyle;
typedef struct _GtkTextMarkBody GtkTextMarkBody;
/*
* Search
*/
/*
* The data structure below is used for searching a B-tree for transitions
* on a single tag (or for all tag transitions). No code outside of
* tkTextBTree.c should ever modify any of the fields in these structures,
* but it's OK to use them for read-only information.
*/
struct _GtkTextViewSearch {
GtkTextBTree *tree;
GtkTextIter curIndex; /* Position of last tag transition
* returned by gtk_text_btree_next_tag, or
* index of start of segment
* containing starting position for
* search if gtk_text_btree_next_tag hasn't
* been called yet, or same as
* stopIndex if search is over. */
GtkTextLineSegment *segPtr; /* Actual tag segment returned
by last call to
gtk_text_btree_next_tag,
or NULL if
gtk_text_btree_next_tag