Discussion:
[Msys2-users] gdb in msys
Baruch Burstein
2016-01-26 10:16:10 UTC
Permalink
Hi all,

When I run gdb in the mingw64 environment (I haven't tested others), it
behaves weirdly. Specifically, If I press the up arrow, instead of
scrolling through the previous commands, it moves the caret up on the
screen, and from there just goes crazy (printing text and seemingly random
places on the screen, no accepting commands, etc.)

"which gdb" returns "/mingw64/bin/gdb". I am fully updated.

Any insights?

Thanks,
Baruch
--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
Ray Donnelly
2016-01-26 10:52:30 UTC
Permalink
Post by Baruch Burstein
Hi all,
When I run gdb in the mingw64 environment (I haven't tested others), it
behaves weirdly. Specifically, If I press the up arrow, instead of scrolling
through the previous commands, it moves the caret up on the screen, and from
there just goes crazy (printing text and seemingly random places on the
screen, no accepting commands, etc.)
"which gdb" returns "/mingw64/bin/gdb". I am fully updated.
Yes. It's to do with mintty. Use "winpty gdb" instead. We should
probably make wrappers like we do for most other REPL things. File a
bug if you wouldn't mind (or better, make pull requests - follow the
examples in python or something like that).
Post by Baruch Burstein
Any insights?
Thanks,
Baruch
--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Msys2-users mailing list
https://lists.sourceforge.net/lists/listinfo/msys2-users
Daniel Goldman
2016-01-26 18:30:52 UTC
Permalink
Related to this post, winpty (never heard of it before) at least
partially fixed the curses problem I had posted on the msys2 discussion
forum before, and no clues had emerged.

The curses program, plus simple test curses programs I had presented,
previously produced error messages like the following and crashed:

$ txu1-tpl-eg1.exe
Redirection is not supported.
$

With "winpty txu1-tpl-eg1.exe" the program at least starts up, looks
perfect visually. The program responds to keyboard commands (eg, q to
quit). Pressing ENTER goes to a submenu, and that works.

Unfortunately, the arrow keys, PgUp, PgDn, Home, End keys don't work.
They work correctly when the program runs under a windows 7 command
window. Does anybody have a clue why the arrow keys do not work for
running a pdcurses program under mintty / winpty?

Thanks,
Daniel

PS -
http://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/
is a related post I found, in case helpful for anyone.
Post by Ray Donnelly
Post by Baruch Burstein
When I run gdb in the mingw64 environment (I haven't tested others), it
behaves weirdly. Specifically, If I press the up arrow, instead of scrolling
through the previous commands, it moves the caret up on the screen, and from
there just goes crazy (printing text and seemingly random places on the
screen, no accepting commands, etc.)
Yes. It's to do with mintty. Use "winpty gdb" instead. We should
probably make wrappers like we do for most other REPL things. File a
bug if you wouldn't mind (or better, make pull requests - follow the
examples in python or something like that).
Daniel Goldman
2016-02-08 04:30:31 UTC
Permalink
I posted the following to the Discussion tab. I thought it would be best
to also post to the email list, in case someone looks here.

------------------------

I wanted to thank Greg Jung for sending a very helpful response. It
might benefit some others.

Run "C:\msys64\usr\bin\bash.exe --login -i" from within the windows 7
command prompt ("dos shell") and get a bash prompt. Then run the curses
(compiled with pdcurses) program with "./txu1-tpl-eg1.exe" - it runs
perfectly! Arrow keys work, everything looks / functions perfectly.

Next, make a copy of the command prompt desktop icon, change the target
to the command line given above, it works perfectly.

------------------------

I'm still confused about the difference between 1) mintty, 2) winpty
from within mintty, 3) bash.exe from within dos window, and 4) dos
window itself. For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors get messed up, it is
slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.

Obviously, I don't really understand what's going on. It would be nice
if someone who understands more about this could post some advice,
related to different options for compiling and running curses
applications under msys2.

Anyway, at least the bash.exe option is good progress.

Daniel
Post by Daniel Goldman
Related to this post, winpty (never heard of it before) at least
partially fixed the curses problem I had posted on the msys2 discussion
forum before, and no clues had emerged.
The curses program, plus simple test curses programs I had presented,
$ txu1-tpl-eg1.exe
Redirection is not supported.
$
With "winpty txu1-tpl-eg1.exe" the program at least starts up, looks
perfect visually. The program responds to keyboard commands (eg, q to
quit). Pressing ENTER goes to a submenu, and that works.
Unfortunately, the arrow keys, PgUp, PgDn, Home, End keys don't work.
They work correctly when the program runs under a windows 7 command
window. Does anybody have a clue why the arrow keys do not work for
running a pdcurses program under mintty / winpty?
Thanks,
Daniel
PS -
http://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/
is a related post I found, in case helpful for anyone.
Post by Ray Donnelly
Post by Baruch Burstein
When I run gdb in the mingw64 environment (I haven't tested others), it
behaves weirdly. Specifically, If I press the up arrow, instead of scrolling
through the previous commands, it moves the caret up on the screen, and from
there just goes crazy (printing text and seemingly random places on the
screen, no accepting commands, etc.)
Yes. It's to do with mintty. Use "winpty gdb" instead. We should
probably make wrappers like we do for most other REPL things. File a
bug if you wouldn't mind (or better, make pull requests - follow the
examples in python or something like that).
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Msys2-users mailing list
https://lists.sourceforge.net/lists/listinfo/msys2-users
David Macek
2016-02-08 20:18:54 UTC
Permalink
Post by Daniel Goldman
I posted the following to the Discussion tab. I thought it would be best
to also post to the email list, in case someone looks here.
------------------------
I wanted to thank Greg Jung for sending a very helpful response. It
might benefit some others.
Run "C:\msys64\usr\bin\bash.exe --login -i" from within the windows 7
command prompt ("dos shell") and get a bash prompt. Then run the curses
(compiled with pdcurses) program with "./txu1-tpl-eg1.exe" - it runs
perfectly! Arrow keys work, everything looks / functions perfectly.
Next, make a copy of the command prompt desktop icon, change the target
to the command line given above, it works perfectly.
------------------------
I'm still confused about the difference between
Msys2 can be substituted for Cygwin in the explanations below. I also put a slightly different version of the text on our wiki: https://sourceforge.net/p/msys2/wiki/MSYS2%20introduction/

Non-graphical Cygwin (generally POSIX) and regular Windows programs use fundamentally different ways to display output and receive input.
Post by Daniel Goldman
1) mintty,
A terminal emulator built for Cygwin programs. It provides pty's and other POSIXy stuff to programs and it draws the result "manually". Cygwin programs "just know" how to use it and usually have no problems with it.

There are other terminal emulators, but they're not provided in MSYS2.
Post by Daniel Goldman
4) dos window itself.
The Windows terminal (console, conhost) does the same for regular Windows programs. It provides the back-end to Windows console handles and regular Windows programs "just know" how to use it.

The "DOS window itself" is actually a combination of this console and the Windows shell (cmd, command line).
Post by Daniel Goldman
3) bash.exe from within dos window, and
Cygwin allows some inter-operation between a Cygwin program and Windows console and between a Windows program and Cygwin terminal emulators. You can run bash in a Windows terminal and also run cmd in mintty. For basic stuff, it works fine. Anything more complicated, like colored text, TUIs and line editing, breaks.
Post by Daniel Goldman
2) winpty from within mintty,
Winpty is a wrapper program that starts a hidden Windows console window and open the wrapped program in it. It then relays input from your Cygwin terminal to the Windows program and output from the program to your terminal. This solves a lot of the issues when running regular Windows programs in a Cygwin terminal.
Post by Daniel Goldman
For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors get messed up, it is
slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.
/usr/bin/mc.exe? On my system, this one runs perfectly in mintty, but is horribly broken in a regular Windows terminal.
Post by Daniel Goldman
Obviously, I don't really understand what's going on. It would be nice
if someone who understands more about this could post some advice,
related to different options for compiling and running curses
applications under msys2.
Anyway, at least the bash.exe option is good progress.
--
David Macek
Daniel Goldman
2016-02-09 23:59:19 UTC
Permalink
David,

