62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
int pos;
} Cursor;
static Uint8 cur_type;
static Uint8 gsizes[16];
static Picture*cur_pic;
static Picture*spare_page;
static void fn_valid_name(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
const char*s=sqlite3_value_text(*argv);
if(!s || !*s || s[strspn(s,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789")]) {
sqlite3_result_error(cxt,"Invalid name",-1);
return;
}
|
>
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
int pos;
} Cursor;
static Uint8 cur_type;
static Uint8 gsizes[16];
static Picture*cur_pic;
static Picture*spare_page;
static sqlite3_stmt**macro[26];
static void fn_valid_name(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
const char*s=sqlite3_value_text(*argv);
if(!s || !*s || s[strspn(s,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789")]) {
sqlite3_result_error(cxt,"Invalid name",-1);
return;
}
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
.xEof=vt_graph_eof,
.xFilter=vt_graph_filter,
.xNext=vt_graph_next,
.xOpen=vt_graph_open,
.xRowid=vt_graph_rowid,
.xUpdate=vt_graph_update,
};
static int load_picture_file(void) {
sqlite3_stmt*st=0;
FILE*fp;
char*nam;
char*buf=0;
int r=0;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
.xEof=vt_graph_eof,
.xFilter=vt_graph_filter,
.xNext=vt_graph_next,
.xOpen=vt_graph_open,
.xRowid=vt_graph_rowid,
.xUpdate=vt_graph_update,
};
static void*load_macros_1(xrm_db*db,void*usr,int loose,xrm_quark q) {
const char*txt;
if(q<Q_A || q>Q_Z) return 0;
if(!(db=xrm_sub(db,loose,q)) || !(txt=xrm_get(db))) return 0;
if(sqlite3_prepare_v3(userdb,txt,-1,SQLITE_PREPARE_PERSISTENT,macro+(q-Q_A),0)) fatal("Error in macro: %s\n%s\n",txt,sqlite3_errmsg(userdb));
return 0;
}
static void*load_macros(xrm_db*db,void*usr) {
xrm_enumerate(db,load_macros_1,0);
return 0;
}
static int load_picture_file(void) {
sqlite3_stmt*st=0;
FILE*fp;
char*nam;
char*buf=0;
int r=0;
|
908
909
910
911
912
913
914
915
916
917
918
919
920
921
|
if(!m.w) m.x=m.y=m.h=0;
flood(x,y,m.x,m.y,m.w?:pict[sel]->size,m.h?:pict[sel]->size,cc,pict[sel]->data[(y+1)*pict[sel]->size+x],i);
}
goto redraw;
}
break;
case SDL_KEYDOWN:
switch(ev.key.keysym.sym) {
case SDLK_ESCAPE: return;
case SDLK_LEFTBRACKET: case SDLK_LEFTPAREN: --sel; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_RIGHTBRACKET: case SDLK_RIGHTPAREN: ++sel; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_1 ... SDLK_9: sel=ev.key.keysym.sym-SDLK_1; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_c: t=6; xx=yy=-1; goto redraw;
case SDLK_d: t=0; xx=yy=-1; goto redraw;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
|
if(!m.w) m.x=m.y=m.h=0;
flood(x,y,m.x,m.y,m.w?:pict[sel]->size,m.h?:pict[sel]->size,cc,pict[sel]->data[(y+1)*pict[sel]->size+x],i);
}
goto redraw;
}
break;
case SDL_KEYDOWN:
if((ev.key.keysym.mod&(KMOD_ALT|KMOD_META)) && ev.key.keysym.sym>=SDLK_a && ev.key.keysym.sym<=SDLK_z) {
sqlite3_stmt*st=macro[ev.key.keysym.sym-SDLK_a];
if(!st) goto redraw;
sqlite3_reset(st);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$cc"),cc);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$xx"),xx);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$yy"),yy);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$mx"),m.x);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$my"),m.y);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$mw"),m.w);
sqlite3_bind_int(st,sqlite3_bind_parameter_index(st,"$mh"),m.h);
while((i=sqlite3_step(st))==SQLITE_ROW) {
for(j=0;j<sqlite3_data_count(st);) switch(sqlite3_column_int(st,j++)) {
case 1:
xx=sqlite3_column_int(st,j++);
yy=sqlite3_column_int(st,j++);
break;
case 2:
m.x=sqlite3_column_int(st,j++);
m.y=sqlite3_column_int(st,j++);
m.w=sqlite3_column_int(st,j++);
m.h=sqlite3_column_int(st,j++);
break;
case 3:
cc=sqlite3_column_int(st,j++);
break;
}
}
if(i!=SQLITE_DONE) screen_message(sqlite3_errmsg(userdb));
goto redraw;
}
switch(ev.key.keysym.sym) {
case SDLK_ESCAPE: return;
case SDLK_LEFTBRACKET: case SDLK_LEFTPAREN: --sel; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_RIGHTBRACKET: case SDLK_RIGHTPAREN: ++sel; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_1 ... SDLK_9: sel=ev.key.keysym.sym-SDLK_1; m.x=m.y=m.w=m.h=0; goto redraw;
case SDLK_c: t=6; xx=yy=-1; goto redraw;
case SDLK_d: t=0; xx=yy=-1; goto redraw;
|
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
|
int max=load_picture_file();
int i,n;
sqlite3_create_function(userdb,"VALID_NAME",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_valid_name,0,0);
sqlite3_create_module(userdb,"GRAPH",&vt_graph,0);
init_palette();
optionquery[1]=Q_imageSize;
picture_size=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"16",0,10);
if(!*gsizes) *gsizes=picture_size;
set_cursor(XC_arrow);
set_caption();
i=sqlite3_prepare_v3(userdb,"SELECT `ID`,SUBSTR(`NAME`,1,LENGTH(`NAME`)-4),`TYPE` FROM `PICEDIT` WHERE `TYPE` ORDER BY `NAME` LIMIT ?1 OFFSET ?2;",-1,SQLITE_PREPARE_PERSISTENT,&st,0);
if(i) fatal("SQL error (%d): %s\n",i,sqlite3_errmsg(userdb));
ids=calloc(screen->h/8,sizeof(sqlite3_int64));
if(!ids) fatal("Allocation failed\n");
|
>
>
>
|
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
|
int max=load_picture_file();
int i,n;
sqlite3_create_function(userdb,"VALID_NAME",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_valid_name,0,0);
sqlite3_create_module(userdb,"GRAPH",&vt_graph,0);
init_palette();
optionquery[1]=Q_imageSize;
picture_size=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"16",0,10);
optionquery[1]=Q_picedit;
optionquery[2]=Q_macro;
xrm_search(resourcedb,optionquery,optionquery,3,load_macros,0);
if(!*gsizes) *gsizes=picture_size;
set_cursor(XC_arrow);
set_caption();
i=sqlite3_prepare_v3(userdb,"SELECT `ID`,SUBSTR(`NAME`,1,LENGTH(`NAME`)-4),`TYPE` FROM `PICEDIT` WHERE `TYPE` ORDER BY `NAME` LIMIT ?1 OFFSET ?2;",-1,SQLITE_PREPARE_PERSISTENT,&st,0);
if(i) fatal("SQL error (%d): %s\n",i,sqlite3_errmsg(userdb));
ids=calloc(screen->h/8,sizeof(sqlite3_int64));
if(!ids) fatal("Allocation failed\n");
|