-
-
Notifications
You must be signed in to change notification settings - Fork 569
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
Cursor in the same line as echo output #428
Comments
No it's not possible, it will require lot of work with current architecture, but maybe I go about and try to make it work, since I had few questions about this. |
As a workaround I am setting the last line of echo data as the prompt. But there are special characters in prompt. So would it be possible to apply the formatting that is done for echo to prompt as well? |
I completely missed formatters in prompt, will add. |
You can now have the same text in prompt as in command. The code is in devel branch. |
I kind of broken, devel branch right now but you can use version from commit. |
works again, need testing. |
Here is example of using prompt to not echo newline, it works with string prompt: var last;
var term = $('body').terminal($.noop, {
echoCommand: false,
keymap: {
'ENTER': function(e, original) {
var str;
if (!last) {
str = this.get_prompt() + this.get_command();
} else {
var str = last + prompt + this.get_command();
last = '';
}
this.echo(str);
original(e);
}
},
prompt: '>>> '
});
var prompt = term.get_prompt();
(function(echo) {
term.echo = function(arg, options) {
var settings = $.extend({
newline: true
}, options);
if (!prompt) {
prompt = this.get_prompt();
}
if (settings.newline === false) {
last += arg;
arg += this.get_prompt();
var arr = arg.split('\n');
var last_line;
if (arr.length === 1) {
last_line = arg;
} else {
echo(arr.slice(0, -1).join('\n'), options);
last_line = arr[arr.length - 1];
}
this.set_prompt(last_line);
} else {
if (prompt) {
this.set_prompt(prompt);
}
if (last) {
echo(last + arg, options);
} else {
echo(arg, options);
}
last = '';
prompt = '';
}
};
})(term.echo); I don't think I will add this hack to the library. It will be more complex if prompt is a function. The prompt function will need to be executed multiple times and I just fixed issue with counter in prompt function. |
Added this to list of examples on the site. |
Is it possible for the cursor to be positioned in the same line as the data printed from echo
(Prompt is set to empty)
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: