OLD | NEW |
| (Empty) |
1 // UserInputUtils.cpp | |
2 | |
3 #include "StdAfx.h" | |
4 | |
5 #include "Common/StdInStream.h" | |
6 #include "Common/StringConvert.h" | |
7 | |
8 #include "UserInputUtils.h" | |
9 | |
10 static const char kYes = 'Y'; | |
11 static const char kNo = 'N'; | |
12 static const char kYesAll = 'A'; | |
13 static const char kNoAll = 'S'; | |
14 static const char kAutoRenameAll = 'U'; | |
15 static const char kQuit = 'Q'; | |
16 | |
17 static const char *kFirstQuestionMessage = "?\n"; | |
18 static const char *kHelpQuestionMessage = | |
19 "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? "; | |
20 | |
21 // return true if pressed Quite; | |
22 | |
23 NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) | |
24 { | |
25 (*outStream) << kFirstQuestionMessage; | |
26 for(;;) | |
27 { | |
28 (*outStream) << kHelpQuestionMessage; | |
29 AString scannedString = g_StdIn.ScanStringUntilNewLine(); | |
30 scannedString.Trim(); | |
31 if(!scannedString.IsEmpty()) | |
32 switch(::MyCharUpper(scannedString[0])) | |
33 { | |
34 case kYes: | |
35 return NUserAnswerMode::kYes; | |
36 case kNo: | |
37 return NUserAnswerMode::kNo; | |
38 case kYesAll: | |
39 return NUserAnswerMode::kYesAll; | |
40 case kNoAll: | |
41 return NUserAnswerMode::kNoAll; | |
42 case kAutoRenameAll: | |
43 return NUserAnswerMode::kAutoRenameAll; | |
44 case kQuit: | |
45 return NUserAnswerMode::kQuit; | |
46 } | |
47 } | |
48 } | |
49 | |
50 UString GetPassword(CStdOutStream *outStream) | |
51 { | |
52 (*outStream) << "\nEnter password:"; | |
53 outStream->Flush(); | |
54 AString oemPassword = g_StdIn.ScanStringUntilNewLine(); | |
55 return MultiByteToUnicodeString(oemPassword, CP_OEMCP); | |
56 } | |
OLD | NEW |