@@ -158,7 +158,7 @@ def find_lines_to_show(all_lines, important_passage):
158158 hour = f"{ now .tm_hour :02d} "
159159
160160 # open the data file for the current hour
161- with open (f"split_data_compressed /{ hour } .csv.gz" , "rb" ) as f :
161+ with open (f"quotes_data /{ hour } .csv.gz" , "rb" ) as f :
162162 # read and unzip the data
163163 compressed_data = f .read ()
164164 rows = zlib .decompress (compressed_data ).split (b"\n " )
@@ -212,9 +212,6 @@ def find_lines_to_show(all_lines, important_passage):
212212 # extract the book title
213213 title = parts [3 ]
214214
215- # set the text in the book info label to show the title and author
216- book_info_lbl .text = f"{ title } - { author } "
217-
218215 # extract the current time reference string
219216 time_part = parts [1 ]
220217
@@ -243,19 +240,31 @@ def find_lines_to_show(all_lines, important_passage):
243240 # Temporary version of final visible quote joined with spaces instead of newlines,
244241 # so we can search for the time_part without worrying about potential newlines.
245242 shown_quote_with_spaces = " " .join (
246- quote_lines [first_line_to_show : first_line_to_show + 7 ]
243+ quote_lines [first_line_to_show : first_line_to_show + 7 ]
247244 )
248245
249246 # find the current time reference within the quote that will be shown
250247 time_start_index = shown_quote_with_spaces .find (time_part )
251248 time_end_index = time_start_index + len (time_part )
252249
253250 # wrap the quote to be shown to multiple lines and set it on the label
254- quote_lbl .text = "\n " .join (quote_lines [first_line_to_show : first_line_to_show + 7 ])
251+ quote_lbl .text = "\n " .join (quote_lines [first_line_to_show : first_line_to_show + 7 ])
255252
256253 # accent the part of the quote that references the current time
257254 quote_lbl .add_accent_range (time_start_index , time_end_index , 4 , 3 , "outline" )
258255
256+ # show title and author in the book info label
257+ # allow it to split to two lines if the quote is short enough
258+ if len (quote_lines ) <= 6 :
259+ book_info = f"{ title } - { author } "
260+ book_info_lbl .text = "\n " .join (wrap_text_to_pixels (
261+ book_info ,
262+ display .width - 4 ,
263+ terminalio .FONT ,
264+ ))
265+ else :
266+ book_info_lbl .text = f"{ title } - { author } "
267+
259268 # update the display and wait 60 seconds
260269 display .refresh ()
261270 time .sleep (60 )
0 commit comments