diff --git a/static/toolbar.js b/static/toolbar.js
index 16ef820..2dc5995 100644
--- a/static/toolbar.js
+++ b/static/toolbar.js
@@ -28,37 +28,46 @@
bar.id='mb';
bar.innerHTML=
'
'+
- '
'+
- '
'+
- '
'+
+ '
'+
+ '
'+
+ '
'+
'
'+
- '
'+
- '
'+
- '
'+
+ '
'+
+ '
'+
+ '
'+
'
'+
- '
'+
- '
'+
- '
'+
- '
'+
+ '
'+
+ '
'+
+ '
'+
+ '
'+
'
'+
''+
'
'+
'
'+
- '
'+
+ '
'+
'
'+
'
'+
- '
'+
- '
'+
- '
'+
- '
'+
+ '
'+
+ '
'+
+ '
'+
+ '
'+
'
';
document.body.appendChild(bar);
+ // Send data to terminal via xterm's _core (bypasses any .input() issues)
function send(k){
if(document.body.classList.contains('selmode')) toggleSel();
- k=k.replace(/\\x([0-9a-f]{2})/gi,function(_,h){return String.fromCharCode(parseInt(h,16));});
- k=k.replace(/\\t/g,'\t');
- if(window.term){window.term.input(k);window.term.focus();}
+ var t=window.term;
+ if(!t) return;
+ // Try _core.triggerDataEvent first (fires onData which ttyd hooks)
+ if(t._core && t._core.coreService && t._core.coreService.triggerDataEvent){
+ t._core.coreService.triggerDataEvent(k);
+ } else if(t._core && t._core._onData){
+ t._core._onData.fire(k);
+ } else if(t.input){
+ t.input(k);
+ }
+ t.focus();
}
function toggleSel(){
@@ -79,18 +88,14 @@
return;
}
navigator.clipboard.readText().then(function(text){
- if(text && window.term){
- window.term.input(text);
- window.term.focus();
- }
+ if(text) send(text);
}).catch(function(e){
alert('Clipboard read failed: '+e.message);
});
}
function doSave(){
- // Trigger tmux capture-pane via the keybinding Ctrl-A S
- send('\\x01S');
+ send('\x01S');
var btn=document.querySelector('[data-save]');
btn.classList.add('on');
btn.textContent='\u2713';
@@ -106,7 +111,7 @@
if(btn.dataset.k) send(btn.dataset.k);
});
- // Shrink terminal for toolbar on mobile (2 rows now)
+ // Shrink terminal for toolbar on mobile (2 rows)
var obs=new MutationObserver(function(){
var el=document.querySelector('.xterm');
if(el && window.innerWidth<=900){