Index: bindings.c ================================================================== --- bindings.c +++ bindings.c @@ -163,16 +163,17 @@ int i,j,k; const char*name; if(ev->type==SDL_MOUSEBUTTONDOWN && !x && !y && ev->button.x>=left_margin) { x=(ev->button.x-left_margin)/picture_size+1; y=ev->button.y/picture_size+1; + if(x<1 || y<1 || x>pfwidth || y>pfheight) return 0; } switch(cmd->cmd) { case 0: return 0; case '^': - return cb(0,cmd->n*'\0\1'+'^\0',0,0,0,aux); + return cb(0,cmd->n*'\0\1'+'^\0',y*64+x,0,0,aux); case '=': case '-': case '+': return cb(0,cmd->cmd*'\1\0'+'\0 ',cmd->n,0,0,aux); case '\'': return cb(0,'\' ',cmd->n,0,0,aux); case '!': @@ -203,10 +204,11 @@ while((i=sqlite3_step(cmd->stmt))==SQLITE_ROW) { if(i=sqlite3_data_count(cmd->stmt)) { j=i>1?sqlite3_column_int(cmd->stmt,1):0; if((name=sqlite3_column_text(cmd->stmt,0)) && *name) { k=name[0]*'\1\0'+name[1]*'\0\1'; + while(i && sqlite3_column_type(cmd->stmt,i-1)==SQLITE_NULL) i--; prev=cb(prev,k,j,i,cmd->stmt,aux); if(prev<0) { i=SQLITE_DONE; break; } Index: edit.c ================================================================== --- edit.c +++ edit.c @@ -12,10 +12,11 @@ #include "heromesh.h" #include "quarks.h" #include "cursorshapes.h" static void redraw_editor(void) { + char buf[32]; SDL_Rect r; int x,y; r.x=r.y=0; r.h=screen->h; r.w=left_margin; @@ -25,12 +26,57 @@ SDL_FillRect(screen,&r,0xF7); r.x=left_margin; r.w=screen->w-r.x; SDL_FillRect(screen,&r,back_color); for(x=1;x<=pfwidth;x++) for(y=1;y<=pfheight;y++) draw_cell(x,y); + x=y=0; + SDL_GetMouseState(&x,&y); + SDL_LockSurface(screen); + if(left_margin>=88) { + snprintf(buf,32,"%5d/%5d",level_ord,level_nindex); + draw_text(0,0,buf,0xF0,0xFC); + snprintf(buf,32,"%5d",level_id); + draw_text(0,8,"ID",0xF0,0xF7); + draw_text(48,8,buf,0xF0,0xFF); + snprintf(buf,32,"%5d",level_version); + draw_text(0,16,"VER",0xF0,0xF7); + draw_text(48,16,buf,0xF0,0xFF); + snprintf(buf,32,"%5d",level_code); + draw_text(0,24,"CODE",0xF0,0xF7); + draw_text(48,24,buf,0xF0,0xFF); + } else { + snprintf(buf,32,"%5d",level_ord); + draw_text(16,0,buf,0xF0,0xFC); + snprintf(buf,32,"%5d",level_id); + draw_text(0,8,"I",0xF0,0xF7); + draw_text(16,8,buf,0xF0,0xFF); + snprintf(buf,32,"%5d",level_version); + draw_text(0,16,"V",0xF0,0xF7); + draw_text(16,16,buf,0xF0,0xFF); + snprintf(buf,32,"%5d",level_code); + draw_text(0,24,"C",0xF0,0xF7); + draw_text(16,24,buf,0xF0,0xFF); + } + x=x>=left_margin?(x-left_margin)/picture_size+1:0; + y=y/picture_size+1; + if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); + else strcpy(buf," "); + draw_text(0,32,buf,0xF0,0xF3); + SDL_UnlockSurface(screen); + SDL_Flip(screen); +} + +static void show_mouse_xy(SDL_Event*ev) { + char buf[32]; + int x,y; + x=(ev->motion.x-left_margin)/picture_size+1; + y=ev->motion.y/picture_size+1; + if(ev->motion.x0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); + else strcpy(buf," "); SDL_LockSurface(screen); - draw_text(0,0,"EDIT",0xF0,0xF7); + draw_text(0,32,buf,0xF0,0xF3); SDL_UnlockSurface(screen); SDL_Flip(screen); } static void set_caption(void) { @@ -77,10 +123,11 @@ case SDL_QUIT: exit(0); break; case SDL_MOUSEMOTION: set_cursor(ev.motion.x