summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-01 23:29:57 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-01 23:29:57 (GMT)
commitbfd81d1f289913f4d6e09cd8d99f4aaeed98436b (patch)
treeefc747ec80f83fc248da1e8e4ac06c4e7d3347dd /src/glibext
parentbb6d0c758f8c720d8074bf74e6bd001e36d6a918 (diff)
Fixed the computing of basic blocks and used them in graphic views.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@316 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/gcodebuffer.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c
index 1f1ff71..22bdcd8 100644
--- a/src/glibext/gcodebuffer.c
+++ b/src/glibext/gcodebuffer.c
@@ -121,10 +121,10 @@ static void g_code_buffer_class_init(GCodeBufferClass *);
static void g_code_buffer_init(GCodeBuffer *);
/* Convertit une adresse en indice de ligne. */
-static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *, vmpa_t);
+static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *, vmpa_t, bool);
/* Convertit une adresse en indice de ligne. */
-static size_t g_code_buffer_get_index_from_address(GCodeBuffer *, vmpa_t);
+static size_t g_code_buffer_get_index_from_address(GCodeBuffer *, vmpa_t, bool);
@@ -296,8 +296,8 @@ static void g_buffer_scan_process(GBufferScan *scan, GtkExtStatusBar *statusbar)
/* TODO : lock scan->buffer->lines */
- first = g_code_buffer_get_index_from_address(scan->buffer, scan->start);
- last = g_code_buffer_get_index_from_address(scan->buffer, scan->end);
+ first = g_code_buffer_get_index_from_address(scan->buffer, scan->start, true);
+ last = g_code_buffer_get_index_from_address(scan->buffer, scan->end, false);
lines = scan->buffer->lines;
@@ -397,6 +397,7 @@ GCodeBuffer *g_code_buffer_new(void)
* *
* Paramètres : buffer = composant GTK à mettre à jour. *
* addr = adresse où va se situer la ligne. *
+* first = indique si on l'arrête à la première ou la dernière.*
* *
* Description : Convertit une adresse en indice de ligne. *
* *
@@ -406,7 +407,7 @@ GCodeBuffer *g_code_buffer_new(void)
* *
******************************************************************************/
-static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t addr)
+static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t addr, bool first)
{
size_t result; /* Indice à retourner */
@@ -419,6 +420,11 @@ static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t
if (g_buffer_line_get_address(buffer->lines[result]) == addr)
break;
+ if (!first)
+ for (; result < (buffer->used - 1); result++)
+ if (g_buffer_line_get_address(buffer->lines[result + 1]) != addr)
+ break;
+
return result;
}
@@ -428,6 +434,7 @@ static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t
* *
* Paramètres : buffer = composant GTK à mettre à jour. *
* addr = adresse où va se situer la ligne. *
+* first = indique si on l'arrête à la première ou la dernière.*
* *
* Description : Convertit une adresse en indice de ligne. *
* *
@@ -437,11 +444,11 @@ static size_t _g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t
* *
******************************************************************************/
-static size_t g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t addr)
+static size_t g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t addr, bool first)
{
size_t result; /* Indice à retourner */
- result = _g_code_buffer_get_index_from_address(buffer, addr);
+ result = _g_code_buffer_get_index_from_address(buffer, addr, first);
/**
* Par commodités, on évite certaines instructions en cas d'échec dans les
@@ -511,7 +518,7 @@ GBufferLine *g_code_buffer_insert_at(GCodeBuffer *buffer, vmpa_t addr, bool befo
GBufferLine *result; /* Instance à retourner */
size_t index; /* Indice de la ligne visée */
- index = _g_code_buffer_get_index_from_address(buffer, addr);
+ index = _g_code_buffer_get_index_from_address(buffer, addr, true /* FIXME : after */);
if (index == buffer->used) return NULL;
if (buffer->used == buffer->count)
@@ -586,7 +593,7 @@ GBufferLine *g_code_buffer_find_line_by_addr(const GCodeBuffer *buffer, vmpa_t a
GBufferLine *result; /* Instance à retourner */
size_t index; /* Indice de la ligne visée */
- index = _g_code_buffer_get_index_from_address(buffer, addr);
+ index = _g_code_buffer_get_index_from_address(buffer, addr, true);
if (index == buffer->used)
result = NULL;
@@ -907,8 +914,8 @@ static void g_buffer_view_compute_required_widths(GBufferView *view, bool addr,
lines = view->buffer->lines;
- first = g_code_buffer_get_index_from_address(view->buffer, view->start);
- last = g_code_buffer_get_index_from_address(view->buffer, view->end);
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start, true);
+ last = g_code_buffer_get_index_from_address(view->buffer, view->end, false);
view->left_margin = 2 * view->line_height;
view->left_text = 2.5 * view->line_height;
@@ -1032,8 +1039,8 @@ void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height, bool a
*width += + MAX(col_width, full_width);
- first = g_code_buffer_get_index_from_address(view->buffer, view->start);
- last = g_code_buffer_get_index_from_address(view->buffer, view->end);
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start, true);
+ last = g_code_buffer_get_index_from_address(view->buffer, view->end, false);
*height *= (last - first + 1);
@@ -1129,8 +1136,8 @@ void g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y)
else
need_redraw = false;
- first = g_code_buffer_get_index_from_address(view->buffer, view->start);
- last = g_code_buffer_get_index_from_address(view->buffer, view->end);
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start, true);
+ last = g_code_buffer_get_index_from_address(view->buffer, view->end, false);
for (i = first; i < last; i++)
view->highlighted = g_buffer_line_highlight_all_same_segments(view->buffer->lines[i],
@@ -1210,13 +1217,13 @@ void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, Gd
- first = g_code_buffer_get_index_from_address(view->buffer, view->start);
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start, true);
first += (real_y / view->line_height);
last = first + (event->area.height / view->line_height);
if (event->area.height % view->line_height > 0) last++;
- end = g_code_buffer_get_index_from_address(view->buffer, view->end);
+ end = g_code_buffer_get_index_from_address(view->buffer, view->end, false);
last = MIN(last, end);
y = event->area.y - (real_y % view->line_height);
@@ -1299,8 +1306,8 @@ bool g_buffer_view_get_address_coordinates(GBufferView *view, vmpa_t addr, gint
lheight = g_buffer_view_get_line_height(view);
current = VMPA_MAX;
- first = g_code_buffer_get_index_from_address(view->buffer, view->start);
- last = g_code_buffer_get_index_from_address(view->buffer, view->end);
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start, true);
+ last = g_code_buffer_get_index_from_address(view->buffer, view->end, false);
if (view->buffer->used > 0)
for (i = first; i <= last; i++)