summaryrefslogtreecommitdiff
path: root/src/glibext/gbuffersegment.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-06-02 13:01:31 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-06-02 13:01:31 (GMT)
commitc23e671df7621ad85f590eee14e6fa7c7e71a526 (patch)
tree4cc2220c58cb416bff9d5b929fdf7e2c34b123f2 /src/glibext/gbuffersegment.c
parentd80df591b6104c98d21e1db5143610fb84e35941 (diff)
Saved some progress about edition views.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@348 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/gbuffersegment.c')
-rw-r--r--src/glibext/gbuffersegment.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/glibext/gbuffersegment.c b/src/glibext/gbuffersegment.c
index 861c7cb..031075c 100644
--- a/src/glibext/gbuffersegment.c
+++ b/src/glibext/gbuffersegment.c
@@ -478,6 +478,57 @@ gint g_buffer_segment_get_width(const GBufferSegment *segment)
/******************************************************************************
* *
+* Paramètres : segment = fragment de texte à consulter. *
+* x = position horizontale au niveau du segment. *
+* *
+* Description : Fournit la position idéale pour un marqueur. *
+* *
+* Retour : Position dans le segment donné. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+gint g_buffer_segment_get_caret_position(const GBufferSegment *segment, gint x)
+{
+ gint result; /* Position à retourner */
+ gint width; /* Largeur du segment */
+ gint char_width; /* Largeur de police fixe */
+
+ width = g_buffer_segment_get_width(segment);
+
+ printf("(seg) x=%d width=%d\n", x, width);
+
+ if (x <= 0)
+ result = 0;
+
+ else if (x >= width)
+ result = width;
+
+ else
+ {
+ if (strlen(segment->text) != segment->glyphs->num_glyphs)
+ {
+
+ printf("STOP ::: %d vs %d\n", strlen(segment->text), segment->glyphs->num_glyphs);
+ exit(0);
+ }
+
+ char_width = width / segment->glyphs->num_glyphs;
+
+ result = (x / char_width) * char_width;
+ if ((x % char_width) > (char_width / 2))
+ result += char_width;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : segment = fragment de texte à manipuler. *
* *
* Description : (Re)charge les couleurs à partir de la liste d'attributs. *