...
|
...
|
@@ -813,8 +813,15 @@ re_processkey_editing(re_t *re, SDL_Event *event)
|
813
|
813
|
memset(&fakeevent,0,sizeof(SDL_Event));
|
814
|
814
|
event=&fakeevent;
|
815
|
815
|
event->type=SDL_TEXTINPUT;
|
816
|
|
- strncpy(event->text.text,spaces+(re->curcol%8),sizeof(event->text.text));
|
817
|
|
- event->text.text[sizeof(event->text.text)-1]='\0';
|
|
816
|
+ /* If control is pressed, insert a real tab, otherwise, insert spaces until next tabstop */
|
|
817
|
+
|
|
818
|
+ if((SDL_GetModState()&KMOD_CTRL)!=0) {
|
|
819
|
+ strncpy(event->text.text,"\t",sizeof(event->text.text));
|
|
820
|
+ event->text.text[sizeof(event->text.text)-1]='\0';
|
|
821
|
+ } else {
|
|
822
|
+ strncpy(event->text.text,spaces+(re->curcol%8),sizeof(event->text.text));
|
|
823
|
+ event->text.text[sizeof(event->text.text)-1]='\0';
|
|
824
|
+ }
|
818
|
825
|
} else if(event->type==SDL_KEYDOWN && event->key.keysym.sym==SDLK_DELETE) {
|
819
|
826
|
#if 0
|
820
|
827
|
fprintf(stderr,"SDL_KEYDOWN: DELETE\n");
|
...
|
...
|
@@ -2265,7 +2272,7 @@ re_drawcontents(re_t *re, printout_t *printout)
|
2265
|
2272
|
/* draw each part of this line */
|
2266
|
2273
|
for(tmpcol=0,pos=realstart,availcol=0;tmpcol<(origincol+maxcol) && pos<=realend;pos=newpos+len,tmpcol+=availcol) {
|
2267
|
2274
|
int has_nl;
|
2268
|
|
- char *ptr;
|
|
2275
|
+ char *ptr,*aux;
|
2269
|
2276
|
int incompletestart,incompleteend,endreq;
|
2270
|
2277
|
int used,usedcol; /* number of bytes/columns used of redata chunk (those are already drawn) */
|
2271
|
2278
|
if(redata_line_rawinfo(data,pos,&newpos,&ptr,&len,&is_continuation)==-1) {
|
...
|
...
|
@@ -2280,6 +2287,18 @@ re_drawcontents(re_t *re, printout_t *printout)
|
2280
|
2287
|
/* while the avail text is larger than the linecolor len */
|
2281
|
2288
|
while(curlinecolor<nlinecolors && (len-has_nl-incompleteend-used)>=(linecolors[curlinecolor].len-usedlenlinecolor)) {
|
2282
|
2289
|
lastcolor=colors[linecolors[curlinecolor].color].rgba;
|
|
2290
|
+ while((aux=memchr(ptr+used,'\t',linecolors[curlinecolor].len-usedlenlinecolor))!=NULL) {
|
|
2291
|
+ /* there is a tab, we want it highlighted with red bg */
|
|
2292
|
+ int thislen=aux-(ptr+used);
|
|
2293
|
+ reui_write(ui,x0+(tmpcol-origincol+usedcol)*ui->fontwidth,y,lastcolor,ptr+used,thislen);
|
|
2294
|
+ usedcol+=redata_generic_utf8len(ptr+used,thislen);
|
|
2295
|
+ used+=thislen;
|
|
2296
|
+ usedlenlinecolor+=thislen;
|
|
2297
|
+ reui_fill(ui,x0+(tmpcol-origincol+usedcol)*ui->fontwidth,y,ui->fontwidth,ui->fontheight+1,"\xba\x07\x07\xff");
|
|
2298
|
+ usedcol++;
|
|
2299
|
+ used++;
|
|
2300
|
+ usedlenlinecolor++;
|
|
2301
|
+ }
|
2283
|
2302
|
reui_write(ui,x0+(tmpcol-origincol+usedcol)*ui->fontwidth,y,lastcolor,ptr+used,linecolors[curlinecolor].len-usedlenlinecolor);
|
2284
|
2303
|
usedcol+=redata_generic_utf8len(ptr+used,linecolors[curlinecolor].len-usedlenlinecolor);
|
2285
|
2304
|
used+=linecolors[curlinecolor].len-usedlenlinecolor;
|
...
|
...
|
@@ -2328,7 +2347,11 @@ re_drawcontents(re_t *re, printout_t *printout)
|
2328
|
2347
|
drawn_cursor=1;
|
2329
|
2348
|
usedcursorchar=0;
|
2330
|
2349
|
redata_getutf8char(re->data,cursorpos,cursorchar,sizeof(cursorchar),&usedcursorchar);
|
2331
|
|
- reui_write(ui,x0+ui->fontwidth*(curcol-origincol),y,"\xff\xff\xff\xff",cursorchar,usedcursorchar);
|
|
2350
|
+ /* tab chars are drawn as an almost filled block, other chars are written as-is */
|
|
2351
|
+ if(usedcursorchar==1 && *cursorchar=='\t')
|
|
2352
|
+ reui_fill(ui,x0+ui->fontwidth*(curcol-origincol)+1,y+1,ui->fontwidth-2,ui->fontheight+1-2,"\xff\xff\xff\xff");
|
|
2353
|
+ else
|
|
2354
|
+ reui_write(ui,x0+ui->fontwidth*(curcol-origincol),y,"\xff\xff\xff\xff",cursorchar,usedcursorchar);
|
2332
|
2355
|
/* get matching braces/parens/anglebracket/curlybraces for highlighting */
|
2333
|
2356
|
if(usedcursorchar==1 && strchr("[]{}<>()",*cursorchar)!=NULL)
|
2334
|
2357
|
matchingpos=re_getmatchingbracket(re,cursorpos,*cursorchar,&matchingchar);
|