diff options
Diffstat (limited to 'src/glibext/gbufferline.c')
-rw-r--r-- | src/glibext/gbufferline.c | 176 |
1 files changed, 124 insertions, 52 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c index 5f1756d..768cbca 100644 --- a/src/glibext/gbufferline.c +++ b/src/glibext/gbufferline.c @@ -56,7 +56,7 @@ struct _GBufferLine mrange_t range; /* Couverture geographique */ BufferLineColumn main_column; /* Colonne principale */ - 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 */ @@ -72,7 +72,6 @@ struct _GBufferLine gint max_widths[BLC_COUNT]; /* Taille cachée des colonnes */ gint merged_width; /* Largeur cumulée avant fusion*/ }; - GBufferLine *manager; /* Représentante d'un groupe */ }; }; @@ -214,9 +213,6 @@ static void g_buffer_line_dispose(GBufferLine *line) { size_t i; /* Boucle de parcours */ - if (line->flags & BLF_WIDTH_MANAGER) - g_object_unref(G_OBJECT(line->manager)); - for (i = 0; i < line->ocount; i++) g_object_unref(G_OBJECT(line->origins[i].creator)); @@ -298,9 +294,9 @@ const mrange_t *g_buffer_line_get_range(const GBufferLine *line) /****************************************************************************** * * -* Paramètres : line = ligne à venir compléter. * -* psize = taille souhaitée de l'impression des positions. * -* vsize = taille souhaitée de l'impression des adresses. * +* Paramètres : line = ligne à venir compléter. * +* size = taille souhaitée de l'impression des positions. * +* addr = localisation physique à venir représenter. * * * * Description : Construit le tronc commun d'une ligne autour de sa position. * * * @@ -310,61 +306,105 @@ const mrange_t *g_buffer_line_get_range(const GBufferLine *line) * * ******************************************************************************/ -void g_buffer_line_fill_mrange(GBufferLine *line, MemoryDataSize psize, MemoryDataSize vsize) +void g_buffer_line_fill_phys(GBufferLine *line, MemoryDataSize size, const vmpa2t *addr) { + VMPA_BUFFER(position); /* Emplacement au format texte */ size_t len; /* Taille de l'élément inséré */ - VMPA_BUFFER(address); /* Adresse au format texte */ - size_t i; /* Boucle de parcours */ + size_t i; /* Boucle de parcours #1 */ - /* Position physique */ + vmpa2_phys_to_string(addr, size, position, &len); - if (has_phys_addr(get_mrange_addr(&line->range))) - { - mrange_phys_to_string(&line->range, psize, true, address, &len); + for (i = 2; i < len; i++) + if (position[i] != '0') break; - for (i = 2; i < len; i++) - if (address[i] != '0') break; + if (i == len) + i = len - 1; - if (i == len) - g_buffer_line_append_text(line, BLC_PHYSICAL, address, len, RTT_PHYS_ADDR_PAD, NULL); + if (i > 0) + g_buffer_line_append_text(line, BLC_PHYSICAL, position, i, RTT_PHYS_ADDR_PAD, NULL); - else - { - g_buffer_line_append_text(line, BLC_PHYSICAL, address, 2, RTT_PHYS_ADDR, NULL); + g_buffer_line_append_text(line, BLC_PHYSICAL, &position[i], len - i, RTT_PHYS_ADDR, NULL); - if (i > 2) - g_buffer_line_append_text(line, BLC_PHYSICAL, &address[2], i - 2, RTT_PHYS_ADDR_PAD, NULL); +} - g_buffer_line_append_text(line, BLC_PHYSICAL, &address[i], len - i, RTT_PHYS_ADDR, NULL); - } +/****************************************************************************** +* * +* Paramètres : line = ligne à venir compléter. * +* size = taille souhaitée de l'impression des positions. * +* addr = localisation virtuelle à venir représenter. * +* * +* Description : Construit le tronc commun d'une ligne autour de sa position. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - } +void g_buffer_line_fill_virt(GBufferLine *line, MemoryDataSize size, const vmpa2t *addr) +{ + VMPA_BUFFER(position); /* Emplacement au format texte */ + size_t len; /* Taille de l'élément inséré */ + size_t i; /* Boucle de parcours #1 */ + + vmpa2_virt_to_string(addr, size, position, &len); + + for (i = 2; i < len; i++) + if (position[i] != '0') break; + + if (i == len) + i = len - 1; + + if (i > 0) + g_buffer_line_append_text(line, BLC_VIRTUAL, position, i, RTT_PHYS_ADDR_PAD, NULL); - /* Adresse virtuelle */ + g_buffer_line_append_text(line, BLC_VIRTUAL, &position[i], len - i, RTT_PHYS_ADDR, NULL); + +} - if (has_virt_addr(get_mrange_addr(&line->range))) - { - mrange_virt_to_string(&line->range, vsize, true, address, &len); - for (i = 2; i < len; i++) - if (address[i] != '0') break; +/****************************************************************************** +* * +* Paramètres : line = ligne à venir compléter. * +* addr = localisation à afficher. * +* psize = taille souhaitée de l'impression des positions. * +* vsize = taille souhaitée de l'impression des adresses. * +* * +* Description : Construit le tronc commun d'une ligne autour de sa position. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - if (i == len) - g_buffer_line_append_text(line, BLC_VIRTUAL, address, len, RTT_VIRT_ADDR_PAD, NULL); +void g_buffer_line_fill_vmpa(GBufferLine *line, const vmpa2t *addr, MemoryDataSize psize, MemoryDataSize vsize) +{ + g_buffer_line_fill_phys(line, psize, addr); - else - { - g_buffer_line_append_text(line, BLC_VIRTUAL, address, 2, RTT_VIRT_ADDR, NULL); + g_buffer_line_fill_virt(line, vsize, addr); - if (i > 2) - g_buffer_line_append_text(line, BLC_VIRTUAL, &address[2], i - 2, RTT_VIRT_ADDR_PAD, NULL); +} - g_buffer_line_append_text(line, BLC_VIRTUAL, &address[i], len - i, RTT_VIRT_ADDR, NULL); - } +/****************************************************************************** +* * +* Paramètres : line = ligne à venir compléter. * +* psize = taille souhaitée de l'impression des positions. * +* vsize = taille souhaitée de l'impression des adresses. * +* * +* Description : Construit le tronc commun d'une ligne autour de sa position. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - } +void g_buffer_line_fill_mrange(GBufferLine *line, MemoryDataSize psize, MemoryDataSize vsize) +{ + g_buffer_line_fill_vmpa(line, get_mrange_addr(&line->range), psize, vsize); } @@ -531,7 +571,7 @@ void g_buffer_line_append_text(GBufferLine *line, BufferLineColumn column, const assert(length > 0); if (column == BLC_MAIN) - column = line->main_column; + column = BLC_ASSEMBLY;//line->main_column; if (column == BLC_LAST_USED) column = line->last_used; @@ -938,6 +978,13 @@ void g_buffer_line_collect_widths(GBufferLine *line, line_width_summary *summary { width = get_column_width(&line->columns[i]); + + /* + if (i == BLC_ASSEMBLY_HEAD) + assert(width > 0); + */ + + if (i < line->merge_start) summary->max_widths[i] = MAX(summary->max_widths[i], width); @@ -1008,7 +1055,10 @@ const line_segment *g_buffer_line_get_segment_from_coord(const GBufferLine *line { line_segment *result; /* Trouvaille à retourner */ - result = get_line_column_content_from_index(&line->columns[coord->column], coord->index); + if (coord->column < BLC_COUNT) + result = get_line_column_content_from_index(&line->columns[coord->column], coord->index); + else + result = false; return result; @@ -1069,6 +1119,9 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar { width = g_buffer_line_compute_max_width(line, i, summary); + /* Si la colonne n'est absolument pas visible, on ne s'arrête pas dessus ! */ + if (width == 0) continue; + if ((i + 1) < BLC_COUNT) limit = width + COL_MARGIN / 2; else limit = width; @@ -1139,7 +1192,10 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar if ((i - 1) < line->merge_start) { width = g_buffer_line_compute_max_width(line, i - 1, summary); - *base += (width + COL_MARGIN); + + if (width > 0) + *base += (width + COL_MARGIN); + } else *base += get_column_width(&line->columns[i - 1]); @@ -1183,8 +1239,19 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar } } + + /* Il n'y a rien sur la ligne ! */ else - result = false; + { + result = true; + + *base = 0; + *offset = 0; + + coord->column = BLC_COUNT; + coord->index = -1; + + } } else @@ -1305,6 +1372,7 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord, BufferLineColumn i; /* Boucle de parcours #1 */ bool displayed; /* Confort de lecture */ BufferLineColumn k; /* Boucle de parcours #2 */ + gint width; /* Largeur d'une colonne donnée*/ result = false; @@ -1381,8 +1449,14 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord, if (displayed) { - *offset += g_buffer_line_compute_max_width(line, k, summary); - if (k < line->merge_start) *offset += COL_MARGIN; + width = g_buffer_line_compute_max_width(line, k, summary); + + if (width > 0) + { + *offset += width; + if (k < line->merge_start) *offset += COL_MARGIN; + } + } } @@ -1469,10 +1543,8 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const line_width_summ { max_width = g_buffer_line_compute_max_width(line, i, summary); - x += max_width; - if (max_width > 0) - x += COL_MARGIN; + x += max_width + COL_MARGIN; } |