Fossil SCM

Enable keyboard navigation for web UI diffs on the new /ckout page. Restore the "Hide Diff" links (at least temporarily), so the keyboard handler can access the URLs.

florian 2024-12-13 17:07 diff-keyboard-navigation
Commit 9e216433bc12868d127ea9907425183ed34cbd901fb132b94f47daf01d8a68e4
1 file changed +24 -2
+24 -2
--- src/info.c
+++ src/info.c
@@ -614,10 +614,13 @@
614614
** WEBPAGE: ckout
615615
**
616616
** Show information about the current checkout. This page only functions
617617
** if the web server is run on a loopback interface (in other words, was
618618
** started using "fossil ui" or similar) from with on open check-out.
619
+**
620
+** See the help screen for the /vdiff web page for a list of available
621
+** keyboard shortcuts.
619622
*/
620623
void ckout_page(void){
621624
int vid;
622625
char *zHostname;
623626
char *zCwd;
@@ -677,15 +680,24 @@
677680
DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
678681
}
679682
@ <hr>
680683
@ <div class="sectionmenu info-changes-menu">
681684
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
685
+ if( diffType!=0 ){
686
+ /* Class "smb-hide-diff" required by the fossil.diff.js script. */
687
+ const char *zBtnClass = "button smb-hide-diff";
688
+ @ %z(chref(zBtnClass,"%R?diff=0"))Hide&nbsp;Diffs</a>
689
+ }
682690
if( diffType!=1 ){
683
- @ %z(chref("button","%R?diff=1%s",zW))Unified&nbsp;Diff</a>
691
+ /* Class "smb-unified-diff" required by the fossil.diff.js script. */
692
+ const char *zBtnClass = "button smb-unified-diff";
693
+ @ %z(chref(zBtnClass,"%R?diff=1%s",zW))Unified&nbsp;Diff</a>
684694
}
685695
if( diffType!=2 ){
686
- @ %z(chref("button","%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
696
+ /* Class "smb-side-by-side-diff" required by the fossil.diff.js script. */
697
+ const char *zBtnClass = "button smb-side-by-side-diff";
698
+ @ %z(chref(zBtnClass,"%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
687699
}
688700
if( diffType!=0 ){
689701
if( *zW ){
690702
@ %z(chref("button","%R?diff=%d",diffType))\
691703
@ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -783,10 +795,11 @@
783795
const char *zParent; /* Hash of the parent check-in (if any) */
784796
const char *zRe; /* regex parameter */
785797
ReCompiled *pRe = 0; /* regex */
786798
const char *zW; /* URL param for ignoring whitespace */
787799
const char *zPage = "vinfo"; /* Page that shows diffs */
800
+ const char *zPageHide = "ci"; /* Page that hides diffs */
788801
const char *zBrName; /* Branch name */
789802
DiffConfig DCfg,*pCfg; /* Type of diff */
790803
791804
login_check_credentials();
792805
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -1052,10 +1065,16 @@
10521065
@ <div class="sectionmenu info-changes-menu">
10531066
/* ^^^ .info-changes-menu is used by diff scroll sync */
10541067
pCfg = construct_diff_flags(diffType, &DCfg);
10551068
DCfg.pRe = pRe;
10561069
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1070
+ if( diffType!=0 ){
1071
+ /* Class "smb-hide-diff" required by the fossil.diff.js script. */
1072
+ const char *zBtnClass = "button smb-hide-diff";
1073
+ @ %z(chref(zBtnClass,"%R/%s/%T?diff=0",zPageHide,zName))\
1074
+ @ Hide&nbsp;Diffs</a>
1075
+ }
10571076
if( diffType!=1 ){
10581077
/* Class "smb-unified-diff" required by the fossil.diff.js script. */
10591078
const char *zBtnClass = "button smb-unified-diff";
10601079
@ %z(chref(zBtnClass,"%R/%s/%T?diff=1%s",zPage,zName,zW))\
10611080
@ Unified&nbsp;Diff</a>
@@ -1436,10 +1455,13 @@
14361455
cgi_check_for_malice();
14371456
style_set_current_feature("vdiff");
14381457
if( zBranch==0 ){
14391458
style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
14401459
}
1460
+ if( diffType!=0 ){
1461
+ style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b%b", &qp, &qpGlob);
1462
+ }
14411463
if( diffType!=2 ){
14421464
style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
14431465
&qpGlob);
14441466
}
14451467
if( diffType!=1 ) {
14461468
--- src/info.c
+++ src/info.c
@@ -614,10 +614,13 @@
614 ** WEBPAGE: ckout
615 **
616 ** Show information about the current checkout. This page only functions
617 ** if the web server is run on a loopback interface (in other words, was
618 ** started using "fossil ui" or similar) from with on open check-out.
 
 
 
619 */
620 void ckout_page(void){
621 int vid;
622 char *zHostname;
623 char *zCwd;
@@ -677,15 +680,24 @@
677 DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
678 }
679 @ <hr>
680 @ <div class="sectionmenu info-changes-menu">
681 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
 
 
 
 
 
682 if( diffType!=1 ){
683 @ %z(chref("button","%R?diff=1%s",zW))Unified&nbsp;Diff</a>
 
 
684 }
685 if( diffType!=2 ){
686 @ %z(chref("button","%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
 
 
687 }
688 if( diffType!=0 ){
689 if( *zW ){
690 @ %z(chref("button","%R?diff=%d",diffType))\
691 @ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -783,10 +795,11 @@
783 const char *zParent; /* Hash of the parent check-in (if any) */
784 const char *zRe; /* regex parameter */
785 ReCompiled *pRe = 0; /* regex */
786 const char *zW; /* URL param for ignoring whitespace */
787 const char *zPage = "vinfo"; /* Page that shows diffs */
 
788 const char *zBrName; /* Branch name */
789 DiffConfig DCfg,*pCfg; /* Type of diff */
790
791 login_check_credentials();
792 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -1052,10 +1065,16 @@
1052 @ <div class="sectionmenu info-changes-menu">
1053 /* ^^^ .info-changes-menu is used by diff scroll sync */
1054 pCfg = construct_diff_flags(diffType, &DCfg);
1055 DCfg.pRe = pRe;
1056 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
 
 
 
 
 
 
1057 if( diffType!=1 ){
1058 /* Class "smb-unified-diff" required by the fossil.diff.js script. */
1059 const char *zBtnClass = "button smb-unified-diff";
1060 @ %z(chref(zBtnClass,"%R/%s/%T?diff=1%s",zPage,zName,zW))\
1061 @ Unified&nbsp;Diff</a>
@@ -1436,10 +1455,13 @@
1436 cgi_check_for_malice();
1437 style_set_current_feature("vdiff");
1438 if( zBranch==0 ){
1439 style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
1440 }
 
 
 
1441 if( diffType!=2 ){
1442 style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
1443 &qpGlob);
1444 }
1445 if( diffType!=1 ) {
1446
--- src/info.c
+++ src/info.c
@@ -614,10 +614,13 @@
614 ** WEBPAGE: ckout
615 **
616 ** Show information about the current checkout. This page only functions
617 ** if the web server is run on a loopback interface (in other words, was
618 ** started using "fossil ui" or similar) from with on open check-out.
619 **
620 ** See the help screen for the /vdiff web page for a list of available
621 ** keyboard shortcuts.
622 */
623 void ckout_page(void){
624 int vid;
625 char *zHostname;
626 char *zCwd;
@@ -677,15 +680,24 @@
680 DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
681 }
682 @ <hr>
683 @ <div class="sectionmenu info-changes-menu">
684 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
685 if( diffType!=0 ){
686 /* Class "smb-hide-diff" required by the fossil.diff.js script. */
687 const char *zBtnClass = "button smb-hide-diff";
688 @ %z(chref(zBtnClass,"%R?diff=0"))Hide&nbsp;Diffs</a>
689 }
690 if( diffType!=1 ){
691 /* Class "smb-unified-diff" required by the fossil.diff.js script. */
692 const char *zBtnClass = "button smb-unified-diff";
693 @ %z(chref(zBtnClass,"%R?diff=1%s",zW))Unified&nbsp;Diff</a>
694 }
695 if( diffType!=2 ){
696 /* Class "smb-side-by-side-diff" required by the fossil.diff.js script. */
697 const char *zBtnClass = "button smb-side-by-side-diff";
698 @ %z(chref(zBtnClass,"%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
699 }
700 if( diffType!=0 ){
701 if( *zW ){
702 @ %z(chref("button","%R?diff=%d",diffType))\
703 @ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -783,10 +795,11 @@
795 const char *zParent; /* Hash of the parent check-in (if any) */
796 const char *zRe; /* regex parameter */
797 ReCompiled *pRe = 0; /* regex */
798 const char *zW; /* URL param for ignoring whitespace */
799 const char *zPage = "vinfo"; /* Page that shows diffs */
800 const char *zPageHide = "ci"; /* Page that hides diffs */
801 const char *zBrName; /* Branch name */
802 DiffConfig DCfg,*pCfg; /* Type of diff */
803
804 login_check_credentials();
805 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -1052,10 +1065,16 @@
1065 @ <div class="sectionmenu info-changes-menu">
1066 /* ^^^ .info-changes-menu is used by diff scroll sync */
1067 pCfg = construct_diff_flags(diffType, &DCfg);
1068 DCfg.pRe = pRe;
1069 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1070 if( diffType!=0 ){
1071 /* Class "smb-hide-diff" required by the fossil.diff.js script. */
1072 const char *zBtnClass = "button smb-hide-diff";
1073 @ %z(chref(zBtnClass,"%R/%s/%T?diff=0",zPageHide,zName))\
1074 @ Hide&nbsp;Diffs</a>
1075 }
1076 if( diffType!=1 ){
1077 /* Class "smb-unified-diff" required by the fossil.diff.js script. */
1078 const char *zBtnClass = "button smb-unified-diff";
1079 @ %z(chref(zBtnClass,"%R/%s/%T?diff=1%s",zPage,zName,zW))\
1080 @ Unified&nbsp;Diff</a>
@@ -1436,10 +1455,13 @@
1455 cgi_check_for_malice();
1456 style_set_current_feature("vdiff");
1457 if( zBranch==0 ){
1458 style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
1459 }
1460 if( diffType!=0 ){
1461 style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b%b", &qp, &qpGlob);
1462 }
1463 if( diffType!=2 ){
1464 style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
1465 &qpGlob);
1466 }
1467 if( diffType!=1 ) {
1468

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button