summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.c
blob: cef34ef6d38dae78eff2f3240630a6f76aae5da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829

/* OpenIDA - Outil d'analyse de fichiers binaires
 * gbufferline.c - représentation de fragments de texte en ligne
 *
 * Copyright (C) 2010-2012 Cyrille Bagard
 *
 *  This file is part of OpenIDA.
 *
 *  OpenIDA is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  OpenIDA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "gbufferline.h"


#include <string.h>
#include <gtk/gtk.h>    /* Récupération du langage par défaut ; FIXME ? */


#include "../common/extstr.h"


#include <malloc.h> /* FIXME : à virer */




/* ---------------------------- REGROUPEMENT PAR COLONNE ---------------------------- */


/* Informations sur le contenu d'une colonne */
typedef struct _buffer_line_column
{
    GBufferSegment **segments;
    size_t count;

    int max_width;                          /* Largeur max. de l'espace    */

} buffer_line_column;



/* Réinitialise une colonne de ligne. */
static void reset_column(buffer_line_column *);

/* Fournit la quantité de pixels requise pour l'impression. */
static gint get_column_width(buffer_line_column *);

/* Ajoute un fragment de texte à une colonne de ligne. */
static void add_segment_to_column(buffer_line_column *, GBufferSegment *);

/* Donne le segment d'une colonne présent à une abscisse donnée. */
static GBufferSegment *get_segment_at(const buffer_line_column *, gint);

/* Met en surbrillance des segments similaires. */
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 *, GdkDrawable *, GdkGC *, gint, gint);



/* ---------------------------- GESTION DE LINE COMPLETE ---------------------------- */


/* Représentation de fragments de texte en ligne (instance) */
struct _GBufferLine
{
    GObject parent;                         /* A laisser en premier        */

    vmpa_t addr;                            /* Adresse geographique        */

    buffer_line_column columns[BLC_COUNT];  /* Répartition du texte        */
    BufferLineColumn merge_start;           /* Début de la zone globale    */
    BufferLineColumn last_used;             /* Dernière colonne utilisée   */

    bool skip_width;                        /* Pas de taille comptabilisée */

};

/* Représentation de fragments de texte en ligne (classe) */
struct _GBufferLineClass
{
    GObjectClass parent;                    /* A laisser en premier        */

    PangoContext *context;                  /* Contexte graphique Pango    */
    PangoAttrList *attribs[RTT_COUNT];      /* Décorateurs pour tampons    */

};


/* Procède à l'initialisation d'une classe de représentation. */
static void g_buffer_line_class_init(GBufferLineClass *);

/* Procède à l'initialisation d'une représentation de fragments. */
static void g_buffer_line_init(GBufferLine *);



/* ---------------------------------------------------------------------------------- */
/*                              REGROUPEMENT PAR COLONNE                              */
/* ---------------------------------------------------------------------------------- */





/******************************************************************************
*                                                                             *
*  Paramètres  : column  = colonne de ligne à mettre à jour.                  *
*                                                                             *
*  Description : Réinitialise une colonne de ligne.                           *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void reset_column(buffer_line_column *column)
{
    column->max_width = -1;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : column  = colonne de ligne à consulter.                      *
*                                                                             *
*  Description : Fournit la quantité de pixels requise pour l'impression.     *
*                                                                             *
*  Retour      : Largeur requise par la colonne, en pixel.                    *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static gint get_column_width(buffer_line_column *column)
{
    size_t i;                               /* Boucle de parcours          */

    if (column->max_width == -1)
    {
        column->max_width = 0;

        for (i = 0; i < column->count; i++)
            column->max_width += g_buffer_segment_get_width(column->segments[i]);

    }

    return column->max_width;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : column  = colonne de ligne à venir compléter.                *
*                segment = fragment de texte à ajouter à la colonne.          *
*                                                                             *
*  Description : Ajoute un fragment de texte à une colonne de ligne.          *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void add_segment_to_column(buffer_line_column *column, GBufferSegment *segment)
{

    /* FIXME : à remplacer */


    column->segments = (GBufferSegment **)realloc(column->segments, ++column->count * sizeof(GBufferSegment *));


    column->segments[column->count - 1] = segment;


}


