- Pango::Rectangle cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
-
- cairo_set_source_rgba (cr, 0.9, 0.1, 0.1, 0.8);
- cairo_rectangle (cr,
- x_leading_padding + cursor.get_x()/PANGO_SCALE + cursor_width,
- (upper_height - layout_height)/2.0,
- 2.0, cursor.get_height()/PANGO_SCALE);
- cairo_fill (cr);
+
+
+ if (input_string.length() < insert_map.size()) {
+ Pango::Rectangle cursor;
+
+ if (input_string.empty()) {
+ /* nothing entered yet, put cursor at the end
+ of string
+ */
+ cursor = _layout->get_cursor_strong_pos (edit_string.length() - 1);
+ } else {
+ cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
+ }
+
+ cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
+ if (!_fixed_width) {
+ cairo_rectangle (cr,
+ min (get_width() - 2.0,
+ (double) cursor.get_x()/PANGO_SCALE + layout_x_offset + em_width), 0,
+ 2.0, cursor.get_height()/PANGO_SCALE);
+ } else {
+ cairo_rectangle (cr,
+ min (get_width() - 2.0,
+ (double) layout_x_offset + cursor.get_x()/PANGO_SCALE + em_width),
+ (upper_height - layout_height)/2.0,
+ 2.0, cursor.get_height()/PANGO_SCALE);
+ }
+ cairo_fill (cr);
+ } else {
+ /* we've entered all possible digits, no cursor */
+ }
+