summaryrefslogtreecommitdiff
path: root/src/glibext/gbuffersegment.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-11-01 20:31:29 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-11-01 20:31:29 (GMT)
commit67c0fe6eddda7ac5ff591ec972425095209d75ff (patch)
treed2f923845545c9b7f94968e9b9ded7539f3dbb7b /src/glibext/gbuffersegment.c
parent085fef16a819cb321fd38e7e0926d3cca863777a (diff)
Moved the caret with mouse and keyboard.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@417 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/gbuffersegment.c')
-rw-r--r--src/glibext/gbuffersegment.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/glibext/gbuffersegment.c b/src/glibext/gbuffersegment.c
index c96b092..0c31b9c 100644
--- a/src/glibext/gbuffersegment.c
+++ b/src/glibext/gbuffersegment.c
@@ -406,6 +406,70 @@ gint g_buffer_segment_get_caret_position(const GBufferSegment *segment, gint x)
/******************************************************************************
* *
* Paramètres : segment = fragment de texte à manipuler. *
+* x = position du curseur à faire évoluer. [OUT] *
+* ctrl = indique la demande d'un parcours rapide. *
+* dir = direction du parcours. *
+* *
+* Description : Déplace le curseur au sein d'un segment de tampon. *
+* *
+* Retour : true si un déplacement a été effectué, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_buffer_segment_move_caret(const GBufferSegment *segment, gint *x, bool ctrl, GdkScrollDirection dir)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ gint width; /* Largeur du segment */
+ gint char_width; /* Largeur de police fixe */
+
+ result = false;
+
+ width = g_buffer_segment_get_width(segment);
+ char_width = width / strlen(segment->text);
+
+ if (dir == GDK_SCROLL_LEFT)
+ {
+ printf(">>>>> left ::: x=%d width=%d char=%d\n", *x, width, char_width);
+
+ if (*x > width) *x = width + char_width;
+
+ if (*x == 0) goto gbsmc_done;
+
+ if (ctrl) *x = 0;
+ else *x = MAX(0, *x - char_width);
+
+ result = true;
+
+ }
+
+ else if (dir == GDK_SCROLL_RIGHT)
+ {
+
+ printf(">>>>> right ::: x=%d width=%d char=%d\n", *x, width, char_width);
+
+ if (*x == width) goto gbsmc_done;
+
+ if (ctrl) *x = width;
+ else *x = MIN(width, *x + char_width);
+
+ result = true;
+
+ }
+
+ gbsmc_done:
+
+ printf(">>>>> result ::: %d\n", result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : segment = fragment de texte à manipuler. *
* style = style de rendu pour le segment. *
* *
* Description : Module l'apparence finale du composant. *