summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-11-06 00:29:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-11-06 00:29:36 (GMT)
commit828124e38d266e382bb1477ef51c9fac8e81c591 (patch)
tree37d1d6af336987030791ba4c41b89a8cf144d270 /src/glibext
parentc1ff0021b42fb5738a0cb31da15c12eb6dfac816 (diff)
Defined the entry point for decompilations.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@189 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/gbufferline.c145
-rw-r--r--src/glibext/gbufferline.h38
-rw-r--r--src/glibext/gcodebuffer.c17
3 files changed, 192 insertions, 8 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index da08184..701cb4b 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -24,6 +24,8 @@
#include "gbufferline.h"
+#include <gtk/gtk.h> /* Récupération du langage par défaut ; FIXME ? */
+
#include <malloc.h> /* FIXME : à virer */
@@ -72,6 +74,9 @@ struct _GBufferLineClass
{
GObjectClass parent; /* A laisser en premier */
+ PangoContext *context; /* Contexte graphique Pango */
+ PangoAttrList *attribs[RTT_COUNT]; /* Décorateurs pour tampons */
+
};
@@ -233,6 +238,117 @@ G_DEFINE_TYPE(GBufferLine, g_buffer_line, G_TYPE_OBJECT);
static void g_buffer_line_class_init(GBufferLineClass *class)
{
+ GdkScreen *screen; /* Ecran pour GDK */
+ PangoFontDescription *font_desc; /* Police de caractère */
+ PangoAttribute *attrib; /* Propriété de rendu */
+
+ /* Base des exportations */
+
+ screen = gdk_screen_get_default();
+ class->context = gdk_pango_context_get_for_screen(screen);
+
+ font_desc = pango_font_description_from_string("mono 10");
+ pango_context_set_font_description(class->context, font_desc);
+
+ pango_context_set_base_dir(class->context, PANGO_DIRECTION_LTR);
+ pango_context_set_language(class->context, gtk_get_default_language());
+
+ /* RTT_RAW */
+
+ class->attribs[RTT_RAW] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(class->attribs[RTT_RAW], attrib);
+
+ /* RTT_COMMENT */
+
+ class->attribs[RTT_COMMENT] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(14335, 45311, 23551);
+ pango_attr_list_insert(class->attribs[RTT_COMMENT], attrib);
+
+ /* RTT_RAW_CODE */
+
+ class->attribs[RTT_RAW_CODE] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(48895, 48895, 48895);
+ pango_attr_list_insert(class->attribs[RTT_RAW_CODE], attrib);
+
+ /* RTT_INSTRUCTION */
+
+ class->attribs[RTT_INSTRUCTION] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(class->attribs[RTT_INSTRUCTION], attrib);
+
+ /* RTT_IMMEDIATE */
+
+ class->attribs[RTT_IMMEDIATE] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(41215, 8447, 61695);
+ pango_attr_list_insert(class->attribs[RTT_IMMEDIATE], attrib);
+
+ /* RTT_REGISTER */
+
+ class->attribs[RTT_REGISTER] = pango_attr_list_new();
+
+ //attrib = pango_attr_foreground_new(23551, 23551, 51455);
+ attrib = pango_attr_foreground_new(16895, 16895, 53759);
+ pango_attr_list_insert(class->attribs[RTT_REGISTER], attrib);
+
+ /* RTT_HOOK */
+
+ class->attribs[RTT_HOOK] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(class->attribs[RTT_HOOK], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert(class->attribs[RTT_HOOK], attrib);
+
+ /* RTT_SIGNS */
+
+ class->attribs[RTT_SIGNS] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(class->attribs[RTT_SIGNS], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_SEMIBOLD);
+ pango_attr_list_insert(class->attribs[RTT_SIGNS], attrib);
+
+ /* RTT_LTGT */
+
+ class->attribs[RTT_LTGT] = pango_attr_list_new();
+
+ /* RTT_SECTION */
+
+ class->attribs[RTT_SECTION] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(51200, 2560, 2560);
+ pango_attr_list_insert(class->attribs[RTT_SECTION], attrib);
+
+ /*
+ attrib = pango_attr_foreground_new(56832, 26880, 43008);
+ pango_attr_list_insert(class->attribs[RTT_SECTION], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert(class->attribs[RTT_SECTION], attrib);
+ */
+
+ /* RTT_SEGMENT */
+
+ class->attribs[RTT_SEGMENT] = pango_attr_list_new();
+
+ /* RTT_STRING */
+
+ class->attribs[RTT_STRING] = pango_attr_list_new();
+
+ attrib = pango_attr_foreground_new(52224, 32256, 0);
+ pango_attr_list_insert(class->attribs[RTT_STRING], attrib);
+
+ /* RTT_VAR_NAME */
+
+ class->attribs[RTT_VAR_NAME] = pango_attr_list_new();
}
@@ -308,6 +424,35 @@ void g_buffer_line_add_segment(GBufferLine *line, BufferLineColumn index, GBuffe
/******************************************************************************
* *
+* Paramètres : line = ligne à venir compléter. *
+* column = colonne de la ligne visée par l'insertion. *
+* text = texte à insérer dans l'existant. *
+* length = taille du texte à traiter. *
+* type = type de décorateur à utiliser. *
+* *
+* Description : Ajoute du texte à formater dans une ligne donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn column, const char *text, size_t length, RenderingTagType type)
+{
+ GBufferLineClass *class; /* Stockage de briques de base */
+ GBufferSegment *segment; /* Portion de texte à ajouter */
+
+ class = G_BUFFER_LINE_GET_CLASS(line);
+
+ segment = g_buffer_segment_new(class->context, class->attribs[type], text, length);
+ g_buffer_line_add_segment(line, column, segment);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : line = ligne à venir compléter. *
* index = index de la colonne visée par la procédure. *
* *
diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h
index d9e1edb..504f0a3 100644
--- a/src/glibext/gbufferline.h
+++ b/src/glibext/gbufferline.h
@@ -61,6 +61,41 @@ typedef enum _BufferLineColumn
} BufferLineColumn;
+/* Types de partie de rendu */
+typedef enum _RenderingTagType
+{
+ RTT_RAW, /* Contenu brut */
+
+ RTT_COMMENT, /* Commentaire */
+ RTT_RAW_CODE, /* Code binaire brut */
+
+ RTT_INSTRUCTION, /* Code binaire brut */
+
+ RTT_IMMEDIATE, /* Valeur immédiate */
+
+ RTT_REGISTER, /* Registre */
+
+ RTT_HOOK, /* Crochets '[' et ']' */
+ RTT_SIGNS, /* Signes '+', '-' et '*' */
+ RTT_LTGT, /* Caractères '<' et '>' */
+
+ RTT_SECTION, /* Identifiant de section */
+ RTT_SEGMENT, /* Indication de segment */
+ RTT_STRING, /* Chaîne de caractères avec " */
+
+ RTT_VAR_NAME, /* Nom de variable */
+
+ RTT_COUNT
+
+} RenderingTagType;
+
+
+#define RTT_NONE RTT_RAW /* TODO : remme */
+
+
+/* Confort pour l'insertion de texte */
+#define SL(str) str, strlen(str)
+
/* Accompagnement du dessin pour compléments */
typedef void (* buffer_line_draw_fc) (GBufferLine *, GdkDrawable *, GdkGC *, gint, gint, void *);
@@ -75,6 +110,9 @@ GBufferLine *g_buffer_line_new(void);
/* Ajoute un fragment de texte à une colonne de ligne. */
void g_buffer_line_add_segment(GBufferLine *, BufferLineColumn, GBufferSegment *);
+/* Ajoute du texte à formater dans une ligne donnée. */
+void g_buffer_line_insert_text(GBufferLine *, BufferLineColumn, const char *, size_t, RenderingTagType);
+
/* Fournit la largeur requise pour une colonne de ligne donnée. */
gint g_buffer_line_get_width(GBufferLine *, BufferLineColumn);
diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c
index 3f9af35..9f22df7 100644
--- a/src/glibext/gcodebuffer.c
+++ b/src/glibext/gcodebuffer.c
@@ -469,18 +469,19 @@ void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, Gd
lines = view->buffer->lines;
- for (i = first; i < last; i++)
- {
- /* TODO : skip if... */
+ if (view->buffer->used > 0)
+ for (i = first; i <= last; i++)
+ {
+ /* TODO : skip if... */
- if (view->drawing_extra != NULL)
- view->drawing_extra(lines[i], drawable, gc, fake_x, y, view->drawing_data);
+ if (view->drawing_extra != NULL)
+ view->drawing_extra(lines[i], drawable, gc, fake_x, y, view->drawing_data);
- g_buffer_line_draw(lines[i], drawable, gc, view->max_widths, real_x, y);
+ g_buffer_line_draw(lines[i], drawable, gc, view->max_widths, real_x, y);
- y += view->line_height;
+ y += view->line_height;
- }
+ }
}