Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enable horizontal scrolling for individual text blocks in unified diffs. Forum Post 91c3e7854c and the following. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
603816d2210d79171114601a8ad0dc6d |
User & Date: | florian 2023-01-11 18:07:00 |
Context
2023-01-13
| ||
13:09 | Documentation and change-log updates. ... (check-in: a90d3aa1 user: drh tags: trunk) | |
2023-01-11
| ||
18:07 | Enable horizontal scrolling for individual text blocks in unified diffs. Forum Post 91c3e7854c and the following. ... (check-in: 603816d2 user: florian tags: trunk) | |
07:56 | Enable horizontal scrolling for individual text blocks in unified diffs. ... (Closed-Leaf check-in: 15ba7e61 user: florian tags: udiff-hscroll) | |
02:51 | Make proxy setting "system" by default to use http_proxy environment variable. Closer to old behavior and conform with most programs on Unix-like system. ... (check-in: 8f9f2cb7 user: mgagnon tags: trunk) | |
Changes
Changes to src/default.css.
︙ | ︙ | |||
573 574 575 576 577 578 579 | /* Avoid odd-looking color swatches in conjunction with (table.diff pre > ins/del) padding */ padding: inherit; } table.diff td.diffln > pre { padding: 0 0.35em 0 0.5em; } | < < < < | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | /* Avoid odd-looking color swatches in conjunction with (table.diff pre > ins/del) padding */ padding: inherit; } table.diff td.diffln > pre { padding: 0 0.35em 0 0.5em; } table.diff td > pre { box-sizing: border-box; /* Workaround for "slight wiggle" when using mouse-wheel in some FF versions, apparently caused by the increased line-height forcing these elements to be a *tick* larger than they should be but not large enough to force a scroll bar to show up. */ overflow-y: hidden; |
︙ | ︙ |
Changes to src/fossil.diff.js.
︙ | ︙ | |||
664 665 666 667 668 669 670 671 672 673 674 675 676 677 | if(force || !f.colsR){ f.colsR = document.querySelectorAll('td.difftxtr pre'); } f.colsR.forEach(function(e){ e.style.width = w + "px"; e.style.maxWidth = w + "px"; }); if(0){ // seems to be unnecessary if(!f.allDiffs){ f.allDiffs = document.querySelectorAll('table.diff'); } w = lastWidth; f.allDiffs.forEach(function f(e){ if(0 && !f.$){ | > > > > > > > > | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | if(force || !f.colsR){ f.colsR = document.querySelectorAll('td.difftxtr pre'); } f.colsR.forEach(function(e){ e.style.width = w + "px"; e.style.maxWidth = w + "px"; }); if(force || !f.colsU){ f.colsU = document.querySelectorAll('td.difftxtu pre'); } w = lastWidth - 100; f.colsU.forEach(function(e){ e.style.width = w + "px"; e.style.maxWidth = w + "px"; }); if(0){ // seems to be unnecessary if(!f.allDiffs){ f.allDiffs = document.querySelectorAll('table.diff'); } w = lastWidth; f.allDiffs.forEach(function f(e){ if(0 && !f.$){ |
︙ | ︙ | |||
689 690 691 692 693 694 695 | const scrollLeft = function(event){ //console.debug("scrollLeft",this,event); const table = this.parentElement/*TD*/.parentElement/*TR*/. parentElement/*TBODY*/.parentElement/*TABLE*/; table.$txtPres.forEach((e)=>(e===this) ? 1 : (e.scrollLeft = this.scrollLeft)); return false; }; | | > | | > > > > | > | | | | | | | | | | | | | | > | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | const scrollLeft = function(event){ //console.debug("scrollLeft",this,event); const table = this.parentElement/*TD*/.parentElement/*TR*/. parentElement/*TBODY*/.parentElement/*TABLE*/; table.$txtPres.forEach((e)=>(e===this) ? 1 : (e.scrollLeft = this.scrollLeft)); return false; }; Diff.initTableDiff = function f(diff, unifiedDiffs){ if(!diff){ let i, diffs; diffs = document.querySelectorAll('table.splitdiff'); for(i=0; i<diffs.length; ++i){ f.call(this, diffs[i], false); } diffs = document.querySelectorAll('table.udiff'); for(i=0; i<diffs.length; ++i){ f.call(this, diffs[i], true); } return this; } diff.$txtCols = diff.querySelectorAll('td.difftxt'); diff.$txtPres = diff.querySelectorAll('td.difftxt pre'); var width = 0; diff.$txtPres.forEach(function(e){ if(width < e.scrollWidth) width = e.scrollWidth; }); //console.debug("diff.$txtPres =",diff.$txtPres); diff.$txtCols.forEach((e)=>e.style.width = width + 'px'); diff.$txtPres.forEach(function(e){ e.style.maxWidth = width + 'px'; e.style.width = width + 'px'; if(!unifiedDiffs && !e.classList.contains('scroller')){ D.addClass(e, 'scroller'); e.addEventListener('scroll', scrollLeft, false); } }); if(!unifiedDiffs){ diff.tabIndex = 0; if(!diff.classList.contains('scroller')){ D.addClass(diff, 'scroller'); diff.addEventListener('keydown', function(e){ e = e || event; const len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode]; if( !len ) return; this.$txtPres[0].scrollLeft += len; /* ^^^ bug: if there is a 2nd column and it has a scrollbar but txtPres[0] does not, no scrolling happens here. We need to find the widest of txtPres and scroll that one. Example: Checkin a7fbefee38a1c522 file diff.c */ return false; }, false); } } return this; } window.fossil.page.tweakSbsDiffs = function(){ document.querySelectorAll('table.splitdiff').forEach((e)=>Diff.initTableDiff(e)); Diff.checkTableWidth(); }; Diff.initTableDiff().checkTableWidth(); window.addEventListener('resize', F.debounce(()=>Diff.checkTableWidth())); }, false); |