You are not logged in.

#26 2017-01-03 15:14:43

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: Command's temporary output is not cleared from terminal

Amphitryon wrote:
nbd wrote:

I tried to read the code and what I don't understand is what caused the temporary menu disappear previously. The script works approximatly as follows....

Many terminal emulators support two virtual screens per terminal and a control sequence to switch between them.  This has typically been used in the past to have one virtual screen for full-screen-oriented programs such as an editor and another for line-oriented output.  The line-oriented output would usually be the default virtual screen - the one the terminal emulator starts with.  Functions in a library such as ncurses would send the codes to switch to the other virtual screen on initialisation and switch back on termination.

I am sure I have seen, in the past, some fancy shell configurations where the shell itself uses this feature to separate output from the shell itself from output from the commands run from the shell.

Since this feature currently doesn't work as it did neither in bash nor in zsh, which have very few common libraries, one could guess that there occurred some change on the terminal side. And on rather deep level, since I observe the same incorrect working in three terminal emulators as well as in virtual console. I wonder, did someone managed to install this script and check if it works in the same way I described?


bing different

Offline

#27 2017-01-03 16:42:20

seth
Member
Registered: 2012-09-03
Posts: 51,905

Re: Command's temporary output is not cleared from terminal

Yes, me - I see what you see (sorry had a misconception of the feature and thought of autocompleting dirs) in xterm/zsh

There should be sth. like

echo -e '\033[?1049h'
echo -e '\033[?1049l'

to switch the buffers (which works as expected for me) - so fasd likely does not operate with alternative screen buffers,  actually I see nothing in that script to suggest it would erase former lines.

echo -e '\033[nA'

would move up n lines (to eg. erase a former line by writing blanks) - there's no "033" token in the script at all, so it doesn't seem to use escape sequences. *shrug*

Offline

#28 2017-01-05 17:27:42

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: Command's temporary output is not cleared from terminal

seth wrote:

There should be sth. like

echo -e '\033[?1049h'
echo -e '\033[?1049l'
echo -e '\033[nA'

The first code completely erases the screen (draws a new empty "alternate screen" on the top of the "primary" screen), and the second one restores the previously erased screen. The third code prints the prompt on the n-th line above, without erasing the lines below it.

I wonder, is there a way to print, say 5 lines without erasing the screen, and then to erase only these 5 lines? That is, when a command is called and waits for the user input, the screen looks like this:

[al /] cd ~
[al~]$ ls
file1 file2 file3
[al ~ ]$ zz tst
4	1.08135    /dir1/tst
3	1.38706    /dir2/tst
2	5.54594    /mnt/dir3/tst
1	78.9584    /mnt/dir4/tst
> _

After typing the input and pressing Enter, the menu lines are erased and the screen looks like this:

[al /] cd ~
[al~]$ ls
file1 file2 file3
[al ~ ]$ zz tst
[al tst]

bing different

Offline

#29 2017-01-05 17:48:16

seth
Member
Registered: 2012-09-03
Posts: 51,905

Re: Command's temporary output is not cleared from terminal

Yes, sure.

echo -en '1\n2\n3\n'; sleep 5; echo -e '\033[1A\033[1A\033[1A\033[1A'

Heads up, be honest: did that actually ever work or are you just seeking for help to implement it?

Offline

#30 2017-01-05 18:30:15

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: Command's temporary output is not cleared from terminal

Of course that worked. Otherwise, that script would be barely usable and not among the most starred projects on GitHub: temporary menus with directory suggestions can be 10,20 and more lines. Had they always kept remaining on the screen on every directory change, I would have used something else. Don't have any idea why it got broken, but before -Syu in December, when I discovered this change, I made last -Syu in March. So I don't know when exactly happened the update that broke it.

Thanks for the advise! In zsh it works OK. (In bash the output is like this:

[al ~ ]$ /usr/bin/bash --noprofile --norc
bash-4.4$ echo -en '1\n2\n3\n'; sleep 5; echo -e '\033[1A\033[1A\033[1A\033[1A'
bash-4.4$ 
2
3

)


bing different

Offline

#31 2017-01-05 19:03:54

seth
Member
Registered: 2012-09-03
Posts: 51,905

Re: Command's temporary output is not cleared from terminal

Try

echo -en '1\n2\n3\n'; sleep 5; echo -e '\033[1A\r \033[1A\r \033[1A\r \033[1A'

\r is a carriage return and the blank afterwards overrides the output.

The thing is that I really see absolutely nothing in that script to provide this, maybe you should contact the author.

Offline

#32 2017-01-05 19:06:47

loqs
Member
Registered: 2014-03-06
Posts: 17,493

Re: Command's temporary output is not cleared from terminal

nbd wrote:

Don't have any idea why it got broken, but before -Syu in December, when I discovered this change, I made last -Syu in March.

Nine months is longer than generally recommended between updates.  If a multi month period between updates is normal rather than the exception then you might be better served by a distribution that supports unsupervised updates than can run automatically on a more regular basis.

Offline

#33 2017-01-05 19:42:06

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: Command's temporary output is not cleared from terminal

seth:

Many thanks! This works exactly as the script worked before.

loqs:

Thanks!


bing different

Offline

#34 2017-01-05 19:45:36

seth
Member
Registered: 2012-09-03
Posts: 51,905

Re: Command's temporary output is not cleared from terminal

You're welcome, but if you contcat the fasd author to get this patched in, I'd *really* like to hear how it was done before (just post a link to a relevant ticked/thread), thanks in advance ;-P

Offline

Board footer

Powered by FluxBB