Commits

mun...@mlap  committed 28b3ddb

Changed version to 0.6.3

  • Participants
  • Parent commits 64208ff
  • Tags moo-0.6.2-real

Comments (0)

Files changed (9)

File configure.ac

 
 m4_define([moo_major_version], [0])
 m4_define([moo_minor_version], [6])
-m4_define([moo_micro_version], [2])
+m4_define([moo_micro_version], [3])
 m4_define([moo_version], [moo_major_version.moo_minor_version.moo_micro_version])
 
 AC_INIT(libmoo, [moo_version], [muntyan@math.tamu.edu], libmoo)

File moo/moopython/pygtk/mooterm-mod.c

     if (!mod)
         return FALSE;
 
-//     _moo_term_add_constants (mod, "MOO_");
+    _moo_term_add_constants (mod, "MOO_TERM_");
     _moo_term_register_classes (PyModule_GetDict (mod));
 
     if (!PyErr_Occurred ())

File moo/moopython/pygtk/mooterm-pygtk.defs

   (gtype-id "MOO_TYPE_TERM")
 )
 
-(define-object TermBuffer
+(define-object Buffer
   (in-module "Moo")
   (parent "GObject")
   (c-name "MooTermBuffer")
   (gtype-id "MOO_TYPE_TERM_BUFFER")
 )
 
-(define-object TermTag
+(define-object Tag
   (in-module "Moo")
   (parent "GObject")
   (c-name "MooTermTag")
   (gtype-id "MOO_TYPE_TERM_TAG")
+  (fields
+    '("char*" "name")
+    '("MooTermTextAttr" "attr")
+  )
 )
 
-(define-object TermWindow
+(define-object Window
   (in-module "Moo")
   (parent "MooWindow")
   (c-name "MooTermWindow")
 )
 
 
-(define-boxed TermIter
+(define-boxed Iter
   (in-module "Moo")
   (c-name "MooTermIter")
   (gtype-id "MOO_TYPE_TERM_ITER")
   )
 )
 
-(define-boxed TermCommand
+(define-boxed Command
   (in-module "Moo")
   (c-name "MooTermCommand")
   (gtype-id "MOO_TYPE_TERM_COMMAND")
   (release-func "moo_term_command_free")
 )
 
-(define-pointer TermLine
+(define-pointer Line
   (in-module "Moo")
   (c-name "MooTermLine")
   (gtype-id "MOO_TYPE_TERM_LINE")
 )
 
+(define-boxed Attr
+  (in-module "Moo")
+  (c-name "MooTermTextAttr")
+  (gtype-id "MOO_TYPE_TERM_TEXT_ATTR")
+  (fields
+    '("MooTermTextAttrMask" "mask")
+    '("MooTermTextColor" "foreground")
+    '("MooTermTextColor" "background")
+  )
+)
+
 
 ;; Enumerations and flags ...
 
-(define-enum TermEraseBinding
+(define-enum EraseBinding
   (in-module "Moo")
   (c-name "MooTermEraseBinding")
   (gtype-id "MOO_TYPE_TERM_ERASE_BINDING")
   )
 )
 
-(define-flags TermTextAttrMask
+(define-flags TextAttrMask
   (in-module "Moo")
   (c-name "MooTermTextAttrMask")
   (gtype-id "MOO_TYPE_TERM_TEXT_ATTR_MASK")
   )
 )
 
-(define-enum TermTextColor
+(define-enum TextColor
   (in-module "Moo")
   (c-name "MooTermTextColor")
   (gtype-id "MOO_TYPE_TERM_TEXT_COLOR")
   (c-name "moo_term_tag_set_attr")
   (return-type "none")
   (parameters
-    '("MooTermTextAttr" "attr")
+    '("MooTermTextAttr*" "attr")
+  )
+  (docstring "Tag.set_attr(attr) -> None.\n"
+             "\n"
+             "attr - TextAttr instance\n"
   )
 )
 
+(define-method set_attributes
+  (of-object "MooTermTag")
+  (c-name "moo_term_tag_set_attributes")
+  (return-type "none")
+  (parameters
+    '("MooTermTextAttrMask" "mask")
+    '("MooTermTextColor" "foreground" (null-ok) (default "0"))
+    '("MooTermTextColor" "background" (null-ok) (default "0"))
+  )
+  (docstring "Tag.set_attributes(mask, foreground=0, background=0) -> None. Sets tag attributes\n"
+             "\n"
+             "mask - combination of TextAttrMask values\n"
+             "foreground - text color as TextColor value, has effect only if TEXT_FOREGROUND mask is set\n"
+             "background - background color as TextColor value, has effect only if TEXT_BACKGROUND mask is set\n"
+  )
+)
+
+(define-function moo_term_text_attr_new
+  (c-name "moo_term_text_attr_new")
+  (is-constructor-of "MooTermTextAttr")
+  (return-type "MooTermTextAttr*")
+  (parameters
+    '("MooTermTextAttrMask" "mask")
+    '("MooTermTextColor" "foreground")
+    '("MooTermTextColor" "background")
+  )
+  (docstring "TextAttr(mask, foreground=0, background=0) -> TextAttr.\n"
+             "\n"
+             "mask - combination of TextAttrMask values\n"
+             "foreground - text color as TextColor value, has effect only if TEXT_FOREGROUND mask is set\n"
+             "background - background color as TextColor value, has effect only if TEXT_BACKGROUND mask is set\n"
+  )
+)
 
 
 ;; From mootermwindow.h

File moo/mooterm/mooterm-draw.c

 
     gdk_window_set_background (widget->window, &term->priv->bg_color);
 
-    gtk_widget_queue_draw (widget);
+    _moo_term_invalidate_all (term);
 }
 
 

File moo/mooterm/mooterm-text.c

         line = buf_line (buf, ITER_ROW (start));
         _moo_term_line_apply_tag (line, tag, ITER_COL (start),
                                   _moo_term_line_width (line) - ITER_COL (start));
-        line = buf_line (buf, ITER_ROW (end));
-        _moo_term_line_apply_tag (line, tag, 0, ITER_COL (end));
+
+        if (ITER_COL (end))
+        {
+            line = buf_line (buf, ITER_ROW (end));
+            _moo_term_line_apply_tag (line, tag, 0, ITER_COL (end));
+        }
+
         if (ITER_ROW (start) + 1 < ITER_ROW (end))
         {
             for (i = ITER_ROW (start) + 1; i < ITER_ROW (end); ++i)

File moo/mooterm/mootermbuffer-private.h

 
 
 struct _MooTermTagTable {
+    MooTermBuffer *buffer;
     GHashTable *named_tags;
     GSList *tags;
 };
 
 
-MooTermTagTable *_moo_term_tag_table_new        (void);
+MooTermTagTable *_moo_term_tag_table_new        (MooTermBuffer   *buffer);
 void    _moo_term_tag_table_free                (MooTermTagTable *table);
 
 void    _moo_term_buffer_set_line_data          (MooTermBuffer  *buf,

File moo/mooterm/mootermbuffer.c

     buf->priv->changed = NULL;
     buf->priv->changed_all = FALSE;
 
-    buf->priv->tag_table = _moo_term_tag_table_new ();
+    buf->priv->tag_table = _moo_term_tag_table_new (buf);
     buf->priv->data_sets = g_hash_table_new (g_direct_hash, g_direct_equal);
 
     set_defaults (buf);

File moo/mooterm/mootermtag.c

 #include "mooterm/mooterm-private.h"
 #include "mooterm/mootermline-private.h"
 #include "mooterm/mooterm-text.h"
+#include "mooutils/moomarshals.h"
 
 
 static void     moo_term_tag_finalize       (GObject        *object);
                                              GValue         *value,
                                              GParamSpec     *pspec);
 
+enum {
+    CHANGED,
+    NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS];
+
 static int
 ptr_cmp (gconstpointer a,
          gconstpointer b)
                                              "name",
                                              NULL,
                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+    signals[CHANGED] =
+            g_signal_new ("changed",
+                          G_OBJECT_CLASS_TYPE (gobject_class),
+                          G_SIGNAL_RUN_LAST,
+                          G_STRUCT_OFFSET (MooTermTagClass, changed),
+                          NULL, NULL,
+                          _moo_marshal_VOID__VOID,
+                          G_TYPE_NONE, 0);
 }
 
 
 
 
 MooTermTagTable*
-_moo_term_tag_table_new (void)
+_moo_term_tag_table_new (MooTermBuffer *buffer)
 {
     MooTermTagTable *table = g_new0 (MooTermTagTable, 1);
 
     table->named_tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+    table->buffer = buffer;
 
     return table;
 }
 
 void
 moo_term_tag_set_attr (MooTermTag         *tag,
-                       MooTermTextAttr     attr)
+                       MooTermTextAttr    *attr)
 {
-    /* TODO */
     g_return_if_fail (MOO_IS_TERM_TAG (tag));
-    tag->attr = attr;
+    g_return_if_fail (attr != NULL);
+    tag->attr = *attr;
+    g_signal_emit (tag, signals[CHANGED], 0);
+
+    /* XXX */
+    buf_changed_set_all (tag->table->buffer);
+    _moo_term_buffer_changed (tag->table->buffer);
+}
+
+
+void
+moo_term_tag_set_attributes (MooTermTag         *tag,
+                             MooTermTextAttrMask mask,
+                             MooTermTextColor    foreground,
+                             MooTermTextColor    background)
+{
+    MooTermTextAttr attr;
+
+    g_return_if_fail (MOO_IS_TERM_TAG (tag));
+
+    attr.mask = mask;
+    attr.foreground = foreground;
+    attr.background = background;
+
+    moo_term_tag_set_attr (tag, &attr);
 }
 
 
 
     return type;
 }
+
+
+MooTermTextAttr*
+moo_term_text_attr_new (MooTermTextAttrMask mask,
+                        MooTermTextColor    foreground,
+                        MooTermTextColor    background)
+{
+    MooTermTextAttr *attr = g_new (MooTermTextAttr, 1);
+    attr->mask = mask;
+    attr->foreground = foreground;
+    attr->background = background;
+    return attr;
+}
+
+
+static gpointer
+copy_attr (gpointer a)
+{
+    MooTermTextAttr *attr = a;
+    MooTermTextAttr *copy = g_new (MooTermTextAttr, 1);
+    *copy = *attr;
+    return copy;
+}
+
+static void
+free_attr (gpointer a)
+{
+    g_free (a);
+}
+
+GType
+moo_term_text_attr_get_type (void)
+{
+    static GType type = 0;
+
+    if (!type)
+        type = g_boxed_type_register_static ("MooTermTextAttr",
+                                             copy_attr, free_attr);
+
+    return type;
+}

File moo/mooterm/mootermtag.h

 G_BEGIN_DECLS
 
 
+#define MOO_TYPE_TERM_TEXT_ATTR         (moo_term_text_attr_get_type ())
 #define MOO_TYPE_TERM_TEXT_ATTR_MASK    (moo_term_text_attr_mask_get_type ())
 #define MOO_TYPE_TERM_TEXT_COLOR        (moo_term_text_color_get_type ())
 
 typedef enum {
     MOO_TERM_TEXT_REVERSE       = 1 << 0,
     MOO_TERM_TEXT_BLINK         = 1 << 1,
-    MOO_TERM_TEXT_FOREGROUND    = 1 << 2,
-    MOO_TERM_TEXT_BACKGROUND    = 1 << 3,
-    MOO_TERM_TEXT_BOLD          = 1 << 4,
-    MOO_TERM_TEXT_UNDERLINE     = 1 << 5
+    MOO_TERM_TEXT_BOLD          = 1 << 2,
+    MOO_TERM_TEXT_UNDERLINE     = 1 << 3,
+    MOO_TERM_TEXT_FOREGROUND    = 1 << 4,
+    MOO_TERM_TEXT_BACKGROUND    = 1 << 5
 } MooTermTextAttrMask;
 
 typedef enum {
 
 
 GType   moo_term_text_attr_mask_get_type    (void) G_GNUC_CONST;
+GType   moo_term_text_attr_get_type         (void) G_GNUC_CONST;
 GType   moo_term_text_color_get_type        (void) G_GNUC_CONST;
 GType   moo_term_tag_get_type               (void) G_GNUC_CONST;
 
+MooTermTextAttr *moo_term_text_attr_new     (MooTermTextAttrMask mask,
+                                             MooTermTextColor    fg,
+                                             MooTermTextColor    bg);
+
 void    moo_term_tag_set_attr               (MooTermTag         *tag,
-                                             MooTermTextAttr     attr);
+                                             MooTermTextAttr    *attr);
+void    moo_term_tag_set_attributes         (MooTermTag         *tag,
+                                             MooTermTextAttrMask mask,
+                                             MooTermTextColor    fg,
+                                             MooTermTextColor    bg);
 
 void    _moo_term_tag_add_line              (MooTermTag         *tag,
                                              gpointer            line);