summaryrefslogtreecommitdiff
path: root/src/glibext/gwidthtracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/gwidthtracker.c')
-rw-r--r--src/glibext/gwidthtracker.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/glibext/gwidthtracker.c b/src/glibext/gwidthtracker.c
index 3a1863e..cd452bc 100644
--- a/src/glibext/gwidthtracker.c
+++ b/src/glibext/gwidthtracker.c
@@ -30,7 +30,7 @@
#include <string.h>
-#include "gcodebuffer.h"
+#include "gbuffercache.h"
@@ -51,7 +51,7 @@ struct _GWidthTracker
{
GObject parent; /* A laisser en premier */
- GCodeBuffer *buffer; /* Ensemble complet de lignes */
+ GBufferCache *cache; /* Ensemble complet de lignes */
common_metrics *portions; /* Portions représentées */
size_t count; /* Quantité de ces portions */
@@ -163,7 +163,7 @@ static void g_width_tracker_init(GWidthTracker *tracker)
static void g_width_tracker_dispose(GWidthTracker *tracker)
{
- g_object_unref(G_OBJECT(tracker->buffer));
+ g_object_unref(G_OBJECT(tracker->cache));
G_OBJECT_CLASS(g_width_tracker_parent_class)->dispose(G_OBJECT(tracker));
@@ -203,14 +203,14 @@ static void g_width_tracker_finalize(GWidthTracker *tracker)
* *
******************************************************************************/
-GWidthTracker *g_width_tracker_new(GCodeBuffer *buffer)
+GWidthTracker *g_width_tracker_new(GBufferCache *cache)
{
GWidthTracker *result; /* Composant à retourner */
result = g_object_new(G_TYPE_WIDTH_TRACKER, NULL);
- g_object_ref(G_OBJECT(buffer));
- result->buffer = buffer;
+ g_object_ref(G_OBJECT(cache));
+ result->cache = cache;
return result;
@@ -240,8 +240,8 @@ GWidthTracker *g_width_tracker_new_restricted(const GWidthTracker *template, siz
result = g_object_new(G_TYPE_WIDTH_TRACKER, NULL);
- g_object_ref(G_OBJECT(template->buffer));
- result->buffer = template->buffer;
+ g_object_ref(G_OBJECT(template->cache));
+ result->cache = template->cache;
start = g_width_tracker_find_metrics(template, first);
assert(start < template->count);
@@ -404,7 +404,6 @@ static const line_width_summary *g_width_tracker_get_up_to_date_widths(GWidthTra
{
common_metrics *portion; /* Portion à actualiser */
size_t i; /* Boucle de parcours */
- GBufferLine *line; /* Ligne à manipuler */
assert(index < tracker->count);
@@ -419,12 +418,7 @@ static const line_width_summary *g_width_tracker_get_up_to_date_widths(GWidthTra
/* Collecte */
for (i = portion->first; i <= portion->last; i++)
- {
- line = g_code_buffer_find_line_by_index(tracker->buffer, i);
-
- g_buffer_line_collect_widths(line, &portion->summary);
-
- }
+ g_buffer_cache_collect_widths(tracker->cache, i, &portion->summary);
/* Marquage pour mémoire */
@@ -441,6 +435,30 @@ static const line_width_summary *g_width_tracker_get_up_to_date_widths(GWidthTra
* *
* Paramètres : tracker = gestionnaire de largeurs de lignes à mettre jour. *
* index = position de la première des lignes à ajouter. *
+* *
+* Description : Prend acte d'un changement sur une ligne pour les largeurs. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_width_tracker_update(GWidthTracker *tracker, size_t index)
+{
+ size_t current; /* Indice de portion visée */
+
+ current = g_width_tracker_find_metrics(tracker, index);
+
+ g_width_tracker_reset_widths(tracker, current);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : tracker = gestionnaire de largeurs de lignes à mettre jour. *
+* index = position de la première des lignes à ajouter. *
* count = quantité de lignes devant être ajoutées. *
* *
* Description : Prend acte de l'ajout de lignes pour les largeurs. *
@@ -457,7 +475,6 @@ void g_width_tracker_update_added(GWidthTracker *tracker, size_t index, size_t c
common_metrics *portion; /* Portion sélectionnée */
size_t next; /* Prochaine portion à décaller*/
size_t i; /* Boucle de parcours */
- GBufferLine *line; /* Ligne à manipuler */
size_t dest; /* Destination d'une recopie */
size_t src; /* Source d'une recopie */
@@ -502,9 +519,7 @@ void g_width_tracker_update_added(GWidthTracker *tracker, size_t index, size_t c
for (i = index + count - 1; i >= index; i--)
{
- line = g_code_buffer_find_line_by_index(tracker->buffer, i);
-
- if (g_buffer_line_get_flags(line) & BLF_WIDTH_MANAGER)
+ if (g_buffer_cache_get_line_flags(tracker->cache, i) & BLF_WIDTH_MANAGER)
{
/* Insertion d'une nouvelle place */
@@ -602,11 +617,11 @@ void g_width_tracker_update_deleted(GWidthTracker *tracker, size_t start, size_t
/* Suppression de portions inutiles ? */
- keep_first = (tracker->portions[first].first > start || end < tracker->portions[first].last);
+ keep_first = (tracker->portions[first].first < start || end < tracker->portions[first].last);
dest = (keep_first ? first + 1 : first);
- keep_last = (tracker->portions[last].first > start || end < tracker->portions[last].last);
+ keep_last = (tracker->portions[last].first < start || end < tracker->portions[last].last);
src = (keep_last ? last : last + 1);
@@ -647,7 +662,7 @@ void g_width_tracker_update_deleted(GWidthTracker *tracker, size_t start, size_t
if (end < tracker->portions[first].last)
tracker->portions[first].last -= diff;
else
- tracker->portions[first].last = start;
+ tracker->portions[first].last = start - 1;
}
if (keep_last && last != first)