Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [ff3e323781]:

To Artifact [603365f23b]:


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
210
211
212
213
214

215
216
217
218
219
220
221
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
210
211
212
213
214
215
216
217
218


219
220
221
222
223
224
225
226







+
+


-
-
+

+
+

+
+
-
-
+
+
+
+








-
+


-
-
+
+







-
+


-


















-
-
+







  if((m&KMOD_NUM) && kb->m[i|MOD_NUMLOCK].cmd) i|=MOD_NUMLOCK;
  return kb->m+i;
}

static void sql_interactive(void) {
  const char*t=screen_prompt("<SQL>");
  const char*u;
  char*err=0;
  char**tab=0;
  SDL_Rect r;
  SDL_Event ev;
  sqlite3_stmt*st=0;
  int i,j,y;
  int n,i,j,y;
  int k=0;
  int nr=0;
  int nc=0;
  if(!t) return;
  sqlite3_get_table(userdb,t,&tab,&nr,&nc,&err);
  if(!tab) {
  if(sqlite3_prepare_v2(userdb,t,-1,&st,0)) screen_message(sqlite3_errmsg(userdb));
  if(!st) return;
    if(err) screen_message(err);
    sqlite3_free(err);
    return;
  }
  redraw:
  r.x=r.y=0;
  r.w=screen->w;
  r.h=screen->h;
  SDL_FillRect(screen,&r,0xF0);
  SDL_LockSurface(screen);
  if(!k) draw_text(0,0,t,0xF8,0xFB);
  y=8-k;
  while((i=sqlite3_step(st))==SQLITE_ROW) {
  for(n=0;n<nr;n++) {
    if(y>=0) {
      if(y>screen->h-8) break;
      for(i=j=0;i<sqlite3_data_count(st);i++) {
        u=sqlite3_column_text(st,i);
      for(i=j=0;i<nc;i++) {
        u=tab[nc*(n+1)+i];
        draw_text(j,y,"\xB3",0xF0,0xF9),j+=8;
        if(u) draw_text(j,y,u,0xF0,0xF7),j+=strlen(u)*8; else draw_text(j,y,"\x04",0xF0,0xF4),j+=8;
      }
    }
    y+=8;
  }
  if(y>=0 && y<=screen->h-8) {
    if(i==SQLITE_DONE) draw_text(0,y,"--END--",0xF8,0xFA); else draw_text(0,y,sqlite3_errmsg(userdb),0xF8,0xFC);
    if(!err) draw_text(0,y,"--END--",0xF8,0xFA); else draw_text(0,y,err,0xF8,0xFC);
  }
  SDL_UnlockSurface(screen);
  sqlite3_reset(st);
  SDL_Flip(screen);
  while(SDL_WaitEvent(&ev)) switch(ev.type) {
    case SDL_KEYDOWN:
      switch(ev.key.keysym.sym) {
        case SDLK_ESCAPE: case SDLK_RETURN: case SDLK_KP_ENTER: goto done;
        case SDLK_UP: k-=8; if(k<0) k=0; break;
        case SDLK_DOWN: k+=8; break;
        case SDLK_HOME: k=0; break;
        case SDLK_PAGEUP: k-=screen->h; if(k<0) k=0; break;
        case SDLK_PAGEDOWN: k+=screen->h; break;
      }
      goto redraw;
    case SDL_VIDEOEXPOSE:
      goto redraw;
    case SDL_QUIT:
      SDL_PushEvent(&ev);
      goto done;
  }
  done:
  sqlite3_finalize(st);
  done: if(tab) sqlite3_free_table(tab); sqlite3_free(err);
}

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;