diff options
Diffstat (limited to 'src/analysis/line_comment.c')
-rw-r--r-- | src/analysis/line_comment.c | 130 |
1 files changed, 34 insertions, 96 deletions
diff --git a/src/analysis/line_comment.c b/src/analysis/line_comment.c index a39cb11..2a3030c 100644 --- a/src/analysis/line_comment.c +++ b/src/analysis/line_comment.c @@ -57,8 +57,8 @@ static void g_comment_line_class_init(GCommentLineClass *); /* Initialise la classe des lignes de commentaires entière. */ static void g_comment_line_init(GCommentLine *); -/* Met à jour la ligne de représentation de commentaires. */ -void g_comment_line_refresh_markup(GCommentLine *, MainRendering); +/* Ajoute à un texte GTK le contenu de la ligne de commentaires. */ +static void g_comment_line_add_to_gtk_buffer(GCommentLine *, MainRendering, GtkTextBuffer *, GtkTextIter *, gint [SAR_COUNT]); @@ -99,13 +99,16 @@ static void g_comment_line_class_init(GCommentLineClass *klass) static void g_comment_line_init(GCommentLine *line) { - GRenderingLine *parent; /* Instance parente */ + GContentExporter *exporter_parent; /* Instance parente #1 */ + GRenderingLine *line_parent; /* Instance parente #2 */ - parent = G_RENDERING_LINE(line); + exporter_parent = G_CONTENT_EXPORTER(line); - parent->type = RLT_PROTOTYPE/* TODO */; + exporter_parent->add_to_gtk_buffer = (add_to_gtk_buffer_fc)g_comment_line_add_to_gtk_buffer; - parent->refresh_markup = (refresh_markup_fc)g_comment_line_refresh_markup; + line_parent = G_RENDERING_LINE(line); + + line_parent->type = RLT_PROTOTYPE/* TODO */; } @@ -114,8 +117,11 @@ static void g_comment_line_init(GCommentLine *line) * * * Paramètres : line = ligne de représentation à actualiser. * * rendering = support effectif final des lignes de code. * +* buffer = zone de texte à venir compléter. * +* iter = point d'insertion du nouveau texte. * +* lengths = taille des différentes composantes de la ligne. * * * -* Description : Met à jour la ligne de représentation de commentaires. * +* Description : Ajoute à un texte GTK le contenu de la ligne de commentaires.* * * * Retour : - * * * @@ -123,116 +129,48 @@ static void g_comment_line_init(GCommentLine *line) * * ******************************************************************************/ -void g_comment_line_refresh_markup(GCommentLine *line, MainRendering rendering) +static void g_comment_line_add_to_gtk_buffer(GCommentLine *line, MainRendering rendering, GtkTextBuffer *buffer, GtkTextIter *iter, gint lengths[SAR_COUNT]) { bool show_address; /* Affichage de l'adresse ? */ bool show_code; /* Affichage du code brut ? */ - size_t len; /* Taille du contenu */ - char *content; /* Contenu réellement imprimé */ - char buffer[CODE_BUFFER_LEN]; /* Zone tampon à utiliser */ - const off_t *max_bin_len; /* Taille de ligne max/globale */ - size_t clen; /* Taille du commentaire */ + MemoryDataSize msize; /* Taille du bus d'adresses */ + char address[VMPA_MAX_SIZE]; /* Adresse au format texte */ + size_t len; /* Taille de l'élément inséré */ show_address = g_rendering_options_has_to_show_address(line->options, rendering); show_code = g_rendering_options_has_to_show_code(line->options, rendering); - len = strlen("<tt>") + 1; - content = (char *)calloc(len, sizeof(char)); - strcpy(content, "<tt>"); - - /* Eventuelle adresse virtuelle */ + /* Eventuelle adresse virtuelle ou physique */ if (show_address) { - switch (g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options))) - { - case MDS_8_BITS: - snprintf(buffer, CODE_BUFFER_LEN, - "<span foreground='#333333'>0x%02llx</span>", - G_RENDERING_LINE(line)->offset); - break; - - case MDS_16_BITS: - snprintf(buffer, CODE_BUFFER_LEN, - "<span foreground='#333333'>0x%04llx</span>", - G_RENDERING_LINE(line)->offset); - break; - - case MDS_32_BITS: - snprintf(buffer, CODE_BUFFER_LEN, - "<span foreground='#333333'>0x%08llx</span>", - G_RENDERING_LINE(line)->offset); - break; - - default: - case MDS_64_BITS: - snprintf(buffer, CODE_BUFFER_LEN, - "<span foreground='#333333'>0x%16llx</span>", - G_RENDERING_LINE(line)->offset); - break; - - } - - len += strlen(buffer); - content = (char *)realloc(content, len * sizeof(char)); - strcat(content, buffer); - - } - - /* Eventuel code brut (sauté) */ - - if (show_code) - { - max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[rendering]; - - clen = (show_address ? strlen("\t") : 0); - clen += *max_bin_len; - - content = (char *)realloc(content, (len + clen) * sizeof(char)); + msize = g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options)); - if (show_address) - { - strcat(content, "\t"); - len += strlen("\t"); - } + len = vmpa_to_string(G_RENDERING_LINE(line)->offset, msize, address); - memset(&content[len - 1], - G_RENDERING_LINE(line)->type == RLT_PROTOTYPE ? '-' : ' ', *max_bin_len); - len += *max_bin_len; + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(line), buffer, iter, + address, len, RTT_NONE); - content[len - 1] = '\0'; + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(line), buffer, iter, + "\t", 1, RTT_NONE); } - /* Commentaire proprement dit */ - - clen = (show_address || show_code ? strlen("\t") : 0); - clen += strlen("<b><span foreground='#003300'>"); - clen += strlen("; ") + strlen(line->comment); - clen += strlen("</span></b>"); - - content = (char *)realloc(content, (len + clen) * sizeof(char)); - - if (show_address || show_code) - { - strcat(content, "\t"); - len += strlen("\t"); - clen -= strlen("\t"); - } - - snprintf(&content[len - 1], clen + 1, "<b><span foreground='#003300'>; %s</span></b>", line->comment); + /* Eventuel code brut (sauté) */ - len += clen; + if (show_code) + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(line), buffer, iter, + "\t", 1, RTT_NONE); - /* Finalisation */ + /* Commentaire proprement dit */ - len += strlen("</tt>"); - content = (char *)realloc(content, len * sizeof(char)); - strcat(content, "</tt>"); + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(line), buffer, iter, + "; ", 2, RTT_COMMENT); - pango_layout_set_markup(G_RENDERING_LINE(line)->layout[rendering], content, len - 1); + len = strlen(line->comment); - free(content); + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(line), buffer, iter, + line->comment, len, RTT_COMMENT); } |