c0derunR icon indicating copy to clipboard operation
c0derunR copied to clipboard

Support keyboard shortcuts

Open Demfier opened this issue 7 years ago • 12 comments

It would be nice to have support for keyboard shortcuts such as Tab to give indentation, shortcuts to move a line of code up/down etc.

Demfier avatar Nov 23 '17 09:11 Demfier

Can you assign me this issue?

142ayushkumar avatar Dec 12 '17 18:12 142ayushkumar

@142ayushkumar - I have assigned this issue to you. Make sure when you make the PR you enumerate a list of keyboard shortcuts that you've added.

Demfier avatar Dec 13 '17 04:12 Demfier

Update: @142ayushkumar working demo isn't required. #33 will take care if it.

Demfier avatar Dec 13 '17 05:12 Demfier

I have a separate .js and .html file and tab works in text area (just to check that my js file is working or not) but they don't work in this project, any idea where i did mistake?

142ayushkumar avatar Dec 14 '17 11:12 142ayushkumar

@142ayushkumar : It would greatly help if you could provide us with the code or something. And by the way you'll have to run python manage.py collectstatic command if you've introduced new static files (html, js, css, images etc) to make sure they are loaded in the app. This is just a hinch though. I would be able to tell you better if you "show" me what you are doing :smile:

Demfier avatar Dec 14 '17 11:12 Demfier

Added this in index.html

{% load staticfiles %}
<script src="{% static "js/my.js" %}"></script>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="static/js/my.js"></script>
</head> 

and in my.js


$(document).delegate('#textbox', 'keydown', function(e) {
  var keyCode = e.keyCode || e.which;

  if (keyCode == 9) {
    e.preventDefault();
    var start = this.selectionStart;
    var end = this.selectionEnd;

    // set textarea value to: text before caret + tab + text after caret
    $(this).val($(this).val().substring(0, start)
                + "\t"
                + $(this).val().substring(end));

    // put caret at right position again
    this.selectionStart =
    this.selectionEnd = start + 1;
  }
});

and yes, i did this python manage.py collectstatic too

142ayushkumar avatar Dec 14 '17 11:12 142ayushkumar

I think the issue stands here with the way you are referring to them. Try using /static/js/my.js instead the way you are using now. Also, as a thumb rule, you should always check your browser's console to get a direction to start you debugging. Let me know if that helps.

Demfier avatar Dec 14 '17 12:12 Demfier

Sorry for my bad, i used /static/js/my.js , was just tweaking and then i copied the code, i used /static/js/my.js ,it doesn't work

142ayushkumar avatar Dec 14 '17 12:12 142ayushkumar

What does the console show? ᐧ

On 14 December 2017 at 17:36, Kumar Ayush [email protected] wrote:

Sorry for my bad, i used /static/js/my.js , was just tweaking and then i copied the code, i used /static/js/my.js ,it doesn't work

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kaustubhhiware/c0derunR/issues/15#issuecomment-351692882, or mute the thread https://github.com/notifications/unsubscribe-auth/AMAyBoaQ91eOXX4UEv23pfi1EiMFK5_Jks5tAQ9WgaJpZM4QocR8 .

Demfier avatar Dec 14 '17 12:12 Demfier

Also, I think it's better if you make a PR.

Demfier avatar Dec 14 '17 12:12 Demfier

[14/Dec/2017 12:15:29] "GET / HTTP/1.1" 200 13504 [14/Dec/2017 12:15:29] "GET /static/js/my.js HTTP/1.1" 304 0 [14/Dec/2017 12:15:29] "GET /static/css/mystyle.css HTTP/1.1" 304 0 [14/Dec/2017 12:15:29] "GET /static/js/terminal_fill.js HTTP/1.1" 304 0 [14/Dec/2017 12:15:29] "GET /static/js/my.js HTTP/1.1" 304 0 [14/Dec/2017 12:15:30] "GET /static/img/logo.ico HTTP/1.1" 304 0

142ayushkumar avatar Dec 14 '17 12:12 142ayushkumar

That's all?

Make a PR. No errors exist in the snippet. Also, I meant your browser's console back then. My bad, I should've specified earlier :sweat_smile: ᐧ

Demfier avatar Dec 14 '17 12:12 Demfier