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_Windoww, SDL_Rendererrend, SDL_Rect area);
?
here’s my pseudo-code for my editor (had to trim all the editor stuff out):
SDL_Rendererre;SDL_Windoww;TTF_Fontfont;
int drawline(chars){
SDL_Surfacesu=SDL_RenderText_Shaded(font,s,a,b));
SDL_Texturetx=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