From fa274175060dfd949638d6ca30bdaa34f3027ccf Mon Sep 17 00:00:00 2001 From: Kermit Mei Date: Wed, 18 Feb 2009 23:27:01 +0800 Subject: [PATCH] improme calling mode the implicit command --- src/ui/Cui.cpp | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/ui/Cui.cpp b/src/ui/Cui.cpp index 27b5e73..8185427 100644 --- a/src/ui/Cui.cpp +++ b/src/ui/Cui.cpp @@ -500,6 +500,7 @@ void CUI::r_scanProcess(Scanner &scanner) { bool result = true; std::string inputStr; while(scanner.isValid()) { + clear(); if(dictionary.lookUp(scanner.getWord())) { std::cout <<" Amount: "<< scanner.capability() <<" R_Num: " << scanner.size() @@ -511,28 +512,28 @@ void CUI::r_scanProcess(Scanner &scanner) { std::cout << "*[T]: /" << dictionary.phonetics() << "/" << std::endl; std::cout << "*[M]: " << dictionary.translation() << std::endl; std::cout << "**********************************************" << std::endl; - std::cout << "Type \'\\help\' to show the implicit command!" << std::endl; + std::cout << "Type \'/help\' to show the implicit command!" << std::endl; std::cout << "Do you remember it?(Y/n) "; std::getline(std::cin,inputStr); - if(inputStr == "\\help"){ + if(inputStr == "/help"){ scanProHelp(); continue; - } else if(inputStr == "\\modify"){ + } else if(inputStr == "/modify"){ modify(scanner.getWord()); continue; - } else if(inputStr == "\\add"){ + } else if(inputStr == "/add"){ std::cout << "Input new word: "; std::getline(std::cin,inputStr); scanner.add(inputStr); std::cout << "SUCCESS!" << std::endl; continue; - } else if(inputStr == "\\rm"){ + } else if(inputStr == "/rm"){ inputStr = scanner.getWord(); scanner.remove(inputStr); std::cout << "SUCCESS!" << std::endl; continue; - } else if(inputStr == "\\stop") { + } else if(inputStr == "/stop") { exit(EXIT_SUCCESS); } if(inputStr == "Y" || inputStr == "y" || inputStr.empty()) @@ -542,8 +543,9 @@ void CUI::r_scanProcess(Scanner &scanner) { std::cout << std::endl; showResult(result); - clear(); scanner.test(result); + if(result == false) + scanner.test(true); } else { //If the dictionary can't look up the current word std::cout << '\"' << scanner.getWord() << '\"' << " can't be found in your dictionary." @@ -565,8 +567,9 @@ void CUI::scanProcess(Scanner &scanner) { bool result; std::string inputStr; while(scanner.isValid()) { + clear(); if(dictionary.lookUp(scanner.getWord())){ - std::cout <<" Type \'\\help\' to show the implicit command!" + std::cout <<" Type \'/help\' to show the implicit command!" << std::endl; std::cout <<" Amount: "<< scanner.capability() <<" R_Num: " << scanner.size() @@ -576,7 +579,7 @@ void CUI::scanProcess(Scanner &scanner) { std::cout<<"*Input : "; std::getline(std::cin,inputStr); - if(inputStr == "\\hint") { + if(inputStr == "/hint") { std::cout << "*Hint : " << dictionary.word().at(0); for(unsigned i = 1; i < dictionary.word().size(); ++i) std::cout << '_'; @@ -586,24 +589,24 @@ void CUI::scanProcess(Scanner &scanner) { std::getline(std::cin,inputStr); } - if(inputStr == "\\help"){ + if(inputStr == "/help"){ scanProHelp(); continue; - } else if(inputStr == "\\modify"){ + } else if(inputStr == "/modify"){ modify(scanner.getWord()); continue; - } else if(inputStr == "\\add"){ + } else if(inputStr == "/add"){ std::cout << "Input new word: "; std::getline(std::cin,inputStr); scanner.add(inputStr); std::cout << "SUCCESS!" << std::endl; continue; - } else if(inputStr == "\\rm"){ + } else if(inputStr == "/rm"){ inputStr = scanner.getWord(); scanner.remove(inputStr); std::cout << "SUCCESS!" << std::endl; continue; - } else if(inputStr == "\\stop") { + } else if(inputStr == "//stop") { exit(EXIT_SUCCESS); } result = ( inputStr == scanner.getWord() ? true : false ); @@ -613,7 +616,6 @@ void CUI::scanProcess(Scanner &scanner) { std::cout << std::endl; std::cout <<"**********************************************" << std::endl; showResult(result); - clear(); scanner.test(result); } else { //If the dictionary can't look up the current word std::cout << '\"' << scanner.getWord() << '\"' @@ -633,14 +635,15 @@ void CUI::scanProcess(Scanner &scanner) { } void CUI::scanProHelp() { - std::cout << std::endl << "usage: \\command " << std::endl - << "\\help Show this help information" << std::endl - << "\\add Add new word to this task" << std::endl - << "\\rm Remove the current word from this task" << std::endl - << "\\modify Modify the current word in the dictionary" << std::endl - << "\\hint Get the hint of current word, but the translation can't use" + std::cout << std::endl << "usage: /command " << std::endl + << "/help Show this help information" << std::endl + << "/add Add new word to this task" << std::endl + << "/rm Remove the current word from this task" << std::endl + << "/modify Modify the current word in the dictionary" << std::endl - << "\\stop Stop Free Recite at once" << std::endl; + << "/hint Get the hint of current word, but the translation can't use" + << std::endl + << "/stop Stop Free Recite at once" << std::endl; } void CUI::help() { -- 2.11.4.GIT