Thanks very much for the reply and the explanation of the differences. I
did have a few points.
Post by David Macek
Non-graphical Cygwin (generally POSIX) and regular
Windows programs use fundamentally different ways
to display output and receive input.
It's unclear to me what you mean by "regular Windows programs". It seems
a vague term (and I am a windows programmer). To me, a "regular Windows
program" is a GUI program, like firefox under windows, Excel under
windows, etc. Is that what you are referring to? BTW, what's an
"irregular windows program"?

I was specifically referring to curses programs. I stated that clearly.
So I don't understand your sole mention of vague "regular windows
programs", no mention of specific "curses program".
Post by David Macek
It provides pty's and other POSIXy stuff to programs and
it draws the result "manually". Cygwin programs "just know"
how to use it and usually have no problems with it.
I would suggest that the explanation is lacking, especially in saying
that cygwin programs "just know" something. Programs don't know
anything, except in a metaphorical sense. "just know" seems a lazy
explanation at best.

I accept that cygwin programs run under mintty. But a real explanation
would mention a specific API or other specific technical means. I am not
asking for that explanation, just pointing out "just knows" is no
explanation. I would delete the bit about "just know", or say something
like "cygwin curses programs, such as A, B, and C, run under mintty
because _________". That would also require knowing which cygwin
programs are compiled with curses, and which version, that would be
specific, helpful information.
Post by David Macek
The Windows terminal (console, conhost) does the same
for regular Windows programs. It provides the back-end
to Windows console handles and regular Windows
programs "just know" how to use it.
Again, the use of the term "regular windows programs" is ambiguous and
ill-defined, as I explained above. Again, my questions are related to
curses programs. Again, programs don't "just know" anything, that's
either a misunderstanding or an unhelpful use of a metaphor where a more
technical explanation is required.
Post by David Macek
Post by Daniel Goldman
For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors
get messed up, it is slow. Oddly, mc (same exe) runs
perfectly when run directly from dos shell.
/usr/bin/mc.exe? On my system, this one runs perfectly
in mintty, but is horribly broken in a regular Windows terminal.
I never said mc.exe had problems under mintty. I believe you misread. I
said "mc runs poorly under the bash.exe environment", which I believe is
separate from mintty, since bash.exe is run from within the windows 7
command prompt. If I'm wrong about this, please let me know.

I again ran /usr/bin/mc.exe again in a regular windows terminal, windows
7 home premium. It is not "horribly broken", as you say, it works
perfectly, I was able to navigate, switch with ^O, do everything I do
when using mc under mintty. I sent screenshots to David (exceeded size
limit for posting to list), before (1) and after (2) running
/usr/bin/mc.exe in command window.

***************************************************
Assuming this is replicated by someone else, which could easily be
tested, this discrepancy ("works perfectly" vs "totally broken") 100%
makes my point that there is confusion about these different interfaces,
what works where, and why the differences.
***************************************************
Post by David Macek
This solves a lot of the issues when running regular
Windows programs in a Cygwin terminal.
Again, I think it would be best to avoid the perhaps vague term "regular
windows programs", and be more specific, especially since my question
specifically related to programs compiled under curses.
Post by David Macek
Cygwin allows some inter-operation between a Cygwin
program and Windows console and between a Windows program
and Cygwin terminal emulators. You can run bash in a Windows
terminal and also run cmd in mintty. For basic stuff, it
works fine. Anything more complicated, like colored text,
TUIs and line editing, breaks.
I'm sorry, but that was totally not my experience, as I clearly stated.
The curses program (a TUI) works perfectly, that was the point of my
post, so I don't understand why you say "Anything more complicated ...
breaks". I sent a snapshot to David (3) (exceeding size limit for
posting to list).

Please don't take my comments the wrong way. I appreciate your response
and that you are trying to make sense of the confusing situation. I
admit I am confused. I just think you are also confused. The worst thing
one can do is act like we know something, when we don't. It is better to
say nothing than place incorrect / misleading / unhelpful information in
an "introduction". For the reasons I've stated above, I don't find the
current "explanation" in the introduction very helpful. Instead of
suggesting that the situation is understood, it might be better to say
"This is a subject of some current confusion. Our current knowledge is
as follows: blah, blah, blah. If you can help with better information
concerning X, Y, and Z, please __________".

I wish there was someone else on the list with more specific knowledge
about how curses programs (pdcurses and ncurses) should be compiled to
work best in the different MSYS2 environments, for both running and
debugging. I'm here to report what I observe, offer my technical
expertise when possible, and to learn. Again, thanks to Greg Jung. I
hope my observations help clear up at least some of the confusion.

Daniel
David Marceau
2016-02-10 02:05:39 UTC
Permalink
OLD UNIX terminals had standard output, standard input, standard
auxiliary and standard error. Every application had these, but it was
to the programmer's discretion whether to fully exploit these file
handles or not.

When MS-Dos was starting out, these 4 file handles were called exactly
the same: standard output, standard input, standard auxiliary, and
standard error.

MS Windows arrived on the scene and the concept of standard input and
standard output wasn't really the recommended way of building windows
applications. MS was recommending ditching these 4 standard file
handles althout inherent to every DOS and WINDOWS app by default, The
recommended way was to open other files through the common dialog apis
for reading/writing that way. The standard error file handle was
replaced with gui dialog messages or windows debug log messages(not
stderr, but windbg found in the 1st,2nd,3rd+ gen windows platform
sdk's(win16,win32,win64+).

As a result of all this GUI favortism, MS seemed to have detached the
console and its associated 4 file handles by providing these console
handles in a separate console api, but from what I understand they
always were part of each app from the very beginning, just very well
encapsulated(hidden). In Unix/Linux/Msys2 land, it has always remained
fashionable to have a terminal to read standard input from and to dump
standard output and standard error to if we wanted it. I am not up to
date with windows apis, but I am certain console file handles are still
available from .net apis.

The common things for a windows app to use console is to create the app
window, then create a console, then attach the windows app to the
console, then send stuff to the console. It's actually very funny
because they used to be part of the app for free from the beginning, but
then MS took this functionality away. Think "embrace, extend,
extinguish" here and you'll figure out what's going on. They took away
the functionality; they weren't aiming for interoperability; they
weren't aiming for compatibility; they were aiming for programmer API
vendor lock-in. The sooner everyone realizes that the sooner everyone
will run away from Microsoft like it was some fatal contagious airborne
virus. Nothing has changed. .Net has the same aspirations to
extinguish NON-MICROSOFT-based languages/operating-systems somehow.
It is not in the public taxpayers interest to continue to use
proprietary software because taxpayers can't see what's happening under
the hood and can't learn/participate in maintaining what's under the
hood. There is no world-synergy occurring from proprietary
software/vendor-lockin. The real synergy is happening in NON-MICROSOFT
operating systems and tools. Msys2 using pacman points to people using
ArchLinux which rocks my world now. Hats off to the
MSYS2/PACMAN/ArchLinux team for existing. MSYS2 is my shell of choice
when forced to do stuff on a windows box.
Post by Daniel Goldman
David,
Thanks very much for the reply and the explanation of the differences. I
did have a few points.
Post by David Macek
Non-graphical Cygwin (generally POSIX) and regular
Windows programs use fundamentally different ways
to display output and receive input.
It's unclear to me what you mean by "regular Windows programs". It seems
a vague term (and I am a windows programmer). To me, a "regular Windows
program" is a GUI program, like firefox under windows, Excel under
windows, etc. Is that what you are referring to? BTW, what's an
"irregular windows program"?
I was specifically referring to curses programs. I stated that clearly.
So I don't understand your sole mention of vague "regular windows
programs", no mention of specific "curses program".
Post by David Macek
It provides pty's and other POSIXy stuff to programs and
it draws the result "manually". Cygwin programs "just know"
how to use it and usually have no problems with it.
I would suggest that the explanation is lacking, especially in saying
that cygwin programs "just know" something. Programs don't know
anything, except in a metaphorical sense. "just know" seems a lazy
explanation at best.
I accept that cygwin programs run under mintty. But a real explanation
would mention a specific API or other specific technical means. I am not
asking for that explanation, just pointing out "just knows" is no
explanation. I would delete the bit about "just know", or say something
like "cygwin curses programs, such as A, B, and C, run under mintty
because _________". That would also require knowing which cygwin
programs are compiled with curses, and which version, that would be
specific, helpful information.
Post by David Macek
The Windows terminal (console, conhost) does the same
for regular Windows programs. It provides the back-end
to Windows console handles and regular Windows
programs "just know" how to use it.
Again, the use of the term "regular windows programs" is ambiguous and
ill-defined, as I explained above. Again, my questions are related to
curses programs. Again, programs don't "just know" anything, that's
either a misunderstanding or an unhelpful use of a metaphor where a more
technical explanation is required.
Post by David Macek
Post by Daniel Goldman
For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors
get messed up, it is slow. Oddly, mc (same exe) runs
perfectly when run directly from dos shell.
/usr/bin/mc.exe? On my system, this one runs perfectly
in mintty, but is horribly broken in a regular Windows terminal.
I never said mc.exe had problems under mintty. I believe you misread. I
said "mc runs poorly under the bash.exe environment", which I believe is
separate from mintty, since bash.exe is run from within the windows 7
command prompt. If I'm wrong about this, please let me know.
I again ran /usr/bin/mc.exe again in a regular windows terminal, windows
7 home premium. It is not "horribly broken", as you say, it works
perfectly, I was able to navigate, switch with ^O, do everything I do
when using mc under mintty. I sent screenshots to David (exceeded size
limit for posting to list), before (1) and after (2) running
/usr/bin/mc.exe in command window.
***************************************************
Assuming this is replicated by someone else, which could easily be
tested, this discrepancy ("works perfectly" vs "totally broken") 100%
makes my point that there is confusion about these different interfaces,
what works where, and why the differences.
***************************************************
Post by David Macek
This solves a lot of the issues when running regular
Windows programs in a Cygwin terminal.
Again, I think it would be best to avoid the perhaps vague term "regular
windows programs", and be more specific, especially since my question
specifically related to programs compiled under curses.
Post by David Macek
Cygwin allows some inter-operation between a Cygwin
program and Windows console and between a Windows program
and Cygwin terminal emulators. You can run bash in a Windows
terminal and also run cmd in mintty. For basic stuff, it
works fine. Anything more complicated, like colored text,
TUIs and line editing, breaks.
I'm sorry, but that was totally not my experience, as I clearly stated.
The curses program (a TUI) works perfectly, that was the point of my
post, so I don't understand why you say "Anything more complicated ...
breaks". I sent a snapshot to David (3) (exceeding size limit for
posting to list).
Please don't take my comments the wrong way. I appreciate your response
and that you are trying to make sense of the confusing situation. I
admit I am confused. I just think you are also confused. The worst thing
one can do is act like we know something, when we don't. It is better to
say nothing than place incorrect / misleading / unhelpful information in
an "introduction". For the reasons I've stated above, I don't find the
current "explanation" in the introduction very helpful. Instead of
suggesting that the situation is understood, it might be better to say
"This is a subject of some current confusion. Our current knowledge is
as follows: blah, blah, blah. If you can help with better information
concerning X, Y, and Z, please __________".
I wish there was someone else on the list with more specific knowledge
about how curses programs (pdcurses and ncurses) should be compiled to
work best in the different MSYS2 environments, for both running and
debugging. I'm here to report what I observe, offer my technical
expertise when possible, and to learn. Again, thanks to Greg Jung. I
hope my observations help clear up at least some of the confusion.
Daniel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Msys2-users mailing list
https://lists.sourceforge.net/lists/listinfo/msys2-users
David Macek
2016-02-10 02:26:00 UTC
Permalink
Post by David Marceau
OLD UNIX terminals had standard output, standard input, standard
auxiliary and standard error. Every application had these, but it was
to the programmer's discretion whether to fully exploit these file
handles or not.
When MS-Dos was starting out, these 4 file handles were called exactly
the same: standard output, standard input, standard auxiliary, and
standard error.
MS Windows arrived on the scene and the concept of standard input and
standard output wasn't really the recommended way of building windows
applications. MS was recommending ditching these 4 standard file
handles althout inherent to every DOS and WINDOWS app by default, The
recommended way was to open other files through the common dialog apis
for reading/writing that way. The standard error file handle was
replaced with gui dialog messages or windows debug log messages(not
stderr, but windbg found in the 1st,2nd,3rd+ gen windows platform
sdk's(win16,win32,win64+).
As a result of all this GUI favortism, MS seemed to have detached the
console and its associated 4 file handles by providing these console
handles in a separate console api, but from what I understand they
always were part of each app from the very beginning, just very well
encapsulated(hidden). In Unix/Linux/Msys2 land, it has always remained
fashionable to have a terminal to read standard input from and to dump
standard output and standard error to if we wanted it. I am not up to
date with windows apis, but I am certain console file handles are still
available from .net apis.
The common things for a windows app to use console is to create the app
window, then create a console, then attach the windows app to the
console, then send stuff to the console. It's actually very funny
because they used to be part of the app for free from the beginning, but
then MS took this functionality away. Think "embrace, extend,
extinguish" here and you'll figure out what's going on. They took away
the functionality; they weren't aiming for interoperability; they
weren't aiming for compatibility; they were aiming for programmer API
vendor lock-in. The sooner everyone realizes that the sooner everyone
will run away from Microsoft like it was some fatal contagious airborne
virus. Nothing has changed. .Net has the same aspirations to
extinguish NON-MICROSOFT-based languages/operating-systems somehow.
It is not in the public taxpayers interest to continue to use
proprietary software because taxpayers can't see what's happening under
the hood and can't learn/participate in maintaining what's under the
hood. There is no world-synergy occurring from proprietary
software/vendor-lockin. The real synergy is happening in NON-MICROSOFT
operating systems and tools. Msys2 using pacman points to people using
ArchLinux which rocks my world now. Hats off to the
MSYS2/PACMAN/ArchLinux team for existing. MSYS2 is my shell of choice
when forced to do stuff on a windows box.
I was even ready to put up with the MS-hate, but you lost me at "taxpayers". :)

It's true that Microsoft pushed (and is still pushing) pure GUI applications, but you could say the same of Xorg, KDE, GNOME, Ubuntu or whichever non-power-user-centered project you think of.

As to the technical aspects, console programs are still first-class citizens in Windows. You can build a console app with stdin, stdout and stderr with MSVC, .NET, mingw-w64 or Cygwin and it will work just the way it always did. The one change for console apps users between DOS and Windows I can think of, is that in Windows, because you don't need have a console open to run a console app, Windows can open a temporary console for you. (And of course, that you can run and see more than one at a time.)

