Esempio n. 1
0
 def handle_keystroke(self, char):
     if char == ord('q'):
         # Notify Retriever to quit
         retr_queue_in.put(RetrieverQuit())
         return -1
     elif char == ord('u'):
         # Update stories NOW
         retr_queue_in.put(ForceUpdate())
         return
     elif char == curses.KEY_DOWN or char== ord('j'):
         # Scroll stories down by one
         if len(self.stories) - self.start_pos > self.display.max_display() / 2:
             self.start_pos += 1
             if self.stories:
                 self.display.display(self.stories)
                 if len(self.stories) - self.start_pos < self.display.max_display() and self.pages_changed:
                     self.pages += 1
                     self.pages_changed = False
                     retr_queue_in.put(ChangePages(self.pages))
         return
     elif char == curses.KEY_UP or char == ord('k'):
         # Scroll stories up by one
         if self.start_pos > 0:
             self.start_pos -= 1
             if self.stories:
                 self.display.display(self.stories)
                 if len(self.stories) - self.start_pos - self.display.max_display() > stories_per_page() and self.pages_changed:
                     self.pages -= 1
                     self.pages_changed = False
                     retr_queue_in.put(ChangePages(self.pages))
         return
     elif char == ord('m'):
         # Change display mode
         self.display_mode += 1 
         self.display_mode %= len(self.display_modes)
         self.display = self.display_modes[self.display_mode](self)
         if self.stories:
             self.display.display(self.stories)
         return
     elif char == ord('o'):
         # Open topmost story in webbrrowser (new window)
         open_url(self.stories[self.start_pos].url)
         return
     elif char == ord('t'):
         # Open topmost story in webbrowser (new tab)
         open_url(self.stories[self.start_pos].url, True)
         return
     elif char == ord('c'):
         # Open topmost story's comments in webbrowser (new tab)
         open_url(self.stories[self.start_pos].comments_url, True)
         return
Esempio n. 2
0
 def handle_keystroke(self, char):
     if char == ord('q'):
         # Notify Retriever to quit
         retr_queue_in.put(RetrieverQuit())
         return -1
     elif char == ord('u'):
         # Update stories NOW
         retr_queue_in.put(ForceUpdate())
         return
     elif char == curses.KEY_DOWN or char== ord('j'):
         # Scroll stories down by one
         if len(self.stories) - self.start_pos > self.display.max_display() / 2:
             self.start_pos += 1
             if self.stories:
                 self.display.display(self.stories)
                 if len(self.stories) - self.start_pos < self.display.max_display() and self.pages_changed:
                     self.pages += 1
                     self.pages_changed = False
                     retr_queue_in.put(ChangePages(self.pages))
         return
     elif char == curses.KEY_UP or char == ord('k'):
         # Scroll stories up by one
         if self.start_pos > 0:
             self.start_pos -= 1
             if self.stories:
                 self.display.display(self.stories)
                 if len(self.stories) - self.start_pos - self.display.max_display() > stories_per_page() and self.pages_changed:
                     self.pages -= 1
                     self.pages_changed = False
                     retr_queue_in.put(ChangePages(self.pages))
         return
     elif char == ord('m'):
         # Change display mode
         self.display_mode += 1 
         self.display_mode %= len(self.display_modes)
         self.display = self.display_modes[self.display_mode](self)
         if self.stories:
             self.display.display(self.stories)
         return