+/* testtext.c
+ * Copyright (C) 2000 Red Hat, Inc
+ * Author: Havoc Pennington
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
#include <config.h>
#include <stdio.h>
#include <sys/stat.h>
GtkTextTag *invisible_tag;
GtkTextTag *not_editable_tag;
GtkTextTag *found_text_tag;
+ GtkTextTag *rise_tag;
+ GtkTextTag *large_tag;
+ GtkTextTag *indent_tag;
+ GtkTextTag *margin_tag;
GtkTextTag *custom_tabs_tag;
GSList *color_tags;
guint color_cycle_timeout;
}
}
+static void
+do_apply_rise (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextIter start;
+ GtkTextIter end;
+
+ if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+ &start, &end))
+ {
+ if (callback_action)
+ {
+ gtk_text_buffer_remove_tag (view->buffer->buffer,
+ view->buffer->rise_tag,
+ &start, &end);
+ }
+ else
+ {
+ gtk_text_buffer_apply_tag (view->buffer->buffer,
+ view->buffer->rise_tag,
+ &start, &end);
+ }
+ }
+}
+
+static void
+do_apply_large (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextIter start;
+ GtkTextIter end;
+
+ if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+ &start, &end))
+ {
+ if (callback_action)
+ {
+ gtk_text_buffer_remove_tag (view->buffer->buffer,
+ view->buffer->large_tag,
+ &start, &end);
+ }
+ else
+ {
+ gtk_text_buffer_apply_tag (view->buffer->buffer,
+ view->buffer->large_tag,
+ &start, &end);
+ }
+ }
+}
+
+static void
+do_apply_indent (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextIter start;
+ GtkTextIter end;
+
+ if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+ &start, &end))
+ {
+ if (callback_action)
+ {
+ gtk_text_buffer_remove_tag (view->buffer->buffer,
+ view->buffer->indent_tag,
+ &start, &end);
+ }
+ else
+ {
+ gtk_text_buffer_apply_tag (view->buffer->buffer,
+ view->buffer->indent_tag,
+ &start, &end);
+ }
+ }
+}
+
+static void
+do_apply_margin (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextIter start;
+ GtkTextIter end;
+
+ if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer,
+ &start, &end))
+ {
+ if (callback_action)
+ {
+ gtk_text_buffer_remove_tag (view->buffer->buffer,
+ view->buffer->margin_tag,
+ &start, &end);
+ }
+ else
+ {
+ gtk_text_buffer_apply_tag (view->buffer->buffer,
+ view->buffer->margin_tag,
+ &start, &end);
+ }
+ }
+}
+
static void
do_apply_tabs (gpointer callback_data,
guint callback_action,
gtk_widget_show_all (dialog);
}
+static void
+do_select_all (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ View *view = view_from_widget (widget);
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ buffer = view->buffer->buffer;
+
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gtk_text_buffer_select_range (buffer, &start, &end);
+}
+
typedef struct
{
/* position is in coordinate system of text_view_move_child */
{ "/_Edit", NULL, 0, 0, "<Branch>" },
{ "/Edit/Find...", NULL, do_search, 0, NULL },
+ { "/Edit/Select All", "<control>A", do_select_all, 0, NULL },
{ "/_Settings", NULL, NULL, 0, "<Branch>" },
{ "/Settings/Wrap _Off", NULL, do_wrap_changed, GTK_WRAP_NONE, "<RadioItem>" },
{ "/Attributes/Not editable", NULL, do_apply_editable, FALSE, NULL },
{ "/Attributes/Invisible", NULL, do_apply_invisible, FALSE, NULL },
{ "/Attributes/Visible", NULL, do_apply_invisible, TRUE, NULL },
+ { "/Attributes/Rise", NULL, do_apply_rise, FALSE, NULL },
+ { "/Attributes/Large", NULL, do_apply_large, FALSE, NULL },
+ { "/Attributes/Indent", NULL, do_apply_indent, FALSE, NULL },
+ { "/Attributes/Margins", NULL, do_apply_margin, FALSE, NULL },
{ "/Attributes/Custom tabs", NULL, do_apply_tabs, FALSE, NULL },
{ "/Attributes/Default tabs", NULL, do_apply_tabs, TRUE, NULL },
{ "/Attributes/Color cycles", NULL, do_apply_colors, TRUE, NULL },
++i;
}
-#if 0
+#if 1
buffer->invisible_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
"invisible", TRUE, NULL);
#endif
buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
"foreground", "red", NULL);
+ buffer->rise_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+ "rise", 10 * PANGO_SCALE, NULL);
+
+ buffer->large_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+ "scale", PANGO_SCALE_X_LARGE, NULL);
+
+ buffer->indent_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+ "indent", 20, NULL);
+
+ buffer->margin_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL,
+ "left_margin", 20, "right_margin", 20, NULL);
+
tabs = pango_tab_array_new_with_positions (4,
TRUE,
PANGO_TAB_LEFT, 10,