I don't remember very many GUI apps that manage their own console window(s). These things are mostly limited to terminal emulators (like ConsoleZ) and special cases like the Cygwin runtime and winpty.
--
David Macek
Daniel Goldman
2016-02-10 07:36:08 UTC
Permalink
On 2/9/2016 6:05 PM, David Marceau wrote: OLD UNIX terminals had
standard output, standard input, standard auxiliary and standard error.
... When MS-Dos was starting out ... MS Windows arrived on the scene and
the concept of standard input and standard output wasn't really the
recommended way of building windows applications. ... MSYS2 is my shell
of choice when forced to do stuff on a windows box.

Thanks for the reply. But I already knew all that. As I said, "I am a
windows programmer". I know the win32 api. I never asked for an
explanation of windows programming. I was suggesting that "regular
windows program" is vague and ill-defined. Also, my post very
specifically related to curses applications. Finally, MSYS2 is also my
shell of choice, I don't see why it needs mentioning. If I didn't like
MSYS2, I wouldn't be posting... - Daniel
Daniel Goldman
2016-02-10 07:36:19 UTC
Permalink
This post might be inappropriate. Click to display it.
Baruch Burstein
2016-02-10 15:52:02 UTC
Permalink
This post might be inappropriate. Click to display it.
Daniel Goldman
2016-02-10 18:43:11 UTC
Permalink
Post by Baruch Burstein
Based on the quotes in the last email, this conversation seems to be
going on in two separate places. I don't know where the second place is,
but this is confusing. Please consolidate.
You are right. I apologize. Obviously, the discussion has veered wildly
from "gdb in msys". I tried to post this separately in the discussion.
And thanks for your detailed response below.
Post by Baruch Burstein
As for the specific issue of running mc directly from the windows
command prompt, my findings on a Windows 7 machine are that mc,
presumably through ncurses, sizes itself to the window buffer width
rather than the actual width, to the actual window height, and does not
get window resize notifications. What this means is that if I size my
command prompt window to it's maximum width, mc looks fine. There are
still at least a couple of issues, specifically that changing the height
of the window does not in itself prompt a redraw of the screen (although
pressing a key after the resize fixes this). Also pressing and holding
an arrow key only moves down one line. running mc directly from the
mintty/bash prompt works fine.
That's my same experience. In other words, mc works fine from within a
windows 7 command prompt, with the exception that that windows resize
does not immediately take effect, but requires pressing a key.
Post by Baruch Burstein
Now for the general issue discussed in this thread.
@Daniel, I would like to point out that you not understanding an
explanation is not a sign of the explainer's lack of understanding
himself. It could also be a sign of either a bad explanation,
language/communication issue, or in rare cases your own misunderstanding.
That said, I admit that I don't fully understand the issue, but here is
I don't think I made my arguments from the point of view that "I don't
understand". If I did, you would have to point out specific examples. I
made my arguments from facts to the best of my knowledge as a high level
programmer and someone 100% fluent in the English language. However, I
admit I can have misunderstandings. I'm here to both help and learn.
Post by Baruch Burstein
First off, terminology. I am only including relevant terms, not all
* User interface (UI)
The part of a program that gets input and sends output.
* console/text terminal
A character input/output device. It sends character input and receives
character output. It may interpret certain character sequences as
special commands. A historic (and important. we will come to this later)
example is the VT-100. All interaction with console apps happens via a
console (real or emulated).
* Graphical terminal (not a common name)
The screen/mouse/keyboard/joystick/touchpad/touchscreen type devices we
are all used to today.
I was not suggesting an exhaustive definition of every possible term. I
think the above goes overboard. For example, we do not need to define
UI. I was pointing out that "regular windows program" is vague and
misleading, I will not repeat the arguments here, and suggesting more
specific / meaningful technical terms.
Post by Baruch Burstein
* Program
There are 3 types of programs, categorized by their UI and terminal use.
1) A "regular" app. Has a stream-based UI. This is what you get when you
compile the standard "Hello, world!" C program. It has 3 abstract I/O
(character-)streams (stdin, stdout, stderr) allocated to it by the OS
upon starting. These streams are usually emulated/mapped by the OS over
the console's character stream, and may be buffered (depending on the
implementation) by the OS and/or the terminal and/or the library. The
streams may be redirected, such as by pipes or redirecting to a file.
Often the input stream is buffered and only sent to the app at a newline
or EOF, so the app has no control over the text entry phase. To correct
input you would typically have to erase (backspace) as needed and
re-enter input. Examples are ls, mv and pacman.
2) A GUI app. This type gets no I/O streams allocated by default (it can
open streams using OS APIs if needed) and it's I/O is not character
based (graphic output, usually to a window, and multiple types of input,
such as pointer and keyboard). It uses a graphical terminal rather than
a text terminal. Examples are firefox, office or media player.
3) A console based non-stream app. These types of programs use a
text-based console, but rely on directly communicating with the console
rather than via abstract streams. This of course means that they are
dependent on each console's particular capabilities and supported
features. 2 classic subtypes of this are the line editing type and the
TUI type. The former mostly uses it's direct console connection to
manage it's own buffering of input/output and to move the cursor around.
This can be used for various REPL apps, as well as things like gdb,
sqlite and many others. Often done with readline, linenoise or similar
library. The TUI type usually use a *curses library, and they rely much
more heavily on console-specific things, such as size, colors, special
keys, etc. Examples are vim, mc, etc.
The above explanations are excellent. However, I don't think we need to
go into detail explaining streams. Again, I think the above goes
overboard. That information (GUI, streams) is explained elsewhere. We
just need to clearly spell out the specific technologies (eg, GUI,
streams, ncurses), instead of using vague terms (eg, regular windows
program, or "just know"), or undefined obscure jargon like REPL.

