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

Alignment with \t #423

Closed
divyareddy12 opened this issue Aug 24, 2018 · 5 comments
Closed

Alignment with \t #423

divyareddy12 opened this issue Aug 24, 2018 · 5 comments

Comments

@divyareddy12
Copy link

\t aligns the text one below each in case of unix output but this is not the case in jquery terminal

String : Test 0.\n\n==============================\nStatus1.\t[ ]\b\b\b\b\b--\r\u001B[KStatus1.\t[ ]\b\b\b\b\bDONE\nLine2.\t[ ]\b\b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b----\b\b\b\b \b\b\b\b-\r\u001B[KLin2.\t[ ]\b\b\b\b\bFAIL\nTest3.\t[ ]\b\b\b\b\b--\r\u001B[KTest3.\t[ ]\b\b\b\b\bWARNING]\n\nFinal status\n\nStatus details\nTime: 11

Expected behavior

(all the '[' are aligned one below the other)

Test 0.

==============================
State1.   [DONE]
Lin2.     [FAIL]
Test3.    [WARNING]

Final status

Status details
Time: 11

Actual behavior

Test 0.

==============================
Status1.    [DONE]
Lin2.    [FAIL]
Test3.    [WARNING]

Final status

Status details
Time: 11
jcubic added a commit that referenced this issue Aug 25, 2018
@jcubic
Copy link
Owner

jcubic commented Aug 25, 2018

The feature is in devel branch, but you can update it in your current version using:

$.terminal.encode = function encode(str, options) {
    var settings = $.extend({
        tabs: 4
    }, options);
    return $.terminal.amp(str).replace(/</g, '&lt;').replace(/>/g, '&gt;')
        .replace(/ /g, '&nbsp;').split('\n').map(function(line) {
            var splitted = line.split(/(\t)/);
            return splitted.map(function(str, i) {
                if (str === '\t') {
                    if (i === 0 || splitted[i - 1] === '\t') {
                        return new Array(settings.tabs + 1).join('&nbsp;');
                    } else {
                        var before = splitted.slice(0, i).join('');
                        var len = $.terminal.length(before);
                        var chars = settings.tabs - (len % settings.tabs);
                        if (chars === 0) {
                            chars = 4;
                        }
                        return new Array(chars + 1).join('&nbsp;');
                    }
                }
                return str;
            }).join('');
        }).join('\n');
};

@jcubic
Copy link
Owner

jcubic commented Aug 25, 2018

Now tabs option actually work (previously it only worked with columns and echo array) you can specify 8 to get the same results as in unix terminal.

@jcubic
Copy link
Owner

jcubic commented Aug 26, 2018

Version 1.21.0 released.

@jcubic jcubic closed this as completed Aug 26, 2018
@jcubic
Copy link
Owner

jcubic commented Sep 7, 2018

there was still issues with tabs in command it's now fixed and it will be in next version.

@jcubic jcubic reopened this Sep 7, 2018
jcubic added a commit that referenced this issue Sep 7, 2018
@jcubic
Copy link
Owner

jcubic commented Sep 9, 2018

version 1.22.0 released

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

No branches or pull requests

2 participants