summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-05-13 20:38:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-05-13 20:38:08 (GMT)
commite92c777c91612c8508d263645480c6c3889b679d (patch)
tree3df428984e2d4371612beb3c8d1a25575d47de1d /src
parent8802a479f37dde99f2709af50cf15e595e32b47e (diff)
Used the correct local width summary when dealing with line widths.
Diffstat (limited to 'src')
-rw-r--r--src/glibext/gbufferview.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/glibext/gbufferview.c b/src/glibext/gbufferview.c
index 214b212..2606ab4 100644
--- a/src/glibext/gbufferview.c
+++ b/src/glibext/gbufferview.c
@@ -86,6 +86,9 @@ static void on_buffer_size_changed(const GCodeBuffer *, bool, size_t, size_t, GB
/* Réagit à un changement de contenu d'une ligne donnée. */
static void on_buffer_line_changed(GCodeBuffer *, GBufferLine *, GBufferSegment *, GBufferView *);
+/* Déplace le curseur au sein d'une vue de tampon. */
+static bool _g_buffer_view_move_caret(GBufferView *, const GBufferLine *, size_t, GdkRectangle *, bool, GdkScrollDirection, const bool *);
+
/* Détermine le type de la vue d'un tampon pour code désassemblé. */
@@ -642,10 +645,13 @@ const vmpa2t *g_buffer_view_compute_caret_full(GBufferView *view, GBufferLine *l
{
GBufferViewClass *class; /* Classe pour les vues */
gint offset; /* Point de travail modifiable */
- const line_width_summary *summary; /* Résumé concis des largeurs */
+ line_width_summary summary; /* Résumé concis des largeurs */
gint base; /* Position absolue de segment */
GBufferSegment *segment; /* Segment visé par le pointeur*/
+
+
+
class = G_BUFFER_VIEW_GET_CLASS(view);
offset = x;
@@ -653,9 +659,9 @@ const vmpa2t *g_buffer_view_compute_caret_full(GBufferView *view, GBufferLine *l
offset -= class->left_text;
if (offset < 0) return NULL;
- summary = g_width_tracker_get_width_summary(view->tracker);
+ g_width_tracker_get_local_width_summary(view->tracker, index, &summary);
- segment = g_buffer_line_get_segment_at(line, summary, display, &base, &offset, GDK_SCROLL_LEFT, true);
+ segment = g_buffer_line_get_segment_at(line, &summary, display, &base, &offset, GDK_SCROLL_LEFT, true);
if (segment == NULL) return NULL;
caret->x = class->left_text + base + offset;
@@ -674,7 +680,9 @@ const vmpa2t *g_buffer_view_compute_caret_full(GBufferView *view, GBufferLine *l
/******************************************************************************
* *
-* Paramètres : line = ligne à venir consulter. *
+* Paramètres : view = vue de tampon à manipuler. *
+* line = ligne à venir consulter. *
+* index = indice de cette même ligne dans le tampon. *
* caret = position du curseur à faire évoluer. *
* ctrl = indique la demande d'un parcours rapide. *
* dir = direction du parcours. *
@@ -688,11 +696,11 @@ const vmpa2t *g_buffer_view_compute_caret_full(GBufferView *view, GBufferLine *l
* *
******************************************************************************/
-static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line, GdkRectangle *caret, bool ctrl, GdkScrollDirection dir, const bool *display)
+static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line, size_t index, GdkRectangle *caret, bool ctrl, GdkScrollDirection dir, const bool *display)
{
bool result; /* Bilan à retourner */
gint offset; /* Point de travail modifiable */
- const line_width_summary *summary; /* Résumé concis des largeurs */
+ line_width_summary summary; /* Résumé concis des largeurs */
gint base; /* Position absolue de segment */
GBufferSegment *segment; /* Segment visé par le pointeur*/
@@ -703,9 +711,9 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
offset -= G_BUFFER_VIEW_GET_CLASS(view)->left_text;
if (offset < 0) return false;
- summary = g_width_tracker_get_width_summary(view->tracker);
+ g_width_tracker_get_local_width_summary(view->tracker, index, &summary);
- segment = g_buffer_line_get_segment_at(line, summary, display, &base, &offset, dir, false);
+ segment = g_buffer_line_get_segment_at(line, &summary, display, &base, &offset, dir, false);
if (segment == NULL) printf(" ===== NO SEG...\n");
@@ -732,7 +740,7 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
{
base = 0;
- segment = g_buffer_line_find_near_segment(line, segment, summary, display, dir, &offset);
+ segment = g_buffer_line_find_near_segment(line, segment, &summary, display, dir, &offset);
printf(" ====== NEAR SEG :: %p ('%s')\n", segment, segment ? g_buffer_segment_get_text(segment, false) : NULL);
@@ -795,7 +803,7 @@ const vmpa2t *g_buffer_view_move_caret(GBufferView *view, GdkRectangle *caret, b
GBufferLine *line; /* Ligne sous le pointeur */
- const line_width_summary *summary; /* Résumé concis des largeurs */
+ line_width_summary summary; /* Résumé concis des largeurs */
bool computed; /* Récursivité pris en compte */
gint left_pos; /* Retour à la ligne */
gint right_pos; /* Position d'extrème droite */
@@ -823,7 +831,7 @@ const vmpa2t *g_buffer_view_move_caret(GBufferView *view, GdkRectangle *caret, b
line = g_buffer_view_find_line_at(view, caret->y, &index);
if (line == NULL) return NULL;
- summary = g_width_tracker_get_width_summary(view->tracker);
+ g_width_tracker_get_local_width_summary(view->tracker, index, &summary);
computed = false;
@@ -835,12 +843,12 @@ const vmpa2t *g_buffer_view_move_caret(GBufferView *view, GdkRectangle *caret, b
case GDK_SCROLL_LEFT:
case GDK_SCROLL_RIGHT:
left_pos = G_BUFFER_VIEW_GET_CLASS(view)->left_text;
- if (display[BLC_PHYSICAL]) left_pos += summary->max_widths[BLC_PHYSICAL] + COL_MARGIN;
- if (display[BLC_VIRTUAL]) left_pos += summary->max_widths[BLC_VIRTUAL] + COL_MARGIN;
- if (display[BLC_BINARY]) left_pos += summary->max_widths[BLC_BINARY] + COL_MARGIN;
+ if (display[BLC_PHYSICAL]) left_pos += summary.max_widths[BLC_PHYSICAL] + COL_MARGIN;
+ if (display[BLC_VIRTUAL]) left_pos += summary.max_widths[BLC_VIRTUAL] + COL_MARGIN;
+ if (display[BLC_BINARY]) left_pos += summary.max_widths[BLC_BINARY] + COL_MARGIN;
right_pos = left_pos;
for (i = BLC_ASSEMBLY_HEAD; i < BLC_COUNT; i++)
- right_pos += summary->max_widths[i] + COL_MARGIN;
+ right_pos += summary.max_widths[i] + COL_MARGIN;
/*
gint g_buffer_line_compute_max_width(const GBufferLine *line, BufferLineColumn index, const gint *max_widths)
@@ -887,7 +895,7 @@ BufferLineColumn g_buffer_line_get_merge_start(const GBufferLine *line)
if (line == NULL) break;
*/
- moved = _g_buffer_view_move_caret(view, line, caret, ctrl, GDK_SCROLL_LEFT, display);
+ moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_LEFT, display);
if (moved)
result = get_mrange_addr(g_buffer_line_get_range(line));
@@ -907,7 +915,7 @@ BufferLineColumn g_buffer_line_get_merge_start(const GBufferLine *line)
if (line == NULL) break;
*/
- moved = _g_buffer_view_move_caret(view, line, caret, ctrl, GDK_SCROLL_RIGHT, display);
+ moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_RIGHT, display);
if (moved)
result = get_mrange_addr(g_buffer_line_get_range(line));
@@ -1220,12 +1228,15 @@ GBufferLine *g_buffer_view_find_line_at(GBufferView *view, gint y, size_t *idx)
GBufferLine *g_buffer_view_find_line_and_segment_at(GBufferView *view, gint *x, gint y, size_t *idx, const bool *display, GBufferSegment **segment)
{
GBufferLine *result; /* Ligne trouvée à retourner */
+ size_t index; /* Indice de la ligne trouvée */
GBufferViewClass *class; /* Classe pour les vues */
- const line_width_summary *summary; /* Résumé concis des largeurs */
+ line_width_summary summary; /* Résumé concis des largeurs */
/* Recherche d'une ligne correspondante */
- result = g_buffer_view_find_line_at(view, y, idx);
+ result = g_buffer_view_find_line_at(view, y, &index);
+
+ if (idx != NULL) *idx = index;
/* Recherche du segment visé éventuel */
@@ -1238,10 +1249,10 @@ GBufferLine *g_buffer_view_find_line_and_segment_at(GBufferView *view, gint *x,
else
{
- summary = g_width_tracker_get_width_summary(view->tracker);
+ g_width_tracker_get_local_width_summary(view->tracker, index, &summary);
*x -= class->left_text;
- *segment = g_buffer_line_get_segment_at(result, summary, display,
+ *segment = g_buffer_line_get_segment_at(result, &summary, display,
(gint []) { 0 }, x, GDK_SCROLL_LEFT, true);
}