summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-11-06 10:54:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-11-06 10:54:54 (GMT)
commit6f89c15215b746f050f8280fac14a77e50bf8077 (patch)
tree37a17cc4a52e291ac6cc16759a476ae927a04dfd /src
parente5d58e1f70405012fd8fbe8d61937f92fa3583a9 (diff)
Handled tabulations as small separation paddings.
Diffstat (limited to 'src')
-rw-r--r--src/glibext/linesegment.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/glibext/linesegment.c b/src/glibext/linesegment.c
index ee79a22..8306320 100644
--- a/src/glibext/linesegment.c
+++ b/src/glibext/linesegment.c
@@ -532,6 +532,8 @@ line_segment *get_new_line_segment(RenderingTagType type, const char *text, size
char atmp[sizeof(line_segment) + 128]; /* Allocation static facile */
line_segment *content; /* Contenu à mettre en place ? */
+ assert(length > 0);
+
if (length < (sizeof(atmp) - sizeof(line_segment)))
content = (line_segment *)atmp;
else
@@ -710,11 +712,17 @@ gint get_line_segment_width(const line_segment *segment)
gint result; /* Largeur à retourner */
cairo_font_slant_t slant; /* Style d'impression */
cairo_font_weight_t weight; /* Poids de la police */
+ size_t length; /* Taille du texte représenté */
slant = segment->pattern->slant;
weight = segment->pattern->weight;
- result = _seg_params.x_advances[CAIRO_FONT_INDEX(slant, weight)] * strlen(segment->text);
+ length = strlen(segment->text);
+
+ if (length == 1 && segment->text[0] == '\t')
+ length = 2;
+
+ result = _seg_params.x_advances[CAIRO_FONT_INDEX(slant, weight)] * length;
return result;
@@ -843,6 +851,9 @@ void draw_line_segment(const line_segment *segment, cairo_t *cr, gint *x, gint y
cairo_operator_t old; /* Sauvegarde avant changement */
const rendering_color_t *used_fg; /* Couleur d'impression utile */
+ if (segment->text[0] == '\t' && segment->text[1] == '\0')
+ goto small_sep;
+
selected = selection_list_has_segment_content(list, segment);
width = get_line_segment_width(segment);
@@ -890,6 +901,8 @@ void draw_line_segment(const line_segment *segment, cairo_t *cr, gint *x, gint y
cairo_show_text(cr, segment->text);
+ small_sep:
+
*x += width;
}