Instead of "regular app" (vague), I would suggest "command-line app" or
even "CLI app" (command-line interface). Instead of "A console based
non-stream app" (wordy), I would suggest "TUI app" (text user
interface). For every concept, having a brief, snappy form would be
helpful. Also, to my understanding, these categories need to
differentiated between those intended for running under MSYS2 and those
running under win32 console (command prompt), since I believe they are
compiled differently.
Post by Baruch Burstein
* console emulator/virtual terminal
This is a GUI app that emulates the console input by translating input
from the GUI input method (keyboard or other) into console character
stream, and the console output to a graphical output in a window. It
will generate/parse the special commands/escape sequences as needed.
Many (most?) terminal apps simulate some form of the VT-100 terminal. A
notable exception is the Win32 console, that dos not simulate the VT-100
escape sequences. I don't know if it even emulates any actual terminal,
or just does its own. Examples are xterm, gterm, Win32 console, mintty.
* shell
This is a console app (usually type #3 line editing, but can be type #1,
or any type of #3 too). It parses its input to figure out what other app
you want to run, and runs it via the OS. Examples are bash, zsh or
Windows cmd.
For the rest of this text, console, terminal and console/terminal
emulator are interchangeable.
Now for the explanation of what is going on.
GUI apps are tied to an api, which usually ties them to an OS, unless
using an abstraction level for the api (Qt, wxWidgets, wine, etc.)
"regular" apps usually work just fine in any console, since they work
with abstract streams, which are basically supplied by both Windows and
Posix OSs with any console.
The problems start with type #3 apps. The more they rely on some special
console capabilities, specifically VT-100, the more likely they are to
break in Win32 console, and vice-verse.
winpty attempts to run the app passed to it in a hidden Win32 console
and translate the input/output from mintty (VT-100) to Win32 command and
back.
Again "regular apps" is way too vague.

As I explained in previous posts, I tested winpty with the pdcurses app
that runs perfectly under windows, and runs perfectly under the bash.exe
/ window 7 "command prompt" combination. The pdcurses app DOES NOT run
correctly under winpty / mintty combination. Arrow keys and other cursor
keys do not work. So I think your wording "attempts" is correct, that
winpty is lacking. I say "winpty program.exe" from within mintty. If
there is some option I might need to be using to make winpty work
better, I'd like to hear. "man winpty" and "winpty --help" fail.
Post by Baruch Burstein
This is my understanding. Please someone who understands this better
correct me as needed.
I think your understanding is fine and your text is helpful. As
mentioned before, a lot of the documentation might be derived from
postings / discussions.
Post by Baruch Burstein
Baruch
--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Msys2-users mailing list
https://lists.sourceforge.net/lists/listinfo/msys2-users
Daniel Goldman
2016-02-11 04:24:21 UTC
Permalink
I'm still surprised that mc works fine for you guys.
Does your /usr/bin/mc.exe come from MSYS2 (just making sure)?
Yes. Look at the attachments I previously sent.
Also, can you check your `TERM` environment
variable and output of `chcp`?
From a windows 7 "command prompt":

D:\msys64\usr\bin>chcp
Active code page: 437

D:\msys64\usr\bin>printenv | grep TERM
TERM=cygwin

I have no idea why TERM is set to cygwin. It's not something I remember
intentionally setting. However, it seems likely that TERM=cygwin has
something to do with mc.exe working correctly in "command prompt" here.

So I did an experiment. In windows 7 "command prompt", I ran "set
TERM=ansi-nt" and tried running MSYS2 mc.exe program. It started, in
black and white instead of color, but was mostly unresponsive, no cursor
keys worked, at least ^O worked, and ^D allowed me to exit. Next, I ran
"set TERM=cygwin" to revert, and things worked perfectly next time I ran
mc.exe program.
Do you have Ansicon, Clink, Cmder, ConEmu or
anything similar installed and enabled?
No. I do have cygwin installed, never use it.
I don't think winpty is supposed to be configurable.
So it seems. All I know is winpty does NOT work correctly in this
instance, as I previously explained. From mintty / winpty combination,
the pdcurses program starts, but the cursor keys do not work.

Daniel
David Macek
2016-02-11 07:15:25 UTC
Permalink
Post by Daniel Goldman
I'm still surprised that mc works fine for you guys.
Does your /usr/bin/mc.exe come from MSYS2 (just making sure)?
Yes. Look at the attachments I previously sent.
Also, can you check your `TERM` environment
variable and output of `chcp`?
D:\msys64\usr\bin>chcp
Active code page: 437
D:\msys64\usr\bin>printenv | grep TERM
TERM=cygwin
I have no idea why TERM is set to cygwin. It's not something I remember intentionally setting. However, it seems likely that TERM=cygwin has something to do with mc.exe working correctly in "command prompt" here.
So I did an experiment. In windows 7 "command prompt", I ran "set TERM=ansi-nt" and tried running MSYS2 mc.exe program. It started, in black and white instead of color, but was mostly unresponsive, no cursor keys worked, at least ^O worked, and ^D allowed me to exit. Next, I ran "set TERM=cygwin" to revert, and things worked perfectly next time I ran mc.exe program.
Ha! I stand corrected. It seems that MSYS2 mc really does know how to handle the Windows console and my environment was the broken one. I noticed I had LANG=en_US.UTF-8 and after unsetting it, mc started rendering fine.

I've updated the wikipage to say "can work, can break" instead of "usually breaks" to reflect this.

Thanks for your patience.
Post by Daniel Goldman
Do you have Ansicon, Clink, Cmder, ConEmu or
anything similar installed and enabled?
No. I do have cygwin installed, never use it.
I don't think winpty is supposed to be configurable.
So it seems. All I know is winpty does NOT work correctly in this instance, as I previously explained. From mintty / winpty combination, the pdcurses program starts, but the cursor keys do not work.
Is the program source code available?
--
David Macek
Fabrice Popineau
2016-02-11 07:25:59 UTC
Permalink
Post by David Macek
Is the program source code available?
https://github.com/rprichard/winpty.git

Fabrice
David Macek
2016-02-11 07:52:13 UTC
Permalink
Post by David Macek
Is the program source code available?
https://github.com/rprichard/winpty.git
:) Thanks, but I was asking about the pdcurses program.
--
David Macek
Daniel Goldman
2016-02-16 21:39:02 UTC
Permalink
Post by David Macek
Is the program source code available?
No, the source code is not available. At this point, I wouldn't send it
anyway, I think it would be a waste of time. I previously asked if you
were a curses programmer. No answer. However, by your other responses it
seems you are not, at least not at any meaningful level. I have no
reason to expect you to be a curses programmer, curses is even kind of
obscure these days. I just don't want to be on a wild goose chase.
Post by David Macek
Even curses programs use the Win32 API
"under the hood". See pdcurses source directory
`win32` and ncurses source directory `win32con`.
I forgot to respond to this one from your previous post. I'm sorry, but
I believe this is another error / false statement on your part. This is
a tangential issue. But you brought it up, you raised the issue.

I'm sorry, but to my knowledge curses programs do not "use the Win32 API
under the hood". The metaphor (under the hood) suggests you have deep
knowledge on the subject. I'm sorry, I see no evidence of that.

I am a curses and C win32 api programmer, for many years, so I know a
bit about these technologies. I don't see the overlap. Please provide me
with specifics (not vague statements) of how "curses programs use the
Win32 API under the hood". I'm willing to be educated, but my guess is
you simply don't know what you are talking about.

You didn't respond to my previous post, where I pointed out other big
misunderstandings on your part (eg, curses uses stdin, stdout, and
stderr). I'm not asking you to respond to that post at this point, I
don't want you to dig any deeper holes. I don't want the list to be
disrupted. I just think it's important to get the facts straight.

I like MSYS2. I'm trying to do my part by providing feedback, doing
experiments, making suggestions. So far, I haven't fallen off a limb.
However, it seems like I have wasted a fair amount of time responding to
an inordinate number of incorrect "facts" you have posted.

Don't get me wrong. I appreciate that you volunteer for MSYS2. Something
is going right. MSYS2 is a great system.

Daniel
David Macek
2016-02-17 13:58:20 UTC
Permalink
Post by Daniel Goldman
Post by David Macek
Is the program source code available?
No, the source code is not available. At this point, I wouldn't send it
anyway, I think it would be a waste of time. I previously asked if you
were a curses programmer. No answer. However, by your other responses it
seems you are not, at least not at any meaningful level. I have no
reason to expect you to be a curses programmer, curses is even kind of
obscure these days. I just don't want to be on a wild goose chase.
Okay. I wasn't going to try changing the source code though, I wanted to do experiments in the building and running phase.
Post by Daniel Goldman
You didn't respond to my previous post, where I pointed out other big
misunderstandings on your part (eg, curses uses stdin, stdout, and
stderr). I'm not asking you to respond to that post at this point, I
don't want you to dig any deeper holes. I don't want the list to be
disrupted. I just think it's important to get the facts straight.
I didn't have time to respond yet. I'd be inclined not to respond (as you advise), but I want get to the truth as well. I'll try to address your concerns from both this message and the one you're referring to when I have time.
Post by Daniel Goldman
I like MSYS2. I'm trying to do my part by providing feedback, doing
experiments, making suggestions. So far, I haven't fallen off a limb.
However, it seems like I have wasted a fair amount of time responding to
an inordinate number of incorrect "facts" you have posted.
Don't get me wrong. I appreciate that you volunteer for MSYS2. Something
is going right. MSYS2 is a great system.
Thanks. We're glad that you like and use MSYS2.
--
David Macek
David Macek
2016-02-10 19:24:37 UTC
Permalink
Based on the quotes in the last email, this conversation seems to be going on in two separate places. I don't know where the second place is, but this is confusing. Please consolidate.
I'll try to separate the two discussions from now on.
Now for the general issue discussed in this thread.
[snip]
This is my understanding. Please someone who understands this better correct me as needed.
I find your explanation great (detailed and understandable). Thanks for taking the time to write it.
--
David Macek
David Macek
2016-02-10 19:57:04 UTC
Permalink
First, don't take all my reactions as defenses of my word choices, but consider they may rather be just explanations. I'm open to changing the wording in most cases.

Also, I have written a large part of this message before reading the other responses, so forgive me if I repeat myself (or anyone else).
Regular Windows program as opposed to Cygwin or MSYS2 programs.
Those are Windows programs as well (EXE and stuff), but the
POSIX compatibility layer is making them "irregular".
Furthermore focusing the definition, I was talking
specifically about console programs (i.e. not pure
GUI ones, but AFAIK the differences between console
and GUI executables are miniscule).
Again, when someone says "normal windows program", they are thinking about GUI programs - firefox on windows, excel on windows, etc. Since you are wanting to describe "console programs", why would you say "normal windows program"? It's totally confusing.
Again, because 1) Cygwin programs are Windows programs as well (they run on Windows, after all), and 2) the domain of console programs is already established in the first paragraph.
Looking in the index of Programming Windows (Petzold), win32 Programming (Rector), and windows 2000 api superbible, there is no entry for "console" programs. We can't use undefined words, it confuses the reader. FWIW, Petzold calls it "character-mode". Even that is not too helpful, IMO.
The problem here is that technical writing is hard, and I'm sorry, but you don't seem very good at it. Join the crowd, most writing stinks. I can't teach you how to do it, you would need to read a book or take a course. I would at least suggest that you put yourself in the role of someone reading the text for the first time, and be prepared to edit a fair amount. Also, good technical writing is structured, is clear, goes through logical sequences, and takes advantage of formatting conventions. I'm also pretty busy, but am at least willing to point out places where the message fails, and have taken some effort here. BTW, the cygwin web site has some of the WORST writing I have ever seen, specifically their incredibly long-winded section on posting etiquette.
I'm okay with sucking at writing in this situation. Consider that I'm also busy and didn't actually spend much time on the article. I'm all for making the article clearer and more accessible and I appreciate your effort. I'll continue to revise the article based on your feedback (and maybe if I find more time, I'll re-read it and come up with my own feedback, as you suggested).
I don't like the term so much either. If you think of
a better term that is not too technical, I'll start
using it instead. Note that I want to cover both
ncurses and readline-type interactive console programs.
There probably is no really good term. That is perhaps because such "console programs" are so rare, at least in the windows world.
Here is my suggestion, based on your first paragraph. We have to both define our terms, and give good examples. A good example is worth 1,000 words. Write something like: 'To make sure we're on the same sheet of music, we need to define the types of programs: 1) The first category is "msys2 programs". These programs are created by blah, blah. They run blah, blah. Good examples are X, Y, and Z. X shows blah, blah. Y is different in that blah, blah. Z shows blah, blah. 2) The next category is "curses programs". These programs are compiled with ncurses or pdcurses. ncurses is used when blah, blah. Use pdcurses if blah, blah. Curses programs have a TUI (text user interface), and optionally may support the mouse. Good examples are X, Y, Z. X shows blah, blah. Y is different in that blah, blah. 3) The final category is "windows console programs". These programs are native windows executables, like excel or firefox, but are NOT GUI programs. They only read and write text to a text
window (the console). They do (do not?) support a mouse.'
I think you've partially fallen into your own trap. What are "native windows executables" to our reader? This term IMO desires further explanation or definition in order to keep the proposed technical level of the article.

