gtk/gtktext.c

Fri Feb 27 01:11:55 1998  Owen Taylor  <owt1@cornell.edu>

	* gtk/gtktext.c

	- gtk_text_delete and gtk_text_insert now update caches
	and refresh screen correctly if the text widget isn't frozen.

	- Fixed bug where text->first_line_start_index wasn't
	being updated correctly on insertion and deletion.

	- Added new public macro GTK_TEXT_INDEX (text, ind), and
	function gtk_text_get_chars(text, index, nchars);

Thu Feb 26 22:36:46 1998  Owen Taylor  <owt1@cornell.edu>

	* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
	to undecorate window.

	* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
This commit is contained in:
Owen Taylor
1998-02-27 06:13:22 +00:00
committed by Owen Taylor
parent 473c1d4d7b
commit 50cc709f77
13 changed files with 656 additions and 76 deletions

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

View File

@@ -1,3 +1,37 @@
Fri Feb 27 01:11:55 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtktext.c
- gtk_text_delete and gtk_text_insert now update caches
and refresh screen correctly if the text widget isn't frozen.
- Fixed bug where text->first_line_start_index wasn't
being updated correctly on insertion and deletion.
- Added new public macro GTK_TEXT_INDEX (text, ind), and
function gtk_text_get_chars(text, index, nchars);
Thu Feb 26 22:36:46 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkwindow.c gdktypes.c gdk.h:
new functions for setting WM hints
gdk_window_set_icon()
gdk_window_set_icon_name()
gdk_window_set_group()
gdk_window_set_decorations()
gdk_window_set_functions()
* gdk/MwmUtil.h: new uninstalled header file from lesstif
distribution, used for setting MWM hints.
* gdk/gdkdnd.c Makefile.am: renamed from gdk/gdk_dnd.c
* gtk/gtkhandlebox.c (gtk_handle_box_realize): Use MWM hints
to undecorate window.
* gtk/testgtk.c gtk/circles.xbm: new test for WM hints.
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
* gtk/gtkspinbutton.h:

46
gtk/circles.xbm Normal file
View File

@@ -0,0 +1,46 @@
#define circles_width 64
#define circles_height 64
static unsigned char circles_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
0xff, 0xff, 0x01, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x3f, 0x00,
0x80, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00,
0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xc0, 0xff, 0x01, 0x00,
0x00, 0xf0, 0x7f, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00,
0xf0, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xf0, 0x1f, 0x00, 0x00,
0x00, 0x00, 0xff, 0x01, 0xf8, 0x1f, 0x00, 0x20, 0x00, 0x00, 0xff, 0x03,
0xf8, 0x0f, 0x00, 0xff, 0x07, 0x00, 0xfe, 0x03, 0xfc, 0x07, 0xc0, 0xff,
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xff, 0x01, 0xfc, 0x07, 0xfc, 0x07, 0xf8, 0xff,
0xff, 0x00, 0xfc, 0x07, 0xf8, 0x0f, 0xf0, 0xff, 0x7f, 0x00, 0xfe, 0x03,
0xf8, 0x1f, 0xc0, 0xff, 0x1f, 0x00, 0xff, 0x03, 0xf0, 0x1f, 0x00, 0xff,
0x07, 0x00, 0xff, 0x01, 0xf0, 0x3f, 0x00, 0x20, 0x00, 0x80, 0xff, 0x01,
0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xc0, 0xff, 0x01, 0x00,
0x00, 0xf0, 0x7f, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00,
0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xff, 0x3f, 0x00,
0x80, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00,
0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0xff,
0xff, 0xff, 0x01, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00,
0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

View File

@@ -206,18 +206,14 @@ gtk_handle_box_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
/* FIXME: we need a property that would tell the window manager not
* to put decoration on this window. This is not part of the ICCCM,
* so we'll have to define our own (a la KWM) and hack some window
* managers to support it.
*/
hb->float_window = gtk_window_new (GTK_WINDOW_DIALOG);
gtk_window_set_policy (GTK_WINDOW (hb->float_window), FALSE, FALSE, TRUE);
gtk_container_border_width (GTK_CONTAINER (hb->float_window), 0);
gtk_signal_connect (GTK_OBJECT (hb->float_window), "delete_event",
(GtkSignalFunc) gtk_handle_box_delete_float,
hb);
gtk_widget_realize (hb->float_window);
gdk_window_set_decorations (hb->float_window->window, 0);
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;

View File

