+
+ mnemon->to_introduce -= mnemon->unlearned;
+ if (mnemon->to_introduce < 0)
+ mnemon->to_introduce = 0;
+
+ /* Get rid of bin with score of 0 if we aren't going to be
+ * introducing anything from it. */
+ if (mnemon->to_introduce == 0) {
+ bin = mnemon_get_bin (mnemon, 0);
+ mnemon_remove_bin (mnemon, bin);
+ }
+
+ if (mnemon->unlearned) {
+ printf ("You've got %d items to learn already. ", mnemon->unlearned);
+ if (mnemon->to_introduce)
+ printf ("I'll introduce %d more as we go.", mnemon->to_introduce);
+ printf ("\n");
+ } else {
+ printf ("Introducing %d new items.\n", mnemon->to_introduce);
+ }
+ printf ("\n");
+
+ do {
+ struct timeval start, end;
+
+ mnemon_select_item (mnemon, &bin, &item_index, &category);
+ item = bin->items[item_index];
+
+ if (bin->score == 0)
+ mnemon->to_introduce--;
+
+ while (1) {
+ if (category->time_limit > 0.0) {
+ response = readline ("The next one is timed. Press enter when ready:");
+ free (response);
+ }
+
+ printf ("%s\n", item->challenge);
+
+ gettimeofday (&start, NULL);
+ response = readline ("> ");
+ gettimeofday (&end, NULL);
+
+ /* Terminate on EOF */
+ if (response == NULL) {
+ printf ("\n");
+ return;
+ }
+
+ if (response[0] == '/') {
+ mnemon_handle_command (mnemon, response + 1);
+ free (response);
+ } else {
+ break;
+ }
+ }
+
+ mnemon_handle_response (mnemon, bin, item_index,
+ item, response,
+ (end.tv_sec + end.tv_usec / 1e6) -
+ (start.tv_sec + start.tv_usec / 1e6),
+ category->time_limit);
+ free (response);
+ } while (mnemon->to_introduce ||
+ mnemon->unlearned ||
+ mnemon->to_master > 0);
+
+ printf ("Great job.\nHere are your current results:\n");
+ mnemon_print_histogram (mnemon, NULL, 0);
+ response = readline ("Press enter to quit.\n");
+ free (response);