Preparation for multiple views
This commit is contained in:
parent
5c4b590d13
commit
e117b0845d
@ -59,9 +59,9 @@ abcdefghij
|
||||
doc.replace_text(doc.get_start_pos(), doc.get_end_pos(), text)
|
||||
tassert(doc.get_start_pos().get_offset() == 1)
|
||||
tassert(doc.get_end_pos().get_offset() == #text + 1)
|
||||
doc.select_text(2, 3)
|
||||
doc.select_range(2, 3)
|
||||
tassert(doc.get_selected_text() == 'b')
|
||||
doc.select_text(3, 4)
|
||||
doc.select_range(3, 4)
|
||||
tassert(doc.get_selected_text() == 'c')
|
||||
doc.select_lines(1)
|
||||
tassert(doc.get_selected_text() == 'abcdefg\n')
|
||||
|
@ -17,17 +17,17 @@ tassert_eq(doc.get_cursor_pos().get_offset(), 3)
|
||||
tassert_eq(doc.get_cursor_pos(), doc.get_selection_end_pos())
|
||||
tassert_eq(doc.get_selection_start_pos(), doc.get_selection_end_pos())
|
||||
tassert_eq(doc.get_selected_text(), '')
|
||||
doc.set_selection(1, 3)
|
||||
doc.select_range(1, 3)
|
||||
tassert_eq(doc.get_cursor_pos().get_offset(), 1)
|
||||
tassert_eq(doc.get_selection_start_pos().get_offset(), 1)
|
||||
tassert_eq(doc.get_selection_end_pos().get_offset(), 3)
|
||||
tassert_eq(doc.get_selected_text(), 'ab')
|
||||
doc.set_selection(1, 2)
|
||||
doc.select_range(1, 2)
|
||||
tassert_eq(doc.get_cursor_pos().get_offset(), 1)
|
||||
tassert_eq(doc.get_selection_start_pos().get_offset(), 1)
|
||||
tassert_eq(doc.get_selection_end_pos().get_offset(), 2)
|
||||
tassert_eq(doc.get_selected_text(), 'a')
|
||||
doc.set_selection(2, 1)
|
||||
doc.select_range(2, 1)
|
||||
tassert_eq(doc.get_cursor_pos().get_offset(), 2)
|
||||
tassert_eq(doc.get_selection_start_pos().get_offset(), 1)
|
||||
tassert_eq(doc.get_selection_end_pos().get_offset(), 2)
|
||||
@ -35,7 +35,7 @@ tassert_eq(doc.get_selected_text(), 'a')
|
||||
|
||||
doc.set_text('abcdef')
|
||||
tassert_eq(doc.get_text(), 'abcdef')
|
||||
doc.set_selection(3, 5)
|
||||
doc.select_range(3, 5)
|
||||
tassert_eq(doc.get_selected_text(), 'cd')
|
||||
doc.delete_selected_text()
|
||||
tassert_eq(doc.get_selected_text(), '')
|
||||
@ -54,7 +54,7 @@ tassert_eq(doc.get_text(), 'af')
|
||||
tassert_eq(doc.get_cursor_pos().get_offset(), 2)
|
||||
|
||||
doc.set_text('abcdef')
|
||||
doc.set_selection(2, 6)
|
||||
doc.select_range(2, 6)
|
||||
doc.replace_selected_text('BCDE')
|
||||
tassert_eq(doc.get_text(), 'aBCDEf')
|
||||
doc.set_cursor_pos(1)
|
||||
|
@ -349,7 +349,6 @@ try_load (MooEdit *edit,
|
||||
const char *encoding,
|
||||
GError **error)
|
||||
{
|
||||
MooEditView *view;
|
||||
GtkTextBuffer *buffer;
|
||||
gboolean enable_highlight;
|
||||
LoadResult result = ERROR_FILE;
|
||||
@ -358,14 +357,13 @@ try_load (MooEdit *edit,
|
||||
g_return_val_if_fail (G_IS_FILE (file), result);
|
||||
g_return_val_if_fail (encoding && encoding[0], result);
|
||||
|
||||
view = moo_edit_get_view (edit);
|
||||
buffer = moo_edit_get_buffer (edit);
|
||||
gtk_text_buffer_set_text (buffer, "", 0);
|
||||
|
||||
g_object_get (view, "enable-highlight", &enable_highlight, (char*) 0);
|
||||
g_object_set (view, "enable-highlight", FALSE, (char*) 0);
|
||||
g_object_get (buffer, "highlight-syntax", &enable_highlight, (char*) 0);
|
||||
g_object_set (buffer, "highlight-syntax", FALSE, (char*) 0);
|
||||
result = do_load (edit, file, encoding, error);
|
||||
g_object_set (view, "enable-highlight", enable_highlight, (char*) 0);
|
||||
g_object_set (buffer, "highlight-syntax", enable_highlight, (char*) 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -407,7 +405,6 @@ moo_edit_load_local (MooEdit *edit,
|
||||
{
|
||||
GtkTextIter start;
|
||||
GtkTextBuffer *buffer;
|
||||
MooTextView *view;
|
||||
gboolean undo;
|
||||
LoadResult result = ERROR_FILE;
|
||||
char *freeme = NULL;
|
||||
@ -424,7 +421,6 @@ moo_edit_load_local (MooEdit *edit,
|
||||
else
|
||||
undo = TRUE;
|
||||
|
||||
view = MOO_TEXT_VIEW (moo_edit_get_view (edit));
|
||||
buffer = moo_edit_get_buffer (edit);
|
||||
|
||||
block_buffer_signals (edit);
|
||||
@ -432,7 +428,7 @@ moo_edit_load_local (MooEdit *edit,
|
||||
if (undo)
|
||||
gtk_text_buffer_begin_user_action (buffer);
|
||||
else
|
||||
moo_text_view_begin_non_undoable_action (view);
|
||||
moo_text_buffer_begin_non_undoable_action (MOO_TEXT_BUFFER (buffer));
|
||||
|
||||
moo_text_buffer_begin_non_interactive_action (MOO_TEXT_BUFFER (buffer));
|
||||
|
||||
@ -510,7 +506,7 @@ moo_edit_load_local (MooEdit *edit,
|
||||
if (undo)
|
||||
gtk_text_buffer_end_user_action (buffer);
|
||||
else
|
||||
moo_text_view_end_non_undoable_action (view);
|
||||
moo_text_buffer_end_non_undoable_action (MOO_TEXT_BUFFER (buffer));
|
||||
|
||||
moo_text_buffer_end_non_interactive_action (MOO_TEXT_BUFFER (buffer));
|
||||
|
||||
@ -771,12 +767,10 @@ moo_edit_reload_local (MooEdit *edit,
|
||||
GtkTextBuffer *buffer;
|
||||
gboolean result, enable_highlight;
|
||||
GFile *file;
|
||||
MooEditView *view;
|
||||
|
||||
file = moo_edit_get_file (edit);
|
||||
moo_return_error_if_fail (G_IS_FILE (file));
|
||||
|
||||
view = moo_edit_get_view (edit);
|
||||
buffer = moo_edit_get_buffer (edit);
|
||||
|
||||
block_buffer_signals (edit);
|
||||
@ -784,15 +778,15 @@ moo_edit_reload_local (MooEdit *edit,
|
||||
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
gtk_text_buffer_delete (buffer, &start, &end);
|
||||
g_object_get (view, "enable-highlight", &enable_highlight, (char*) 0);
|
||||
g_object_set (view, "enable-highlight", FALSE, (char*) 0);
|
||||
g_object_get (buffer, "highlight-syntax", &enable_highlight, (char*) 0);
|
||||
g_object_set (buffer, "highlight-syntax", FALSE, (char*) 0);
|
||||
|
||||
result = _moo_edit_load_file (edit, file,
|
||||
encoding ? encoding : edit->priv->encoding,
|
||||
NULL,
|
||||
error);
|
||||
|
||||
g_object_set (view, "enable-highlight", enable_highlight, (char*) 0);
|
||||
g_object_set (buffer, "highlight-syntax", enable_highlight, (char*) 0);
|
||||
gtk_text_buffer_end_user_action (buffer);
|
||||
unblock_buffer_signals (edit);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "mooedit/mooedit-script.h"
|
||||
#include "mooedit/mootextview.h"
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooutils/mooutils.h"
|
||||
|
||||
/**
|
||||
@ -9,7 +10,7 @@ gboolean
|
||||
moo_edit_can_undo (MooEdit *doc)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (doc), FALSE);
|
||||
return moo_text_view_can_undo (MOO_TEXT_VIEW (moo_edit_get_view (doc)));
|
||||
return moo_text_buffer_can_undo (MOO_TEXT_BUFFER (moo_edit_get_buffer (doc)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -19,7 +20,7 @@ gboolean
|
||||
moo_edit_can_redo (MooEdit *doc)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (doc), FALSE);
|
||||
return moo_text_view_can_redo (MOO_TEXT_VIEW (moo_edit_get_view (doc)));
|
||||
return moo_text_buffer_can_redo (MOO_TEXT_BUFFER (moo_edit_get_buffer (doc)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +50,7 @@ void
|
||||
moo_edit_begin_non_undoable_action (MooEdit *doc)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
moo_text_view_begin_non_undoable_action (MOO_TEXT_VIEW (moo_edit_get_view (doc)));
|
||||
moo_text_buffer_begin_non_undoable_action (MOO_TEXT_BUFFER (moo_edit_get_buffer (doc)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +80,7 @@ void
|
||||
moo_edit_end_non_undoable_action (MooEdit *doc)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
moo_text_view_end_non_undoable_action (MOO_TEXT_VIEW (moo_edit_get_view (doc)));
|
||||
moo_text_buffer_end_non_undoable_action (MOO_TEXT_BUFFER (moo_edit_get_buffer (doc)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,18 +176,6 @@ moo_edit_set_cursor_pos (MooEdit *doc,
|
||||
gtk_text_buffer_place_cursor (moo_edit_get_buffer (doc), pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* moo_edit_set_selection:
|
||||
**/
|
||||
void
|
||||
moo_edit_set_selection (MooEdit *doc,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
gtk_text_buffer_select_range (moo_edit_get_buffer (doc), start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* moo_edit_get_char_count:
|
||||
**/
|
||||
@ -564,14 +553,14 @@ moo_edit_paste (MooEdit *doc)
|
||||
}
|
||||
|
||||
/**
|
||||
* moo_edit_select_text:
|
||||
* moo_edit_select_range:
|
||||
*
|
||||
* Select text from @start to @end.
|
||||
**/
|
||||
void
|
||||
moo_edit_select_text (MooEdit *doc,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end)
|
||||
moo_edit_select_range (MooEdit *doc,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
g_return_if_fail (start != NULL);
|
||||
@ -848,6 +837,5 @@ moo_edit_replace_selected_text (MooEdit *doc,
|
||||
gboolean
|
||||
moo_edit_has_selection (MooEdit *doc)
|
||||
{
|
||||
MooEditView *view = moo_edit_get_view (doc);
|
||||
return moo_text_view_has_selection (MOO_TEXT_VIEW (view));
|
||||
return moo_text_buffer_has_selection (MOO_TEXT_BUFFER (moo_edit_get_buffer (doc)));
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ void moo_edit_set_cursor_pos (MooEdit *doc,
|
||||
const GtkTextIter *pos);
|
||||
GtkTextIter *moo_edit_get_selection_start_pos (MooEdit *doc);
|
||||
GtkTextIter *moo_edit_get_selection_end_pos (MooEdit *doc);
|
||||
void moo_edit_set_selection (MooEdit *doc,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end);
|
||||
|
||||
int moo_edit_get_char_count (MooEdit *doc);
|
||||
int moo_edit_get_line_count (MooEdit *doc);
|
||||
@ -66,7 +63,7 @@ void moo_edit_cut (MooEdit *doc);
|
||||
void moo_edit_copy (MooEdit *doc);
|
||||
void moo_edit_paste (MooEdit *doc);
|
||||
|
||||
void moo_edit_select_text (MooEdit *doc,
|
||||
void moo_edit_select_range (MooEdit *doc,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end);
|
||||
void moo_edit_select_lines (MooEdit *doc,
|
||||
|
@ -117,6 +117,8 @@ static MooUndoAction *delete_action_new (GtkTextBuffer *buffer,
|
||||
static void before_undo_redo (MooTextBuffer *buffer);
|
||||
#endif
|
||||
static void after_undo_redo (MooTextBuffer *buffer);
|
||||
static void proxy_notify_can_undo_redo (MooTextBuffer *buffer,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void line_mark_moved (MooTextBuffer *buffer,
|
||||
MooLineMark *mark);
|
||||
@ -149,7 +151,9 @@ enum {
|
||||
PROP_BRACKET_MISMATCH_STYLE,
|
||||
PROP_HAS_TEXT,
|
||||
PROP_HAS_SELECTION,
|
||||
PROP_LANG
|
||||
PROP_LANG,
|
||||
PROP_CAN_UNDO,
|
||||
PROP_CAN_REDO
|
||||
};
|
||||
|
||||
|
||||
@ -244,6 +248,22 @@ moo_text_buffer_class_init (MooTextBufferClass *klass)
|
||||
MOO_TYPE_LANG,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_CAN_UNDO,
|
||||
g_param_spec_boolean ("can-undo",
|
||||
"can-undo",
|
||||
"can-undo",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_CAN_REDO,
|
||||
g_param_spec_boolean ("can-redo",
|
||||
"can-redo",
|
||||
"can-redo",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
signals[HIGHLIGHT_UPDATED] =
|
||||
g_signal_new ("highlight_updated",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
@ -365,6 +385,11 @@ moo_text_buffer_init (MooTextBuffer *buffer)
|
||||
buffer, NULL,
|
||||
G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
|
||||
g_signal_connect_swapped (buffer->priv->undo_stack, "notify::can-undo",
|
||||
G_CALLBACK (proxy_notify_can_undo_redo), buffer);
|
||||
g_signal_connect_swapped (buffer->priv->undo_stack, "notify::can-redo",
|
||||
G_CALLBACK (proxy_notify_can_undo_redo), buffer);
|
||||
|
||||
moo_text_buffer_set_brackets (buffer, NULL);
|
||||
}
|
||||
|
||||
@ -446,18 +471,18 @@ _moo_text_buffer_get_undo_stack (MooTextBuffer *buffer)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_buffer_begin_not_undoable_action (MooTextBuffer *buffer)
|
||||
gboolean
|
||||
moo_text_buffer_can_redo (MooTextBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer));
|
||||
moo_undo_stack_freeze (buffer->priv->undo_stack);
|
||||
g_return_val_if_fail (MOO_IS_TEXT_BUFFER (buffer), FALSE);
|
||||
return moo_undo_stack_can_redo (buffer->priv->undo_stack);
|
||||
}
|
||||
|
||||
void
|
||||
moo_text_buffer_end_not_undoable_action (MooTextBuffer *buffer)
|
||||
gboolean
|
||||
moo_text_buffer_can_undo (MooTextBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer));
|
||||
moo_undo_stack_thaw (buffer->priv->undo_stack);
|
||||
g_return_val_if_fail (MOO_IS_TEXT_BUFFER (buffer), FALSE);
|
||||
return moo_undo_stack_can_undo (buffer->priv->undo_stack);
|
||||
}
|
||||
|
||||
|
||||
@ -778,6 +803,13 @@ after_undo_redo (MooTextBuffer *buffer)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_notify_can_undo_redo (MooTextBuffer *buffer,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
g_object_notify (G_OBJECT (buffer), pspec->name);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_buffer_set_lang (MooTextBuffer *buffer,
|
||||
@ -1030,6 +1062,21 @@ moo_text_buffer_thaw (MooTextBuffer *buffer)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_buffer_begin_non_undoable_action (MooTextBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer));
|
||||
moo_undo_stack_freeze (buffer->priv->undo_stack);
|
||||
}
|
||||
|
||||
void
|
||||
moo_text_buffer_end_non_undoable_action (MooTextBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer));
|
||||
moo_undo_stack_thaw (buffer->priv->undo_stack);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_buffer_begin_non_interactive_action (MooTextBuffer *buffer)
|
||||
{
|
||||
|
@ -45,6 +45,9 @@ struct MooTextBufferClass
|
||||
{
|
||||
GtkTextBufferClass parent_class;
|
||||
|
||||
gboolean (* undo) (MooTextBuffer *buffer);
|
||||
gboolean (* redo) (MooTextBuffer *buffer);
|
||||
|
||||
void (*cursor_moved) (MooTextBuffer *buffer,
|
||||
const GtkTextIter *iter);
|
||||
void (*selection_changed) (MooTextBuffer *buffer);
|
||||
@ -80,12 +83,15 @@ gboolean moo_text_buffer_get_highlight (MooTextBuffer *buf
|
||||
void moo_text_buffer_set_brackets (MooTextBuffer *buffer,
|
||||
const char *brackets);
|
||||
|
||||
gboolean moo_text_buffer_can_redo (MooTextBuffer *buffer);
|
||||
gboolean moo_text_buffer_can_undo (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_begin_non_undoable_action (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_end_non_undoable_action (MooTextBuffer *buffer);
|
||||
|
||||
void moo_text_buffer_freeze (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_thaw (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_begin_non_interactive_action(MooTextBuffer *buffer);
|
||||
void moo_text_buffer_end_non_interactive_action (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_begin_not_undoable_action (MooTextBuffer *buffer);
|
||||
void moo_text_buffer_end_not_undoable_action (MooTextBuffer *buffer);
|
||||
|
||||
gboolean moo_text_buffer_has_text (MooTextBuffer *buffer);
|
||||
gboolean moo_text_buffer_has_selection (MooTextBuffer *buffer);
|
||||
|
@ -197,10 +197,10 @@ enum {
|
||||
GOTO_LINE_INTERACTIVE,
|
||||
CURSOR_MOVED,
|
||||
CHAR_INSERTED,
|
||||
UNDO,
|
||||
REDO,
|
||||
LINE_MARK_CLICKED,
|
||||
START_QUICK_SEARCH,
|
||||
UNDO,
|
||||
REDO,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -292,8 +292,6 @@ static void moo_text_view_class_init (MooTextViewClass *klass)
|
||||
klass->find_prev_interactive = find_prev_interactive;
|
||||
klass->replace_interactive = replace_interactive;
|
||||
klass->goto_line_interactive = goto_line_interactive;
|
||||
klass->undo = moo_text_view_undo;
|
||||
klass->redo = moo_text_view_redo;
|
||||
klass->char_inserted = moo_text_view_char_inserted;
|
||||
klass->apply_style_scheme = moo_text_view_apply_style_scheme;
|
||||
klass->get_text_cursor = moo_text_view_get_text_cursor;
|
||||
@ -520,22 +518,22 @@ static void moo_text_view_class_init (MooTextViewClass *klass)
|
||||
G_PARAM_READABLE));
|
||||
|
||||
signals[UNDO] =
|
||||
g_signal_new ("undo",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (MooTextViewClass, undo),
|
||||
g_signal_accumulator_true_handled, NULL,
|
||||
_moo_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
_moo_signal_new_cb ("undo",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_CALLBACK (moo_text_view_undo),
|
||||
g_signal_accumulator_true_handled, NULL,
|
||||
_moo_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
|
||||
signals[REDO] =
|
||||
g_signal_new ("redo",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (MooTextViewClass, redo),
|
||||
g_signal_accumulator_true_handled, NULL,
|
||||
_moo_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
_moo_signal_new_cb ("redo",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_CALLBACK (moo_text_view_redo),
|
||||
g_signal_accumulator_true_handled, NULL,
|
||||
_moo_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
|
||||
signals[DELETE_SELECTION] =
|
||||
_moo_signal_new_cb ("delete-selection",
|
||||
@ -844,13 +842,6 @@ moo_text_view_finalize (GObject *object)
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *
|
||||
moo_text_view_new (void)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (MOO_TYPE_TEXT_VIEW, (const char*) NULL));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_text_view_delete_selection (MooTextView *view)
|
||||
{
|
||||
@ -973,22 +964,6 @@ moo_text_view_can_undo (MooTextView *view)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_view_begin_non_undoable_action (MooTextView *view)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
|
||||
moo_undo_stack_freeze (get_undo_stack (view));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_view_end_non_undoable_action (MooTextView *view)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
|
||||
moo_undo_stack_thaw (get_undo_stack (view));
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
moo_text_view_redo (MooTextView *view)
|
||||
{
|
||||
|
@ -49,9 +49,6 @@ struct MooTextViewClass
|
||||
{
|
||||
GtkTextViewClass parent_class;
|
||||
|
||||
gboolean (* undo) (MooTextView *view);
|
||||
gboolean (* redo) (MooTextView *view);
|
||||
|
||||
gboolean (* char_inserted) (MooTextView *view,
|
||||
GtkTextIter *where, /* points to position after the char */
|
||||
const char *character); /* single character as string */
|
||||
@ -88,7 +85,6 @@ struct MooTextViewClass
|
||||
|
||||
GType moo_text_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *moo_text_view_new (void);
|
||||
void moo_text_view_set_buffer_type (MooTextView *view,
|
||||
GType type);
|
||||
|
||||
@ -103,8 +99,6 @@ gboolean moo_text_view_can_redo (MooTextView *view);
|
||||
gboolean moo_text_view_can_undo (MooTextView *view);
|
||||
gboolean moo_text_view_redo (MooTextView *view);
|
||||
gboolean moo_text_view_undo (MooTextView *view);
|
||||
void moo_text_view_begin_non_undoable_action(MooTextView *view);
|
||||
void moo_text_view_end_non_undoable_action (MooTextView *view);
|
||||
|
||||
void moo_text_view_set_font_from_string (MooTextView *view,
|
||||
const char *font);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include "mooedit/mooplugin-macro.h"
|
||||
#include "mooedit/mooedit-script.h"
|
||||
#include "plugins/mooplugin-builtin.h"
|
||||
#include "moofileview/moofileentry.h"
|
||||
#include "moocmdview.h"
|
||||
@ -495,10 +496,10 @@ init_grep_dialog (MooEditWindow *window,
|
||||
view = moo_edit_window_get_active_view (window);
|
||||
doc = view ? moo_edit_view_get_doc (view) : NULL;
|
||||
|
||||
if (view)
|
||||
if (doc)
|
||||
{
|
||||
char *sel = moo_text_view_get_selection (GTK_TEXT_VIEW (view));
|
||||
if (sel && !strchr (sel, '\n'))
|
||||
char *sel = moo_edit_get_selected_text (doc);
|
||||
if (sel && *sel && !strchr (sel, '\n'))
|
||||
gtk_entry_set_text (GTK_ENTRY (pattern_entry), sel);
|
||||
g_free (sel);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ if doc.has_selection() then
|
||||
else
|
||||
pos = doc.get_cursor_pos().get_offset()
|
||||
doc.insert_text('$ $')
|
||||
doc.set_selection(pos + 1, pos + 2)
|
||||
doc.select_range(pos + 1, pos + 2)
|
||||
end
|
||||
]]></lua:code>
|
||||
</command>
|
||||
|
@ -18,6 +18,7 @@
|
||||
#endif
|
||||
#include "moocommand-exe.h"
|
||||
#include "mooedit/mooeditor.h"
|
||||
#include "mooedit/mooedit-script.h"
|
||||
#include "moocmdview.h"
|
||||
#include "mooeditwindowoutput.h"
|
||||
#include "mooutils/mooi18n.h"
|
||||
@ -194,7 +195,6 @@ get_input (MooCommandExe *cmd,
|
||||
gboolean select_it)
|
||||
{
|
||||
MooEdit *doc = moo_command_context_get_doc (ctx);
|
||||
MooEditView *view = doc ? moo_edit_get_view (doc) : NULL;
|
||||
|
||||
g_return_val_if_fail (cmd->priv->input == MOO_COMMAND_EXE_INPUT_NONE || doc != NULL, NULL);
|
||||
|
||||
@ -206,9 +206,9 @@ get_input (MooCommandExe *cmd,
|
||||
case MOO_COMMAND_EXE_INPUT_LINES:
|
||||
return get_lines (doc, select_it);
|
||||
case MOO_COMMAND_EXE_INPUT_SELECTION:
|
||||
return moo_text_view_get_selection (GTK_TEXT_VIEW (view));
|
||||
return moo_edit_get_selected_text (doc);
|
||||
case MOO_COMMAND_EXE_INPUT_DOC:
|
||||
return moo_text_view_get_text (GTK_TEXT_VIEW (view));
|
||||
return moo_edit_get_text (doc, NULL, NULL);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user