digitalmars.D.learn - is there a way to pause a program and resume with just a key press (or
- WhatMeWorry (11/11) Jul 14 2014 Sorry if this is an incredibly naive question.
- H. S. Teoh via Digitalmars-d-learn (8/20) Jul 14 2014 [...]
- ponce (2/7) Jul 15 2014 In the Windows shell, the "pause" key will halt a program and
- rumbu (4/15) Jul 15 2014 getch() reads any key and continues;
- Meta (2/5) Jul 15 2014 Don't forget that getch() is also Windows-specific.
- Adam D. Ruppe (19/21) Jul 15 2014 Yeah. It is more complex than you'd think but my terminal library
Sorry if this is an incredibly naive question. I prefer to pragmatically pause my programs periodically so that I can peruse output statements. Ideally, I'd like to continue by just hitting any old key. My feeble attempt below requires I enter at least one character and then the enter key. char ignore; writeln("Enter to continue"); readf(" %s", &ignore); Is there a way to continue with any old key press? or just the enter key? Thanks in advance.
Jul 14 2014
On Tue, Jul 15, 2014 at 02:49:55AM +0000, WhatMeWorry via Digitalmars-d-learn wrote:Sorry if this is an incredibly naive question. I prefer to pragmatically pause my programs periodically so that I can peruse output statements. Ideally, I'd like to continue by just hitting any old key. My feeble attempt below requires I enter at least one character and then the enter key. char ignore; writeln("Enter to continue"); readf(" %s", &ignore); Is there a way to continue with any old key press? or just the enter key?[...] I don't know about Windows, but on Linux, you can just press ctrl-s and ctrl-q to pause/resume the console. (This is a Linux terminal function, not specific to D.) T -- Ruby is essentially Perl minus Wall.
Jul 14 2014
I don't know about Windows, but on Linux, you can just press ctrl-s and ctrl-q to pause/resume the console. (This is a Linux terminal function, not specific to D.)In the Windows shell, the "pause" key will halt a program and "return" will resume it.
Jul 15 2014
On Tuesday, 15 July 2014 at 02:49:56 UTC, WhatMeWorry wrote:Sorry if this is an incredibly naive question. I prefer to pragmatically pause my programs periodically so that I can peruse output statements. Ideally, I'd like to continue by just hitting any old key. My feeble attempt below requires I enter at least one character and then the enter key. char ignore; writeln("Enter to continue"); readf(" %s", &ignore); Is there a way to continue with any old key press? or just the enter key? Thanks in advance.getch() reads any key and continues; On Windows you can pipe you executable with the "more" command to pause after each page: your.exe | more
Jul 15 2014
On Tuesday, 15 July 2014 at 10:22:52 UTC, rumbu wrote:getch() reads any key and continues; On Windows you can pipe you executable with the "more" command to pause after each page: your.exe | moreDon't forget that getch() is also Windows-specific.
Jul 15 2014
On Tuesday, 15 July 2014 at 02:49:56 UTC, WhatMeWorry wrote:Is there a way to continue with any old key press? or just the enter key?Yeah. It is more complex than you'd think but my terminal library can do it: https://github.com/adamdruppe/arsd/blob/master/terminal.d Example usage: import terminal; void main() { auto terminal = Terminal(ConsoleOutputType.linear); // gives real time input capability auto input = RealTimeConsoleInput(&terminal, ConsoleInputFlags.raw); // write to them terminal.writeln("Press any key to exit"); // get a single key auto ch = input.getch(); terminal.writeln("Bye!"); } PS this is also described in my book http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
Jul 15 2014