trying to do a blinking text cursor

Jack Andrews <[email protected]>
Newsgroups gmane.comp.lib.sdl
Message-ID <CAJvHTNxHjOkurANWFUKWYsKo3wu3FP-m+nONwAj6zn3jG8NQ9A@mail.gmail.com>
Hi,

I'm using SDL2 as it looks like the most cross-platform UI library out
there.  I don't want a GUI toolkit.

I'm writing a very simple text editor and so far, the most challenging
thing has been showing a blinking cursor at the text insertion point.

I think I can work how an SDL timer works, but I can't work out how to
invert the colours of a SDL_Rect at the insertion point.  How would I
implement a function:

  int ColourInvert(SDL_Window*w, SDL_Renderer*rend, SDL_Rect area);

?

here's my pseudo-code for my editor (had to trim all the editor stuff out):

SDL_Renderer*re;SDL_Window*w;TTF_Font*font;
int drawline(char*s){
  SDL_Surface*su=SDL_RenderText_Shaded(font,s,a,b));
  SDL_Texture*tx=SDL_CreateTextureFromSurface,(re,su));
  SDL_RenderCopy(re,tx,0,&rect));
  SDL_DestroyTexture(tx);
  SDL_FreeSurface(su);
}
main(){
  SDL_Init(SDL_INIT_EVERYTHING);TTF_Init();
  w=SDL_CreateWindow(x,a,a,y,z,SDL_WINDOW_SHOWN);
  re=SDL_CreateRenderer(w,-1,SDL_RENDERER_ACCELERATED);
  SDL_SetRenderDrawColor(g.v,255,255,255,255);
  SDL_RenderClear(g.v);
  SDL_RenderPresent(g.v);
  //message loop
  //a keypress changes a line
  // for each line in lines{drawline(line)}
}

Thanks for all your work, guys,


Jack

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.