moo_term_get_selection_bounds()

master
Yevgen Muntyan 2006-03-15 16:16:20 -06:00
parent 89cf6424d2
commit 7b479ab420
5 changed files with 42 additions and 9 deletions

View File

@ -369,6 +369,15 @@
)
)
(define-method get_selection_bounds
(of-object "MooTerm")
(c-name "moo_term_get_selection_bounds")
(return-type "gboolean")
(parameters
'("MooTermIter*" "start")
'("MooTermIter*" "end")
)
)
;; From mooterm.h

View File

@ -348,3 +348,22 @@ _wrap_moo_term_iter_tp_setattr (PyGBoxed *self, char *attr, PyObject *value)
PyErr_Format (PyExc_AttributeError, "no attribute '%s'", attr);
return -1;
}
%%
override moo_term_get_selection_bounds noargs
static PyObject *
_wrap_moo_term_get_selection_bounds (PyGObject *self)
{
MooTermIter start, end;
if (moo_term_get_selection_bounds (MOO_TERM (self->obj), &start, &end))
{
PyObject *tuple = PyTuple_New (2);
PyTuple_SET_ITEM (tuple, 0, pyg_boxed_new (MOO_TYPE_TERM_ITER, &start, TRUE, TRUE));
PyTuple_SET_ITEM (tuple, 1, pyg_boxed_new (MOO_TYPE_TERM_ITER, &end, TRUE, TRUE));
return tuple;
}
else
{
return_None;
}
}

View File

@ -22,9 +22,6 @@
#include "mooedit/mootextview.h"
gboolean _moo_term_get_selection_bounds (MooTerm *term,
MooTermIter *sel_start,
MooTermIter *sel_end);
void _moo_term_iter_order (MooTermIter *first,
MooTermIter *second);
gboolean _moo_term_iter_in_range (const MooTermIter *iter,

View File

@ -399,7 +399,7 @@ _moo_term_button_press (GtkWidget *widget,
#if 0
/* TODO: implement drag'n'drop */
/* if clicked in selected, start drag */
if (_moo_term_get_selection_bounds (term, &sel_start, &sel_end))
if (moo_term_get_selection_bounds (term, &sel_start, &sel_end))
{
moo_term_iter_order (&sel_start, &sel_end);
if (_moo_term_iter_in_range (&iter, &sel_start, &sel_end)
@ -438,7 +438,7 @@ _moo_term_button_press (GtkWidget *widget,
{
MooTermIter bound;
if (_moo_term_get_selection_bounds (term, NULL, NULL))
if (moo_term_get_selection_bounds (term, NULL, NULL))
{
/* it may happen sometimes, if you click fast enough */
_moo_term_select_range (term, &iter, &iter);
@ -864,12 +864,16 @@ moo_term_get_iter_at_pos (MooTerm *term,
gboolean
_moo_term_get_selection_bounds (MooTerm *term,
MooTermIter *sel_start,
MooTermIter *sel_end)
moo_term_get_selection_bounds (MooTerm *term,
MooTermIter *sel_start,
MooTermIter *sel_end)
{
Segment *selection = term->priv->selection;
g_return_val_if_fail (MOO_IS_TERM (term), FALSE);
selection = term->priv->selection;
if (sel_start)
*sel_start = selection->start;
@ -958,7 +962,7 @@ _moo_term_cell_selected (MooTerm *term,
{
MooTermIter start, end, iter;
if (_moo_term_get_selection_bounds (term, &start, &end))
if (moo_term_get_selection_bounds (term, &start, &end))
{
_moo_term_iter_order (&start, &end);
FILL_ITER (&iter, term, row, col);

View File

@ -43,6 +43,10 @@ guint moo_term_get_line_count (MooTerm *term);
MooTermLine *moo_term_get_line (MooTerm *term,
guint line_no);
gboolean moo_term_get_selection_bounds (MooTerm *term,
MooTermIter *start,
MooTermIter *end);
void moo_term_set_line_data (MooTerm *term,
MooTermLine *line,
const char *key,