kaustubhhiware / c0derunR

An attempt at a cleaner UI for online IDE's: http://c0derunr.herokuapp.com
MIT License
21 stars 8 forks source link

Support keyboard shortcuts #15

Open Demfier opened 6 years ago

Demfier commented 6 years ago

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.

142ayushkumar commented 6 years ago

Can you assign me this issue?

Demfier commented 6 years ago

@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 commented 6 years ago

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

142ayushkumar commented 6 years ago

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?

Demfier commented 6 years ago

@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:

142ayushkumar commented 6 years ago

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

Demfier commented 6 years ago

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.

142ayushkumar commented 6 years ago

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

Demfier commented 6 years ago

What does the console show? ᐧ

On 14 December 2017 at 17:36, Kumar Ayush notifications@github.com 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 commented 6 years ago

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

142ayushkumar commented 6 years ago

[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

Demfier commented 6 years ago

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: ᐧ