summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-04-12 22:07:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-04-12 22:07:56 (GMT)
commit90923fccb863075722d2ed17360e2c330b262e04 (patch)
treeb7588517a6437efa2d4cd885984e0b87ef8307fe /src/glibext/gbufferline.c
parent054d2d76f1951c20822286bce0128e60c26c4b9b (diff)
Highlighted the current segment on caret location changes.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@511 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/gbufferline.c')
-rw-r--r--src/glibext/gbufferline.c214
1 files changed, 7 insertions, 207 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index d763e9d..238bfb3 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -74,11 +74,8 @@ static GBufferSegment *get_segment_at(const buffer_line_column *, gint *, GdkScr
/* Fournit le segment voisin d'un autre segment identifié. */
static GBufferSegment *find_near_segment(const buffer_line_column *, GBufferSegment *, GdkScrollDirection);
-/* Met en surbrillance des segments similaires. */
-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);
+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);
@@ -351,41 +348,11 @@ static GBufferSegment *find_near_segment(const buffer_line_column *column, GBuff
/******************************************************************************
* *
-* 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 : - *
-* *
-******************************************************************************/
-
-static 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. *
* 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. *
* *
@@ -395,7 +362,7 @@ static GSList *highlight_all_same_segments(const buffer_line_column *column, GSL
* *
******************************************************************************/
-static void draw_segments_of_column(buffer_line_column *column, cairo_t *cairo, gint x_init, gint y)
+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 */
@@ -403,7 +370,7 @@ static void draw_segments_of_column(buffer_line_column *column, cairo_t *cairo,
x = x_init;
for (i = 0; i < column->count; i++)
- g_buffer_segment_draw(column->segments[i], cairo, &x, y);
+ g_buffer_segment_draw(column->segments[i], cairo, &x, y, list);
}
@@ -933,148 +900,6 @@ GBufferSegment *g_buffer_line_get_segment_at(const GBufferLine *line, const gint
}
-#if 0
-GBufferSegment *g_buffer_line_get_segment_at(const GBufferLine *line, const gint max_widths[BLC_COUNT], const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force)
-{
- GBufferSegment *result; /* Trouvaille à retourner */
- gint old; /* Valeur d'origine de position*/
- BufferLineColumn last; /* Dernière colonne remplie */
- gint last_x; /* Dernière abscisse associée */
- gint sum; /* Somme de toutes les largeurs*/
- BufferLineColumn i; /* Boucle de parcours */
- gint width; /* Largeur d'une colonne donnée*/
- gint consumed; /* Distance vers le segment */
-
- result = NULL;
-
- old = *x;
- last = BLC_COUNT;
- last_x = *x; /* Pour GCC */
-
- sum = 0;
-
- printf("---------------\n");
-
- /* On cible déjà la colonne idéale */
-
- for (i = 0; i < BLC_COUNT; i++)
- {
- printf(" @ (%d) x=%d width=%d max=%d display ? %d\n",
- i, *x, get_column_width(&line->columns[i]), max_widths[i], i < BLC_DISPLAY ? display[i] : true);
-
-
- if (i < BLC_DISPLAY && !display[i]) continue;
-
- /* Mémorisation de la dernière colonne contenant quelque chose... */
- if (get_column_width(&line->columns[i]) > 0)
- {
- last = i;
- last_x = sum;
- }
-
- if (i < line->merge_start)
- {
- width = max_widths[i];
- if ((i + 1) < BLC_COUNT) width += COL_MARGIN;
-
- if (*x <= width) break;
- else
- {
- *x -= width;
- sum += width;
- }
-
- }
- else
- {
- width = get_column_width(&line->columns[i]);
-
- if (*x <= width) break;
- else
- {
- *x -= width;
- sum += width;
- }
-
- }
-
-
- }
-
- printf(" -- get segment at -- found index %u (max=%u)\n", i, BLC_COUNT);
-
-
- printf(" last seen = %u\n", last);
-
-
-
-
-
- if (i < BLC_COUNT)
- {
-
- printf(" -- width @ %u : %d\n", i, get_column_width(&line->columns[i]));
-
- if (get_column_width(&line->columns[i]) > 0)
- {
- result = get_segment_at(&line->columns[i], x, dir, &consumed);
- *x += sum + consumed;
- }
-
- /* La position fournie tombe dans une colonne vide ! */
- else
- {
- if (force || get_column_width(&line->columns[i]) == 0)
- {
- result = NULL;
- *x = sum;
-
- for (i++; i < BLC_COUNT && result == NULL; i++)
- {
- printf(" -- update to col %u -- x = %d\n", i, *x);
-
- if ((i - 1) < line->merge_start)
- *x += (max_widths[i - 1] + COL_MARGIN);
- else
- *x += get_column_width(&line->columns[i - 1]);
-
- result = get_first_segment(&line->columns[i]);
-
- }
-
- printf(" -- final x = %d (result=%p)\n", *x, result);
-
- if (result == NULL)
- goto use_right_border;
-
- }
-
- }
-
- }
-
- else /* if (i == BLC_COUNT) */
- {
- if (force && last != BLC_COUNT)
- {
- use_right_border:
-
- result = get_last_segment(&line->columns[last]);
- *x = last_x + get_column_width(&line->columns[last]);
-
- }
- else
- result = NULL;
-
- }
-
- return result;
-
-}
-#endif
-
-
-
/******************************************************************************
* *
* Paramètres : line = ligne à venir consulter. *
@@ -1195,32 +1020,6 @@ GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBuffer
/******************************************************************************
* *
-* 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 = 0; 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. *
@@ -1470,6 +1269,7 @@ void g_buffer_line_remove_flag(GBufferLine *line, BufferLineFlags flag)
* x_init = abscisse du point d'impression de départ. *
* y = ordonnée du point d'impression. *
* display = règles d'affichage des colonnes modulables. *
+* list = liste de contenus à mettre en évidence. *
* *
* Description : Imprime la ligne de texte représentée. *
* *
@@ -1479,7 +1279,7 @@ void g_buffer_line_remove_flag(GBufferLine *line, BufferLineFlags flag)
* *
******************************************************************************/
-void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const gint max_widths[BLC_COUNT], gint x_init, gint y, const bool *display)
+void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const gint max_widths[BLC_COUNT], gint x_init, gint y, const bool *display, const segcnt_list *list)
{
GBufferLineClass *class; /* Stockage de briques de base */
gint x; /* Point de départ d'impression*/
@@ -1504,7 +1304,7 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const gint max_widths
{
if (i < BLC_DISPLAY && !display[i]) continue;
- draw_segments_of_column(&line->columns[i], cairo, x, y);
+ draw_segments_of_column(&line->columns[i], cairo, x, y, list);
if (i < line->merge_start)
x += max_widths[i] + COL_MARGIN;