Overview
Comment: | Implement the $KEY_XY SQL host variable, to allow coordinate selection by keyboard, as suggested on IRC. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8c73b0a17e32734d54685e03ff065615 |
User & Date: | user on 2021-04-26 03:20:55 |
Other Links: | manifest | tags |
Context
2021-04-26
| ||
04:05 | Implement more operations with marks. check-in: e742adc13a user: user tags: trunk | |
03:20 | Implement the $KEY_XY SQL host variable, to allow coordinate selection by keyboard, as suggested on IRC. check-in: 8c73b0a17e user: user tags: trunk | |
01:05 | Implement case blocks. check-in: f4215e7216 user: user tags: trunk | |
Changes
Modified TODO from [06c5cc8fb0] to [62fb593ca2].
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - | * Bizarro world * Testing the deferred movement * String data (?) * A ,PopUp command to use a popup with arguments starting from a mark * Operations with marks (duplicate a list, length of a list, etc) * "Goto message" instruction * Class inheritance (abstract) |
︙ |
Modified bindings.c from [ec2dd85ae4] to [59715bfb2c].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | + | #include <stdlib.h> #include <string.h> #include "SDL.h" #include "sqlite3.h" #include "smallxrm.h" #include "quarks.h" #include "heromesh.h" #include "cursorshapes.h" #define MOD_SHIFT 1 #define MOD_CTRL 2 #define MOD_ALT 4 #define MOD_META 8 #define MOD_NUMLOCK 14 typedef struct { |
︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | goto redraw; case SDL_QUIT: SDL_PushEvent(&ev); goto done; } done: if(tab) sqlite3_free_table(tab); sqlite3_free(err); } static int key_xy(void) { char buf[32]; SDL_Rect r; SDL_Event ev; int x,y; int xc=pfwidth/2+1; int yc=pfheight/2+1; set_cursor(XC_hand1); redraw: r.x=r.y=0; r.h=screen->h; r.w=left_margin; SDL_FillRect(screen,&r,0xF0); r.x=left_margin-1; r.w=1; 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); SDL_LockSurface(screen); snprintf(buf,8,"(%2d,%2d)",xc,yc); draw_text(0,0,buf,0xF0,0xF7); SDL_UnlockSurface(screen); r.x=left_margin+(xc-1)*picture_size+picture_size/2; r.y=(yc-1)*picture_size; r.w=1; r.h=picture_size; SDL_FillRect(screen,&r,0xF6); r.x=left_margin+(xc-1)*picture_size; r.y=(yc-1)*picture_size+picture_size/2; r.w=picture_size; r.h=1; SDL_FillRect(screen,&r,0xF6); r.x=left_margin+(xc-1)*picture_size+picture_size/2; r.y=(yc-1)*picture_size+picture_size/2; r.w=r.h=2; SDL_FillRect(screen,&r,0xFE); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) switch(ev.type) { case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_h: case SDLK_LEFT: case SDLK_KP4: if(xc>1) xc--; break; case SDLK_j: case SDLK_DOWN: case SDLK_KP2: if(yc<pfheight) yc++; break; case SDLK_k: case SDLK_UP: case SDLK_KP8: if(yc>1) yc--; break; case SDLK_l: case SDLK_RIGHT: case SDLK_KP6: if(xc<pfwidth) xc++; break; case SDLK_RETURN: case SDLK_KP_ENTER: case SDLK_SPACE: return xc+yc*64; case SDLK_ESCAPE: case SDLK_DELETE: case SDLK_q: return -1; } goto redraw; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) break; x=(ev.button.x-left_margin)/picture_size+1; y=ev.button.y/picture_size+1; if(x>0 && x<=pfwidth && y>0 && y<=pfheight) { xc=x,yc=y; if(ev.button.button==2) return xc+yc*64; if(ev.button.button==3) return -1; goto redraw; } break; case SDL_VIDEOEXPOSE: goto redraw; case SDL_QUIT: SDL_PushEvent(&ev); return -1; } return -1; } int exec_key_binding(SDL_Event*ev,int editing,int x,int y,int(*cb)(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux),void*aux) { const UserCommand*cmd=find_key_binding(ev,editing); int prev=0; int i,j,k; const char*name; if(ev->type==SDL_MOUSEBUTTONDOWN && !x && !y && ev->button.x>=left_margin) { |
︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | + + + + | if(x) sqlite3_bind_int(cmd->stmt,i,x); } else if(!sqlite3_stricmp(name+1,"Y")) { if(y) sqlite3_bind_int(cmd->stmt,i,y); } else if(!sqlite3_stricmp(name+1,"LEVEL")) { sqlite3_bind_int(cmd->stmt,i,level_ord); } else if(!sqlite3_stricmp(name+1,"LEVEL_ID")) { sqlite3_bind_int(cmd->stmt,i,level_id); } else if(!sqlite3_stricmp(name+1,"KEY_XY")) { j=key_xy(); if(j<0) return 0; sqlite3_bind_int(cmd->stmt,i,j); } } else if(*name==':') { name=screen_prompt(name); if(!name) return 0; sqlite3_bind_text(cmd->stmt,i,name,-1,SQLITE_TRANSIENT); } } |
︙ |
Modified bindings.doc from [ab99235ee1] to [1bf7746fc4].
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - - + + + | commands to execute, where the first column is a string of two characters (the possibilities are explained below) and the rest of the columns (if any) are the arguments. You can use NULL for trailing arguments if you do not need that many arguments. SQL statements can also contain host parameters. The valid host parameters are $X (clicked X coordinate), $Y (clicked Y coordinate), $LEVEL (level |
︙ |
Modified default.heromeshrc from [b105198fc2] to [804c1e8ecd].
︙ | |||
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | + | ?.gameKey.shift.f3: -100 ?.gameKey.shift.f4: -1000 ?.gameKey.f5: ^M ?.gameKey.f6: ^< ?.gameKey.f7: ^> ?.gameKey.f8: ^s ?.gameKey.tab: ^I ?.gameKey.alt.D: select '^d',$key_xy; ?.gameKey.alt.G: ^g ! Editor key bindings ?.editKey.1: select 'mr',0; ?.editKey.2: select 'mr',1; ?.editKey.3: select 'mr',2; ?.editKey.4: select 'mr',3; |
︙ |