1
1

gmc mcedit selection now works

Этот коммит содержится в:
Paul Sheer 1998-12-16 12:35:43 +00:00
родитель 9d3578f803
Коммит 99c03a1cda
4 изменённых файлов: 115 добавлений и 48 удалений

Просмотреть файл

@ -2435,12 +2435,10 @@ int edit_copy_to_X_buf_cmd (WEdit * edit)
return 1; return 1;
} }
#ifdef GTK #ifdef GTK
#if 0 gtk_selection_owner_set (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
gtk_set_selection_owner (CWindowOf (edit->widget)); edit->widget->editable.selection_start_pos = start_mark;
#else edit->widget->editable.selection_end_pos = end_mark;
/* *** */ edit->widget->editable.has_selection = TRUE;
printf ("gtk_set_selection_owner\n");
#endif
#else #else
XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime); XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime);
#endif #endif
@ -2455,16 +2453,15 @@ int edit_cut_to_X_buf_cmd (WEdit * edit)
return 0; return 0;
edit_XStore_block (edit, start_mark, end_mark); edit_XStore_block (edit, start_mark, end_mark);
if (!edit_save_block_to_clip_file (edit, start_mark, end_mark)) { if (!edit_save_block_to_clip_file (edit, start_mark, end_mark)) {
edit_error_dialog (_(" Cut to clipboard "), _(" Unable to save to file. ")); edit_error_dialog (_ (" Cut to clipboard "), _ (" Unable to save to file. "));
return 1; return 1;
} }
edit_block_delete_cmd (edit); edit_block_delete_cmd (edit);
#ifdef GTK #ifdef GTK
#if 0 gtk_selection_owner_set (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
gtk_set_selection_owner (CWindowOf (edit->widget)); edit->widget->editable.selection_start_pos = start_mark;
#else edit->widget->editable.selection_end_pos = end_mark;
printf ("gtk_set_selection_owner\n"); edit->widget->editable.has_selection = TRUE;
#endif
#else #else
XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime); XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime);
#endif #endif
@ -2487,11 +2484,8 @@ void edit_paste_from_X_buf_cmd (WEdit * edit)
#endif #endif
else else
#ifdef GTK #ifdef GTK
#if 0 gtk_selection_convert (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY,
gtk_convert_selection (); gdk_atom_intern ("COMPOUND_TEXT", FALSE), GDK_CURRENT_TIME);
#else
/* *** */
#endif
#else #else
XConvertSelection (CDisplay, XA_PRIMARY, XA_STRING, XConvertSelection (CDisplay, XA_PRIMARY, XA_STRING,
XInternAtom (CDisplay, "VT_SELECTION", False), XInternAtom (CDisplay, "VT_SELECTION", False),

Просмотреть файл

@ -137,7 +137,7 @@ static void move_mark (WEdit *edit)
edit_mark_cmd (edit, 0); edit_mark_cmd (edit, 0);
} }
static void release_mark (WEdit *edit, XEvent *event) static void release_mark (WEdit * edit, XEvent * event)
{ {
if (edit->mark2 < 0) if (edit->mark2 < 0)
edit_mark_cmd (edit, 0); edit_mark_cmd (edit, 0);
@ -146,13 +146,21 @@ static void release_mark (WEdit *edit, XEvent *event)
if (edit->mark1 != edit->mark2 && event) { if (edit->mark1 != edit->mark2 && event) {
edit_get_selection (edit); edit_get_selection (edit);
#ifdef GTK #ifdef GTK
{
#if 0 #if 0
/* *** */ long start_mark = 0, end_mark = 0;
gtk_set_selection_owner (CWindowOf (edit->widget)); edit->widget->editable.has_selection = !eval_marks (edit, &start_mark, &end_mark);
edit->widget->editable.selection_start_pos = start_mark;
edit->widget->editable.selection_end_pos = end_mark;
if (edit->widget->editable.has_selection)
#endif #endif
gtk_selection_owner_set (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
}
#else #else
XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), event->xbutton.time); XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), event->xbutton.time);
#endif #endif
} else {
edit->widget->editable.has_selection = TRUE;
} }
} }
@ -589,6 +597,7 @@ void selection_send (XSelectionRequestEvent * rq)
/*{{{ paste selection */ /*{{{ paste selection */
#ifndef GTK
/* /*
* Respond to a notification that a primary selection has been sent * Respond to a notification that a primary selection has been sent
*/ */
@ -606,20 +615,6 @@ void paste_prop (void *data, void (*insert) (void *, int), Window win, unsigned
Atom actual_type; Atom actual_type;
int actual_fmt, i; int actual_fmt, i;
unsigned long nitems; unsigned long nitems;
#ifdef GTK
#if 0
/* *** */
if (gtk_get_window_property (win, prop,
nread / 4, 65536, delete,
AnyPropertyType, &actual_type, &actual_fmt,
&nitems, &bytes_after,
&s) != Success) {
XFree (s);
return;
}
#endif
#else
if (XGetWindowProperty (CDisplay, win, prop, if (XGetWindowProperty (CDisplay, win, prop,
nread / 4, 65536, delete, nread / 4, 65536, delete,
AnyPropertyType, &actual_type, &actual_fmt, AnyPropertyType, &actual_type, &actual_fmt,
@ -628,7 +623,6 @@ void paste_prop (void *data, void (*insert) (void *, int), Window win, unsigned
XFree (s); XFree (s);
return; return;
} }
#endif
nread += nitems; nread += nitems;
for (i = 0; i < nitems; i++) for (i = 0; i < nitems; i++)
(*insert) (data, s[i]); (*insert) (data, s[i]);
@ -647,6 +641,8 @@ void selection_paste (WEdit * edit, Window win, unsigned prop, int delete)
edit->force |= REDRAW_COMPLETELY | REDRAW_LINE; edit->force |= REDRAW_COMPLETELY | REDRAW_LINE;
} }
#endif
/*}}} */ /*}}} */
void selection_clear (void) void selection_clear (void)

Просмотреть файл

@ -1,4 +1,5 @@
/* gtkedit.c - front end for gtk/gnome version /* gtkedit.c -
front end for gtk/gnome version
Copyright (C) 1996, 1997 the Free Software Foundation Copyright (C) 1996, 1997 the Free Software Foundation
@ -533,6 +534,7 @@ static gint
GtkEdit *edit; GtkEdit *edit;
GtkEditable *editable; GtkEditable *editable;
static GdkAtom ctext_atom = GDK_NONE; static GdkAtom ctext_atom = GDK_NONE;
long start_mark = 0, end_mark = 0;
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_EDIT (widget), FALSE); g_return_val_if_fail (GTK_IS_EDIT (widget), FALSE);
@ -573,6 +575,14 @@ static gint
xevent.xbutton.state = event->state; xevent.xbutton.state = event->state;
edit_mouse_mark (edit->editor, &xevent, double_click); edit_mouse_mark (edit->editor, &xevent, double_click);
editable->current_pos = edit->editor->curs1;
editable->has_selection = !eval_marks (edit->editor, &start_mark, &end_mark);
editable->selection_start_pos = start_mark;
editable->selection_end_pos = end_mark;
if (event->type == GDK_BUTTON_PRESS && event->button == 2)
gtk_selection_convert (GTK_WIDGET (edit), GDK_SELECTION_PRIMARY,
ctext_atom, event->time);
return FALSE; return FALSE;
} }
@ -691,6 +701,67 @@ static void get_home_dir (void)
abort (); abort ();
} }
static gchar *gtk_edit_get_chars (GtkEditable * editable,
gint start_pos,
gint end_pos)
{
GtkEdit *edit;
gchar *retval;
int i;
g_return_val_if_fail (editable != NULL, NULL);
g_return_val_if_fail (GTK_IS_EDIT (editable), NULL);
edit = GTK_EDIT (editable);
if (end_pos < 0)
end_pos = edit->editor->last_byte;
if ((start_pos < 0) ||
(end_pos > edit->editor->last_byte) ||
(end_pos < start_pos))
return 0;
retval = malloc (end_pos - start_pos + 1);
retval[end_pos - start_pos] = '\0';
for (i = 0; start_pos < end_pos; start_pos++, i++)
retval[i] = (gchar) edit_get_byte (edit->editor, start_pos);
return retval;
}
static void gtk_edit_set_selection (GtkEditable * editable,
gint start,
gint end)
{
GtkEdit *edit = GTK_EDIT (editable);
guint start1, end1, start2, end2;
if (end < 0)
end = edit->editor->last_byte;
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) {
guint tmp;
tmp = start1;
start1 = start2;
start2 = tmp;
tmp = end1;
end1 = end2;
end2 = tmp;
}
editable->selection_start_pos = start;
editable->selection_end_pos = end;
editable->has_selection = TRUE;
return;
}
static void gtk_edit_insert_text (GtkEditable * editable,
const gchar * new_text,
gint new_text_length,
gint * position)
{
GtkEdit *edit = GTK_EDIT (editable);
edit_cursor_move (edit->editor, *position - edit->editor->curs1);
while (new_text_length--)
edit_insert_ahead (edit->editor, new_text[new_text_length]);
*position = edit->editor->curs1;
}
static void gtk_edit_class_init (GtkEditClass * class) static void gtk_edit_class_init (GtkEditClass * class)
{ {
@ -726,19 +797,19 @@ static void gtk_edit_class_init (GtkEditClass * class)
widget_class->focus_in_event = 0; widget_class->focus_in_event = 0;
widget_class->focus_out_event = 0; widget_class->focus_out_event = 0;
#if 0
editable_class->insert_text = gtk_edit_insert_text; editable_class->insert_text = gtk_edit_insert_text;
#if 0
editable_class->delete_text = gtk_edit_delete_text; editable_class->delete_text = gtk_edit_delete_text;
editable_class->update_text = gtk_edit_update_text; editable_class->update_text = gtk_edit_update_text;
editable_class->get_chars = gtk_edit_get_chars; #else
editable_class->set_selection = gtk_edit_set_selection;
#endif
editable_class->set_position = gtk_edit_set_position;
editable_class->insert_text = 0;
editable_class->delete_text = 0; editable_class->delete_text = 0;
editable_class->update_text = 0; editable_class->update_text = 0;
editable_class->get_chars = 0; #endif
editable_class->get_chars = gtk_edit_get_chars;
editable_class->set_selection = gtk_edit_set_selection;
editable_class->set_position = gtk_edit_set_position;
#if 0 #if 0
editable_class->set_position = 0; editable_class->set_position = 0;

Просмотреть файл

@ -956,7 +956,7 @@ void edit_free_syntax_rules (WEdit * edit)
syntax_free (edit->rules); syntax_free (edit->rules);
} }
#define CURRENT_SYNTAX_RULES_VERSION "43" #define CURRENT_SYNTAX_RULES_VERSION "44"
char *syntax_text[] = { char *syntax_text[] = {
"# syntax rules version " CURRENT_SYNTAX_RULES_VERSION, "# syntax rules version " CURRENT_SYNTAX_RULES_VERSION,
@ -1051,9 +1051,6 @@ char *syntax_text[] = {
"###############################################################################", "###############################################################################",
"file ..\\*\\\\.sh$ Shell\\sScript ^#!\\s\\*/.\\*/(ksh|bash|sh|pdkzsh)$", "file ..\\*\\\\.sh$ Shell\\sScript ^#!\\s\\*/.\\*/(ksh|bash|sh|pdkzsh)$",
"", "",
"wholechars right abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"wholechars left abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"",
"context default", "context default",
" keyword whole for yellow/24", " keyword whole for yellow/24",
" keyword whole in yellow/24", " keyword whole in yellow/24",
@ -1170,6 +1167,9 @@ char *syntax_text[] = {
"", "",
" keyword wholeleft function*() brightblue/11", " keyword wholeleft function*() brightblue/11",
"", "",
"wholechars right abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"wholechars left abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"",
" keyword whole arch cyan/14", " keyword whole arch cyan/14",
" keyword whole ash cyan/14", " keyword whole ash cyan/14",
" keyword whole awk cyan/14", " keyword whole awk cyan/14",
@ -1259,6 +1259,9 @@ char *syntax_text[] = {
" keyword whole zcat cyan/14", " keyword whole zcat cyan/14",
" keyword whole zsh cyan/14", " keyword whole zsh cyan/14",
"", "",
"wholechars right abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",
"wholechars left abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",
"",
"context # \\n brown/22", "context # \\n brown/22",
"", "",
"context exclusive whole <\\[\\s\\\\\\]EOF EOF green/6", "context exclusive whole <\\[\\s\\\\\\]EOF EOF green/6",
@ -1452,6 +1455,9 @@ char *syntax_text[] = {
"", "",
" keyword $ brightgreen/16", " keyword $ brightgreen/16",
"", "",
"wholechars right abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"wholechars left abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._",
"",
" keyword whole arch cyan/14", " keyword whole arch cyan/14",
" keyword whole ash cyan/14", " keyword whole ash cyan/14",
" keyword whole awk cyan/14", " keyword whole awk cyan/14",