Added GdkAtom argument for copy_clipboard() and paste_clipboard()

master
Yevgen Muntyan 2005-07-17 16:41:15 +00:00
parent b4d02e60d8
commit 80377391a6
4 changed files with 54 additions and 13 deletions

View File

@ -132,13 +132,15 @@ gboolean moo_term_key_press (GtkWidget *widget,
case GDK_Insert: case GDK_Insert:
if (modifiers & GDK_SHIFT_MASK) if (modifiers & GDK_SHIFT_MASK)
{ {
moo_term_paste_clipboard (term); moo_term_paste_clipboard (term,
GDK_SELECTION_CLIPBOARD);
handled = TRUE; handled = TRUE;
suppress_meta_esc = TRUE; suppress_meta_esc = TRUE;
} }
else if (modifiers & GDK_CONTROL_MASK) else if (modifiers & GDK_CONTROL_MASK)
{ {
moo_term_copy_clipboard (term); moo_term_copy_clipboard (term,
GDK_SELECTION_CLIPBOARD);
handled = TRUE; handled = TRUE;
suppress_meta_esc = TRUE; suppress_meta_esc = TRUE;
} }

View File

@ -56,6 +56,12 @@ char *term_selection_get_text (MooTerm *term)
} }
#define HOWMANY(x, y) (((x) + (y) - 1) / y())
#define CALC_ROW(y, char_height) (HOWMANY (y + 1, char_height) - 1)
#define CALC_COL(x, char_width) (HOWMANY (x + 1, char_width) - 1)
#define DIFF(x, y) (ABS ((x) - (y)))
gboolean moo_term_button_press (GtkWidget *widget, gboolean moo_term_button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
@ -65,7 +71,26 @@ gboolean moo_term_button_press (GtkWidget *widget,
moo_term_set_pointer_visible (term, TRUE); moo_term_set_pointer_visible (term, TRUE);
return FALSE; if (event->button != 1)
{
if (event->type != GDK_BUTTON_PRESS)
return TRUE;
switch (event->button)
{
case 2:
moo_term_paste_clipboard (term, GDK_SELECTION_PRIMARY);
break;
case 3:
moo_term_do_popup_menu (term, event);
break;
}
return TRUE;
}
return TRUE;
} }
@ -78,7 +103,7 @@ gboolean moo_term_button_release (GtkWidget *widget,
moo_term_set_pointer_visible (term, TRUE); moo_term_set_pointer_visible (term, TRUE);
return FALSE; return TRUE;
} }
@ -91,5 +116,5 @@ gboolean moo_term_motion_notify (GtkWidget *widget,
moo_term_set_pointer_visible (term, TRUE); moo_term_set_pointer_visible (term, TRUE);
return FALSE; return TRUE;
} }

View File

@ -463,9 +463,14 @@ static void scrollback_changed (MooTerm *term,
guint scrollback = buf_scrollback (term->priv->buffer); guint scrollback = buf_scrollback (term->priv->buffer);
if (term->priv->_scrolled && term->priv->_top_line > scrollback) if (term->priv->_scrolled && term->priv->_top_line > scrollback)
{
term_selection_clear (term);
scroll_to_bottom (term, TRUE); scroll_to_bottom (term, TRUE);
}
else else
{
update_adjustment (term); update_adjustment (term);
}
} }
} }
@ -748,13 +753,19 @@ void moo_term_feed_child (MooTerm *term,
} }
void moo_term_copy_clipboard (MooTerm *term) void moo_term_copy_clipboard (MooTerm *term,
GdkAtom selection)
{ {
char *text = term_selection_get_text (term); GtkClipboard *cb;
char *text;
text = term_selection_get_text (term);
if (text && *text) if (text && *text)
gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), {
text, -1); cb = gtk_clipboard_get (selection);
gtk_clipboard_set_text (cb, text, -1);
}
if (text) if (text)
{ {
@ -770,14 +781,15 @@ void moo_term_ctrl_c (MooTerm *term)
} }
void moo_term_paste_clipboard (MooTerm *term) void moo_term_paste_clipboard (MooTerm *term,
GdkAtom selection)
{ {
GtkClipboard *cb; GtkClipboard *cb;
char *text; char *text;
g_return_if_fail (MOO_IS_TERM (term)); g_return_if_fail (MOO_IS_TERM (term));
cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); cb = gtk_clipboard_get (selection);
text = gtk_clipboard_wait_for_text (cb); text = gtk_clipboard_wait_for_text (cb);
if (text) if (text)

View File

@ -90,8 +90,10 @@ void moo_term_scroll_lines (MooTerm *term,
void moo_term_scroll_pages (MooTerm *term, void moo_term_scroll_pages (MooTerm *term,
int pages); int pages);
void moo_term_copy_clipboard (MooTerm *term); void moo_term_copy_clipboard (MooTerm *term,
void moo_term_paste_clipboard (MooTerm *term); GdkAtom selection);
void moo_term_paste_clipboard (MooTerm *term,
GdkAtom selection);
void moo_term_ctrl_c (MooTerm *term); void moo_term_ctrl_c (MooTerm *term);