forked from AuroraMiddleware/gtk
gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu> * gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch] Turned off debugging in gtktext.c Bug fixes for cutting, pasting, deleting, etc. Some of the bugs that were there before have definitely been fixed. * gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds, to make things look nicer.
This commit is contained in:
parent
9205edae41
commit
2630943eb3
23
ChangeLog
23
ChangeLog
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
Sun Mar 1 03:20:39 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtk/gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Turned off debugging in gtktext.c
|
||||
|
||||
Bug fixes for cutting, pasting, deleting, etc.
|
||||
|
||||
Some of the bugs that were there before have definitely
|
||||
been fixed.
|
||||
|
||||
* gtk/testgtk.c gtk/testgtkrc: Removed my ugly orange backgrounds,
|
||||
to make things look nicer.
|
||||
|
||||
Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkentry.[ch] gtktext.c gtkeditable.[ch]
|
||||
* gtk/gtkentry.[ch] gtktext.[ch] gtkeditable.[ch]
|
||||
|
||||
Created a new base widget type Editable for the entry and
|
||||
text widgets, which encapsulates most of the selection and
|
||||
@ -17,8 +31,15 @@ Sat Feb 28 23:58:54 1998 Owen Taylor <owt1@cornell.edu>
|
||||
- Clipboard style cut and paste
|
||||
- Emacs style key bindings (~same as Entry)
|
||||
- Word motion
|
||||
- "changed" signal
|
||||
|
||||
There are definitely still some bugs in the new stuff.
|
||||
|
||||
Use style->base for the background and style->text for
|
||||
the foreground.
|
||||
|
||||
* gtkfilesel.c gtkspinbutton.c testgtk.c: small changes
|
||||
to fit the new interface more exactly.
|
||||
|
||||
Sat Feb 28 19:29:09 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
|
60
TODO
60
TODO
@ -142,3 +142,63 @@ TODO AFTER GTK 1.0
|
||||
( You'd have to extend gdk_window_set_hints to accept the
|
||||
window gravity option to get it right. )
|
||||
|
||||
* Text/Edit widget: (some of these might be bugs that should be fixed now)
|
||||
|
||||
Bugs:
|
||||
|
||||
- In Entry and Text widget, you can ungrab while still
|
||||
dragging by pressing button-1, pressing button 3, releaseing 3,
|
||||
then releasing 1.
|
||||
|
||||
- When selecting on a Text or Entry widget, the selection isn't
|
||||
claimed until you release the button, and that shows by the
|
||||
color of the selection. (Which is the real problem - it probably
|
||||
is OK/better to delay claiming the selection)
|
||||
|
||||
- Related to the above, when you Shift/arrow to select text, the
|
||||
selected text doesn't show that you have the selection immediately.
|
||||
|
||||
- Selecting an entire line with triple-click doesn't work write -
|
||||
it should select the wrapped portion too.
|
||||
|
||||
- Selecting an entire line should probably select the newline as
|
||||
well, so when the selection is cut/deleted, the newline goes
|
||||
along.
|
||||
|
||||
- Do something about the bg pixmap situation. (It will produce
|
||||
garbage when editing is enabled)
|
||||
|
||||
Improvements:
|
||||
|
||||
- Finish making the key bindings consistent between the Entry
|
||||
and Text widgets
|
||||
|
||||
- Unify the key binding support in some fashion between the
|
||||
two widgets (???)
|
||||
|
||||
- When inserting or deleting large chunks of text, do a freeze/thaw
|
||||
automatically, to avoid scrolling around for ever on screen.
|
||||
|
||||
- Jump scroll on large insertions/deletions
|
||||
|
||||
- Prune the line start cache. But since it is only 68 bytes
|
||||
per line, and it is a lot faster when lines are in the cache,
|
||||
it may be better not to, at least for now.
|
||||
|
||||
- Show the non-editable state by changing colors. (Use the
|
||||
style entries for insensitive?)
|
||||
|
||||
- Multibyte support for the Text widget.
|
||||
|
||||
- Unicode support to do the multi-byte right.
|
||||
|
||||
- Support an .inputrc. (The readline one doesn't really work,
|
||||
unless it is extended because it can't represent X keysyms,
|
||||
just terminal type input)
|
||||
|
||||
- A vi mode
|
||||
|
||||
- Word wrap, instead of line folding. (Should the continuation
|
||||
characters be shown?)
|
||||
|
||||
- Horizontal scrolling
|
||||
|
@ -53,9 +53,9 @@ typedef void (*GtkEditableSignal2) (GtkObject *object,
|
||||
gpointer data);
|
||||
|
||||
typedef gpointer (*GtkEditableSignal3) (GtkObject *object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer data);
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static void gtk_editable_marshal_signal_1 (GtkObject *object,
|
||||
@ -312,8 +312,8 @@ gtk_editable_finalize (GtkObject *object)
|
||||
void
|
||||
gtk_editable_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position)
|
||||
gint new_text_length,
|
||||
gint *position)
|
||||
{
|
||||
gchar buf[64];
|
||||
gchar *text;
|
||||
@ -338,8 +338,8 @@ gtk_editable_insert_text (GtkEditable *editable,
|
||||
|
||||
void
|
||||
gtk_editable_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
g_return_if_fail (editable != NULL);
|
||||
g_return_if_fail (GTK_IS_EDITABLE (editable));
|
||||
@ -363,8 +363,8 @@ gtk_editable_update_text (GtkEditable *editable,
|
||||
|
||||
gchar *
|
||||
gtk_editable_get_chars (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start,
|
||||
gint end)
|
||||
{
|
||||
gchar *retval = NULL;
|
||||
|
||||
@ -444,7 +444,8 @@ gtk_editable_selection_handler (GtkWidget *widget,
|
||||
{
|
||||
selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos);
|
||||
selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos);
|
||||
str = gtk_editable_get_chars(editable, selection_start_pos,
|
||||
str = gtk_editable_get_chars(editable,
|
||||
selection_start_pos,
|
||||
selection_end_pos);
|
||||
length = selection_end_pos - selection_start_pos;
|
||||
}
|
||||
@ -576,14 +577,15 @@ gtk_editable_selection_received (GtkWidget *widget,
|
||||
void
|
||||
gtk_editable_delete_selection (GtkEditable *editable)
|
||||
{
|
||||
if (editable->selection_start_pos != editable->selection_end_pos)
|
||||
gtk_editable_delete_text (editable,
|
||||
MIN (editable->selection_start_pos, editable->selection_end_pos),
|
||||
MAX (editable->selection_start_pos, editable->selection_end_pos));
|
||||
guint start = editable->selection_start_pos;
|
||||
guint end = editable->selection_end_pos;
|
||||
|
||||
editable->selection_start_pos = 0;
|
||||
editable->selection_end_pos = 0;
|
||||
|
||||
if (start != end)
|
||||
gtk_editable_delete_text (editable, MIN (start, end), MAX (start,end));
|
||||
|
||||
if (editable->has_selection)
|
||||
{
|
||||
editable->has_selection = FALSE;
|
||||
@ -614,8 +616,8 @@ gtk_editable_claim_selection (GtkEditable *editable,
|
||||
|
||||
void
|
||||
gtk_editable_select_region (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start,
|
||||
gint end)
|
||||
{
|
||||
if (GTK_WIDGET_REALIZED (editable))
|
||||
gtk_editable_claim_selection (editable, start != end, GDK_CURRENT_TIME);
|
||||
@ -645,8 +647,8 @@ gtk_editable_copy_clipboard (GtkEditable *editable, GdkEventKey *event)
|
||||
clipboard_atom,
|
||||
event->time))
|
||||
editable->clipboard_text = gtk_editable_get_chars (editable,
|
||||
editable->selection_start_pos,
|
||||
editable->selection_end_pos);
|
||||
selection_start_pos,
|
||||
selection_end_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,37 +59,37 @@ struct _GtkEditableClass
|
||||
|
||||
void (* insert_text) (GtkEditable *editable,
|
||||
const gchar *text,
|
||||
guint length,
|
||||
guint *position);
|
||||
gint length,
|
||||
gint *position);
|
||||
void (* delete_text) (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
void (* update_text) (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
gchar* (* get_chars) (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
void (* set_selection)(GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
void (* changed) (GtkEditable *editable);
|
||||
};
|
||||
|
||||
guint gtk_editable_get_type (void);
|
||||
void gtk_editable_select_region (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start,
|
||||
gint end);
|
||||
void gtk_editable_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position);
|
||||
gint new_text_length,
|
||||
gint *position);
|
||||
void gtk_editable_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
gchar * gtk_editable_get_chars (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
void gtk_editable_cut_clipboard (GtkEditable *editable,
|
||||
GdkEventKey *event);
|
||||
void gtk_editable_copy_clipboard (GtkEditable *editable,
|
||||
|
@ -75,19 +75,19 @@ static gint gtk_entry_position (GtkEntry *entry,
|
||||
gint x);
|
||||
void gtk_entry_adjust_scroll (GtkEntry *entry);
|
||||
static void gtk_entry_grow_text (GtkEntry *entry);
|
||||
static void gtk_entry_insert_text (GtkEditable *editable,
|
||||
static void gtk_entry_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position);
|
||||
static void gtk_entry_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint new_text_length,
|
||||
gint *position);
|
||||
static void gtk_entry_delete_text (GtkEditable *editable,
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
static void gtk_entry_update_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
static gchar *gtk_entry_get_chars (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
|
||||
static gint move_backward_character (gchar *str, gint index);
|
||||
static void gtk_move_forward_character (GtkEntry *entry);
|
||||
@ -107,8 +107,8 @@ static void gtk_select_line (GtkEntry *entry);
|
||||
|
||||
|
||||
static void gtk_entry_set_selection (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start,
|
||||
gint end);
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
static gint entry_signals[LAST_SIGNAL] = { 0 };
|
||||
@ -1383,9 +1383,9 @@ gtk_entry_grow_text (GtkEntry *entry)
|
||||
|
||||
static void
|
||||
gtk_entry_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position)
|
||||
const gchar *new_text,
|
||||
gint new_text_length,
|
||||
gint *position)
|
||||
{
|
||||
gchar *text;
|
||||
gint start_pos;
|
||||
@ -1435,8 +1435,8 @@ gtk_entry_insert_text (GtkEditable *editable,
|
||||
|
||||
static void
|
||||
gtk_entry_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
gchar *text;
|
||||
gint deletion_length;
|
||||
@ -1454,6 +1454,9 @@ gtk_entry_delete_text (GtkEditable *editable,
|
||||
if (editable->selection_end_pos > start_pos)
|
||||
editable->selection_end_pos -= MIN(end_pos, editable->selection_end_pos) - start_pos;
|
||||
|
||||
if (end_pos < 0)
|
||||
end_pos = entry->text_length;
|
||||
|
||||
if ((start_pos < end_pos) &&
|
||||
(start_pos >= 0) &&
|
||||
(end_pos <= entry->text_length))
|
||||
@ -1476,16 +1479,16 @@ gtk_entry_delete_text (GtkEditable *editable,
|
||||
|
||||
static void
|
||||
gtk_entry_update_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
gtk_entry_queue_draw (GTK_ENTRY(editable));
|
||||
}
|
||||
|
||||
gchar *
|
||||
gtk_entry_get_chars (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
gchar *retval;
|
||||
GtkEntry *entry;
|
||||
@ -1496,15 +1499,18 @@ gtk_entry_get_chars (GtkEditable *editable,
|
||||
|
||||
entry = GTK_ENTRY (editable);
|
||||
|
||||
start = MIN(entry->text_length, start);
|
||||
end = MIN(entry->text_length, end);
|
||||
if (end_pos < 0)
|
||||
end_pos = entry->text_length;
|
||||
|
||||
c = entry->text[end];
|
||||
entry->text[end] = '\0';
|
||||
start_pos = MIN(entry->text_length, start_pos);
|
||||
end_pos = MIN(entry->text_length, end_pos);
|
||||
|
||||
retval = g_strdup (&entry->text[start]);
|
||||
c = entry->text[end_pos];
|
||||
entry->text[end_pos] = '\0';
|
||||
|
||||
entry->text[end] = c;
|
||||
retval = g_strdup (&entry->text[start_pos]);
|
||||
|
||||
entry->text[end_pos] = c;
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -1772,11 +1778,14 @@ gtk_select_line (GtkEntry *entry)
|
||||
|
||||
static void
|
||||
gtk_entry_set_selection (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start,
|
||||
gint end)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ENTRY (editable));
|
||||
|
||||
if (end < 0)
|
||||
end = GTK_ENTRY (editable)->text_length;
|
||||
|
||||
editable->selection_start_pos = start;
|
||||
editable->selection_end_pos = end;
|
||||
|
||||
@ -1785,8 +1794,8 @@ gtk_entry_set_selection (GtkEditable *editable,
|
||||
|
||||
void
|
||||
gtk_entry_select_region (GtkEntry *entry,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start,
|
||||
gint end)
|
||||
{
|
||||
gtk_editable_select_region (GTK_EDITABLE(entry), start, end);
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ void gtk_entry_set_position (GtkEntry *entry,
|
||||
gint position);
|
||||
gchar* gtk_entry_get_text (GtkEntry *entry);
|
||||
void gtk_entry_select_region (GtkEntry *entry,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start,
|
||||
gint end);
|
||||
void gtk_entry_set_visibility (GtkEntry *entry,
|
||||
gboolean visible);
|
||||
void gtk_entry_set_editable (GtkEntry *entry,
|
||||
|
123
gtk/gtktext.c
123
gtk/gtktext.c
@ -169,20 +169,20 @@ static void gtk_text_disconnect (GtkAdjustment *adjustment,
|
||||
|
||||
static void gtk_text_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position);
|
||||
static void gtk_text_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint new_text_length,
|
||||
gint *position);
|
||||
static void gtk_text_delete_text (GtkEditable *editable,
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
static void gtk_text_update_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos);
|
||||
gint start_pos,
|
||||
gint end_pos);
|
||||
static gchar *gtk_text_get_chars (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start,
|
||||
gint end);
|
||||
static void gtk_text_set_selection (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end);
|
||||
gint start,
|
||||
gint end);
|
||||
|
||||
/* Event handlers */
|
||||
static void gtk_text_draw (GtkWidget *widget,
|
||||
@ -289,7 +289,7 @@ static void gtk_text_delete_to_line_end (GtkText *text);
|
||||
static void gtk_text_select_word (GtkText *text);
|
||||
static void gtk_text_select_line (GtkText *text);
|
||||
|
||||
#define DEBUG_GTK_TEXT
|
||||
/* #define DEBUG_GTK_TEXT */
|
||||
|
||||
#if defined(DEBUG_GTK_TEXT) && defined(__GNUC__)
|
||||
/* Debugging utilities. */
|
||||
@ -636,6 +636,7 @@ gtk_text_insert (GtkText *text,
|
||||
gint length)
|
||||
{
|
||||
gint i;
|
||||
GtkEditable *editable = GTK_EDITABLE (text);
|
||||
|
||||
gint new_line_count = 1;
|
||||
guint old_height = 0;
|
||||
@ -671,6 +672,11 @@ gtk_text_insert (GtkText *text,
|
||||
if (text->point.index < text->first_line_start_index)
|
||||
text->first_line_start_index += length;
|
||||
|
||||
if (text->point.index < editable->selection_start_pos)
|
||||
editable->selection_start_pos += length;
|
||||
if (text->point.index < editable->selection_end_pos)
|
||||
editable->selection_end_pos += length;
|
||||
|
||||
move_gap_to_point (text);
|
||||
|
||||
if (font == NULL)
|
||||
@ -708,9 +714,10 @@ gtk_text_backward_delete (GtkText *text,
|
||||
|
||||
gint
|
||||
gtk_text_forward_delete (GtkText *text,
|
||||
guint nchars)
|
||||
guint nchars)
|
||||
{
|
||||
guint old_lines, old_height;
|
||||
GtkEditable *editable = GTK_EDITABLE (text);
|
||||
|
||||
g_return_val_if_fail (text != NULL, 0);
|
||||
g_return_val_if_fail (GTK_IS_TEXT (text), 0);
|
||||
@ -738,6 +745,11 @@ gtk_text_forward_delete (GtkText *text,
|
||||
text->first_line_start_index -= nchars;
|
||||
}
|
||||
|
||||
if (text->point.index < editable->selection_start_pos)
|
||||
editable->selection_start_pos -= nchars;
|
||||
if (text->point.index < editable->selection_end_pos)
|
||||
editable->selection_end_pos -= nchars;
|
||||
|
||||
move_gap_to_point (text);
|
||||
|
||||
text->gap_size += nchars;
|
||||
@ -752,42 +764,44 @@ gtk_text_forward_delete (GtkText *text,
|
||||
|
||||
static gchar *
|
||||
gtk_text_get_chars (GtkEditable *editable,
|
||||
guint index,
|
||||
guint nchars)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
GtkText *text;
|
||||
|
||||
gchar *retval;
|
||||
gchar *p;
|
||||
guint n;
|
||||
guint n, nchars;
|
||||
|
||||
if (end_pos < 0)
|
||||
end_pos = TEXT_LENGTH (text);
|
||||
|
||||
g_return_val_if_fail (editable != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_TEXT (editable), NULL);
|
||||
text = GTK_TEXT (editable);
|
||||
|
||||
if (index+nchars > TEXT_LENGTH (text))
|
||||
if (end_pos > TEXT_LENGTH (text))
|
||||
return NULL;
|
||||
|
||||
if (nchars < 0)
|
||||
nchars = TEXT_LENGTH (text) - index;
|
||||
|
||||
nchars = end_pos - start_pos;
|
||||
|
||||
retval = g_new (gchar, nchars+1);
|
||||
p = retval;
|
||||
|
||||
if (index < text->gap_position)
|
||||
if (start_pos < text->gap_position)
|
||||
{
|
||||
n = MIN (text->gap_position - index, nchars);
|
||||
memcpy (p, &text->text[index], n);
|
||||
n = MIN (text->gap_position - start_pos, nchars);
|
||||
memcpy (p, &text->text[start_pos], n);
|
||||
p += n;
|
||||
index += n;
|
||||
start_pos += n;
|
||||
nchars -= n;
|
||||
}
|
||||
|
||||
if (index+nchars >= text->gap_position)
|
||||
if (start_pos+nchars >= text->gap_position)
|
||||
{
|
||||
memcpy (p,
|
||||
text->text + MAX (text->gap_position + text->gap_size,
|
||||
index + text->gap_size),
|
||||
start_pos + text->gap_size),
|
||||
nchars);
|
||||
p += nchars;
|
||||
}
|
||||
@ -1276,9 +1290,8 @@ gtk_text_button_press (GtkWidget *widget,
|
||||
find_mouse_cursor (text, event->x, event->y);
|
||||
draw_cursor (text, FALSE);
|
||||
|
||||
editable->current_pos = text->cursor_mark.index;
|
||||
}
|
||||
|
||||
|
||||
gtk_selection_convert (widget, GDK_SELECTION_PRIMARY,
|
||||
ctext_atom, event->time);
|
||||
}
|
||||
@ -1385,8 +1398,8 @@ gtk_text_insert_1_at_point (GtkText* text, gchar key)
|
||||
static void
|
||||
gtk_text_insert_text (GtkEditable *editable,
|
||||
const gchar *new_text,
|
||||
guint new_text_length,
|
||||
guint *position)
|
||||
gint new_text_length,
|
||||
gint *position)
|
||||
{
|
||||
GtkText *text = GTK_TEXT (editable);
|
||||
|
||||
@ -1398,12 +1411,15 @@ gtk_text_insert_text (GtkEditable *editable,
|
||||
|
||||
static void
|
||||
gtk_text_delete_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
GtkText *text = GTK_TEXT (editable);
|
||||
|
||||
gtk_text_set_point (text, start_pos);
|
||||
if (end_pos < 0)
|
||||
end_pos = TEXT_LENGTH (text);
|
||||
|
||||
gtk_text_forward_delete (text, end_pos - start_pos);
|
||||
}
|
||||
|
||||
@ -1554,14 +1570,20 @@ gtk_text_key_press (GtkWidget *widget,
|
||||
}
|
||||
else if (event->length > 0)
|
||||
{
|
||||
extend_selection = FALSE;
|
||||
|
||||
if (event->length == 1)
|
||||
gtk_text_insert_1_at_point (text, event->string[0]);
|
||||
{
|
||||
gtk_editable_delete_selection (editable);
|
||||
gtk_text_insert_1_at_point (text, event->string[0]);
|
||||
gtk_editable_changed (editable);
|
||||
}
|
||||
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
}
|
||||
editable->current_pos = text->cursor_mark.index;
|
||||
|
||||
if (return_val)
|
||||
{
|
||||
@ -1869,7 +1891,7 @@ compute_lines_pixels (GtkText* text, gint char_count,
|
||||
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;
|
||||
char_count -= CACHE_DATA(line).end.index -CACHE_DATA(line).start.index + 1;
|
||||
|
||||
if (!text->line_wrap || !CACHE_DATA(line).wraps)
|
||||
*lines += 1;
|
||||
@ -2761,6 +2783,7 @@ find_cursor (GtkText* text)
|
||||
&CACHE_DATA(text->current_line),
|
||||
pixel_height_of(text, text->current_line));
|
||||
|
||||
GTK_EDITABLE (text)->current_pos = text->cursor_mark.index;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3007,11 +3030,11 @@ gtk_text_move_backward_word (GtkText *text)
|
||||
undraw_cursor (text, FALSE);
|
||||
|
||||
while ((text->cursor_mark.index > 0) &&
|
||||
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
|
||||
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
|
||||
decrement_mark (&text->cursor_mark);
|
||||
|
||||
while ((text->cursor_mark.index > 0) &&
|
||||
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
|
||||
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
|
||||
decrement_mark (&text->cursor_mark);
|
||||
|
||||
find_cursor (text);
|
||||
@ -4052,8 +4075,8 @@ expose_text (GtkText* text, GdkRectangle *area, gboolean cursor)
|
||||
|
||||
static void
|
||||
gtk_text_update_text (GtkEditable *editable,
|
||||
guint start_pos,
|
||||
guint end_pos)
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
GtkText *text = GTK_TEXT (editable);
|
||||
|
||||
@ -4062,7 +4085,10 @@ gtk_text_update_text (GtkEditable *editable,
|
||||
GdkRectangle area;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
|
||||
if (end_pos < 0)
|
||||
end_pos = TEXT_LENGTH (text);
|
||||
|
||||
gdk_window_get_size (text->text_area, &width, &height);
|
||||
area.x = 0;
|
||||
area.y = -1;
|
||||
@ -4128,15 +4154,20 @@ recompute_geometry (GtkText* text)
|
||||
|
||||
void
|
||||
gtk_text_set_selection (GtkEditable *editable,
|
||||
guint start,
|
||||
guint end)
|
||||
gint start,
|
||||
gint end)
|
||||
{
|
||||
GtkText *text = GTK_TEXT (editable);
|
||||
|
||||
guint start1 = MIN(start,end);
|
||||
guint end1 = MAX(start,end);
|
||||
guint start2 = MIN(editable->selection_start_pos, editable->selection_end_pos);
|
||||
guint end2 = MAX(editable->selection_start_pos, editable->selection_end_pos);
|
||||
guint start1, end1, start2, end2;
|
||||
|
||||
if (end < 0)
|
||||
end = TEXT_LENGTH (text);
|
||||
|
||||
start1 = MIN(start,end);
|
||||
end1 = MAX(start,end);
|
||||
start2 = MIN(editable->selection_start_pos, editable->selection_end_pos);
|
||||
end2 = MAX(editable->selection_start_pos, editable->selection_end_pos);
|
||||
|
||||
if (start2 < start1)
|
||||
{
|
||||
|
@ -177,10 +177,6 @@ gint gtk_text_backward_delete (GtkText *text,
|
||||
gint gtk_text_forward_delete (GtkText *text,
|
||||
guint nchars);
|
||||
|
||||
void gtk_text_select_region (GtkText *entry,
|
||||
guint start,
|
||||
guint end);
|
||||
|
||||
#define GTK_TEXT_INDEX(t, index) \
|
||||
((index) < (t)->gap_position ? (t)->text[index] : \
|
||||
(t)->text[(index) + (t)->gap_size])
|
||||
|
@ -1620,16 +1620,15 @@ create_entry ()
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), "hello world");
|
||||
gtk_entry_select_region (GTK_ENTRY (entry),
|
||||
0, GTK_ENTRY(entry)->text_length);
|
||||
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
|
||||
gtk_box_pack_start (GTK_BOX (box2), entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (entry);
|
||||
|
||||
cb = gtk_combo_new ();
|
||||
gtk_combo_set_popdown_strings (GTK_COMBO (cb), cbitems);
|
||||
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world");
|
||||
gtk_entry_select_region (GTK_ENTRY (GTK_COMBO(cb)->entry),
|
||||
0, GTK_ENTRY(entry)->text_length);
|
||||
gtk_editable_select_region (GTK_EDITABLE (GTK_COMBO(cb)->entry),
|
||||
0, -1);
|
||||
gtk_box_pack_start (GTK_BOX (box2), cb, TRUE, TRUE, 0);
|
||||
gtk_widget_show (cb);
|
||||
|
||||
@ -2782,7 +2781,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->white, NULL,
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->bg[GTK_STATE_NORMAL], NULL,
|
||||
"is\n", -1);
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
|
||||
"a\n", -1);
|
||||
|
@ -12,8 +12,8 @@ pixmap_path "."
|
||||
|
||||
style "default"
|
||||
{
|
||||
fontset = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*,*"
|
||||
base[NORMAL] = { 1.0, 0.8, 0.8 }
|
||||
fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
|
||||
# base[NORMAL] = { 1.0, 0.8, 0.8 }
|
||||
}
|
||||
|
||||
style "window"
|
||||
|
@ -1620,16 +1620,15 @@ create_entry ()
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), "hello world");
|
||||
gtk_entry_select_region (GTK_ENTRY (entry),
|
||||
0, GTK_ENTRY(entry)->text_length);
|
||||
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
|
||||
gtk_box_pack_start (GTK_BOX (box2), entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (entry);
|
||||
|
||||
cb = gtk_combo_new ();
|
||||
gtk_combo_set_popdown_strings (GTK_COMBO (cb), cbitems);
|
||||
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world");
|
||||
gtk_entry_select_region (GTK_ENTRY (GTK_COMBO(cb)->entry),
|
||||
0, GTK_ENTRY(entry)->text_length);
|
||||
gtk_editable_select_region (GTK_EDITABLE (GTK_COMBO(cb)->entry),
|
||||
0, -1);
|
||||
gtk_box_pack_start (GTK_BOX (box2), cb, TRUE, TRUE, 0);
|
||||
gtk_widget_show (cb);
|
||||
|
||||
@ -2782,7 +2781,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->white, NULL,
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->bg[GTK_STATE_NORMAL], NULL,
|
||||
"is\n", -1);
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
|
||||
"a\n", -1);
|
||||
|
@ -12,8 +12,8 @@ pixmap_path "."
|
||||
|
||||
style "default"
|
||||
{
|
||||
fontset = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*,*"
|
||||
base[NORMAL] = { 1.0, 0.8, 0.8 }
|
||||
fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
|
||||
# base[NORMAL] = { 1.0, 0.8, 0.8 }
|
||||
}
|
||||
|
||||
style "window"
|
||||
|
Loading…
Reference in New Issue
Block a user