lhmouse / nano-win

GNU nano text editor for Windows [WARNING: The master branch is constantly rebased and force-pushed so don't expect it to be steady!! -end WARNING]
https://files.lhmouse.com/nano-win/
GNU General Public License v3.0
210 stars 25 forks source link

Why does nano editor clears the shell buffer on Windows? #6

Closed ghost closed 6 years ago

ghost commented 6 years ago

Steps to repro:

  1. Install nano for windows
  2. Run some native commands in CMD or PowerShell (dir, cd etc.)
  3. Open nano: nano test.txt
  4. Close it Ctrl+X

The output of previously ran commands (step 2 above) are wiped clean.

Tested on Windows 10.

Can this be fixed?

lhmouse commented 6 years ago

I cannot reproduce the issue in either CMD or PowerShell on Windows 10 x64 Enterprise 1709 (internal version 16299.192).

I cannot reproduce this on Windows 7 x64 either.

4721

ghost commented 6 years ago

This is really strange. It happens to me on CMD, PowerShell as well as Hyper (https://hyper.is/); when i close nano, the previous output goes away.

WinVer suggests that I have exactly the same version and edition of Windows 10 as yours.

Can you think of any setting that might be causing it and that I should check?

ghost commented 6 years ago

After closing nano, the cursor goes to the bottom of the screen while rest of the screen is blank

image

lhmouse commented 6 years ago

Try nano >stdout.txt 2>stderr.txt and see whether there are any error messages.

ghost commented 6 years ago

stderr.txt got one:

LINES value must be >= 2 and <= 0: got -11360 initscr(): Unable to create SP

ghost commented 6 years ago

Seems related to:

https://superuser.com/questions/996245/cannot-run-vifm-on-windows-10-x64 and https://github.com/macton/pdcurses/blob/3635905/pdcurses/initscr.c#L122

lhmouse commented 6 years ago

Apparently you are using pdcurses.

  1. We do NOT use pdcurses.
  2. We have a bundled ncurses and a patch. Use it.
lhmouse commented 6 years ago

Prebuilt binaries are available at https://files.lhmouse.com/nano-win/. Any issue that cannot be reproduced on the newest package will be marked as wontfix and consequently closed.

ghost commented 6 years ago

Thanks that fixed the issue! For release, would be nice if you could make .zip file instead of .7z, that will make the extraction experience double-click. 7z a -r "path\to\my-destination.zip" <glob-patter-to-archive>.

I switched to using this nano-win, everything works except Hyper, that aborts on opening nano.. It wasn't happening with pdcurses-enabled-nano for some reason. Can't get the crash report as the whole process of Hyper.exe terminates. Have you encountered any such reports from hyper users?

lhmouse commented 6 years ago

For release, would be nice if you could make .zip file instead of .7z, that will make the extraction experience double-click. 7z a -r "path\to\my-destination.zip" .

7-Zip for Windows has shell extensions. Using 7z saves more than 30% space in case of nano-win so it has been a convention for me.

I switched to using this nano-win, everything works except Hyper, that aborts on opening nano.. It wasn't happening with pdcurses-enabled-nano for some reason. Can't get the crash report as the whole process of Hyper.exe terminates. Have you encountered any such reports from hyper users?

You may try removing the patch mentioned above. This will make nano-win fail to start in CMD without a proper TERM envvar set. But you only need to try it in hyper.

[Update] The emphasized 'fail to start in CMD without a proper TERM envvar set' above means that, if you don't set it, nano can start. But if you set TERM to something trivial elsewhere such as xterm, nano may fail to start.

ghost commented 6 years ago

On releases, I think many repos are using GitHub releases to upload build artifacts:

https://github.com/lhmouse/nano-win/releases/tag/v2.9.1

You can even automate it from CI to upload the build artifact whenever you push a tag.

Example of git-for-windows: https://github.com/git-for-windows/git/releases/latest (we have zip, bz2, exe and portable-self-extractable-7z.exe)

ghost commented 6 years ago

Thanks, Hyper actually set TERM to xterm-256color, if i unset it and open nano, it still crashes. In regular CMD or PowerShell, I don't have TERM set, and it works.

I will try compiling without that patch.

lhmouse commented 6 years ago

On releases, I think many repos are using GitHub releases to upload build artifacts:

I used to do that. But now I am too lazy to play with git tags. So releases are totally rolling now.

I dislike GitHub's release system. It is nothing better than

sh$ ./package.sh
sh$ sftp myuser@myhost.com
sftp> put *.7z /path/to/my/nginx/directory

in my favor.

lhmouse commented 6 years ago

I have updated the patch for ncurses-6.0.

It should be noted that the ncurses library bundled was built with --disable-database to reduce dependency. I do not claim support for any terminal emulator. If nano-win fails to run in a terminal emulator that does not make use of the Windows Consoles directly, it is probably ncurses' limitation. There is no plan to work around such limitation.

lhmouse commented 6 years ago

I am closing this issue as the compatibility with PDCurses will hardly come true.

wmcbrine commented 4 years ago

So, I just came upon this after thinking I'd like to try building nano with PDCurses. I find comments in the (oldest) ChangeLog and NEWS about support being added, but nothing about it being withdrawn... except this. Can you outline the problem(s) for me?

wmcbrine commented 4 years ago

OK, it took about five minutes of hacking to get nano to build with PDCurses. (It would take longer to do a proper patch.)

lhmouse commented 4 years ago

@wmcbrine Recently nano has adopted more key bindings, including Ctrl+Shift+Delete (cut word to the left), which IIRC do not work with PDCurses.

wmcbrine commented 4 years ago

Yeah, the extended key codes were the only obstacle I found to building it. They could be made to work, with only a little effort -- PDCurses would report that as CTL_DEL, with the shift modifier set.

Resizing also doesn't work (it seems to rely on SIGWINCH, and ignore KEY_RESIZE), but that doesn't break it otherwise.

lhmouse commented 4 years ago

No I am not willing to alter those macro names, which exist in ncurses, but either do not exist at all or exist under different names in PDCurses. Otherwise rebasing constantly on the official master would result in a number of conflicts each time because their developers refactor their code very very often.