moo_edit_get_selection(), moo_edit_get_text()
This commit is contained in:
parent
fb55184c33
commit
c74f0e16eb
@ -1002,3 +1002,43 @@ GType moo_edit_file_info_get_type (void)
|
||||
(GBoxedFreeFunc)moo_edit_file_info_free);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
char *moo_edit_get_selection (MooEdit *edit)
|
||||
{
|
||||
GtkTextBuffer *buf;
|
||||
GtkTextIter start, end;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
||||
|
||||
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (edit));
|
||||
|
||||
if (gtk_text_buffer_get_selection_bounds (buf, &start, &end))
|
||||
return gtk_text_buffer_get_text (buf, &start, &end, TRUE);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
char *moo_edit_get_text (MooEdit *edit)
|
||||
{
|
||||
GtkTextBuffer *buf;
|
||||
GtkTextIter start, end;
|
||||
char *text;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
||||
|
||||
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (edit));
|
||||
gtk_text_buffer_get_bounds (buf, &start, &end);
|
||||
text = gtk_text_buffer_get_text (buf, &start, &end, TRUE);
|
||||
|
||||
if (text && *text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +196,10 @@ gboolean moo_edit_get_read_only (MooEdit *edit);
|
||||
void moo_edit_set_read_only (MooEdit *edit,
|
||||
gboolean readonly);
|
||||
|
||||
void moo_edit_delete_selection (MooEdit *edit);
|
||||
char *moo_edit_get_selection (MooEdit *edit);
|
||||
char *moo_edit_get_text (MooEdit *edit);
|
||||
|
||||
void moo_edit_delete_selection (MooEdit *edit);
|
||||
|
||||
MooEditFileInfo *moo_edit_file_info_new (const char *filename,
|
||||
const char *encoding);
|
||||
|
Loading…
x
Reference in New Issue
Block a user