|
512 | 512 | `(begin ,@(kbd-map-body '() l)) |
513 | 513 | ) ;tm-define-macro |
514 | 514 |
|
| 515 | +(tm-define (utf8-kbd-binding conds key2 cmd help) |
| 516 | + (:synopsis "Helper routine for utf8-kbd-map macro") |
| 517 | + (with key |
| 518 | + (kbd-pre-rewrite (string-convert key2 "UTF-8" "Cork")) |
| 519 | + (kbd-sub-bindings conds key) |
| 520 | + (kbd-insert-key-binding conds key (list cmd help)) |
| 521 | + ) ;with |
| 522 | +) ;tm-define |
| 523 | + |
| 524 | +(define (utf8-kbd-map-one conds l) |
| 525 | + (if (not (and (pair? l) (string? (car l)) (pair? (cdr l)))) |
| 526 | + (texmacs-error "utf8-kbd-map-pre-one" "Bad keymap in: ~S" l) |
| 527 | + ) ;if |
| 528 | + (with (key action . opt) |
| 529 | + l |
| 530 | + (if (string? action) |
| 531 | + (with help |
| 532 | + (if (null? opt) "" (car opt)) |
| 533 | + `(utf8-kbd-binding (list ,@conds) ,key ,action ,help) |
| 534 | + ) ;with |
| 535 | + `(utf8-kbd-binding (list ,@conds) ,key (lambda ,() ,action ,@opt) ,"") |
| 536 | + ) ;if |
| 537 | + ) ;with |
| 538 | +) ;define |
| 539 | + |
| 540 | +(define (utf8-kbd-map-body conds l) |
| 541 | + (cond ((null? l) '()) |
| 542 | + ((symbol? (car l)) (utf8-kbd-map-body (list 0 (car l)) (cdr l))) |
| 543 | + ((and (pair? (car l)) (== (caar l) :profile)) |
| 544 | + (if (not (has-look-and-feel? (cdar l))) |
| 545 | + '((noop)) |
| 546 | + (utf8-kbd-map-body conds (cdr l)) |
| 547 | + ) ;if |
| 548 | + ) ; |
| 549 | + ((and (pair? (car l)) (keyword? (caar l))) |
| 550 | + (utf8-kbd-map-body (kbd-add-condition conds (car l)) (cdr l)) |
| 551 | + ) ; |
| 552 | + (else (map (lambda (x) (utf8-kbd-map-one conds x)) l)) |
| 553 | + ) ;cond |
| 554 | +) ;define |
| 555 | + |
| 556 | +(tm-define-macro (utf8-kbd-map . l) |
| 557 | + (:synopsis "Add entries with UTF-8 key names to the keyboard mapping") |
| 558 | + `(begin ,@(utf8-kbd-map-body '() l)) |
| 559 | +) ;tm-define-macro |
| 560 | + |
515 | 561 | (tm-define-macro (delayed-kbd-map . l) |
516 | 562 | (:synopsis "Like kbd-map, but register bindings in chunks via the event loop") |
517 | 563 | `(kbd-enqueue (list ,@(map (lambda (x) `(lambda ,() ,x)) (kbd-map-body '() l)))) |
518 | 564 | ) ;tm-define-macro |
519 | 565 |
|
| 566 | +(tm-define-macro (utf8-delayed-kbd-map . l) |
| 567 | + (:synopsis "Like utf8-kbd-map, but register bindings in chunks via the event loop" |
| 568 | + ) ;:synopsis |
| 569 | + `(kbd-enqueue (list ,@(map (lambda (x) `(lambda ,() ,x)) |
| 570 | + (utf8-kbd-map-body '() l)))) |
| 571 | +) ;tm-define-macro |
| 572 | + |
520 | 573 | (define (kbd-remove-one conds key) |
521 | 574 | `(kbd-delete-key-binding2 (list ,@conds) ,key) |
522 | 575 | ) ;define |
|
0 commit comments