Re: How to read a single character in D language?

2021-11-24 Thread forkit via Digitalmars-d-learn
On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote: Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the program should stop. module test; void main() { import core.s

Re: How to read a single character in D language?

2021-11-23 Thread Alexey via Digitalmars-d-learn
On Wednesday, 24 November 2021 at 04:51:03 UTC, Alexey wrote: On Wednesday, 24 November 2021 at 04:48:46 UTC, Alexey wrote: oh, also I completely missed what you need it to work without Enter key presses. so here is fixed version ```D import std.stdio; import core.sys.posix.termios; void m

Re: How to read a single character in D language?

2021-11-23 Thread Alexey via Digitalmars-d-learn
On Wednesday, 24 November 2021 at 04:48:46 UTC, Alexey wrote: writefln(0x"%c (%1$x %1$d) is inputed", c); sorry: ```diff 10c10

Re: How to read a single character in D language?

2021-11-23 Thread Alexey via Digitalmars-d-learn
On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote: Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the program should stop. ```D import std.stdio; void main() {

Re: How to read a single character in D language?

2021-11-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 19, 2021 at 10:21:42PM +, Adam Ruppe via Digitalmars-d-learn wrote: [...] > The OS functions for getch alone though are actually pretty simple: > > 1) change the terminal to "raw" mode. the default is to buffer lines, > which means your application doesn't get anything until a lin

Re: How to read a single character in D language?

2021-11-19 Thread Imperatorn via Digitalmars-d-learn
On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote: Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the program should stop. If you want to test on Windows you can do thi

Re: How to read a single character in D language?

2021-11-19 Thread Adam Ruppe via Digitalmars-d-learn
On Friday, 19 November 2021 at 20:51:09 UTC, BoQsc wrote: But the source file overwhelmed me by its size. Yeah, the getch function in there builds on the rest of the events the library offers, so it won't be that useful outside. The OS functions for getch alone though are actually pretty s

Re: How to read a single character in D language?

2021-11-19 Thread BoQsc via Digitalmars-d-learn
On Friday, 19 November 2021 at 18:01:57 UTC, Adam D Ruppe wrote: On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote: Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the pro

Re: How to read a single character in D language?

2021-11-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote: Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the program should stop. This is platform specific. About 10 lines of

How to read a single character in D language?

2021-11-19 Thread BoQsc via Digitalmars-d-learn
Let's say I want to write a simple program that asks for an input of a single character. After pressing a single key on a keyboard, the character is printed out and the program should stop.