I've realized that instead of trying to accommodate every possible reader in the article, it could be better to establish a baseline using references to Wikipedia. If the reader doesn't know a term, they can read up on it.
I may (probably do) have the details wrong in the above description. Another point about technical writing is don't put something down as true unless you are sure. You can always say "This section needs expansion. Can someone please suggest additions?".
I'm not sure about my writing, but I'm pretty sure of the facts. Maybe it's all just terminology confusions.
Ncurses isn't really a regular visitor on Windows, is it?
I noticed the irony of calling Windows ncurses programs "regular" (but didn't come up with a better term yet).
But non-Cygwin ncurses programs were supposed to belong into
the group of "regular Windows programs". The general
explanation should apply to them as well.
I didn't limit myself to ncurses. So I don't understand the comment.
Post by Daniel Goldman
I was specifically referring to curses programs. I stated that clearly.
I reacted to that to say that I covered them as well regardless of the "regular" adjective I used.

I saw "curses", "ncurses" and "pdcurses" as interchangeable in this context, so maybe that was the source of this specific confusion.
"non-Cygwin ncurses programs" are ** NOT ** regular windows programs. I'm sorry, that's totally ridiculous and shows a total misunderstanding of the two programming models. I'm willing to be corrected if I am wrong. However, I write both curses and native windows applications, at the source code level, so I know the difference. Why would you not want to split out programs that use the win32 api from those using curses? If they share some characteristics, that's fine to point out, but they seem like apples and oranges to me.
Even curses programs use the Win32 API "under the hood". See pdcurses source directory `win32` and ncurses source directory `win32con`.

I've mixing these two categories intentionally because both fall under the category of console programs.
I agree. I wasn't intending to describe the technical details, but I
could've rephrased like so: "The way mintty expects input and output
matches the way other Cygwin programs were built to send and receive."
I'm sorry, I find that confusing, all the business about the input and output matching. Get to the main point. I might say, "cygwin programs built using the standard X method or the standard Y method run correctly under mintty". I have no idea what the "standard methods" I mention are. Hopefully, there is some agreed upon vocabulary for the methods. If not, that should be a first priority.
Okay, rewritten.
As part of this, I would hope that you define what the standard method(s) for building curses cygwin programs to run under mintty, the point of my original post. :) If that is not currently known, then I would put a note. IMO, it doesn't help for us to act like we understand something when we obviously don't.
I don't think there was anything profound to say. You should use Cygwin gcc and Cygwin ncurses and it should work out fine.
I'm not so sure about specifying versions of ncurses,
but I could add Cygwin bash and Cygwin mc as examples.
There are not "versions" of ncurses, except in the sense of new release numbers. There is just ncurses. I said "version of curses". The separate version is pdcurses. It would help to clarify which is used for what. My thinking is that ncurses is used to compile cygwin curses exes (eg, mc), and pdcurses to compile curses exes intended to run under windows (eg, my program). If that is the case, why doesn't MSYS2 come with pdcurses (my understanding) (I copied pdcurses library to under MSYS2 root myself by hand)?
I admit that I know little of the difference between ncurses and pdcurses. I always thought they just implement the same APIs, but are from different authors. I would disagree with the statement that one is for Cygwin and other for Windows. Note that MSYS2 has both `ncurses` and `mingw-w64-ncurses`, both of which should work in their respective environments (didn't test myself).
Cygwin bash can be run both inside a Windows console and
inside mintty (or other Cygwin terminal emulators). I was
assuming you mean bash+mintty. Bash does little to affect
if mc will work or not, it's the console/terminal.
I very clearly said bash under windows 7 command window. That was the entire point of the post, which you seem to have totally missed.
Post by Daniel Goldman
For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors get messed up, it is
slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.
I assumed you meant bash+mintty in the first ("poorly") case and cmd+conhost in the second ("perfectly") case and responded accordingly.
Post by Daniel Goldman
I never said mc.exe had problems under mintty. I believe you misread. I said "mc runs poorly under the bash.exe environment", which I believe is separate from mintty, since bash.exe is run from within the windows 7 command prompt. If I'm wrong about this, please let me know.
So I explained my misunderstanding (I didn't misread -- there was no indication of whether mintty or conhost was used in that example). After you explained, I threw away my original assumption and went on to talk about the situation you were actually interested in.
That's surprising. I've attached a screenshot of
my /usr/bin/mc.exe. Input seems to work fine, but
the UI is not good.
Thanks for doing the test / screenshot. Indeed, it looks like garbage. However, you don't provide enough detail for me to be sure you are running under the same kind of window (windows 7 command window / command prompt). If you are running same window, it makes my point about how these different environments (mintty, etc.) are so poorly understood. Again, someone else could easily, in a few seconds, repeat the experiment.
Like you, I'm speaking from my personal experience. I
really wonder why your mc works in a Windows console. I'm
on Windows 10, but I've tried both legacy mode and the new
mode, but without luck.
Now we are maybe making progress. You're using Windows 10. Maybe that's the difference. Could someone else please repeat the experiment?
More test results in the other discussion.
================ START
About mintty, winpty, bash, cmd, consoles and terminals
This topic is not totally understood. The following information is our best understanding. If the reader has any corrections / clarifications, please post to the email list. Note that where we say MSYS2 below, one could usually substitute Cygwin and get the same meaning.
Using primarily MSYS2 instead of Cygwin sounds good.
-------------- Types of programs
1) The first category is "MSYS2 command line programs". These programs are created by the process described in the section XXX. They normally run in the standard mintty window. Good examples are ls and cat. "MSYS2 command line programs" use stdin, stdout, and stderr.
2) The second category is "MSYS2 curses programs". These programs are created by programming in and linking to the ncurses library (reader, please correct if that is not the case!). Good examples are vim and mc. curses programs do not normally use stdin, stdout, or stderr. Instead, they present a TUI (text user interface), such as with vim and mc.
They do use stdin, stdout and stderr. See article or <https://en.wikipedia.org/wiki/ANSI_escape_code>.
3) The third category is "Windows curses programs". These are like category 2) except that they are intended to run under the Windows "command prompt", not under wintty. An example would be some curses program you write, but not for MSYS2. pdcurses is normally used to compile curses programs designed to run in the "command prompt".
IMO confusing.
4) The next category is "Windows GUI programs", such as excel or firefox. An example would be a GUI program you compile under MSYS2.
Two other categories are not further discussed. "Windows console programs" are native windows executables, but are NOT GUI programs. They only read and write text to a "command prompt" window (the console). Basically, nobody writes these kinds of programs.
Not true. Console programs may not be the most popular thing in the Windows world, but in context of MSYS2, there's lots of console programs (see /mingw64/bin/*.exe).
"Windows .NET apps", to our understanding, are totally separate from MSYS2.
.NET apps can be console programs as well as GUI programs. No need to separate them out.
-------------- Ways to compile under MSYS2
1) Compile for running the executable under MSYS2 (categories 1 and 2 above). An example would be from compiling mc (midnight commander) to run in a mintty window. Methods for compiling MSYS2 programs are detailed in the section XXXXX.
2) Compile for running the executable under Windows (categories 1 and 2 above). An example would be a Windows GUI or curses program you are using MSYS2 to compile. We do not have separate documentation describing how to compile these kinds of programs. Please refer to standard sources concerning how to compile using gcc or clang.
Keep in mind to use the correct MSYSTEM mintty window for compiling (MINGW32 for 32 bit, MINGW64 for 64 bit).
-------------- mintty, win32 console, shells
mintty is a terminal emulator built for running MSYS2 programs. It's the window where you enter commands. It provides the necessary POSIX interface for MSYS2 programs to correctly display and receive text. MSYS2 programs compiled with the XXX method run correctly under mintty.
mintty only runs console (non-GUI) programs. If for some reason you start a "Windows GUI program" from mintty, it runs independently of MSYS2, under Windows. Similarly, a "Windows curses program" will normally not run correctly under mintty, probably won't even start.
There are other terminal emulators, but they're not provided in MSYS2. You will normally use mintty.
The Windows "command prompt" (formally called "win32 console") (https://en.wikipedia.org/wiki/Win32_console) is the command line interpreter under Windows, and may also be used to run curses programs. It might also be referred to as "DOS prompt".
A shell is the actual program that reads commands from you and then runs them. When you open a mintty window, you'll probably see bash (a shell) running inside and waiting for your commands. The Windows "command prompt" runs cmd.exe to read and run commands.
-------------- Terminal emulator combinations
Normally, you will run 1) "MSYS2 command line programs" and 2) "MSYS2 curses programs" from mintty, 3) "Windows curses programs" and 4) "Windows GUI programs" from Windows "command prompt".
- It is possible to run an "MSYS2 command line program" program (eg, ls or grep) in a Windows "command prompt".
- Conversely, you can run "DOS commands" and batch files in mintty. Not sure why you might want to do this. A major point of using MSYS2 is to take advantage of the superior UNIX environment.
- You can run MSYS2 bash.exe in a Windows "command prompt". This allows you to run and debug "Windows curses programs" from within a UNIX-type environment.
For basic stuff, the above combinations work fine. Anything more complicated, like colored text, TUIs and line editing, may break (or may work). For example, as of Feb, 2016, mc (midnight commander) is reported to run correctly under windows 7 "command prompt", but not for windows 10.
------------ winpty
winpty is a wrapper program that works as a translator between Windows curses programs and mintty. It opens a hidden Windows "command prompt" window and opens the wrapped program in it. It then relays input from your terminal to the program and output from the program to your terminal. This may solve issues of running Windows curses programs in a Cygwin terminal. However, as of Feb, 2016 this is reported to not work correctly.
------------ Open issues
- Could MSYS2 have pdcurses included, for Windows curses programs?
- Is ncurses always used for compiling MSYS2 curses programs (eg, vim)?
============ END
I took some parts of the text, but I'm not convinced of the usefulness of mentioning all of it. It doesn't mean your text will go to waste. I'm thinking maybe a separate, developer-focused page on TUI/curses apps would be a good place for it. What do you think?
--
David Macek
Daniel Goldman
2016-02-11 04:26:31 UTC
Permalink
Post by David Macek
Again, because 1) Cygwin programs are Windows
programs as well (they run on Windows, after all),
and 2) the domain of console programs is already
established in the first paragraph.
We can use whatever brief terms we please, as long as they:

- correspond with real-world things.
- are clear to the reader.
- if needed, are briefly defined or have examples.

"normal windows program" by itself, without clarification, fails those
criteria. I'm a windows programmer, and I don't know exactly what the
phrase means. The phrase is not in common usage.
Post by David Macek
I think you've partially fallen into your own trap.
What are "native windows executables" to our reader?
This term IMO desires further explanation or definition
in order to keep the proposed technical level of the article.