@@ -58,8 +58,6 @@
#define MARK_CURRENT_FORE(mark) (&((TextProperty*)(mark)->property->data)->fore_color)
#define MARK_CURRENT_BACK(mark) (&((TextProperty*)(mark)->property->data)->back_color)
#define MARK_CURRENT_TEXT_FONT(m) (((TextProperty*)(m)->property->data)->font)
#define TEXT_INDEX(t, index) ((index) < (t)->gap_position ? (t)->text[index] : \
(t)->text[(index) + (t)->gap_size])
#define TEXT_LENGTH(t) ((t)->text_end - (t)->gap_size)
#define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
#define LINE_HEIGHT(l) ((l).font_ascent + (l).font_descent)
@@ -212,6 +210,9 @@ static void find_line_containing_point (GtkText* text, guint point);
static TextProperty* new_text_property (GdkFont* font, GdkColor* fore, GdkColor* back, guint length);
/* Display */
static void compute_lines_pixels (GtkText* text, gint char_count,
guint *lines, guint *pixels);
static gint total_line_height (GtkText* text,
GList* line,
gint line_count);
@@ -220,8 +221,11 @@ static LineParams find_line_params (GtkText* text,
const PrevTabCont *tab_cont,
PrevTabCont *next_cont);
static void recompute_geometry (GtkText* text);
static void insert_char_line_expose (GtkText* text, gchar key, guint old_pixels);
static void delete_char_line_expose (GtkText* text, gchar key, guint old_pixels);
static void insert_expose (GtkText* text, guint old_pixels, gint nchars, guint new_line_count);
static void delete_expose (GtkText* text,
gint nchars,
guint old_lines,
guint old_pixels);
static void clear_area (GtkText *text, GdkRectangle *area);
static void draw_line (GtkText* text,
gint pixel_height,
@@ -258,7 +262,7 @@ static void move_cursor_page_ver (GtkText *text, int dir);
static void move_cursor_ver (GtkText *text, int count);
static void move_cursor_hor (GtkText *text, int count);
/* #define DEBUG_GTK_TEXT */
#define DEBUG_GTK_TEXT
#if defined(DEBUG_GTK_TEXT) && defined(__GNUC__)
/* Debugging utilities. */
@@ -538,6 +542,11 @@ gtk_text_insert (GtkText *text,
const char *chars,
gint length)
{
gint i;
gint new_line_count = 1;
guint old_height = 0;
g_return_if_fail (text != NULL);
g_return_if_fail (GTK_IS_TEXT (text));
@@ -557,6 +566,18 @@ gtk_text_insert (GtkText *text,
if (length == 0)
return;
if (!text->freeze && (text->line_start_cache != NULL))
{
find_line_containing_point (text, text->point.index);
old_height = total_line_height (text, text->current_line, 1);
for (i=0; i<length; i++)
if (chars[i] == '\n')
new_line_count++;
}
if (text->point.index < text->first_line_start_index)
text->first_line_start_index += length;
move_gap_to_point (text);
if (font == NULL)
@@ -572,6 +593,9 @@ gtk_text_insert (GtkText *text,
text->gap_position += length;
advance_mark_n (&text->point, length);
if (!text->freeze && (text->line_start_cache != NULL))
insert_expose (text, old_height, length, new_line_count);
}
gint
@@ -593,21 +617,78 @@ gint
gtk_text_forward_delete (GtkText *text,
guint nchars)
{
guint old_lines, old_height;
g_return_val_if_fail (text != NULL, 0);
g_return_val_if_fail (GTK_IS_TEXT (text), 0);
if (text->point.index + nchars > TEXT_LENGTH (text) || nchars <= 0)
return FALSE;
if (!text->freeze && (text->line_start_cache != NULL))
{
find_line_containing_point (text, text->point.index);
compute_lines_pixels (text, nchars, &old_lines, &old_height);
}
if (text->point.index < text->first_line_start_index)
text->first_line_start_index -= MIN(nchars,
text->first_line_start_index -
text->point.index);
move_gap_to_point (text);
text->gap_size += nchars;
delete_text_property (text, nchars);
if (!text->freeze && (text->line_start_cache != NULL))
delete_expose (text, nchars, old_lines, old_height);
return TRUE;
}
gchar *
gtk_text_get_chars (GtkText *text,
guint index,
guint nchars)
{
gchar *retval;
gchar *p;
guint n;
if (index+nchars > TEXT_LENGTH (text))
return NULL;
if (nchars < 0)
nchars = TEXT_LENGTH (text) - index;
retval = g_new (gchar, nchars+1);
p = retval;
if (index < text->gap_position)
{
n = MIN (text->gap_position - index, nchars);
memcpy (p, text->text + GTK_TEXT_INDEX(text, index), n);
p += n;
index += n;
nchars -= n;
}
if (index+nchars >= text->gap_position)
{
memcpy (p,
text->text + MAX (text->gap_position + text->gap_size,
index + text->gap_size),
nchars);
}
retval[nchars+1] = 0;
return retval;
}
static void
gtk_text_finalize (GtkObject *object)
{
@@ -1117,47 +1198,23 @@ gtk_text_motion_notify (GtkWidget *widget,
static void
gtk_text_insert_1_at_point (GtkText* text, gchar key)
{
guint old_height= total_line_height (text, text->current_line, 1);
gtk_text_insert (text,
MARK_CURRENT_FONT (&text->point),
MARK_CURRENT_FORE (&text->point),
MARK_CURRENT_BACK (&text->point),
&key, 1);
insert_char_line_expose (text, key, old_height );
}
static void
gtk_text_backward_delete_1_at_point (GtkText* text)
{
guint old_height;
gchar key= TEXT_INDEX(text,text->cursor_mark.index-1);
if (1 > text->point.index )
return;
gtk_text_set_point (text, text->point.index - 1);
find_line_containing_point (text, text->cursor_mark.index-1);
old_height= total_line_height (text, text->current_line, 1 + (key == LINE_DELIM));
gtk_text_forward_delete (text, 1);
delete_char_line_expose (text, key, old_height);
gtk_text_backward_delete (text, 1);
}
static void
gtk_text_forward_delete_1_at_point (GtkText* text)
{
guint old_height;
gchar key= TEXT_INDEX(text,text->cursor_mark.index);
old_height= total_line_height (text, text->current_line, 1 + (key == LINE_DELIM));
gtk_text_forward_delete (text, 1);
delete_char_line_expose (text, key, old_height);
}
static gint
@@ -1386,7 +1443,7 @@ find_this_line_start_mark (GtkText* text, guint point_position, const GtkPropert
mark = find_mark_near (text, point_position, near);
while (mark.index > 0 &&
TEXT_INDEX (text, mark.index - 1) != LINE_DELIM)
GTK_TEXT_INDEX (text, mark.index - 1) != LINE_DELIM)
decrement_mark (&mark);
return mark;
@@ -1536,6 +1593,41 @@ fetch_lines_forward (GtkText* text, gint line_count)
line->next->prev = line;
}
/* Compute the number of lines, and vertical pixels for n characters
* starting from the point
*/
static void
compute_lines_pixels (GtkText* text, gint char_count,
guint *lines, guint *pixels)
{
GList *line = text->current_line;
*lines = 0;
*pixels = 0;
/* If char_count == 0, that means we're joining two lines in a
* deletion, so add in the values for the next line as well
*/
for (; line && char_count >= 0; line = line->next)
{
*pixels += LINE_HEIGHT(CACHE_DATA(line));
if (line == text->current_line)
char_count -= CACHE_DATA(line).end.index - text->point.index + 1;
else
char_count -= CACHE_DATA(line).end.index -CACHE_DATA(line).end.index + 1;
if (!text->line_wrap || !CACHE_DATA(line).wraps)
*lines += 1;
else
if (char_count < 0)
char_count = 0; /* force another loop */
if (!line->next)
fetch_lines_forward (text, 1);
}
}
static gint
total_line_height (GtkText* text, GList* line, gint line_count)
{
@@ -1610,7 +1702,7 @@ swap_lines (GtkText* text, GList* old, GList* new, gint old_line_count)
}
static void
correct_cache_delete (GtkText* text, gint lines)
correct_cache_delete (GtkText* text, gint nchars, gint lines)
{
GList* cache = text->current_line;
gint i;
@@ -1623,8 +1715,8 @@ correct_cache_delete (GtkText* text, gint lines)
GtkPropertyMark *start = &CACHE_DATA(cache).start;
GtkPropertyMark *end = &CACHE_DATA(cache).end;
start->index -= 1;
end->index -= 1;
start->index -= nchars;
end->index -= nchars;
if (start->property == text->point.property)
start->offset = start->index - (text->point.index - text->point.offset);
@@ -1638,11 +1730,10 @@ correct_cache_delete (GtkText* text, gint lines)
}
static void
delete_char_line_expose (GtkText* text, gchar key, guint old_pixels)
delete_expose (GtkText* text, gint nchars, guint old_lines, guint old_pixels)
{
gint pixel_height;
guint new_pixels = 0;
gint old_line_count = 1 + (key == LINE_DELIM);
GdkRectangle rect;
GList* new_line = NULL;
gint width, height;
@@ -1651,7 +1742,7 @@ delete_char_line_expose (GtkText* text, gchar key, guint old_pixels)
undraw_cursor (text, FALSE);
correct_cache_delete (text, old_line_count);
correct_cache_delete (text, nchars, old_lines);
pixel_height = pixel_height_of(text, text->current_line) -
LINE_HEIGHT(CACHE_DATA(text->current_line));
@@ -1665,7 +1756,7 @@ delete_char_line_expose (GtkText* text, gchar key, guint old_pixels)
FetchLinesCount,
1);
swap_lines (text, text->current_line, new_line, old_line_count);
swap_lines (text, text->current_line, new_line, old_lines);
text->current_line = new_line;
@@ -1711,30 +1802,31 @@ delete_char_line_expose (GtkText* text, gchar key, guint old_pixels)
TEXT_SHOW(text);
}
/* note, the point has already been moved forward */
static void
correct_cache_insert (GtkText* text)
correct_cache_insert (GtkText* text, gint nchars)
{
GList* cache = text->current_line;
GList* cache = text->current_line->next;
for (; cache; cache = cache->next)
{
GtkPropertyMark *start = &CACHE_DATA(cache).start;
GtkPropertyMark *end = &CACHE_DATA(cache).end;
if (start->index >= text->point.index)
if (start->index >= text->point.index - nchars)
{
if (start->property == text->point.property)
move_mark_n(start, 1);
move_mark_n(start, nchars);
else
start->index += 1;
start->index += nchars;
}
if (end->index >= text->point.index)
if (end->index >= text->point.index - nchars)
{
if (end->property == text->point.property)
move_mark_n(end, 1);
move_mark_n(end, nchars);
else
end->index += 1;
end->index += nchars;
}
/*TEXT_ASSERT_MARK(text, start, "start");*/
@@ -1744,37 +1836,37 @@ correct_cache_insert (GtkText* text)
static void
insert_char_line_expose (GtkText* text, gchar key, guint old_pixels)
insert_expose (GtkText* text, guint old_pixels, gint nchars,
guint new_line_count)
{
gint pixel_height;
guint new_pixels = 0;
guint new_line_count = 1 + (key == LINE_DELIM);
GdkRectangle rect;
GList* new_line = NULL;
GList* new_lines = NULL;
gint width, height;
text->cursor_virtual_x = 0;
undraw_cursor (text, FALSE);
correct_cache_insert (text);
correct_cache_insert (text, nchars);
TEXT_SHOW_ADJ (text, text->vadj, "vadj");
pixel_height = pixel_height_of(text, text->current_line) -
LINE_HEIGHT(CACHE_DATA(text->current_line));
new_line = fetch_lines (text,
&CACHE_DATA(text->current_line).start,
&CACHE_DATA(text->current_line).tab_cont,
FetchLinesCount,
new_line_count);
new_lines = fetch_lines (text,
&CACHE_DATA(text->current_line).start,
&CACHE_DATA(text->current_line).tab_cont,
FetchLinesCount,
new_line_count);
swap_lines (text, text->current_line, new_line, 1);
swap_lines (text, text->current_line, new_lines, 1);
text->current_line = new_line;
text->current_line = new_lines;
new_pixels = total_line_height (text, new_line, new_line_count);
new_pixels = total_line_height (text, new_lines, new_line_count);
gdk_window_get_size (text->text_area, &width, &height);
@@ -2275,7 +2367,7 @@ find_line_containing_point (GtkText* text, guint point)
}
}
g_assert (FALSE); /* Must set text->current_line here */
g_assert_not_reached (); /* Must set text->current_line here */
}
static guint
@@ -2303,7 +2395,7 @@ pixel_height_of (GtkText* text, GList* cache_line)
static gint
find_char_width (GtkText* text, const GtkPropertyMark *mark, const TabStopMark *tab_mark)
{
gchar ch = TEXT_INDEX (text, mark->index);
gchar ch = GTK_TEXT_INDEX (text, mark->index);
gint16* char_widths = MARK_CURRENT_TEXT_FONT (mark)->char_widths;
if (ch == '\t')
@@ -2358,7 +2450,7 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei
{
pixel_width += find_char_width (text, &mark, &tab_mark);
advance_tab_mark (text, &tab_mark, TEXT_INDEX(text, mark.index));
advance_tab_mark (text, &tab_mark, GTK_TEXT_INDEX(text, mark.index));
advance_mark (&mark);
}
@@ -2367,7 +2459,7 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei
text->cursor_char_offset = start_line->font_descent;
text->cursor_mark = mark;
ch = TEXT_INDEX (text, mark.index);
ch = GTK_TEXT_INDEX (text, mark.index);
if (!isspace(ch))
text->cursor_char = ch;
@@ -2429,7 +2521,7 @@ mouse_click_1_at_line (GtkText *text, const LineParams* lp,
for (;;)
{
gchar ch = TEXT_INDEX (text, mark.index);
gchar ch = GTK_TEXT_INDEX (text, mark.index);
if (button_x < pixel_width || mark.index == lp->end.index)
{
@@ -2578,7 +2670,7 @@ move_cursor_ver (GtkText *text, int count)
{
mark = text->cursor_mark;
while (!LAST_INDEX(text, mark) && TEXT_INDEX(text, mark.index) != LINE_DELIM)
while (!LAST_INDEX(text, mark) && GTK_TEXT_INDEX(text, mark.index) != LINE_DELIM)
advance_mark (&mark);
if (LAST_INDEX(text, mark))
@@ -2588,7 +2680,7 @@ move_cursor_ver (GtkText *text, int count)
}
for (i=0; i < text->cursor_virtual_x; i += 1, advance_mark(&mark))
if (LAST_INDEX(text, mark) || TEXT_INDEX(text, mark.index) == LINE_DELIM)
if (LAST_INDEX(text, mark) || GTK_TEXT_INDEX(text, mark.index) == LINE_DELIM)
break;
undraw_cursor (text, FALSE);
@@ -2987,7 +3079,7 @@ find_line_params (GtkText* text,
{
g_assert (lp.end.property);
ch = TEXT_INDEX (text, lp.end.index);
ch = GTK_TEXT_INDEX (text, lp.end.index);
font = MARK_CURRENT_FONT (&lp.end);
if (ch == LINE_DELIM)
@@ -3118,7 +3210,7 @@ draw_line (GtkText* text,
expand_scratch_buffer (text, chars);
for (i = 0; i < chars; i += 1)
text->scratch_buffer[i] = TEXT_INDEX(text, mark.index + i);
text->scratch_buffer[i] = GTK_TEXT_INDEX(text, mark.index + i);
buffer = text->scratch_buffer;
}
@@ -3629,7 +3721,7 @@ gtk_text_show_cache_line (GtkText *text, GList *cache,
LINE_HEIGHT(*lp));
for (i = lp->start.index; i < (lp->end.index + lp->wraps); i += 1)
g_print ("%c", TEXT_INDEX (text, i));
g_print ("%c", GTK_TEXT_INDEX (text, i));
g_print (")\n");
}

View File

@@ -21,6 +21,8 @@
#include "../gdk/gdk.h"
#include "../gdk/gdkx.h"
#include "circles.xbm"
/* Variables used by the Drag/Drop and Shape Window demos */
static GtkWidget *modeller = NULL;
static GtkWidget *sheets = NULL;
@@ -2746,7 +2748,7 @@ create_text ()
"spencer blah blah blah\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
"kimball\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->white, NULL,
"is\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
"a\n", -1);
@@ -3608,6 +3610,84 @@ create_shapes ()
gtk_widget_destroy (rings);
}
void
create_wmhints ()
{
static GtkWidget *window = NULL;
GtkWidget *label;
GtkWidget *separator;
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box2;
GdkBitmap *circles;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_window_set_title (GTK_WINDOW (window), "WM Hints");
gtk_container_border_width (GTK_CONTAINER (window), 0);
gtk_widget_realize (window);
circles = gdk_bitmap_create_from_data (window->window,
circles_bits,
circles_width,
circles_height);
gdk_window_set_icon (window->window, NULL,
circles, circles);
gdk_window_set_icon_name (window->window, "WMHints Test Icon");
gdk_window_set_decorations (window->window, GDK_DECOR_ALL | GDK_DECOR_MENU);
gdk_window_set_functions (window->window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1);
label = gtk_label_new ("Try iconizing me!");
gtk_widget_set_usize (label, 150, 50);
gtk_box_pack_start (GTK_BOX (box1), label, TRUE, TRUE, 0);
gtk_widget_show (label);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);
box2 = gtk_vbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
gtk_widget_show (box2);
button = gtk_button_new_with_label ("close");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
/*
* Progress Bar
@@ -4571,6 +4651,7 @@ create_main_window ()
{ "panes", create_panes },
{ "shapes", create_shapes },
{ "dnd", create_dnd },
{ "WM hints", create_wmhints },
{ "progress bar", create_progress_bar },
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },

46
tests/circles.xbm Normal file
View File

@@ -0,0 +1,46 @@
#define circles_width 64
#define circles_height 64
static unsigned char circles_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
0xff, 0xff, 0x01, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x3f, 0x00,
0x80, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00,
0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xc0, 0xff, 0x01, 0x00,
0x00, 0xf0, 0x7f, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00,
0xf0, 0x3f, 0x00, 0x00, 0x00, 0x80, 0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,
0xfe, 0x01, 0xff, 0x00, 0xf8, 0x07, 0xf0, 0x0f, 0xfe, 0x03, 0xfe, 0x01,
0xfc, 0x03, 0xf8, 0x0f, 0xfc, 0x03, 0xfe, 0x8f, 0xff, 0x03, 0xf8, 0x07,
0xfc, 0x07, 0xfc, 0xff, 0xff, 0x01, 0xfc, 0x07, 0xfc, 0x07, 0xf8, 0xff,
0xff, 0x00, 0xfc, 0x07, 0xf8, 0x0f, 0xf0, 0xff, 0x7f, 0x00, 0xfe, 0x03,
0xf8, 0x1f, 0xc0, 0xff, 0x1f, 0x00, 0xff, 0x03, 0xf0, 0x1f, 0x00, 0xff,
0x07, 0x00, 0xff, 0x01, 0xf0, 0x3f, 0x00, 0x20, 0x00, 0x80, 0xff, 0x01,
0xe0, 0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xc0, 0xff, 0x01, 0x00,
0x00, 0xf0, 0x7f, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0xf8, 0x3f, 0x00,
0x80, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xff, 0x3f, 0x00,
0x80, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0xff, 0x01, 0xf0, 0xff, 0x0f, 0x00,
0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0xff,
0xff, 0xff, 0x01, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00,
0x00, 0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

View File

@@ -21,6 +21,8 @@
#include "../gdk/gdk.h"
#include "../gdk/gdkx.h"
#include "circles.xbm"
/* Variables used by the Drag/Drop and Shape Window demos */
static GtkWidget *modeller = NULL;
static GtkWidget *sheets = NULL;
@@ -2746,7 +2748,7 @@ create_text ()
"spencer blah blah blah\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
"kimball\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->white, NULL,
"is\n", -1);
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
"a\n", -1);
@@ -3608,6 +3610,84 @@ create_shapes ()
gtk_widget_destroy (rings);
}
void
create_wmhints ()
{
static GtkWidget *window = NULL;
GtkWidget *label;
GtkWidget *separator;
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box2;
GdkBitmap *circles;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_window_set_title (GTK_WINDOW (window), "WM Hints");
gtk_container_border_width (GTK_CONTAINER (window), 0);
gtk_widget_realize (window);
circles = gdk_bitmap_create_from_data (window->window,
circles_bits,
circles_width,
circles_height);
gdk_window_set_icon (window->window, NULL,
circles, circles);
gdk_window_set_icon_name (window->window, "WMHints Test Icon");
gdk_window_set_decorations (window->window, GDK_DECOR_ALL | GDK_DECOR_MENU);
gdk_window_set_functions (window->window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1);
label = gtk_label_new ("Try iconizing me!");
gtk_widget_set_usize (label, 150, 50);
gtk_box_pack_start (GTK_BOX (box1), label, TRUE, TRUE, 0);
gtk_widget_show (label);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);
box2 = gtk_vbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
gtk_widget_show (box2);
button = gtk_button_new_with_label ("close");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy),
GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
/*
* Progress Bar
@@ -4571,6 +4651,7 @@ create_main_window ()
{ "panes", create_panes },
{ "shapes", create_shapes },
{ "dnd", create_dnd },
{ "WM hints", create_wmhints },
{ "progress bar", create_progress_bar },
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },