Make the cards look more like cards. (#31)

* Make the cards look more like cards.

* travis

* travis

* travis 2
This commit is contained in:
Gustavo 2020-07-17 15:19:48 -04:00 committed by GitHub
parent e2384023d0
commit 748b79e8d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

23
flash
View File

@ -230,14 +230,18 @@ esac
# The top part of the flash display so that code is not duplicated twice # The top part of the flash display so that code is not duplicated twice
print_head(){ print_head(){
QUESTION=$(echo "${q[1]}" | fold --spaces --width=59)
echo -e "${WHITEBG} Fla.sh - Flash Cards In Your Terminal ${NC} echo -e "${WHITEBG} Fla.sh - Flash Cards In Your Terminal ${NC}
${ORANGE}${BOLD} Current Deck:${BOLD}${NC}\t$CURRENT_DECK ${ORANGE}${BOLD} Current Deck:${BOLD}${NC}\t$(basename -s .csv "$CURRENT_DECK")
${ORANGE}${BOLD}Cards Reviewed:${BOLD}${NC}\t$COUNTER ${ORANGE}${BOLD}Cards Reviewed:${BOLD}${NC}\t$COUNTER
\t${ORANGE}${BOLD}High Score:${BOLD}${NC}\t$(cat "$HIGH_SCORE") \t${ORANGE}${BOLD}High Score:${BOLD}${NC}\t$(cat "$HIGH_SCORE")
\t${ORANGE}${BOLD}Avg review:${BOLD}${NC}\t$(awk '{ sum += $7; n++ } END { if (n > 0) print sum / n; }' "$REVIEW_LOG") \t${ORANGE}${BOLD}Avg review:${BOLD}${NC}\t$(awk '{ sum += $7; n++ } END { if (n > 0) print sum / n; }' "$REVIEW_LOG")
${LGREY}Category:${NC}\n\t\t${q[0]} ${LGREY}Category:${NC} ${q[0]}
${LGREY}Question:${NC}\n\t\t${q[1]}" ___________________________________________________________
$(if [ ${#QUESTION} -lt 59 ]; then printf "%$(( ( 59 - ${#QUESTION} ) / 2 ))s"; fi)$QUESTION"
} }
# Creating new entries in the log for the average score generation # Creating new entries in the log for the average score generation
@ -265,9 +269,7 @@ main(){
clear clear
print_head print_head
echo -e " echo -e "
${LGREY}──────────────── Press [Enter] to continue ────────────────${NC}"
${LGREY}Press [Enter] to continue...${NC}"
# shellcheck disable=SC2162 # shellcheck disable=SC2162
read -sn 1 NEXT read -sn 1 NEXT
while [ ! "$NEXT" = "" ] && [ ! "$NEXT" = q ] && [ ! "$NEXT" = Q ]; do while [ ! "$NEXT" = "" ] && [ ! "$NEXT" = q ] && [ ! "$NEXT" = Q ]; do
@ -279,7 +281,10 @@ ${LGREY}Press [Enter] to continue...${NC}"
if [ "$NEXT" = q ] || [ "$NEXT" = Q ]; then if [ "$NEXT" = q ] || [ "$NEXT" = Q ]; then
add_usage_entry && cd "$PWD" && clear && exit 0 add_usage_entry && cd "$PWD" && clear && exit 0
fi fi
echo -e "${LGREY}Answer:${NC}\n\t\t${q[2]} ANSWER=$(echo "${q[2]}" | fold --spaces --width=59)
echo -e "___________________________________________________________
$(if [ ${#ANSWER} -lt 59 ]; then printf "%$(( ( 59 - ${#ANSWER} ) / 2 ))s"; fi)$ANSWER
${WHITEBG}${WHITE}===========================================================${NC} ${WHITEBG}${WHITE}===========================================================${NC}
@ -332,8 +337,8 @@ ${LGREY}Select a number to continue, or${NC} ${LRED}Q${NC} ${LGREY}to quit...${N
# Update item score for each flashcard item # Update item score for each flashcard item
## Remove forward slashes in the Questions and answers ## Remove forward slashes in the Questions and answers
QUESTION_REGEX=$(sed "s/\(\/\|\[\|\]\)/\\\\\1/g" <<< "${q[1]}") QUESTION_REGEX=$(sed "s/\(\/\|\[\|\]\|\*\)/\\\\\1/g" <<< "${q[1]}")
ANSWER_REGEX=$(sed "s/\(\/\|\[\|\]\)/\\\\\1/g" <<< "${q[2]}") ANSWER_REGEX=$(sed "s/\(\/\|\[\|\]\|\*\)/\\\\\1/g" <<< "${q[2]}")
sed -i "s/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:${q[3]}/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:$NEW_ITEM_SCORE/g" "$DECK" sed -i "s/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:${q[3]}/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:$NEW_ITEM_SCORE/g" "$DECK"
# If no highscore currently set, set it. # If no highscore currently set, set it.
if [ -z "$(cat "$HIGH_SCORE")" ]; then if [ -z "$(cat "$HIGH_SCORE")" ]; then