summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-01-15 14:57:19 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-01-15 14:57:19 (GMT)
commite28ba4839188307f94293af4e29ed6e774c0a499 (patch)
tree2b3ce4dd609f5fe03fcfc3641c9723b39205079b /src/glibext/gbufferline.c
parent0a028b306093746324eabdb94881083f9b7e61c1 (diff)
Exported disassembled content in plain text or HTML format properly.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@455 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/gbufferline.c')
-rw-r--r--src/glibext/gbufferline.c136
1 files changed, 119 insertions, 17 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index 6b5ab18..54f5fb6 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -51,7 +51,6 @@ typedef struct _buffer_line_column
} buffer_line_column;
-
/* Réinitialise une colonne de ligne. */
static void reset_column(buffer_line_column *);
@@ -71,11 +70,14 @@ static GBufferSegment *get_segment_at(const buffer_line_column *, gint *, GdkScr
static GBufferSegment *find_near_segment(const buffer_line_column *, GBufferSegment *, GdkScrollDirection, bool *);
/* Met en surbrillance des segments similaires. */
-GSList *highlight_all_same_segments(const buffer_line_column *, GSList *, const GBufferSegment *);
+static GSList *highlight_all_same_segments(const buffer_line_column *, GSList *, const GBufferSegment *);
/* Imprime le contenu d'une colonne de ligne de texte. */
static void draw_segments_of_column(buffer_line_column *, cairo_t *, gint, gint);
+/* Exporte la ligne de texte représentée. */
+static void export_segments_of_column(buffer_line_column *, buffer_export_context *, BufferExportType, int);
+
/* ---------------------------- GESTION DE LINE COMPLETE ---------------------------- */
@@ -313,7 +315,7 @@ static GBufferSegment *find_near_segment(const buffer_line_column *column, GBuff
* *
******************************************************************************/
-GSList *highlight_all_same_segments(const buffer_line_column *column, GSList *list, const GBufferSegment *ref)
+static GSList *highlight_all_same_segments(const buffer_line_column *column, GSList *list, const GBufferSegment *ref)
{
size_t i; /* Boucle de parcours */
@@ -347,8 +349,8 @@ GSList *highlight_all_same_segments(const buffer_line_column *column, GSList *li
static void draw_segments_of_column(buffer_line_column *column, cairo_t *cairo, gint x_init, gint y)
{
- gint x;
- size_t i;
+ gint x; /* Abscisse d'impression */
+ size_t i; /* Boucle de parcours */
x = x_init;
@@ -358,6 +360,59 @@ static void draw_segments_of_column(buffer_line_column *column, cairo_t *cairo,
}
+/******************************************************************************
+* *
+* Paramètres : column = colonne de ligne de texte à manipuler. *
+* ctx = éléments à disposition pour l'exportation. *
+* type = type d'exportation attendue. *
+* span = fusion de colonnes au sein des cellules ? *
+* *
+* Description : Exporte la ligne de texte représentée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void export_segments_of_column(buffer_line_column *column, buffer_export_context *ctx, BufferExportType type, int span)
+{
+ size_t i; /* Boucle de parcours */
+
+ switch (type)
+ {
+ case BET_HTML:
+ switch (span)
+ {
+ case 0:
+ break;
+ case 1:
+ dprintf(ctx->fd, "\t\t<TD>");
+ break;
+ default:
+ if (span > 0) dprintf(ctx->fd, "\t\t<TD colspan=\"%d\">", span);
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ for (i = 0; i < column->count; i++)
+ g_buffer_segment_export(column->segments[i], ctx, type);
+
+ switch (type)
+ {
+ case BET_HTML:
+ if (span < 0 || span == 1) dprintf(ctx->fd, "</TD>\n");
+ break;
+ default:
+ break;
+ }
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* GESTION DE LINE COMPLETE */
@@ -1117,16 +1172,12 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const gint max_widths
}
-
/******************************************************************************
* *
* Paramètres : line = ligne de texte à manipuler. *
-* fd = flux ouvert en écriture. *
+* ctx = éléments à disposition pour l'exportation. *
* type = type d'exportation attendue. *
-* phys = indique si les positions doivent être affichées. *
-* virt = indique si les adresses doivent être affichées. *
-* code = indique si le code binaire doit être affiché. *
-* content = indique si le gros du contenu doit être affiché. *
+* display = règles d'affichage des colonnes modulables. *
* *
* Description : Exporte la ligne de texte représentée. *
* *
@@ -1136,19 +1187,70 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const gint max_widths
* *
******************************************************************************/
-void g_buffer_line_export(GBufferLine *line, int fd, BufferExportType type, bool phys, bool virt, bool code, bool content)
+void g_buffer_line_export(GBufferLine *line, buffer_export_context *ctx, BufferExportType type, const bool *display)
{
BufferLineColumn i; /* Boucle de parcours */
+ int col_span; /* Fusion de colonnes ? */
+
+ switch (type)
+ {
+ case BET_HTML:
+ dprintf(ctx->fd, "\t<TR>\n");
+ break;
+ default:
+ break;
+ }
for (i = 0; i < BLC_COUNT; i++)
{
- if (i == BLC_PHYSICAL && !phys) continue;
- if (i == BLC_VIRTUAL && !virt) continue;
- if (i == BLC_BINARY && !code) continue;
- if (!(i == BLC_PHYSICAL || i == BLC_VIRTUAL || i == BLC_BINARY) && !content) continue;
+ if (i < BLC_DISPLAY && !display[i]) continue;
+
+ switch (type)
+ {
+ case BET_TEXT:
+ if (i > 0) dprintf(ctx->fd, ctx->sep);
+ break;
+ default:
+ break;
+ }
+
+ /**
+ * Pour la signification des différentes valeurs assignées,
+ * se référer au code de export_segments_of_column().
+ *
+ * En gros :
+ * - 1 = rien de spécial.
+ * - >1 = il s'agit de la première cellule fusionnée de la ligne.
+ * - 0 = fusion déjà faite, on ne peut que rajouter du contenu dedans.
+ * - <1 = il s'agit de la dernière cellule fusionnée de la ligne.
+ *
+ * On considère qu'une fusion ne peut pas se réaliser sur la dernière
+ * cellule uniquement (ce qui a du sens : c'est inutile).
+ */
- dprintf(fd, "TODO\n");
+ if (i < line->merge_start)
+ col_span = 1;
+ else if (i == line->merge_start)
+ col_span = BLC_COUNT - i;
+
+ else
+ col_span = ((i + 1) == BLC_COUNT ? -1 : 0);
+
+ export_segments_of_column(&line->columns[i], ctx, type, col_span);
+
+ }
+
+ switch (type)
+ {
+ case BET_TEXT:
+ dprintf(ctx->fd, "\n");
+ break;
+ case BET_HTML:
+ dprintf(ctx->fd, "</TR>\n");
+ break;
+ default:
+ break;
}
}