summaryrefslogtreecommitdiff
path: root/src/analysis/line_code.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-07-04 12:21:26 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-07-04 12:21:26 (GMT)
commita60e81ac70b3d829f486ce7b6534005a9d025206 (patch)
tree0e3b284a12a1f8f4932f5cd05247a556cf8c5bf9 /src/analysis/line_code.c
parentb6893c7b85c34f7a3c65ac76bfd9d95b1c4ebf55 (diff)
Defined general rendering options using a GLib object.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@89 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/line_code.c')
-rw-r--r--src/analysis/line_code.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/analysis/line_code.c b/src/analysis/line_code.c
index 84ab36c..c44899e 100644
--- a/src/analysis/line_code.c
+++ b/src/analysis/line_code.c
@@ -38,7 +38,7 @@ struct _GCodeLine
GRenderingLine parent; /* Instance parente */
GArchInstruction *instr; /* Instruction représentée */
- const disass_options *options; /* Options de représentation */
+ const GRenderingOptions *options; /* Options de représentation */
};
@@ -61,7 +61,7 @@ static void g_code_line_init(GCodeLine *);
void g_code_line_get_binary_len(GCodeLine *, off_t *);
/* Met à jour la ligne de représentation de code. */
-void g_code_line_refresh_markup(GCodeLine *, LinesMainOwner);
+void g_code_line_refresh_markup(GCodeLine *, MainRendering);
@@ -140,8 +140,8 @@ void g_code_line_get_binary_len(GCodeLine *line, off_t *blen)
/******************************************************************************
* *
-* Paramètres : line = ligne de représentation à actualiser. *
-* owner = support effectif final des lignes de code. *
+* Paramètres : line = ligne de représentation à actualiser. *
+* rendering = support effectif final des lignes de code. *
* *
* Description : Met à jour la ligne de représentation de code. *
* *
@@ -151,8 +151,10 @@ void g_code_line_get_binary_len(GCodeLine *line, off_t *blen)
* *
******************************************************************************/
-void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
+void g_code_line_refresh_markup(GCodeLine *line, MainRendering rendering)
{
+ 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é */
off_t bin_offset; /* Début de l'instruction */
@@ -165,18 +167,21 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
off_t k; /* Boucle de parcours #2 */
off_t j; /* Boucle de parcours #1 */
+ 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>");
- if (line->options->show_code)
+ if (show_code)
g_arch_instruction_get_location(line->instr, &bin_offset, &bin_len, NULL);
/* Eventuelle adresse virtuelle */
- if (line->options->show_address)
+ if (show_address)
{
- switch (g_arch_processor_get_memory_size(line->options->proc))
+ switch (g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options)))
{
case MDS_8_BITS:
snprintf(buffer, CODE_BUFFER_LEN,
@@ -213,10 +218,10 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
/* Eventuel code brut */
- if (line->options->show_code)
+ if (show_code)
{
- exe_content = get_exe_content(line->options->format, NULL);
- max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[owner];
+ exe_content = get_exe_content(g_rendering_options_get_format(line->options), NULL);
+ max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[rendering];
bin_code = (char *)calloc(*max_bin_len + 1, sizeof(char));
@@ -233,10 +238,10 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
for (; k < *max_bin_len; k++)
snprintf(&bin_code[k], 2, " ");
- if (line->options->show_address) len += strlen("\t");
+ if (show_address) len += strlen("\t");
len += strlen(bin_code);
content = (char *)realloc(content, len * sizeof(char));
- if (line->options->show_address) strcat(content, "\t");
+ if (show_address) strcat(content, "\t");
strcat(content, bin_code);
free(bin_code);
@@ -245,13 +250,13 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
/* Instruction proprement dite */
- buffer2 = g_arch_instruction_get_text(line->instr, line->options->format, ASX_INTEL/*FIXME*/);
+ buffer2 = g_arch_instruction_get_text(line->instr, g_rendering_options_get_format(line->options), ASX_INTEL/*FIXME*/);
- if (line->options->show_address || line->options->show_code) len += strlen("\t");
+ if (show_address || show_code) len += strlen("\t");
len += strlen(buffer2);
content = (char *)realloc(content, len * sizeof(char));
- if (line->options->show_address || line->options->show_code) strcat(content, "\t");
+ if (show_address || show_code) strcat(content, "\t");
strcat(content, buffer2);
free(buffer2);
@@ -262,7 +267,7 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
content = (char *)realloc(content, len * sizeof(char));
strcat(content, "</tt>");
- pango_layout_set_markup(G_RENDERING_LINE(line)->layout[owner], content, len - 1);
+ pango_layout_set_markup(G_RENDERING_LINE(line)->layout[rendering], content, len - 1);
free(content);
@@ -283,7 +288,7 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)
* *
******************************************************************************/
-GRenderingLine *g_code_line_new(uint64_t offset, GArchInstruction *instr, const disass_options *options)
+GRenderingLine *g_code_line_new(uint64_t offset, GArchInstruction *instr, const GRenderingOptions *options)
{
GCodeLine *result; /* Structure à retourner */