summaryrefslogtreecommitdiffstats
path: root/flashcards
diff options
context:
space:
mode:
Diffstat (limited to 'flashcards')
-rwxr-xr-xflashcards22
1 files changed, 13 insertions, 9 deletions
diff --git a/flashcards b/flashcards
index 7ba5fa6..e0ba548 100755
--- a/flashcards
+++ b/flashcards
@@ -5,8 +5,7 @@ import sys
from pathlib import Path
from random import shuffle
-'''
-class color:
+class Color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
@@ -18,8 +17,7 @@ class color:
UNDERLINE = '\033[4m'
END = '\033[0m'
-print color.BOLD + 'Hello World !' + color.END
-'''
+#print color.BOLD + 'Hello World !' + color.END
cardRegex = "CARD: "
prefixLength = len(cardRegex)
@@ -63,15 +61,21 @@ def extractCards(f):
cards.append([front.strip(), back.strip()])
return cards
+# Waits for user input and reacts accordingly
+def wait():
+ cmd = input().strip()
+ if cmd.startswith("q") or cmd.startswith("quit") or cmd.startswith("exit"):
+ sys.exit(0)
+
# Loops serving cards to the user until the program is exited
def serveCards(cards):
while True:
- for card in cards:
- print("----------------------------------------------------------------------------")
- print(card[0])
- input()
+ for i, card in enumerate(cards):
+ print("----------------------------------------------------------------------------(" + str(i + 1) + "/" + str(len(cards)) + ")")
+ print(Color.BLUE + Color.BOLD + card[0] + Color.END)
+ wait()
print(card[1])
- input()
+ wait()
def debugCards(cardList):
for c in cardList: