128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
++f;
}
t++;
if(!--len) return;
pix+=8;
}
}
const char*screen_prompt(const char*txt) {
static char*t=0;
int n=0;
SDL_Rect r={0,0,screen->w,16};
int m=r.w>>3;
SDL_Event ev;
if(!t) {
t=malloc(m+2);
if(!t) fatal("Allocation failed\n");
}
*t=0;
SDL_FillRect(screen,&r,0xF1);
r.y=16;
r.h=1;
SDL_FillRect(screen,&r,0xF8);
SDL_LockSurface(screen);
draw_text(0,0,txt,0xF1,0xFE);
draw_text(0,8,"\xB1",0xF1,0xFB);
SDL_UnlockSurface(screen);
set_cursor(XC_iron_cross);
SDL_Flip(screen);
r.y=8;
r.h=8;
while(SDL_WaitEvent(&ev)) {
switch(ev.type) {
case SDL_QUIT:
SDL_PushEvent(&ev);
return 0;
case SDL_KEYDOWN:
SDL_FillRect(screen,&r,0xF1);
switch(ev.key.keysym.sym) {
case SDLK_RETURN: case SDLK_KP_ENTER:
r.y=0;
r.h=17;
SDL_FillRect(screen,&r,0xF0);
t[n]=0;
return t;
case SDLK_BACKSPACE: case SDLK_DELETE:
if(n) t[n--]=0;
break;
case SDLK_CLEAR:
t[n=0]=0;
break;
default:
if(ev.key.keysym.sym==SDLK_u && (ev.key.keysym.mod&KMOD_CTRL)) {
t[n=0]=0;
} else if(ev.key.keysym.sym==SDLK_c && (ev.key.keysym.mod&KMOD_CTRL)) {
r.y=0;
r.h=17;
SDL_FillRect(screen,&r,0xF0);
return 0;
} else if(n<m && ev.key.keysym.unicode<127 && ev.key.keysym.unicode>=32 && !(ev.key.keysym.mod&KMOD_CTRL)) {
t[n++]=ev.key.keysym.unicode;
t[n]=0;
}
}
t[n]=0;
SDL_FillRect(screen,&r,0xF1);
SDL_LockSurface(screen);
draw_text(0,8,t,0xF1,0xFF);
draw_text(n<<3,8,"\xB1",0xF1,0xFB);
SDL_UnlockSurface(screen);
SDL_Flip(screen);
}
}
}
static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize,int n) {
int i,j;
if(!nwantsize) fatal("Unable to determine what picture size is wanted\n");
for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]==n) return j;
for(i=*wantsize;i;--i) if(havesize[i]) return i;
fatal("Unable to determine what picture size is wanted\n");
|
353
354
355
356
357
358
359
360
361
362
|
421
422
423
424
425
426
427
428
429
430
431
|
+
|
if(v=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
w=strtol(v,(void*)&v,10);
h=strtol(v,0,10);
SDL_EnableKeyRepeat(w,h);
} else {
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
}
SDL_EnableUNICODE(1);
optionquery[1]=Q_margin;
left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10);
}
|