Fossil SCM

Link keyboard and mouse navigation and enable changing keyboard focus with Ctrl+Click.

florian 2022-09-25 07:34 timeline-keyboard-navigation
Commit 29824137be667a39ba034c8ac7cbee13d82cdb085345fd7ea993f76a398a7ed0
+23
--- src/graph.js
+++ src/graph.js
@@ -1149,10 +1149,33 @@
11491149
}
11501150
else if ( !id ) id = focusDefaultId();
11511151
focusCacheSet(id);
11521152
focusVisualize(id,true);
11531153
}/*,true*/);
1154
+ // NOTE: To be able to override the default CTRL+CLICK behavior (to "select"
1155
+ // the elements, indicated by an outline) for normal (non-input) elements in
1156
+ // FF it's necessary to listen to `mousedown' instead of `click' events.
1157
+ window.addEventListener('mousedown',function(evt){
1158
+ var
1159
+ bMAIN = 0,
1160
+ mCTRL = 1<<14,
1161
+ mod = evt.altKey<<15 | evt.ctrlKey<<14 | evt.shiftKey<<13;
1162
+ if( evt.target.tagName in { 'INPUT':1, 'SELECT':1, 'A':1 } ||
1163
+ evt.button!=bMAIN || mod!=mCTRL ){
1164
+ return;
1165
+ }
1166
+ var e = evt.target;
1167
+ while( e && !/\btimeline\w+Cell\b/.test(e.className) ){
1168
+ e = e.parentElement;
1169
+ }
1170
+ if( e && (e = e.previousElementSibling.querySelector('.tl-nodemark')) ){
1171
+ evt.preventDefault();
1172
+ evt.stopPropagation();
1173
+ focusCacheSet(e.id);
1174
+ focusVisualize(e.id,false);
1175
+ }
1176
+ },false);
11541177
window.addEventListener('pageshow',function(evt){
11551178
var id = focusCacheGet();
11561179
if( !id || !focusVisualize(id,false) ){
11571180
if( focusCookieQuery() ){
11581181
id = focusDefaultId();
11591182
--- src/graph.js
+++ src/graph.js
@@ -1149,10 +1149,33 @@
1149 }
1150 else if ( !id ) id = focusDefaultId();
1151 focusCacheSet(id);
1152 focusVisualize(id,true);
1153 }/*,true*/);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1154 window.addEventListener('pageshow',function(evt){
1155 var id = focusCacheGet();
1156 if( !id || !focusVisualize(id,false) ){
1157 if( focusCookieQuery() ){
1158 id = focusDefaultId();
1159
--- src/graph.js
+++ src/graph.js
@@ -1149,10 +1149,33 @@
1149 }
1150 else if ( !id ) id = focusDefaultId();
1151 focusCacheSet(id);
1152 focusVisualize(id,true);
1153 }/*,true*/);
1154 // NOTE: To be able to override the default CTRL+CLICK behavior (to "select"
1155 // the elements, indicated by an outline) for normal (non-input) elements in
1156 // FF it's necessary to listen to `mousedown' instead of `click' events.
1157 window.addEventListener('mousedown',function(evt){
1158 var
1159 bMAIN = 0,
1160 mCTRL = 1<<14,
1161 mod = evt.altKey<<15 | evt.ctrlKey<<14 | evt.shiftKey<<13;
1162 if( evt.target.tagName in { 'INPUT':1, 'SELECT':1, 'A':1 } ||
1163 evt.button!=bMAIN || mod!=mCTRL ){
1164 return;
1165 }
1166 var e = evt.target;
1167 while( e && !/\btimeline\w+Cell\b/.test(e.className) ){
1168 e = e.parentElement;
1169 }
1170 if( e && (e = e.previousElementSibling.querySelector('.tl-nodemark')) ){
1171 evt.preventDefault();
1172 evt.stopPropagation();
1173 focusCacheSet(e.id);
1174 focusVisualize(e.id,false);
1175 }
1176 },false);
1177 window.addEventListener('pageshow',function(evt){
1178 var id = focusCacheGet();
1179 if( !id || !focusVisualize(id,false) ){
1180 if( focusCookieQuery() ){
1181 id = focusDefaultId();
1182
--- src/timeline.c
+++ src/timeline.c
@@ -1636,10 +1636,12 @@
16361636
** n Focus next (newer) entry, or open next page.
16371637
** m Focus previous (older) entry, or open previous page.
16381638
** M Focus last (oldest) entry.
16391639
** j Move focus between selected, current (check-out) and ticked entries.
16401640
** , Focus entry closest to center of viewport.
1641
+** Ctrl+Click
1642
+** Focus clicked entry.
16411643
** J Scroll to focused entry.
16421644
** h Tick/untick focused entry, or open diff if two entries ticked.
16431645
** H Untick all entries.
16441646
** b Copy commit hash of focused entry to clipboard.
16451647
** B Copy branch name of focused entry to clipboard.
16461648
--- src/timeline.c
+++ src/timeline.c
@@ -1636,10 +1636,12 @@
1636 ** n Focus next (newer) entry, or open next page.
1637 ** m Focus previous (older) entry, or open previous page.
1638 ** M Focus last (oldest) entry.
1639 ** j Move focus between selected, current (check-out) and ticked entries.
1640 ** , Focus entry closest to center of viewport.
 
 
1641 ** J Scroll to focused entry.
1642 ** h Tick/untick focused entry, or open diff if two entries ticked.
1643 ** H Untick all entries.
1644 ** b Copy commit hash of focused entry to clipboard.
1645 ** B Copy branch name of focused entry to clipboard.
1646
--- src/timeline.c
+++ src/timeline.c
@@ -1636,10 +1636,12 @@
1636 ** n Focus next (newer) entry, or open next page.
1637 ** m Focus previous (older) entry, or open previous page.
1638 ** M Focus last (oldest) entry.
1639 ** j Move focus between selected, current (check-out) and ticked entries.
1640 ** , Focus entry closest to center of viewport.
1641 ** Ctrl+Click
1642 ** Focus clicked entry.
1643 ** J Scroll to focused entry.
1644 ** h Tick/untick focused entry, or open diff if two entries ticked.
1645 ** H Untick all entries.
1646 ** b Copy commit hash of focused entry to clipboard.
1647 ** B Copy branch name of focused entry to clipboard.
1648

Keyboard Shortcuts

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