Projects STRLCPY stackexplain Commits 2ed642de
🤬
  • ■ ■ ■ ■ ■ ■
    stackexplain/stackexplain.py
    skipped 28 lines
    29 29   
    30 30   print()
    31 31   
    32  - with printers.LoadingMessage():
     32 + with printers.LoadingMessage(): # Context-based loading message
    33 33   explanation = gpt.get_chatgpt_explanation(language, error_message)
    34 34   
    35 35   # TODO: Add syntax highlighting to code
    36  - # TODO: Print word-by-word
    37  - print(explanation)
     36 + 
     37 + printers.print_error_explanation(explanation)
    38 38   
  • ■ ■ ■ ■ ■ ■
    stackexplain/utilities/printers.py
     1 +import sys
    1 2  from itertools import cycle
    2 3  from shutil import get_terminal_size
    3 4  from threading import Thread
    4 5  from time import sleep
     6 +from random import random
    5 7   
    6 8  # ASCII color codes
    7 9  GREEN = '\033[92m'
    skipped 70 lines
    78 80   # handle exceptions with those variables ^
    79 81   self.stop()
    80 82   
     83 + 
     84 +def print_error_explanation(explanation):
     85 + for word in f"{explanation}\n":
     86 + sys.stdout.write(word)
     87 + sys.stdout.flush() # Defeat buffering
     88 + sleep(0.01)
     89 + 
Please wait...
Page is in error, reload to recover