Jump to content

  • Log In with Google      Sign In   
  • Create Account


fix the tabs issue?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Vortez   Crossbones+   -  Reputation: 2697

Posted 26 April 2014 - 04:59 AM

Something that annoy me when posting code is, when you press tab, instead of making a tab, you loose the keyboard/mouse focus instead.

 

Could this be fixed? And if you fix it, should as well do like vs and make it work on multiples selected lines as well, i find this feature incredibly usefull in visual studio.

But i would set up for a regular tab if that's fesable.

 

Just saying smile.png


Edited by Vortez, 26 April 2014 - 05:02 AM.


Sponsor:

#2 Migi0027   Crossbones+   -  Reputation: 1617

Posted 29 April 2014 - 09:18 AM

I have the same issue, it would be awesome if we could get that implemented.

 

if you're interested, I made a small demo that shows how it 'could' be done, my javascript skills aren't top, just saying. happy.png

 

http://jsfiddle.net/e5PK5/11/

 

But if you're too lazy to click the link, here's the code:

HTML::>
<textarea style="width:100%;" rows="25" id="Content">
........
</textarea>

JS::>
/*********************************/
// Fellow Game-Devs, here ya go! //
/*********************************/

$(document).ready(function () {
    // Remember, is shift down?
    var bShiftDown = false;

    $(document).delegate('#Content', 'keyup', function (e) {
        // Shift Up
        if ((e.keyCode || e.which) == 16) bShiftDown = false;
    });

    $(document).delegate('#Content', 'keydown', function (e) {
        // Store it
        var keyCode = e.keyCode || e.which;

        // Shift Down
        if (keyCode == 16) bShiftDown = true;

        // Tab Down
        if (keyCode == 9) {
            e.preventDefault();

            // Get the positions
            var start = $(this).get(0).selectionStart;
            var end = $(this).get(0).selectionEnd;

            // What type of command is this? Indent, or Dedent? ( If that's even a word )
            if (!bShiftDown) {
                // Get array of lines and add \t
                var code = $(this).val().substring(start, end).match(/[^\r\n]+/g);
                if (!code) return;
                for (var i = 0; i < code.length; i++) {
                    code[i] = '\t' + code[i];
                }

                // Fill it in
                $(this).val($(this).val().substring(0, start) + code.join('\n') + $(this).val().substring(end));

                // Remember to put the cursor somewhere!
                $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1;
            } else {
                // Get array of lines and remove one \t
                // SUGGESTION: maybe remove some spaces if no t found...
                var code = $(this).val().substring(start, end).match(/[^\r\n]+/g);
                if (!code) return;
                for (var i = 0; i < code.length; i++) {
                    code[i] = code[i].replace("\t", '');
                }

                // Fill it in
                $(this).val($(this).val().substring(0, start) + code.join('\n') + $(this).val().substring(end));

                // Remember to put the cursor there!
                $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start;
            }
        }
    });
});

   
And you reached the bottom!

-MIGI0027


Edited by Migi0027, 29 April 2014 - 09:19 AM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS