Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help for using SHIFT+Insert and Ctrl+V #537

Closed
Sravs66 opened this issue Nov 6, 2019 · 4 comments
Closed

Need help for using SHIFT+Insert and Ctrl+V #537

Sravs66 opened this issue Nov 6, 2019 · 4 comments
Labels

Comments

@Sravs66
Copy link

Sravs66 commented Nov 6, 2019

I have question related to jQuery Terminal

Hi @jcubic ,
I have a situation where I need to enable SHIFT+Insert and CTRL+V on success of one condition only.
I disabled these two by using keymap and keydown. so if i want enable them by using settings, like
window.getTerm().settings().echoCommand=false, how to use these two events..?

@jcubic
Copy link
Owner

jcubic commented Nov 6, 2019

You can use code like this:

var flag = false;
function key(e, original) {
    if (flag) {
        return original();
    } else {
        return false;
    }
}
var term = $('body').terminal({
    toggle: function() {
        flag = !flag;
    }
}, {
    completion: true,
    keymap: {
        'SHIFT+INSERT': key,
        'CTRL+V': key
    }
});

echoCommand option is when you don't want to insert "> foo" when you type "foo" into terminal.

@jcubic jcubic added the question label Nov 6, 2019
@Sravs66
Copy link
Author

Sravs66 commented Nov 7, 2019

HI @jcubic ,
I understand what echoCommand will do, but my intention was can we disable the CTRL+V property like by using,
window.getTerm().settings().keymap["CTRL+V"]= true --- what does it mean if it make any sense.

My problem is, i'm using same terminal inside two windows.

  1. First i logged into terminal1, then logging into terminal2.
  2. while terminal 2 is logging in( when waiting for the response ), i moved to terminal 1 and executing some commands by pasting(CTRL+V/Shift+Insert).
    3.At this point, when terminal 2 gets response and that response will be printed on terminal2, at the same time as i'm pasting commands on terminal1, the same text also got pasting on terminal 2.
    4.If manually entering commands, i managed to enter only on enabled terminal, but i'm not able to stop pasting the text.
    Is there any possibility for this scenario...?

@jcubic
Copy link
Owner

jcubic commented Nov 7, 2019

To answer your exact question you can disable keys, you should use getTerm().keymap("CTRL+V", fn). but you should not have to call it, paste should only go into one instance. So this sounds like a bug to me, but I'm not able to reproduce it here:

https://codepen.io/jcubic/pen/MWWGQBQ?editors=0010

Tested on Windows 10+Chrome 78

I did those steps, I've logged to first terminal, waited for prompt, then logged into second one and pasted text into terminal that was ready. I've also tested without async function, using callback in login (there is issue that it don't pause while it was waiting for callback to be called)

Maybe the problem is with your code, can you share your code? If you can reproduce on codepen please provide the steps.

Or maybe you just found a way to have two terminals enabled in same time.

@jcubic
Copy link
Owner

jcubic commented Jan 1, 2020

Closing because of inactivity. If you still have issue please reopen or comment and I'll do this.

@jcubic jcubic closed this as completed Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants