~hypedyn-team/hypedyn/2.3-experimental

« back to all changes in this revision

Viewing changes to src/common/hypertextpane.scm

  • Committer: Chuah Teong Leong
  • Date: 2014-01-03 16:08:09 UTC
  • Revision ID: teongleong@gmail.com-20140103160809-0v44thf8cuu7eem3
removed some debug print statements; [partial bugfix] #1258157 lagginess is caused by two things, one the time to build the sexpr of the whole story, second the time to write to the file. By switching to write-simple instead of write in kawa I was able to make the saving process to be fast

Show diffs side-by-side

added added

removed removed

Lines of Context:
398
398
            (let ((link-start (ask thislink 'start-index))
399
399
                  (link-end (ask thislink 'end-index))
400
400
                  (del-end (+ del-start del-len)))
401
 
              (display "adjust one link delete ")(display (list del-start del-end link-start link-end))(newline)
402
401
 
403
402
              ;; making sure I dont leave out any conditions and 
404
403
              ;; there is not conflicts/overlap between conditions
451
450
                     )
452
451
                    ((<= del-end link-start) ;; Case 1; del-start del-end link-start link-end (eg [a]aBBaa, [aa]BBaa) 0123
453
452
                     ; Entire deletion is before link (shift link)
454
 
                     (display " delete case 1 ")(newline)
455
453
                     (shift-link-boundary linkID 'start (- link-start del-len))
456
454
                     (shift-link-boundary linkID 'end (- link-end del-len))
457
455
                     ;(set! link-deleted 0)
459
457
                     )
460
458
                    ((<= link-end del-start) ;; Case 2; link-start link-end del-start del-end (eg aaBB[a]a, aaBBa[a]) 2301
461
459
                     ;; Entire deletion after link (DO NOTHING to this link)
462
 
                     (display " delete case 2 ")(newline)
463
460
                     (set! link-deleted '())
464
461
                     ;(set! link-deleted 0)
465
462
                     )
466
463
                    ((and (<= del-start link-start) ;; Case 3; del-start link-start link-end del-end (eg a[aBB]aa, a[aBBa]a, aa[BBa]a, aa[BB]aa)
467
464
                          (<= link-end del-end))
468
 
                     (display " delete case 3 ")(newline)
469
465
                     ;; Entire link is inside deletion, (delete link)
470
466
                     ;(set! link-deleted (- link-end link-start))
471
467
                     (set! link-deleted (list link-start link-end))
476
472
                    ((and (<= del-end link-end)         ;; Case 4; link-start del-start del-end link-end (eg aaB[B]a, aa[B]Baa, aaB[B]Baa) 
477
473
                          (<= link-start del-start))    ;; makes sure not the whole link 
478
474
                     ;; Entire deletion is inside link but not encompassing it, (shorten link by length of deletion)
479
 
                     (display " delete case 4 ")(newline)
480
475
                     (post-clickback-resize-undoable linkID)
481
476
                     (shift-link-boundary linkID 'end (- link-end del-len) #t)
482
 
                     (display "link start ")(display link-start)(newline)
483
 
                     (display "new link end ")(display (- link-end del-len))(newline)
484
477
                     ;(set! link-deleted del-len)
485
478
                     (set! link-deleted (list del-start del-end))
486
479
                     )
487
480
                    ((and (< del-start link-start)  ;; Case 5; del-start link-start del-end link-end (eg a[aB]Baa)
488
481
                          (< link-start del-end)    ;; link boundaries does not coincides with deletion boundary    
489
482
                          (< del-end link-end))
490
 
                     (display " delete case 5 ")(newline)
491
483
                     ; a portion of the link at the head is deleted (shift link and shorten)
492
484
                     (post-clickback-resize-undoable linkID)
493
485
                     (shift-link-boundary linkID 'start del-start #t)
497
489
                    ((and (< link-start del-start)   ;; Case 6; link-start del-start link-end del-end  (eg aaB[Ba]a)
498
490
                          (< del-start link-end)     ;; link boundaries does not coincides with deletion boundary
499
491
                          (< link-end del-end))
500
 
                     (display " delete case 6 ")(newline)
501
492
                     ;; cut off an end portion of link (shift link-end)
502
493
                     (post-clickback-resize-undoable linkID)
503
494
                     (shift-link-boundary linkID 'end del-start #t)
505
496
                     (set! link-deleted (list del-start link-end))
506
497
                     ))
507
498
              ))
508
 
        (display "end of adjust one link delete ")(newline)
509
499
        link-deleted))
510
500
    
511
501
    ; adjust links after inserting
519
509
    ; adjust one link after insertion
520
510
    ; Note: if extend-len is more than 0, extend the end of link 
521
511
    (define (adjust-one-link-insert ins-start ins-len linkID break-link)
522
 
      (display "adjust one link insert ")(newline)
523
512
      (let ((thislink (get 'links linkID)))
524
513
        (if thislink
525
514
            (let ((link-start (ask thislink 'start-index))
527
516
                  (ins-end (+ ins-start ins-len)))
528
517
;              (display "ins len ")(display ins-len)(newline)
529
518
;              (display "in adjust one link insert ")(display (list link-start link-end))(newline)
530
 
              (display "ins-start ins-end ")(display (list ins-start ins-end))(newline)
531
 
              (display "link-start link-end ")(display (list link-start link-end))(newline)
532
519
  
533
520
              (cond ((and (<= ins-start link-start) ) ;; Case 1 : ins before link (eg aa[i]LLLaa, a[i]aLLLaa)
534
 
                     (display "insert case 1 insert before link (just shift link) ")(newline)
535
 
                     (display "link start end ")(display (list link-start link-end))(newline)
536
521
                     ;; just shift link without changing length
537
522
                     ;(ask thislink 'set-start-index! (+ link-start ins-len))
538
523
                     ;(ask thislink 'set-end-index! (+ link-end ins-len))
540
525
                     (shift-link-boundary linkID 'end (+ link-end ins-len))
541
526
                     )
542
527
                    ((and (< link-start ins-start) (< ins-start link-end) ) ;; Case 2 : ins within link (eg aaL[i]LLaa)
543
 
                     (display "insert case 2 (within link) ")(newline)
544
528
                     (shift-link-boundary linkID 'end (+ link-end ins-len))
545
529
                     )
546
530
                    ((= link-end ins-start)   ;; Case 3b : ins RIGHT after link end (eg aaLLL[i]aa)
547
 
                     (display "insert case 3 (ins right after link) ")(newline)
548
531
                     (if (not break-link) ;; used by insert-blank-space (custom call that does not extend link len ie extend-len is 0)
549
532
                                          ;(ask thislink 'set-end-index! (+ link-end ins-len))
550
533
                         (shift-link-boundary linkID 'end (+ link-end ins-len))
551
534
                         )) ;; lengthen link by ins-len
552
535
 
553
536
                    ((< link-end ins-start) ;; Case 3a: ins after link (do nothing) (eg aaLLLa[i]a)
554
 
                     (display "INSERT AFTER LINK")(newline)
555
537
                     #f)))
556
538
              )))
557
539