stdInputRange

Salih Dincer salihdb at hotmail.com
Mon Jul 21 03:09:37 UTC 2025


On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote:
> I want the program to end with the F6 key on my keyboard 
> instead of the tilde. I use Windows as the platform.

Thank you for all your responses. I checked the ASCII table, and 
0x1A is indeed the character I was looking for. I'm not sure what 
this would be for Linux, but it works on Windows:

```d
struct StdinByChar
{
   @property bool empty()
   {
     if(isEmpty)
       return true;

     if(!hasChar)
     {
       auto buff = new char[1];
       stdin.rawRead(buff);

       if (buff[0] == 0x1A) // F6 (^Z) character
       {
         isEmpty = true;
         return true;
       }
       chr = buff[0];
       hasChar = true;
     }
     return false;
   }

   @property auto front() => chr;

   auto popFront() => hasChar = false;

   private:
     char chr;
     bool hasChar, isEmpty;
}
```

SDB at 79




More information about the Digitalmars-d-learn mailing list