Re: A bug in GTK



Matthew wrote:

Hi Matthew!

> > I have found a bug in the Gtk_Text_Get_Point() function. Where have I
> > mail to inform about this?

> Let's hear it.

I found the problem while I was writting a programmer editor. Since I
need to print the cursor position, in order to allow the user to go to
the line with an error, and since the GTKText class has not a call to
get it (yes, this is a subliminal message :-) I made a little routine
to get it by using Gtk_Text_Get_Point(). The idea is to get the text,
and count the number of carriage returns from the start until reaching
the point returned by Gtk_Text_Get_Point. This is the routine:

gint calcula_linea(gpointer datos) {

  GtkWidget *texto,*mi_widget;
  int posicion,temporal,linea;
  gchar *puntero,*puntero2;
  char cadena[10];
  
  texto=lookup_widget(main_w,"text1");
  posicion=(int)gtk_text_get_point(GTK_TEXT(texto));
  puntero=gtk_editable_get_chars(GTK_EDITABLE(texto),0,-1);
  puntero2=puntero;
  linea=1;
  for(temporal=0;temporal<posicion;temporal++) {
    if(*puntero2==10)
      linea++;
    puntero2++;
  }
  printf("Line: %d  Position: %d",linea,posicion);
  g_free(puntero);
  return(1);
}

This routine is only a test, that prints the data in the terminal. I
called it from a timer.

The routine works fine when you press the key letters or the return
key. But if you click with the mouse in the windows to change the
cursor location, it isn't refreshed until you press a key. Other bug
is that, when you use the cursor keys to move the cursor, there's a
delay of one keystroke. This is: if you are in the position 100 of the
text and you press, for example, the right cursor,
Gtk_Get_Text_Point() returns 100, but the cursor is in the position
101. If you press again the right cursor, then Gtk_Get_Text_Point()
returns 101, but the cursor is in the position 102. If then you press
a letter key, the cursor goes to the 103 position and then the
Gtk_Get_Text_Point() returns the right value. This occurs with the
other cursor keys. The value returned by Gtk_Get_Text_Point() is the
old value.

Of course, this is a big problem in this case, because if you use the
up or down cursor, the program will tell you that you are in the line
N, but really you are in the N+1 or N-1 line.

I'm not sure if I have explained it right O:-)

-- 
Nos leemos
		           RASTER

raster@rastersoft.com                   http://www.rastersoft.com

Have you tried GAG?  http://www.rastersoft.com/gageng.htm




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]