summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/gbufferline.c')
-rw-r--r--src/glibext/gbufferline.c806
1 files changed, 118 insertions, 688 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index a33817b..d03dfaf 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -27,84 +27,18 @@
#include <assert.h>
#include <malloc.h>
#include <string.h>
-#include <gtk/gtk.h> /* Récupération du langage par défaut ; FIXME ? */
#include "chrysamarshal.h"
+#include "linecolumn.h"
#include "../common/extstr.h"
#include "../gtkext/support.h"
-/* ---------------------------- 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 *);
-
-/* Recalcule la largeur d'une colonne de segments. */
-static void refresh_column_width(buffer_line_column *);
-
-/* Fournit la quantité de pixels requise pour l'impression. */
-static gint get_column_width(const buffer_line_column *);
-
-/* Ajoute un fragment de texte à une colonne de ligne. */
-static void add_segment_to_column(buffer_line_column *, GBufferSegment *) __attribute__ ((deprecated));
-
-/* Ajoute un fragment de texte à une colonne de ligne. */
-static size_t append_text_to_line_column(buffer_line_column *, const char *, size_t, RenderingTagType);
-
-/* Valide ou non la présence d'un segment dans une colonne. */
-static bool column_has_segment(const buffer_line_column *, const GBufferSegment *, size_t *);
-
-/* Indique l'indice du premier contenu de la colonne. */
-static bool get_column_first_content_index(const buffer_line_column *, size_t *);
-
-/* Indique l'indice du dernier contenu de la colonne. */
-static bool get_column_last_content_index(const buffer_line_column *, size_t *);
-
-#define get_first_segment(col) ((col)->count > 0 ? (col)->segments[0] : NULL)
-#define get_last_segment(col) ((col)->count > 0 ? (col)->segments[(col)->count - 1] : NULL)
-
-/* Indique l'indice du contenu de colonne à une abscisse donnée. */
-static bool get_column_content_index_at(const buffer_line_column *, gint *, GdkScrollDirection, gint *, size_t *);
-
-/* Donne le segment d'une colonne présent à un indice donné. */
-static GBufferSegment *get_column_content_from_index(const buffer_line_column *, size_t);
-
-/* Fournit le segment voisin d'un autre segment identifié. */
-static GBufferSegment *find_near_segment(const buffer_line_column *, GBufferSegment *, GdkScrollDirection);
-
-/* Imprime le contenu d'une colonne de ligne de texte. */
-static void draw_segments_of_column(buffer_line_column *, cairo_t *, gint, gint, const segcnt_list *);
-
-/* 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 ---------------------------- */
-/* Identification d'un contenu de colonne */
-typedef struct _col_coord_t
-{
- BufferLineColumn column; /* Colonne concernée */
- size_t index; /* Indice d'insertion */
-
-} col_coord_t;
-
/* Mémorisation des origines de texte */
typedef struct _content_origin
{
@@ -122,7 +56,7 @@ struct _GBufferLine
mrange_t range; /* Couverture geographique */
BufferLineColumn main_column; /* Colonne principale */
- buffer_line_column columns[BLC_COUNT]; /* Répartition du texte */
+ 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 */
@@ -153,7 +87,7 @@ struct _GBufferLineClass
/* Signaux */
- void (* content_changed) (GBufferLine *, GBufferSegment *);
+ void (* content_changed) (GBufferLine *, line_segment *);
void (* flip_flag) (GBufferLine *, BufferLineFlags, BufferLineFlags);
@@ -172,465 +106,6 @@ static void g_buffer_line_dispose(GBufferLine *);
/* Procède à la libération totale de la mémoire. */
static void g_buffer_line_finalize(GBufferLine *);
-/* Réagit au changement de contenu d'un segment encapsulé. */
-static void on_line_segment_changed(GBufferSegment *, GBufferLine *);
-
-/* Fournit les coordonnées correspondant à une abscisse donnée. */
-static bool g_buffer_line_get_coord_at(const GBufferLine *, const line_width_summary *, const bool *, gint *, gint *, GdkScrollDirection, bool, col_coord_t *);
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* 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)
-{
- size_t i; /* Boucle de parcours */
-
- for (i = 0; i < column->count; i++)
- g_object_unref(G_OBJECT(column->segments[i]));
-
- if (column->segments != NULL)
- {
- free(column->segments);
- column->segments = NULL;
- }
-
- column->count = 0;
-
- column->max_width = 0;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne à mettre à jour. *
-* *
-* Description : Recalcule la largeur d'une colonne de segments. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void refresh_column_width(buffer_line_column *column)
-{
- size_t i; /* Boucle de parcours */
-
- column->max_width = 0;
-
- for (i = 0; i < column->count; i++)
- column->max_width += g_buffer_segment_get_width(column->segments[i]);
-
-}
-
-
-/******************************************************************************
-* *
-* 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(const buffer_line_column *column)
-{
- 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;
-
-
- column->max_width += g_buffer_segment_get_width(segment);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne à venir compléter. *
-* text = texte à insérer dans l'existant. *
-* length = taille du texte à traiter. *
-* type = type de décorateur à utiliser. *
-* *
-* Description : Ajoute un fragment de texte à une colonne de ligne. *
-* *
-* Retour : Indice du point d'insertion. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static size_t append_text_to_line_column(buffer_line_column *column, const char *text, size_t length, RenderingTagType type)
-{
- size_t result; /* Indice à retourner */
- GBufferSegment *content; /* Contenu à représenter */
-
- result = column->count;
-
- content = g_buffer_segment_new(type, text, length);
-
- column->segments = (GBufferSegment **)realloc(column->segments, ++column->count * sizeof(GBufferSegment *));
-
- column->segments[result] = content;
-
- column->max_width += g_buffer_segment_get_width(content);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne à venir consulter. *
-* segment = fragment de texte à trouver dans la colonne. *
-* index = indice du segment retrouvé ou NULL. [OUT] *
-* *
-* Description : Valide ou non la présence d'un segment dans une colonne. *
-* *
-* Retour : Statut de présence du segment indiqué. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool column_has_segment(const buffer_line_column *column, const GBufferSegment *segment, size_t *index)
-{
- size_t i; /* Boucle de parcours */
-
- for (i = 0; i < column->count; i++)
- if (column->segments[i] == segment)
- {
- if (index != NULL) *index = i;
- break;
- }
-
- return (i < column->count);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à consulter. *
-* index = indice du contenu enregistré à la position. [OUT] *
-* *
-* Description : Indique l'indice du premier contenu de la colonne. *
-* *
-* Retour : Validité de l'indice renseigné. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool get_column_first_content_index(const buffer_line_column *column, size_t *index)
-{
- bool result; /* Bilan à retourner */
-
- result = (column->count > 0);
-
- if (result)
- *index = 0;
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à consulter. *
-* index = indice du contenu enregistré à la position. [OUT] *
-* *
-* Description : Indique l'indice du dernier contenu de la colonne. *
-* *
-* Retour : Validité de l'indice renseigné. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool get_column_last_content_index(const buffer_line_column *column, size_t *index)
-{
- bool result; /* Bilan à retourner */
-
- result = (column->count > 0);
-
- if (result)
- *index = column->count - 1;
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à consulter. *
-* x = position de recherche, puis position locale. [OUT]*
-* dir = direction d'un éventuel déplacement en cours. *
-* consumed = distance pour arriver à la base du segment. [OUT] *
-* index = indice du contenu enregistré à la position. [OUT] *
-* *
-* Description : Indique l'indice du contenu de colonne à une abscisse donnée.*
-* *
-* Retour : Validité de l'indice renseigné. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool get_column_content_index_at(const buffer_line_column *column, gint *x, GdkScrollDirection dir, gint *consumed, size_t *index)
-{
- bool result; /* Bilan à retourner */
- size_t i; /* Boucle de parcours */
- gint width; /* Largeur à retirer */
- bool included; /* Appartenance à une largeur ?*/
-
- result = false;
- *consumed = 0;
-
- for (i = 0; i < column->count && !result; i++)
- {
- width = g_buffer_segment_get_width(column->segments[i]);
-
- /**
- * Soit une limite entre deux segments A et B :
- *
- * - dans le cas d'un déplacement vers la gauche, on part de cette limite
- * pour progresser à l'intérieur de A. Donc la limite fait partie de A.
- *
- * - dans le cas d'un déplacement vers la droite, on part de cette limite
- * pour progresser à l'intérieur de B. Donc la limite ne fait pas partie de A.
- */
- if (dir == GDK_SCROLL_LEFT) included = (width >= *x);
- else included = (width > *x);
-
- if (included)
- {
- *index = i;
- result = true;
- }
-
- else if ((i + 1) == column->count)
- {
- *index = i;
- result = true;
- *x = width;
- }
-
- else
- {
- *x -= width;
- *consumed += width;
- }
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à consulter. *
-* index = indice du contenu à fournir. *
-* *
-* Description : Donne le segment d'une colonne présent à un indice donné. *
-* *
-* Retour : Segment trouvé ou NULL si hors borne. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static GBufferSegment *get_column_content_from_index(const buffer_line_column *column, size_t index)
-{
- GBufferSegment *result; /* Trouvaille à retourner */
-
- assert(index < column->count);
-
- result = column->segments[index];
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à consulter. *
-* target = segment dont un voisin est à retourner. *
-* dir = orientation des recherches. *
-* *
-* Description : Fournit le segment voisin d'un autre segment identifié. *
-* *
-* Retour : Segment trouvé ou NULL si hors borne ou inconnu. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static GBufferSegment *find_near_segment(const buffer_line_column *column, GBufferSegment *target, GdkScrollDirection dir)
-{
- GBufferSegment *result; /* Trouvaille à retourner */
- bool found; /* Le segment est bien présent */
- size_t i; /* Boucle de parcours */
-
- result = NULL;
-
- found = column_has_segment(column, target, &i);
-
- if (found)
- switch (dir)
- {
- case GDK_SCROLL_LEFT:
- if (i > 0)
- result = column->segments[i - 1];
- break;
-
- case GDK_SCROLL_RIGHT:
- if ((i + 1) < column->count)
- result = column->segments[i + 1];
- break;
-
- default:
- break;
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : column = colonne de ligne de texte à manipuler. *
-* cairo = contexte graphique à utiliser pour les pinceaux. *
-* x_init = abscisse du point d'impression de départ. *
-* y = ordonnée du point d'impression. *
-* list = liste de contenus à mettre en évidence. *
-* *
-* Description : Imprime le contenu d'une colonne de ligne de texte. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void draw_segments_of_column(buffer_line_column *column, cairo_t *cairo, gint x_init, gint y, const segcnt_list *list)
-{
- gint x; /* Abscisse d'impression */
- size_t i; /* Boucle de parcours */
-
- x = x_init;
-
- for (i = 0; i < column->count; i++)
- g_buffer_segment_draw(column->segments[i], cairo, &x, y, list);
-
-}
-
-
-/******************************************************************************
-* *
-* 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;
- }
-
-}
-
/* ---------------------------------------------------------------------------------- */
@@ -715,7 +190,7 @@ static void g_buffer_line_init(GBufferLine *line)
BufferLineColumn i; /* Boucle de parcours */
for (i = 0; i < BLC_COUNT; i++)
- reset_column(&line->columns[i]);
+ init_line_column(&line->columns[i]);
line->merge_start = BLC_COUNT;
line->last_used = BLC_COUNT;
@@ -851,16 +326,16 @@ void g_buffer_line_fill_mrange(GBufferLine *line, MemoryDataSize psize, MemoryDa
if (address[i] != '0') break;
if (i == len)
- g_buffer_line_insert_text(line, BLC_PHYSICAL, address, len, RTT_PHYS_ADDR_PAD);
+ g_buffer_line_append_text(line, BLC_PHYSICAL, address, len, RTT_PHYS_ADDR_PAD, NULL);
else
{
- g_buffer_line_insert_text(line, BLC_PHYSICAL, address, 2, RTT_PHYS_ADDR);
+ g_buffer_line_append_text(line, BLC_PHYSICAL, address, 2, RTT_PHYS_ADDR, NULL);
if (i > 2)
- g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[2], i - 2, RTT_PHYS_ADDR_PAD);
+ g_buffer_line_append_text(line, BLC_PHYSICAL, &address[2], i - 2, RTT_PHYS_ADDR_PAD, NULL);
- g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[i], len - i, RTT_PHYS_ADDR);
+ g_buffer_line_append_text(line, BLC_PHYSICAL, &address[i], len - i, RTT_PHYS_ADDR, NULL);
}
@@ -876,16 +351,16 @@ void g_buffer_line_fill_mrange(GBufferLine *line, MemoryDataSize psize, MemoryDa
if (address[i] != '0') break;
if (i == len)
- g_buffer_line_insert_text(line, BLC_VIRTUAL, address, len, RTT_VIRT_ADDR_PAD);
+ g_buffer_line_append_text(line, BLC_VIRTUAL, address, len, RTT_VIRT_ADDR_PAD, NULL);
else
{
- g_buffer_line_insert_text(line, BLC_VIRTUAL, address, 2, RTT_VIRT_ADDR);
+ g_buffer_line_append_text(line, BLC_VIRTUAL, address, 2, RTT_VIRT_ADDR, NULL);
if (i > 2)
- g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[2], i - 2, RTT_VIRT_ADDR_PAD);
+ g_buffer_line_append_text(line, BLC_VIRTUAL, &address[2], i - 2, RTT_VIRT_ADDR_PAD, NULL);
- g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[i], len - i, RTT_VIRT_ADDR);
+ g_buffer_line_append_text(line, BLC_VIRTUAL, &address[i], len - i, RTT_VIRT_ADDR, NULL);
}
@@ -987,7 +462,7 @@ void g_buffer_line_fill_for_instr(GBufferLine *line, MemoryDataSize psize, Memor
/* Conclusion */
- g_buffer_line_insert_text(line, BLC_BINARY, bin_code, iter - bin_code, RTT_RAW_CODE);
+ g_buffer_line_append_text(line, BLC_BINARY, bin_code, iter - bin_code, RTT_RAW_CODE, NULL);
if (bin_code != static_buffer)
free(bin_code);
@@ -1033,91 +508,12 @@ GObject *g_buffer_line_find_first_segment_creator(const GBufferLine *line, Buffe
/******************************************************************************
* *
-* Paramètres : line = ligne à venir consulter. *
-* creator = créateur à l'origine du segment recherché. *
-* *
-* Description : Fournit le segment créé par un objet particulier. *
-* *
-* Retour : Segment trouvé dans la ligne ou NULL. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GBufferSegment *g_buffer_line_find_segment_from_creator(const GBufferLine *line, GObject *creator)
-{
- GBufferSegment *result; /* Trouvaille à retourner */
- size_t i; /* Boucle de parcours */
- const col_coord_t *coord; /* Emplacement du contenu visé */
-
- result = NULL;
-
- for (i = 0; i < line->ocount; i++)
- {
- if (line->origins[i].creator == creator)
- {
- coord = &line->origins[i].coord;
-
- result = get_column_content_from_index(&line->columns[coord->column], coord->index);
-
- break;
-
- }
-
- }
-
- if (result != NULL)
- g_object_ref(G_OBJECT(result));
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : segment = segment de texte dont le contenu vient de changer. *
-* line = ligne contenant ce segment. *
-* *
-* Description : Réagit au changement de contenu d'un segment encapsulé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void on_line_segment_changed(GBufferSegment *segment, GBufferLine *line)
-{
- BufferLineColumn i; /* Boucle de parcours */
- buffer_line_column *column;
-
- /* Actualisation de la largeur de la colonne */
-
- for (i = 0; i < BLC_COUNT; i++)
- {
- column = &line->columns[i];
-
- if (column_has_segment(column, segment, NULL))
- {
- refresh_column_width(column);
- break;
- }
-
- }
-
- g_signal_emit_by_name(line, "content-changed", segment);
-
-}
-
-
-/******************************************************************************
-* *
-* 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. *
+* 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. *
+* creator = instance GLib quelconque à associer. *
* *
* Description : Ajoute du texte à formater dans une ligne donnée. *
* *
@@ -1127,9 +523,10 @@ static void on_line_segment_changed(GBufferSegment *segment, GBufferLine *line)
* *
******************************************************************************/
-GBufferSegment *g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn column, const char *text, size_t length, RenderingTagType type)
+void g_buffer_line_append_text(GBufferLine *line, BufferLineColumn column, const char *text, size_t length, RenderingTagType type, GObject *creator)
{
- GBufferSegment *result; /* Portion de texte à renvoyer */
+ size_t index; /* Indice d'insertion */
+ content_origin *origin; /* Définition d'une origine */
assert(length > 0);
@@ -1141,13 +538,21 @@ GBufferSegment *g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn co
else
line->last_used = column;
- result = g_buffer_segment_new(type, text, length);
+ index = append_text_to_line_column(&line->columns[column], text, length, type);
- add_segment_to_column(&line->columns[column], result);
+ if (creator != NULL)
+ {
+ line->origins = (content_origin *)realloc(line->origins, ++line->ocount * sizeof(content_origin));
- g_signal_connect(result, "content-changed", G_CALLBACK(on_line_segment_changed), line);
+ origin = &line->origins[line->ocount - 1];
- return result;
+ origin->coord.column = column;
+ origin->coord.index = index;
+
+ origin->creator = creator;
+ g_object_ref(G_OBJECT(creator));
+
+ }
}
@@ -1155,51 +560,44 @@ GBufferSegment *g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn co
/******************************************************************************
* *
* Paramètres : line = ligne à venir compléter. *
-* column = colonne de la ligne visée par l'insertion. *
+* creator = instance GLib quelconque identifiant un segment. *
* text = texte à insérer dans l'existant. *
* length = taille du texte à traiter. *
-* type = type de décorateur à utiliser. *
-* creator = instance GLib quelconque à associer. *
* *
-* Description : Ajoute du texte à formater dans une ligne donnée. *
+* Description : Remplace du texte dans une ligne donnée. *
* *
-* Retour : Portion de texte mis en place, voire NULL. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-void g_buffer_line_append_text(GBufferLine *line, BufferLineColumn column, const char *text, size_t length, RenderingTagType type, GObject *creator)
+bool g_buffer_line_replace_text(GBufferLine *line, const GObject *creator, const char *text, size_t length)
{
- size_t index; /* Indice d'insertion */
- content_origin *origin; /* Définition d'une origine */
-
- assert(length > 0);
-
- if (column == BLC_MAIN)
- column = line->main_column;
-
- if (column == BLC_LAST_USED)
- column = line->last_used;
- else
- line->last_used = column;
+ bool result; /* Bilan à retourner */
+ size_t i; /* Boucle de parcours */
+ const col_coord_t *coord; /* Emplacement du contenu visé */
- index = append_text_to_line_column(&line->columns[column], text, length, type);
+ result = false;
- if (creator != NULL)
+ for (i = 0; i < line->ocount && !result; i++)
{
- line->origins = (content_origin *)realloc(line->origins, ++line->ocount * sizeof(content_origin));
+ if (line->origins[i].creator == creator)
+ {
+ coord = &line->origins[i].coord;
- origin = &line->origins[line->ocount - 1];
+ replace_text_in_line_column(&line->columns[coord->column], coord->index, text, length);
- origin->coord.column = column;
- origin->coord.index = index;
+ g_signal_emit_by_name(line, "content-changed", NULL);
- origin->creator = creator;
- g_object_ref(G_OBJECT(creator));
+ result = true;
+
+ }
}
+ return result;
+
}
@@ -1267,7 +665,7 @@ char *g_buffer_line_get_text(const GBufferLine *line, BufferLineColumn first, Bu
for (j = 0; j < line->columns[i].count; j++)
{
- extra = g_buffer_segment_get_text(line->columns[i].segments[j], markup);
+ extra = get_line_segment_text(line->columns[i].segments[j], markup);
if (result == NULL)
result = extra;
@@ -1307,7 +705,7 @@ void g_buffer_line_delete_text(GBufferLine *line, BufferLineColumn first, Buffer
assert(first < end);
for (i = first; i < end; i++)
- reset_column(&line->columns[i]);
+ reset_line_column(&line->columns[i]);
}
@@ -1469,7 +867,7 @@ void g_buffer_line_export(GBufferLine *line, buffer_export_context *ctx, BufferE
/**
* Pour la signification des différentes valeurs assignées,
- * se référer au code de export_segments_of_column().
+ * se référer au code de export_line_column_segments().
*
* En gros :
* - 1 = rien de spécial.
@@ -1490,7 +888,7 @@ void g_buffer_line_export(GBufferLine *line, buffer_export_context *ctx, BufferE
else
col_span = ((i + 1) == BLC_COUNT ? -1 : 0);
- export_segments_of_column(&line->columns[i], ctx, type, col_span);
+ export_line_column_segments(&line->columns[i], ctx, type, col_span);
}
@@ -1591,6 +989,32 @@ gint g_buffer_line_compute_max_width(const GBufferLine *line, BufferLineColumn i
}
+
+
+/******************************************************************************
+* *
+* Paramètres : line = ligne à venir consulter. *
+* coord = coordonnées interne du segment à retrouver. *
+* *
+* Description : Fournit le segment présent à une position donnée. *
+* *
+* Retour : Segment trouvé ou NULL si hors borne. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const line_segment *g_buffer_line_get_segment_from_coord(const GBufferLine *line, const col_coord_t *coord)
+{
+ line_segment *result; /* Trouvaille à retourner */
+
+ result = get_line_column_content_from_index(&line->columns[coord->column], coord->index);
+
+ return result;
+
+}
+
+
/******************************************************************************
* *
* Paramètres : line = ligne à venir consulter. *
@@ -1610,7 +1034,7 @@ gint g_buffer_line_compute_max_width(const GBufferLine *line, BufferLineColumn i
* *
******************************************************************************/
-static bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force, col_coord_t *coord)
+bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force, col_coord_t *coord)
{
bool result; /* Bilan à retourner */
BufferLineColumn last; /* Dernière colonne remplie */
@@ -1687,7 +1111,7 @@ static bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width
*/
if (*offset < 0) *offset = 0;
- result = get_column_content_index_at(&line->columns[i], offset, dir, &consumed, &coord->index);
+ result = get_line_column_content_index_at(&line->columns[i], offset, dir, &consumed, &coord->index);
if (result)
{
@@ -1720,7 +1144,7 @@ static bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width
else
*base += get_column_width(&line->columns[i - 1]);
- result = get_column_first_content_index(&line->columns[i], &coord->index);
+ result = get_line_column_first_content_index(&line->columns[i], &coord->index);
if (result)
coord->column = i;
@@ -1747,7 +1171,7 @@ static bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width
if (last != BLC_COUNT)
{
- result = get_column_last_content_index(&line->columns[last], &coord->index);
+ result = get_line_column_last_content_index(&line->columns[last], &coord->index);
if (result)
{
@@ -1791,16 +1215,16 @@ static bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width
* *
******************************************************************************/
-GBufferSegment *g_buffer_line_get_segment_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force)
+const line_segment *g_buffer_line_get_segment_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force)
{
- GBufferSegment *result; /* Trouvaille à retourner */
+ const line_segment *result; /* Trouvaille à retourner */
col_coord_t coord; /* Emplacement du contenu visé */
bool status; /* Bilan de la localisation */
status = g_buffer_line_get_coord_at(line, summary, display, base, offset, dir, force, &coord);
if (status)
- result = get_column_content_from_index(&line->columns[coord.column], coord.index);
+ result = g_buffer_line_get_segment_from_coord(line, &coord);
return result;
@@ -1861,43 +1285,40 @@ GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_
/******************************************************************************
* *
* Paramètres : line = ligne à venir consulter. *
-* target = segment dont un voisin est à retourner. *
+* coord = cordonnées à consulter puis renseigner. [OUT] *
* summary = résumé des largeurs maximales. *
* display = règles d'affichage des colonnes modulables. *
* dir = orientation des recherches. *
* offset = décalage pour amener à l'extrémité nouvelle. [OUT] *
* *
-* Description : Fournit le segment voisin d'un autre segment identifié. *
+* Description : Fournit des coordonnées voisines selon une direction donnée. *
* *
-* Retour : Segment trouvé dans la ligne ou NULL. *
+* Retour : true si des coordonnées valides ont été renseignées. *
* *
* Remarques : - *
* *
******************************************************************************/
-GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBufferSegment *target, const line_width_summary *summary, const bool *display, GdkScrollDirection dir, gint *offset)
+bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord, const line_width_summary *summary, const bool *display, GdkScrollDirection dir, gint *offset)
{
- GBufferSegment *result; /* Trouvaille à retourner */
+ bool result; /* Bilan à retourner */
BufferLineColumn i; /* Boucle de parcours #1 */
bool displayed; /* Confort de lecture */
BufferLineColumn k; /* Boucle de parcours #2 */
- result = NULL;
+ result = false;
/* Recherche dans la colonne de départ */
- for (i = 0; i < BLC_COUNT; i++)
- if (column_has_segment(&line->columns[i], target, NULL))
- break;
+ i = coord->column;
- if (i == BLC_COUNT) return NULL;
+ if (i == BLC_COUNT) return false;
- result = find_near_segment(&line->columns[i], target, dir);
- if (result != NULL) return result;
+ result = find_near_segment(&line->columns[i], &coord->index, dir);
/* Recherche dans la direction des colonnes voisines */
- if (result == NULL)
+ if (!result)
switch (dir)
{
case GDK_SCROLL_LEFT:
@@ -1906,12 +1327,18 @@ GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBuffer
if (i == 0) break;
/* On s'assure que la colonne précédente est visible et peuplée */
- for (; i > BLC_FIRST && result == NULL; i--)
+ for (; i > BLC_FIRST && !result; i--)
{
displayed = (i <= BLC_DISPLAY ? display[i - 1] : true);
if (displayed)
- result = get_last_segment(&line->columns[i - 1]);
+ {
+ result = get_line_column_first_content_index(&line->columns[i - 1], &coord->index);
+
+ if (result)
+ coord->column = i - 1;
+
+ }
}
@@ -1919,16 +1346,19 @@ GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBuffer
case GDK_SCROLL_RIGHT:
- /* Si on a atteint la dernière colonne sans trouver... */
- /*if (i == BLC_COUNT) break;*/
-
/* On s'assure que la colonne suivante est visible et peuplée */
- for (; (i + 1) < BLC_COUNT && result == NULL; i++)
+ for (; (i + 1) < BLC_COUNT && !result; i++)
{
displayed = ((i + 1) < BLC_DISPLAY ? display[i + 1] : true);
if (displayed)
- result = get_first_segment(&line->columns[i + 1]);
+ {
+ result = get_line_column_first_content_index(&line->columns[i + 1], &coord->index);
+
+ if (result)
+ coord->column = i + 1;
+
+ }
}
@@ -1941,7 +1371,7 @@ GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBuffer
/* Calcul de la position finale */
- if (result != NULL)
+ if (result)
{
*offset = 0;
@@ -2033,7 +1463,7 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const line_width_summ
{
if (i < BLC_DISPLAY && !display[i]) continue;
- draw_segments_of_column(&line->columns[i], cairo, x, y, list);
+ draw_line_column_segments(&line->columns[i], cairo, x, y, list);
if (i < line->merge_start)
{