/******************************************************************************
*                                                                             *
*  Paramètres  : column = colonne de ligne de texte à consulter.              *
*                x      = position de recherche à ajuster.                    *
*                                                                             *
*  Description : Donne le segment d'une colonne présent à une abscisse donnée.*
*                                                                             *
*  Retour      : Segment trouvé ou NULL si hors borne.                        *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static GBufferSegment *get_segment_at(const buffer_line_column *column, gint x)
{
    GBufferSegment *result;                 /* Trouvaille à retourner      */
    size_t i;                               /* Boucle de parcours          */
    gint width;                             /* Largeur à retirer           */

    result = NULL;

    for (i = 0; i < column->count && result == NULL; i++)
    {
        width = g_buffer_segment_get_width(column->segments[i]);

        if (width <= x)
            x -= width;

        else
            result = column->segments[i];

    }

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : column = colonne de ligne de texte à consulter.              *
*                list   = liste de segments identiques à constituer.          *
*                ref    = segment de référence à comparer avec les autres.    *
*                                                                             *
*  Description : Met en surbrillance des segments similaires.                 *
*                                                                             *
*  Retour      : Liste de segments identiques complétée.                      *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GSList *highlight_all_same_segments(const buffer_line_column *column, GSList *list, const GBufferSegment *ref)
{
    size_t i;                               /* Boucle de parcours          */

    for (i = 0; i < column->count; i++)
        if (g_buffer_segment_compare(column->segments[i], ref))
        {
            g_buffer_segment_set_style(column->segments[i], SRS_HIGHLIGHT_SAME);
            g_object_ref(G_OBJECT(column->segments[i]));
            list = g_slist_prepend(list, column->segments[i]);
        }

    return list;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : column   = colonne de ligne de texte à manipuler.            *
*                drawable = surface de rendu où travailler.                   *
*                gc       = contexte graphique à utiliser pour les pinceaux.  *
*                x_init   = abscisse du point d'impression de départ.         *
*                y        = ordonnée du point d'impression.                   *
*                                                                             *
*  Description : Imprime le contenu d'une colonne de ligne de texte.          *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void draw_segments_of_column(buffer_line_column *column, GdkDrawable *drawable, GdkGC *gc, gint x_init, gint y)
{
    gint x;
    size_t i;

    x = x_init;

    for (i = 0; i < column->count; i++)
        g_buffer_segment_draw(column->segments[i], drawable, gc, &x, y);

}



/* ---------------------------------------------------------------------------------- */
/*                              GESTION DE LINE COMPLETE                              */
/* ---------------------------------------------------------------------------------- */


/* Détermine le type de la représentation de fragments de texte en ligne. */
G_DEFINE_TYPE(GBufferLine, g_buffer_line, G_TYPE_OBJECT);



/******************************************************************************
*                                                                             *
*  Paramètres  : class = classe de composant GTK à initialiser.               *
*                                                                             *
*  Description : Procède à l'initialisation d'une classe de représentation.   *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

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_INDICATION */

    class->attribs[RTT_INDICATION] = pango_attr_list_new();

    attrib = pango_attr_foreground_new(33410, 33410, 33410);
    pango_attr_list_insert(class->attribs[RTT_INDICATION], attrib);

    attrib = pango_attr_style_new(PANGO_STYLE_ITALIC);
    pango_attr_list_insert(class->attribs[RTT_INDICATION], 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_PUNCT */

    class->attribs[RTT_PUNCT] = pango_attr_list_new();

    attrib = pango_attr_foreground_new(0, 0, 0);
    pango_attr_list_insert(class->attribs[RTT_PUNCT], attrib);

    attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
    pango_attr_list_insert(class->attribs[RTT_PUNCT], 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();

    attrib = pango_attr_foreground_new(0, 0, 0);
    pango_attr_list_insert(class->attribs[RTT_VAR_NAME], attrib);

    /* RTT_KEY_WORD */

    class->attribs[RTT_KEY_WORD] = pango_attr_list_new();

    attrib = pango_attr_foreground_new(0, 0, 0);
    pango_attr_list_insert(class->attribs[RTT_KEY_WORD], attrib);

    /* RTT_ERROR */

    class->attribs[RTT_ERROR] = pango_attr_list_new();

    attrib = pango_attr_foreground_new(65535, 0, 0);
    pango_attr_list_insert(class->attribs[RTT_ERROR], attrib);

    attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
    pango_attr_list_insert(class->attribs[RTT_ERROR], attrib);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line = composant GTK à initialiser.                          *
*                                                                             *
*  Description : Procède à l'initialisation d'une représentation de fragments.*
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

static void g_buffer_line_init(GBufferLine *line)
{
    BufferLineColumn i;                     /* Boucle de parcours          */

    for (i = BLC_ADDRESS; i < BLC_COUNT; i++)
        reset_column(&line->columns[i]);

    line->merge_start = BLC_COUNT;
    line->last_used = BLC_COUNT;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : addr = adresse où va se situer la ligne.                     *
*                                                                             *
*  Description : Crée une nouvelle représentation de fragments de texte.      *
*                                                                             *
*  Retour      : Composant GTK créé.                                          *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GBufferLine *g_buffer_line_new(vmpa_t addr)
{
    GBufferLine *result;                    /* Composant à retourner       */

    result = g_object_new(G_TYPE_BUFFER_LINE, NULL);

    result->addr = addr;

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line = ligne à venir consulter.                              *
*                                                                             *
*  Description : Indique l'adresse à laquelle se situe la ligne.              *
*                                                                             *
*  Retour      : Adresse mémoire ou physique.                                 *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

vmpa_t g_buffer_line_get_address(const GBufferLine *line)
{
    return line->addr;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line    = ligne à venir compléter.                           *
*                index   = index de la colonne visée par la procédure.        *
*                segment = fragment de texte à ajouter à la colonne.          *
*                                                                             *
*  Description : Ajoute un fragment de texte à une colonne de ligne.          *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_buffer_line_add_segment(GBufferLine *line, BufferLineColumn index, GBufferSegment *segment)
{
    add_segment_to_column(&line->columns[index], segment);

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line       = ligne à venir consulter.                        *
*                max_widths = largeurs de colonne à respecter.                *
*                x          = position à la colonne visée par la procédure.   *
*                                                                             *
*  Description : Donne le segment présent à une abscisse donnée.              *
*                                                                             *
*  Retour      : Segment trouvé ou NULL si hors borne.                        *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GBufferSegment *g_buffer_line_get_segment_at(const GBufferLine *line, const gint max_widths[BLC_COUNT], gint x)
{
    GBufferSegment *result;                 /* Trouvaille à retourner      */
    BufferLineColumn i;                     /* Boucle de parcours          */

    result = NULL;

    for (i = BLC_ADDRESS; i < BLC_COUNT; i++)
        if (x < max_widths[i]) break;
        else x -= (max_widths[i] + COL_MARGIN);

    if (i < BLC_COUNT)
        result = get_segment_at(&line->columns[i], x);

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line = ligne à venir consulter.                              *
*                list = liste de segments identiques à constituer.            *
*                ref  = segment de référence à comparer avec tous les autres. *
*                                                                             *
*  Description : Met en surbrillance des segments similaires.                 *
*                                                                             *
*  Retour      : Liste de segments identiques complétée.                      *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GSList *g_buffer_line_highlight_all_same_segments(const GBufferLine *line, GSList *list, const GBufferSegment *ref)
{
    BufferLineColumn i;                     /* Boucle de parcours          */

    for (i = BLC_ADDRESS; i < BLC_COUNT; i++)
        list = highlight_all_same_segments(&line->columns[i], list, ref);

    return list;

}


/******************************************************************************
*                                                                             *
*  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);

    if (column == BLC_LAST_USED)
        column = line->last_used;
    else
        line->last_used = column;

    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 consulter.                              *
*                                                                             *
*  Description : Donne le texte représenté par une ligne de tampon.           *
*                                                                             *
*  Retour      : Texte à libérer de la mémoire après usage.                   *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

char *g_buffer_line_get_text(const GBufferLine *line)
{
    char *result;                           /* Construction à retourner    */
    BufferLineColumn i;                     /* Boucle de parcours #1       */
    size_t j;                               /* Boucle de parcours #2       */

    result = NULL;

    for (i = BLC_ASSEMBLY_HEAD; i < BLC_COUNT; i++)
        for (j = 0; j < line->columns[i].count; j++)
            if (result == NULL)
            {
                result = strdup(g_buffer_segment_get_text(line->columns[i].segments[j]));
                result = stradd(result, " ");
            }
            else
                result = stradd(result, g_buffer_segment_get_text(line->columns[i].segments[j]));

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line = ligne à venir compléter.                              *
*                                                                             *
*  Description : Marque la ligne comme étant sans largeur à comptabiliser.    *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_buffer_line_skip_width(GBufferLine *line)
{
    line->skip_width = true;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line  = ligne à venir compléter.                             *
*                index = index de la colonne visée par la procédure.          *
*                                                                             *
*  Description : Fournit la largeur requise pour une colonne de ligne donnée. *
*                                                                             *
*  Retour      : Largeur en pixel requise.                                    *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

gint g_buffer_line_get_width(GBufferLine *line, BufferLineColumn index)
{
    gint result;                            /* Largeur à retourner         */

    if (line->skip_width) result = 0;
    else result = get_column_width(&line->columns[index]);

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line  = ligne à venir compléter.                             *
*                start = début de la première (et unique) zone globale.       *
*                                                                             *
*  Description : Définit la colonne à partir de laquelle la fusion opère.     *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_buffer_line_start_merge_at(GBufferLine *line, BufferLineColumn start)
{
    line->merge_start = start;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : line       = ligne de texte à manipuler.                     *
*                drawable   = surface de rendu où travailler.                 *
*                gc         = contexte graphique à utiliser pour les pinceaux.*
*                max_widths = largeurs de colonne à respecter.                *
*                x_init     = abscisse du point d'impression de départ.       *
*                y          = ordonnée du point d'impression.                 *
*                addr   = indique si les positions doivent être affichées.    *
*                code   = indique si le code binaire doit être affiché.       *
*                                                                             *
*  Description : Imprime la ligne de texte représentée.                       *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_buffer_line_draw(GBufferLine *line, GdkDrawable *drawable, GdkGC *gc, const gint max_widths[BLC_COUNT], gint x_init, gint y, bool addr, bool code)
{
    gint x;                                 /* Point de départ d'impression*/
    BufferLineColumn i;                     /* Boucle de parcours          */

    x = x_init;

    for (i = BLC_ADDRESS; i < BLC_COUNT; i++)
    {
        if (i == BLC_ADDRESS && !addr) continue;
        if (i == BLC_BINARY && !code) continue;

        draw_segments_of_column(&line->columns[i], drawable, gc, x, y);

        if (i < line->merge_start)
            x += max_widths[i] + COL_MARGIN;

    }

}



/******************************************************************************
*                                                                             *
*  Paramètres  : line    = ligne de texte à manipuler.                        *
*                fd      = flux ouvert en écriture.                           *
*                type    = type d'exportation attendue.                       *
*                addr    = indique si les positions doivent être affichées.   *
*                code    = indique si le code binaire doit être affiché.      *
*                content = indique si le gros du contenu doit être affiché.   *
*                                                                             *
*  Description : Exporte la ligne de texte représentée.                       *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void g_buffer_line_export(GBufferLine *line, int fd, BufferExportType type, bool addr, bool code, bool content)
{
    BufferLineColumn i;                     /* Boucle de parcours          */

    for (i = BLC_ADDRESS; i < BLC_COUNT; i++)
    {
        if (i == BLC_ADDRESS && !addr) continue;
        if (i == BLC_BINARY && !code) continue;
        if (!(i == BLC_ADDRESS || i == BLC_BINARY) && !content) continue;

        dprintf(fd, "TODO\n");

    }

}