def renderContentScreen(stdscr):
    
    global OBJ_CONTENTSCREEN
    global OBJ_CONTENTSCREEN_SCROLL_TEXT
    global OBJ_CONTENTSCREEN_SCROLL_POSITION
    
    OBJ_CONTENTSCREEN_SCROLL_POSITION = 0
    
    height, width = stdscr.getmaxyx()
    
    OBJ_CONTENTSCREEN = curses.newwin(height - 2, width, 1, 0)
    OBJ_CONTENTSCREEN.border(0)
    OBJ_CONTENTSCREEN.bkgd(1, AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.addstr(1, 5, "Article:", AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.addstr(6, 5, "Loading...", AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.refresh()
    
    # Fetch the article's content
    url = ArticleMenu.OBJ_ARTICLEMENU_SCROLL_ITEMS[ArticleMenu.OBJ_ARTICLEMENU_SCROLL_POSITION]['url']
    
    try:
        # Fetch the full content from the website
        content = Content_SMH.fetchArticleContent(url)
        
        OBJ_CONTENTSCREEN_SCROLL_TEXT = "\n" + ''.join([i if ord(i) < 128 else ' ' for i in content['title']]) + "\n"
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join([i if ord(i) < 128 else ' ' for i in content['date']]) + "\n"
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join([i if ord(i) < 128 else ' ' for i in content['author']]) + "\n\n\n"
        
        # Strip out non-ASCII characters for the body text
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join([i if ord(i) < 128 else ' ' for i in content['body']])
        
    except Exception, e:
        print e
        OBJ_CONTENTSCREEN_SCROLL_TEXT = "ERROR: Unable to fetch article :( \n\n" + str(e)
示例#2
0
def renderContentScreen(stdscr):

    global OBJ_CONTENTSCREEN
    global OBJ_CONTENTSCREEN_SCROLL_TEXT
    global OBJ_CONTENTSCREEN_SCROLL_POSITION

    OBJ_CONTENTSCREEN_SCROLL_POSITION = 0

    height, width = stdscr.getmaxyx()

    OBJ_CONTENTSCREEN = curses.newwin(height - 2, width, 1, 0)
    OBJ_CONTENTSCREEN.border(0)
    OBJ_CONTENTSCREEN.bkgd(1, AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.addstr(1, 5, "Article:", AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.addstr(6, 5, "Loading...", AppCommon.COLOR_BODY)
    OBJ_CONTENTSCREEN.refresh()

    # Fetch the article's content
    url = ArticleMenu.OBJ_ARTICLEMENU_SCROLL_ITEMS[
        ArticleMenu.OBJ_ARTICLEMENU_SCROLL_POSITION]['url']

    try:
        # Fetch the full content from the website
        content = Content_SMH.fetchArticleContent(url)

        OBJ_CONTENTSCREEN_SCROLL_TEXT = "\n" + ''.join(
            [i if ord(i) < 128 else ' ' for i in content['title']]) + "\n"
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join(
            [i if ord(i) < 128 else ' ' for i in content['date']]) + "\n"
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join(
            [i if ord(i) < 128 else ' ' for i in content['author']]) + "\n\n\n"

        # Strip out non-ASCII characters for the body text
        OBJ_CONTENTSCREEN_SCROLL_TEXT += ''.join(
            [i if ord(i) < 128 else ' ' for i in content['body']])

    except Exception, e:
        print e
        OBJ_CONTENTSCREEN_SCROLL_TEXT = "ERROR: Unable to fetch article :( \n\n" + str(
            e)
      \/____/                  \/____/                  \/____/         
                                                                        
 """
 
 stdscr = curses.initscr()
 curses.noecho() # Don't display text input on the screen
 curses.cbreak() # Allow processing keys before 'enter' is pressed
 stdscr.keypad(1) # Detect special key presses
 curses.start_color() # We want to use colours
 curses.setsyx(0, 0) # Set the cursor default position to 0,0
 
 curses.init_pair(1, curses.COLOR_WHITE, 24)
 curses.init_pair(2, curses.COLOR_WHITE, 1)
 curses.init_pair(3, 4, curses.COLOR_WHITE)
 
 AppCommon.COLOR_MENU = curses.color_pair(2)
 AppCommon.COLOR_BODY = curses.color_pair(1)
 AppCommon.COLOR_BLOCKTEXT = curses.color_pair(3)
 
 # Fetch index content before we properly load the app
 ArticleMenu.OBJ_ARTICLEMENU_SCROLL_ITEMS = Content_SMH.fetchArticleIndex()
 
 # Load the app via a wrapper
 curses.wrapper(runapp)
 
 curses.nocbreak()
 stdscr.keypad(0)
 curses.echo()
 curses.endwin()