I must point out that the very first sentence of the MSYS2 wiki mentions
"native Windows software". :) In any case, I gave examples to make it
clear what I was referring to. "Theoretical" definitions (eg, "native
windows") are often weak. Examples are usually better. Anyway, I think
this kind of got rewritten below.
Post by David Macek
I've realized that instead of trying to accommodate
every possible reader in the article, it could be better
to establish a baseline using references to Wikipedia.
If the reader doesn't know a term, they can read up on it.
I agree. Mention which technologies (eg, ncurses) are used where. Other
than perhaps brief mention of what the technology does (eg, TUI
programming library), it's up to the reader to read elsewhere.
Post by David Macek
I'm not sure about my writing, but I'm pretty sure of
the facts. Maybe it's all just terminology confusions.
I agree it's largely terminology confusions. However, I think I have
also seen and documented some wrong understanding of the facts. I admit
some of my understanding of the facts is incorrect. That was the whole
point of my original post, trying to get some clarification.
Post by David Macek
I noticed the irony of calling Windows ncurses programs
"regular" (but didn't come up with a better term yet).
Right. ncurses programs are ncurses programs. That's it. It perhaps (not
sure about this) needs to specified whether they are compiled to run
under mintty or under "command prompt". Again, this was why I originally
posted, to ask for clarification.
Post by David Macek
I saw "curses", "ncurses" and "pdcurses" as interchangeable
in this context, so maybe that was the source of this
specific confusion.
Right, you had a misunderstanding. The terms are NOT interchangeable.
"pdcurses" and "ncurses" are both "curses" libraries. But they are
different.

For the most part they share the same function calls, but the code needs
to written somewhat differently, especially related to various
constants, for one or the other.

And they are intended (to my understanding) for different purposes.
ncurses -> unix. pdcurses -> dos / windows. And I take it that ncurses
-> msys2 though I have never seen this explicitly stated.

Again, given that msys2 is designed to support compiling programs to run
under windows, I don't understand why pdcurses is not built in.
Post by David Macek
I admit that I know little of the difference between ncurses
and pdcurses. I always thought they just implement the same APIs,
but are from different authors. I would disagree with the statement
that one is for Cygwin and other for Windows. Note that MSYS2 has
both `ncurses` and `mingw-w64-ncurses`, both of which should work
in their respective environments (didn't test myself).
You may be right that ncurses could be used for either cygwin or
windows. However, it's not my understanding. I have previously used
ncurses under windows, and it turned out pdcurses worked better in some
ways. I would have to do some research to be more specific. Does anyone
else know the preferred usage, and for what reason?
Post by David Macek
Post by Daniel Goldman
For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors get messed up, it is
slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.
(I didn't misread -- there was no indication of
whether mintty or conhost was used in that example)
I'm sorry, but I did say it clearly, you did misread / selectively
quoted the post, the first attribute of the good programmer is to admit
reality and move on, here is the relevant text from the post:

Run "C:\msys64\usr\bin\bash.exe --login -i" from within the windows 7
command prompt ("dos shell") and get a bash prompt. Then run the curses
(compiled with pdcurses) program with "./txu1-tpl-eg1.exe" - it runs
perfectly! Arrow keys work, everything looks / functions perfectly.

I'm still confused about the difference between 1) mintty, 2) winpty
from within mintty, 3) bash.exe from within dos window, and 4) dos
window itself. For example, I notice that mc runs poorly under the
bash.exe environment. Arrow keys don't work, colors get messed up, it is
slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.

Obviously, "bash environment" refers to "bash.exe from within dos
window", not mintty. I never suggested that mc.exe had a problem running
under mintty. Obviously, that would have been a priority #1 bug report,
it wouldn't make sense to just mention that as an aside.
Post by David Macek
They (curses programs) do use stdin, stdout and stderr.
See article or <https://en.wikipedia.org/wiki/ANSI_escape_code>.
I disagree. I stand by my statement that "curses programs do not
normally use stdin, stdout, or stderr", but am ready to be corrected and
learn. However, when I search the article you cite for "stdin",
"stdout", "stderr", nothing comes up.

Are you a curses programmer? If yes, then why do you offer such
irrelevant evidence? If no, then why are you disputing?
Post by David Macek
So I explained my misunderstanding (I didn't misread --
there was no indication of whether mintty or conhost
was used in that example). After you explained, I threw
away my original assumption and went on to talk about
the situation you were actually interested in.
You know nothing about me, so I can't criticize your directing me to the
bin directory. But you just misread some. I already categorized those
programs as "MSYS2 command line programs". I was referring to someone a
win32 api app for running under windows, and stand by my statement that
the overwhelming number are GUI.
Post by David Macek
"Windows .NET apps", to our understanding, are totally separate from MSYS2.
.NET apps can be console programs as well as GUI programs. No need to separate them out.
Whatever you want to do with .NET apps is OK with me. I'm also a C#
programmer. I'm well aware of what is possible. I have no idea if MSYS2
is structured to allow compilations of .NET apps. I did not see it
mentioned, but did not particularly look for it. You can edit as you see
fit depending on whether MSYS2 actually compiles .NET apps (no, I am not
asking for that capability).
Post by David Macek
I took some parts of the text, but I'm not convinced of
the usefulness of mentioning all of it. It doesn't mean your
text will go to waste. I'm thinking maybe a separate,
developer-focused page on TUI/curses apps would be a good
place for it. What do you think?
I think it is a good idea, especially if it lists the uncertainties. You
can use as little or as much of my suggested text as you like, it's up
to you. I appreciate your volunteering. MSYS2 is very useful.

Daniel
David Macek
2016-02-21 20:58:17 UTC
Permalink
Oh shoot. My sincere apologies for that previous subject line. I used the exclamation marks to mark the message draft and I forgot to remove them.
--
David Macek
waterlan
2016-03-13 02:11:07 UTC
Permalink
Post by Baruch Burstein
Hi all,
When I run gdb in the mingw64 environment (I haven't tested others), it behaves weirdly. Specifically, If I press the up arrow, instead of scrolling through the previous commands, it moves the caret up on the screen, and from there just goes crazy (printing text and seemingly random places on the screen, no accepting commands, etc.)
"which gdb" returns "/mingw64/bin/gdb". I am fully updated.
Any insights?
Hi,

This is because /mingw64/bin/gdb is a native Windows program and you are
running it in mintty which is a Unix terminal emulator. Unix terminal
emulators (PTY) work with a TTY interface. If you want to know about TTY
go here: http://www.linusakesson.net/programming/tty/

This problem is old and also existed with msys 1 when it used by default
an rxvt terminal (mintty did not exist yet). See for instance this
discussion: https://sourceforge.net/p/mingw/mailman/message/20318652/
Because many people complained about this they switched the default msys
1 terminal to a Windows Console terminal, but you can still choose rxvt
and also mintty now.

Your solution is to run mingw-gdb in a Windows Console terminal, or a
similar like ConEmu. But then you have the problem that some msys2
applications don't work properly, because msys2 programs expect like
Unix programs a TTY interface.

Msys2 programs work well in mintty (MINimal TTY). When you run msys2-gdb
in an msys2_shell in mintty, you don't have the problem.
Remember that msys is a POSIX layer which makes it easy to port Unix
programs to Windows. So msys programs act as if they are on Unix/Linux.
They are ignorant of Windows.

The same also holds for ncurses. mingw-ncurses is intended for native
Windows programs, and runs fine in Windows Console/ConEmu/ConsoleZ.
msys2-ncurses runs fine in mintty, because msys2-ncurses expects a Unix
like environment.
PDCurses is, like mingw-ncurses, intended for the Windows Console (an
alike). Programs built with PDCurses do not run in mintty.

In the beginning of Cygwin there was no mintty, Cygwin ran by default in
a Windows Console like terminal. So they created the terminal type
TERM=cygwin to get IO working. It worked reasonable, but things like
resizing did not work properly. Now Cygwin uses mintty by default,
because mintty fits naturally.

The ConEmu author seems to be working on a solution to get cygwin and
msys working properly in ConEmu. See
https://conemu.github.io/en/CygwinMsys.html

regards,
--
Erwin Waterlander
http://waterlan.home.xs4all.nl/
Loading...