about summary refs log tree commit diff stats
path: root/main.c
Commit message (Expand)AuthorAgeFilesLines
* new color stuff/new rendering stuffAnselm R. Garbe2006-08-251-5/+9
* back to 3 colorsAnselm R. Garbe2006-08-251-4/+3
* 3->4 colorsAnselm R. Garbe2006-08-241-3/+4
* changing tag indicator through underlineAnselm R. Garbe2006-08-241-0/+1
* removed a blank lineAnselm R. Garbe2006-08-231-1/+0
* separated setup stuff into main.c:setup() - this makes main() more readableAnselm R. Garbe2006-08-231-86/+95
* rearranged getprotoAnselm R. Garbe2006-08-221-6/+5
* removed winprop (merged into getproto)Anselm R. Garbe2006-08-221-27/+7
* removed DEFTAGAnselm R. Garbe2006-08-221-1/+1
* small renamings of two static functionsAnselm R.Garbe2006-08-211-2/+2
* small changes to dwm.1, rearranged order within main event loopAnselm R.Garbe2006-08-211-4/+4
* corrected order of cleanup code Anselm R.Garbe2006-08-161-1/+1
* we close stdin as wellAnselm R.Garbe2006-08-161-3/+4
* extended cleanupAnselm R.Garbe2006-08-151-0/+7
* applied jk_to_tab patchAnselm R.Garbe2006-08-151-2/+1
* changed main event loopAnselm R.Garbe2006-08-151-10/+7
* removed NUMLOCKMASK, added dynamically calculated numlockmask insteadAnselm R.Garbe2006-08-141-7/+19
* changed order of selecting input at root windowAnselm R.Garbe2006-08-141-4/+4
* removed unneecessary crapAnselm R.Garbe2006-08-141-1/+0
* some other small fixesAnselm R.Garbe2006-08-141-8/+8
* removed ungrabkeys again (because of sander's mail)Anselm R.Garbe2006-08-141-1/+0
* implemented ungrabkeys() which is called in cleanup()Anselm R.Garbe2006-08-141-0/+1
* supplying NULL args in selectAnselm R.Garbe2006-08-141-1/+1
* reducing ConnectionNumber calls to a bare minimumAnselm R.Garbe2006-08-141-4/+5
* implemented viewextend and added M-S-C-n shortcuts for extending the current ...Anselm R.Garbe2006-08-111-3/+3
* implement multi-tag selection through button3 click on the specific tagAnselm R.Garbe2006-08-111-1/+3
* prepared 0.8 0.8Anselm R.Garbe2006-08-101-0/+1
* readded border color, this sucks leastAnselm R.Garbe2006-08-101-0/+1
* removed unnecessary border colorAnselm R.Garbe2006-08-101-1/+0
* removed NET_ACTIVE_WINDOW handlingAnselm R.Garbe2006-08-081-1/+0
* implemented NET_ACTIVE_WINDOW supportAnselm R.Garbe2006-08-081-0/+1
* applied Sanders tiny patchesAnselm R.Garbe2006-08-081-1/+2
* small fix of a commentarg@10ksloc.org2006-08-071-1/+1
* changed getproto, maybe that might fix the killclient issue reported on the listarg@10ksloc.org2006-08-071-2/+3
* slight fixarg@10ksloc.org2006-08-051-3/+2
* switched to regexp matching for Rulesarg@10ksloc.org2006-08-041-0/+1
* removed TLast tag enum, now tags is simple defined as char *[] array, the res...arg@10ksloc.org2006-08-031-0/+3
* made fullscreen apps working fine in floating mode (there is no sane way to m...arg@10ksloc.org2006-08-021-7/+8
* dwm is now exit, if stdin is closed due broken pipearg@10ksloc.org2006-08-021-8/+5
* renamed WM_PROTOCOL_DELWIN into PROTODELWINarg@10ksloc.org2006-08-011-1/+1
* centralized/externalized configuration to config.harg@10ksloc.org2006-08-011-3/+1
* some cleanups/fixes inspired by Jukka Salmi's feedbackarg@10ksloc.org2006-07-211-1/+2
* simplified main.c, switching back to single urxvt usagearg@10ksloc.org2006-07-211-27/+13
* added yet another CUTOMIZE tagarg@10ksloc.org2006-07-201-0/+2
* cleaned up codearg@10ksloc.org2006-07-201-27/+16
* applied Sanders resize patch, fixed lower bugarg@10ksloc.org2006-07-191-1/+1
* implemened distinguishing float/managed geometries of clients (works quite well)Anselm R. Garbe2006-07-181-0/+1
* using EXIT_stuff in exit() nowAnselm R. Garbe2006-07-181-5/+4
* ordered variables in structs and source files alphabeticallyAnselm R. Garbe2006-07-171-20/+18
* fixed XSync handling and finished man pageAnselm R. Garbe2006-07-151-1/+1
#n159'>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 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547



































                                                                              
                                               

                                                                        
                                             


































                                                                                 




                                                                    
               

                                                                     








































                                                                               


                                                






                                                           
                          




                                                                 


                             









                                                                           
                                                                    



















































































































































































                                                                              

                                                                                  


























                                        
                        














































                                                            
                     























                                                                                                














































































































                                                                              
ef='#n175'>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

                                                                          




                                                         

          


















































                                                                                                                                                                         
                                            

          





                  
                                                                                                                                                                             











                                                        
 




















                                                                                                          







                                                                                  
                                                                         





                                                                                     
                                                                                      





                                                      
                                                        





                          
                                                                                                                                           
             
                  
                                                      
                                                                 




                                                                                   
                                                                                 








                                                                                      
                                                                   
                                                                                 

                                                                

 
                                                                                                         
             
                  
                                                                                                            



                                        
                                       

                                                     
                                                                          
                                     





                                                                             

                                                                                                        
                                                                                              
                                                                   
                                                                              

                                            
                                                                             


                                                
                                                                               



                                  

                                          


                                                                                    
## clicking on sandbox results to 'fix' them and turn sandboxes into tests

scenario sandbox-click-on-result-toggles-color-to-green [
  trace-until 100/app  # trace too long
  assume-screen 50/width, 20/height
  # basic recipe
  1:address:shared:array:character <- new [ 
def foo [
  return 4
]]
  # run it
  2:address:shared:array:character <- new [foo]
  assume-console [
    press F4
  ]
  3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 2:address:shared:array:character
  event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 1:address:shared:array:character/test-recipes
  screen-should-contain [
    .                               run (F4)           .
    .                                                  .
    .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
    .0                                                x.
    .foo                                               .
    .4                                                 .
    .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
    .                                                  .
  ]
  # click on the '4' in the result
  assume-console [
    left-click 5, 21
  ]
  run [
    event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 1:address:shared:array:character/test-recipes
  ]
  # color toggles to green
  screen-should-contain-in-color 2/green, [
    .                                                  .
    .                                                  .
    .                                                  .
    .                                                  .
    .                                                  .
    .4                                                 .
    .                                                  .
  ]
  # cursor should remain unmoved
  run [
    4:character/cursor <- copy 9251/    print screen:address:shared:screen, 4:character/cursor
  ]
  screen-should-contain [
    .                               run (F4)           .
    .                                                 .
    .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
    .0                                                x.
    .foo                                               .
    .4                                                 .
    .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
    .                                                  .
  ]
  # now change the result
  1:address:shared:array:character <- new [ 
def foo [
  return 3
]]
  # then rerun
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 1:address:shared:array:character/new-test-recipes
  ]
  # result turns red
  screen-should-contain-in-color 1/red, [
    .                                                  .
    .                                                  .
    .                                                  .
    .                                                  .
    .                                                  .
    .3                                                 .
    .                                                  .
  ]
]

# this requires tracking a couple more things
container sandbox-data [
  response-starting-row-on-screen:number
  expected-response:address:shared:array:character
]

# include expected response when saving or restoring a sandbox
before <end-save-sandbox> [
  {
    expected-response:address:shared:array:character <- get *curr, expected-response:offset
    break-unless expected-response
    filename <- append filename, suffix
    save filename, expected-response
  }
]

before <end-restore-sandbox> [
  expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset
  *expected-response <- copy contents
]

# clicks on sandbox responses save it as 'expected'
after <global-touch> [
  # check if it's inside the output of any sandbox
  {
    sandbox-left-margin:number <- get *current-sandbox, left:offset
    click-column:number <- get *t, column:offset
    on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin
    break-unless on-sandbox-side?
    first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset
    break-unless first-sandbox
    first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset
    click-row:number <- get *t, row:offset
    below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins
    break-unless below-sandbox-editor?
    # identify the sandbox whose output is being clicked on
    sandbox:address:shared:sandbox-data <- find-click-in-sandbox-output env, click-row
    break-unless sandbox
    # toggle its expected-response, and save session
    sandbox <- toggle-expected-response sandbox
    save-sandboxes env
    hide-screen screen
    screen <- render-sandbox-side screen, env, 1/clear
    screen <- update-cursor screen, current-sandbox, env
    # no change in cursor
    show-screen screen
    loop +next-event:label
  }
]

def find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [
  local-scope
  load-ingredients
  # assert click-row >= sandbox.starting-row-on-screen
  sandbox:address:shared:sandbox-data <- get *env, sandbox:offset
  start:number <- get *sandbox, starting-row-on-screen:offset
  clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start
  assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
  # while click-row < sandbox.next-sandbox.starting-row-on-screen
  {
    next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset
    break-unless next-sandbox
    next-start:number <- get *next-sandbox, starting-row-on-screen:offset
    found?:boolean <- lesser-than click-row, next-start
    break-if found?
    sandbox <- copy next-sandbox
    loop
  }
  # return sandbox if click is in its output region
  response-starting-row:number <- get *sandbox, response-starting-row-on-screen:offset
  return-unless response-starting-row, 0/no-click-in-sandbox-output
  click-in-response?:boolean <- greater-or-equal click-row, response-starting-row
  return-unless click-in-response?, 0/no-click-in-sandbox-output
  return sandbox
]

def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [
  local-scope
  load-ingredients
  expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset
  {
    # if expected-response is set, reset
    break-unless *expected-response
    *expected-response <- copy 0
    return sandbox/same-as-ingredient:0
  }
  # if not, current response is the expected response
  response:address:shared:array:character <- get *sandbox, response:offset
  *expected-response <- copy response
]

# when rendering a sandbox, color it in red/green if expected response exists
after <render-sandbox-response> [
  {
    break-unless sandbox-response
    response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset
    *response-starting-row <- copy row
    expected-response:address:shared:array:character <- get *sandbox, expected-response:offset
    break-unless expected-response  # fall-through to print in grey
    response-is-expected?:boolean <- equal expected-response, sandbox-response
    {
      break-if response-is-expected?:boolean
      row, screen <- render screen, sandbox-response, left, right, 1/red, row
    }
    {
      break-unless response-is-expected?:boolean
      row, screen <- render screen, sandbox-response, left, right, 2/green, row
    }
    jump +render-sandbox-end:label
  }
]

before <end-render-sandbox-reset-hidden> [
  tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset
  *tmp <- copy 0
]