Adjust pause binary

This commit is contained in:
zontreck 2024-08-31 00:56:39 -07:00
parent db9964e9e5
commit c47500e878

View file

@ -2,29 +2,37 @@ import 'dart:io';
import 'package:libac_dart/utils/IOTools.dart'; import 'package:libac_dart/utils/IOTools.dart';
String getKeyPress() { String getKeyPress() {
// Disable line mode to capture a single key press without requiring Enter bool ret = false;
stdin.echoMode = false; String str = "";
stdin.lineMode = false; while (!ret) {
// Disable line mode to capture a single key press without requiring Enter
stdin.echoMode = false;
stdin.lineMode = false;
// Read a single byte from stdin // Read a single byte from stdin
int byte = stdin.readByteSync(); int byte = stdin.readByteSync();
// Restore line mode and echo mode to default settings // Restore line mode and echo mode to default settings
stdin.echoMode = true; stdin.echoMode = true;
stdin.lineMode = true; stdin.lineMode = true;
// Return the character representation of the byte // Return the character representation of the byte
return String.fromCharCode(byte); str = String.fromCharCode(byte);
if (RegExp(r'^[A-Za-z]$').hasMatch(str)) ret = true;
}
return str;
} }
int main() { Future<int> main() async {
prnt("\rPress Any Key To Continue..."); await prnt("\rPress Any Key To Continue...");
// Listen for a key press // Listen for a key press
String key = getKeyPress(); String key = getKeyPress();
// Erase the line by printing a new line // Erase the line by printing a new line
prnt("\r\n"); await prnt("\r\n");
// Check if the pressed key is 'Z' // Check if the pressed key is 'Z'
if (key.toUpperCase() == 'Z') { if (key.toUpperCase() == 'Z') {