some suggestions arround tabulation use

73 views
Skip to first unread message

garkin

unread,
Oct 7, 2012, 12:03:42 AM10/7/12
to persona...@googlegroups.com
As most of u, i prefer to use tabulations for code formatting. And currently its rough with this extension, since textfields change focus on [Tab] hit, instead of of /t inserting, and useless, since extension interface fully mouse oriented and default tab size is just awful. So extension textfields, supposed for working with code, only works like copypaste text storage. All code work with HTML, CSS and JS have to be done in external text editor, even with relatively small code pieces.

My suggestions is:

- Add CSS rule for normal tabulation size in textfields, which will allow at least for recive readable code:
.rule-css, rule-js, rule-html { tab-size: 4; }
 
- Add [Tab] input for this textfields:
$("textarea").keydown(function(e) {
    if(e.keyCode === 9) { // tab was pressed
        // get caret position/selection
        var start = this.selectionStart;
        var end = this.selectionEnd;
        var $this = $(this);
        var value = $this.val();
        // set textarea value to: text before caret + tab + text after caret
        $this.val(value.substring(0, start)
                    + "\t"
                    + value.substring(end));
        // put caret at right position again (add one for the tab)
        this.selectionStart = this.selectionEnd = start + 1;
        // prevent the focus lose
        e.preventDefault();
    }
});
Reply all
Reply to author
Forward
0 new messages