Esempio n. 1
0
def main():
    try:
        stdscr = unicurses.initscr()
        unicurses.cbreak()
        # unicurses.noecho()
        unicurses.start_color()
        stdscr.keypad(1)
        # Determine if we need color
        if args.nocolor:
            unicurses.init_pair(1, unicurses.COLOR_WHITE,
                                unicurses.COLOR_BLACK)
            unicurses.init_pair(2, unicurses.COLOR_WHITE,
                                unicurses.COLOR_BLACK)
        else:
            unicurses.init_pair(1, unicurses.COLOR_BLUE, unicurses.COLOR_BLACK)
            unicurses.init_pair(2, unicurses.COLOR_RED, unicurses.COLOR_BLACK)
            unicurses.init_pair(3, unicurses.COLOR_GREEN,
                                unicurses.COLOR_BLACK)
        # Game loop after this point
        gameLoop(stdscr)
    except KeyboardInterrupt:
        pass
        # TODO: Use global variables to fix this
        #saveGame( playerName )
    finally:
        stdscr.erase()
        stdscr.refresh()
        stdscr.keypad(0)
        unicurses.echo()
        unicurses.nocbreak()
        unicurses.endwin()
Esempio n. 2
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    stdscr.addstr("Hello World\n")
    curses.getch()
    curses.endwin()
    return 0
Esempio n. 3
0
def init():
    """Initialize curses and start application."""
    global stdscr
    stdscr = curses.initscr()

    # Display settings
    curses.cbreak()
    curses.noecho()

    # Key input settings
    curses.raw()
    curses.keypad(stdscr, 1)

    # No cursor
    curses.curs_set(0)

    global TERMNAME
    TERMNAME = curses.termname()
    info('Terminal name: ' + TERMNAME)

    global LONGNAME
    LONGNAME = curses.longname()
    info('Long terminal name: ' + LONGNAME)

    global TERMATTRS
    TERMATTRS = curses.termattrs()
    info('Terminal attributes: ' + str(TERMATTRS))

    init_colors()
Esempio n. 4
0
def main():
    try:
        stdscr = unicurses.initscr()
        unicurses.cbreak()
        # unicurses.noecho()
        unicurses.start_color()
        stdscr.keypad(1)
        # Determine if we need color
        if args.nocolor:
            unicurses.init_pair(1, unicurses.COLOR_WHITE, unicurses.COLOR_BLACK)
            unicurses.init_pair(2, unicurses.COLOR_WHITE, unicurses.COLOR_BLACK)
        else:
            unicurses.init_pair(1, unicurses.COLOR_BLUE, unicurses.COLOR_BLACK)
            unicurses.init_pair(2, unicurses.COLOR_RED, unicurses.COLOR_BLACK)
            unicurses.init_pair(3, unicurses.COLOR_GREEN, unicurses.COLOR_BLACK)
        # Game loop after this point
        gameLoop(stdscr)
    except KeyboardInterrupt:
        pass
        # TODO: Use global variables to fix this
        #saveGame( playerName )
    finally:
        stdscr.erase()
        stdscr.refresh()
        stdscr.keypad(0)
        unicurses.echo()
        unicurses.nocbreak()
        unicurses.endwin()
Esempio n. 5
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    try:
        stdscr.addstr("Hello ")
        curses.attron(curses.A_BOLD)
        stdscr.addstr("World! (Bold)")
        curses.attroff(curses.A_BOLD)

        stdscr.addstr("\nHello ")
        curses.attron(curses.A_REVERSE)
        stdscr.addstr("World! (Reverse)")
        curses.attroff(curses.A_REVERSE)

        stdscr.addstr("\nHello World! (Inline Bold)", curses.A_BOLD)
        stdscr.addstr("\nHello World! (Inline Reverse)", curses.A_REVERSE)

        stdscr.addstr("\nHello World! (Inline Underline)", curses.A_UNDERLINE)
        stdscr.addstr("\nHello World! (Inline BLINK!)", curses.A_BLINK)
        stdscr.addstr("\nHello World! (Inline RED)", curses.COLOR_RED)

        stdscr.getch()
    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
def initInteractive(setup):
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try:
            unicurses.start_color()
        except:
            pass
        scr = Screen(stdscr, setup.args)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
        raise
    finally:
        logging.info("Terminating Nexus migration tool.")
        logging.shutdown()
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
            unicurses.endwin()
Esempio n. 7
0
    def _start(self):
        """
        Initialize the screen and input mode.
        """
        self.stdscr = curses.initscr()
        self.has_color = curses.has_colors()
        if self.has_color:
            curses.start_color()
            if curses_.COLORS < 8:
                # not colourful enough
                self.has_color = False
        if self.has_color:
            try:
                curses.use_default_colors()
                self.has_default_colors=True
            except _curses.error:
                self.has_default_colors=False
        self._setup_colour_pairs()
        curses.noecho()
        # curses.meta(None, 1)
        #todo
        curses.meta( None,1)
        curses.halfdelay(1) # use set_input_timeouts to adjust
        self.stdscr.keypad(True)

        if not self._signal_keys_set:
            self._old_signal_keys = self.tty_signal_keys()
            
        self.set_mouse_tracking(True)

        super(Screen, self)._start()
def initInteractive(setup):
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try: unicurses.start_color()
        except: pass
        scr = Screen(stdscr, setup.args)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
        raise
    finally:
        logging.info("Terminating Nexus migration tool.")
        logging.shutdown()
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
            unicurses.endwin()
Esempio n. 9
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        window = curses.newwin(10, 25, 3, 3)
        window.addstr(1, 1, "Hey there!")

        window.box()

        while True:
            key = window.getch()
            if key == 27:
                break

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 10
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        curses.update_panels()
        curses.doupdate()

        while True:
            key = curses.getch()
            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 11
0
def main():
  ## Curses normal init sequence
  stdscr = curses.initscr()
  curses.noecho() # no echo, but we still see the cursor
  curses.curs_set(False) #turns off the cursor drawing
  stdscr.keypad(True) # allows special keys and arrow keys
  
  try:
    curses.start_color()

    window = curses.newwin(2, 25, 3, 5)
    window.addstr(0,0,"Hello, World!")

    # this window will now be displayed. Since we are doing getch
    # on window, that one is brought to front, window 2 isn't.
    # We can tackle this with panels. Or, explicitly call window2.refresh()
    window2 = curses.newwin(2, 25, 3, 50)
    window2.addstr(0,0,"Hello, World again!")
    
    while True:
      key = window.getch()
      if key == 27:
        break

  except Exception as e:
    stdscr.addstr(0,0,str(e))
    stdscr.getch()
  finally:
    
    curses.endwin()
  
  return 0
Esempio n. 12
0
    def __init__(self):
        global stdscr
        global _BASE_SCREEN

        stdscr = unicurses.initscr()
        unicurses.start_color()
        unicurses.use_default_colors()
        self.screen = stdscr

        _BASE_SCREEN = self
Esempio n. 13
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()

    curses.move(5, 0)
    stdscr.addstr("Hello World (move)")
    for i in range(50):
        stdscr.addstr(10, i, "Hello World")
        curses.getch()

    curses.endwin()
    return 0
Esempio n. 14
0
def initializeCursesTerminal():
    """Initialize the curses terminal and return the window object."""

    stdscr = unicurses.initscr()
    
    unicurses.start_color()
    unicurses.noecho()
    unicurses.cbreak()
    unicurses.keypad(stdscr, True)
    unicurses.timeout(False)
    unicurses.curs_set(False)

    return stdscr
Esempio n. 15
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        window = curses.newwin(3, 20, 5, 5)
        window.addstr(1, 1, "Hey there!")
        window.box()

        window2 = curses.newwin(3, 20, 4, 4)
        window2.addstr(1, 1, "Hey there, again!")
        window2.box()

        panel = curses.new_panel(window)
        panel2 = curses.new_panel(window2)

        #curses.move_panel(panel, 10, 30)

        curses.update_panels()
        curses.doupdate()

        top_p = None

        while True:
            key = curses.getch()
            if key == 27:
                break

            top_p = panel if top_p is panel2 else panel2
            curses.top_panel(top_p)

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 16
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    try:
        max_y, max_x = curses.getmaxyx(stdscr)
        coords = str((max_y, max_x))
        stdscr.addstr(max_y // 2, max_x // 2 - len(coords) // 2, coords)
        curses.move(max_y - 1, max_x - 1)
        curses.getch()
    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        curses.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 17
0
def start():
    global screen
    screen = curses.initscr()
    curses.noecho()
    curses.cbreak()
    curses.curs_set(0)
    screen.keypad(1)
    screen.nodelay(1)
    curses.nonl()
    screen.scrollok(False)
    curses.start_color()

    for i in range(0, 17):
        curses.init_pair(i+1, i, 0)
        #log.log("Pair : ({}, {}, 0)".format(i+1,i))

    h, w = screen.getmaxyx()
    log.log("Screen size : {}x{}".format(h, w))
Esempio n. 18
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        avatar = Player(stdscr, "@", curses.COLOR_RED, curses.COLOR_BLACK,
                        curses.A_BOLD)

        curses.attron(curses.color_pair(1))
        curses.vline("|", 10)
        curses.hline("-", 10)
        curses.attroff(curses.color_pair(1))

        while True:
            key = curses.getch()

            avatar.move(key)

            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 19
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_GREEN)
        curses.init_pair(2, curses.COLOR_RED, curses.COLOR_GREEN)

        dude = curses.newwin(1, 1, 10, 30)
        curses.waddstr(dude, "@", curses.color_pair(2) + curses.A_BOLD)
        dude_panel = curses.new_panel(dude)

        grass = curses.newwin(10, 50, 5, 5)
        grass.bkgd(" ", curses.color_pair(1))
        grass_panel = curses.new_panel(grass)

        curses.top_panel(dude_panel)

        curses.update_panels()
        curses.doupdate()

        while True:
            key = curses.getch()
            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 20
0
    def __init__(self):  #, stdscreen):
        self.screen = uni.initscr()  #stdscreen
        uni.keypad(self.screen, True)
        uni.curs_set(0)
        uni.noecho()
        uni.cbreak()
        #menuwin = uni.subwin(self.screen, 23, 79, 0, 0)
        menuwin = uni.newwin(10, 40, 0, 0)
        #uni.box(menuwin, 0, 0)
        #uni.hline(2, 1)#, uni.ACS_HLINE, 77)
        #uni.mvwhline(menuwin, 2, 1, uni.ACS_HLINE, 40 - 2)
        uni.new_panel(menuwin)
        uni.refresh()

        submenu_items = [('beep', uni.beep), ('flash', uni.flash)]
        submenu = Menu(submenu_items, self.screen)

        main_menu_items = [('beep', uni.beep), ('flash', uni.flash),
                           ('submenu', submenu.display)]
        main_menu = Menu(main_menu_items, self.screen)
        main_menu.display()
Esempio n. 21
0
def main():
    stdscr = curses.initscr()
    curses.keypad(stdscr, True)
    curses.curs_set(False)
    curses.noecho()
    curses.start_color()

    select = mainmenu()
    curses.erase()
    if (select == 3):
        pass

    elif (select == 2):
        curses.mvaddstr(1, 1, "Lataa peli")

    elif (select == 1):
        newgame()
        create_game()
        game_main_loop()

    curses.endwin()
Esempio n. 22
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    try:
        curses.start_color()
        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_RED, curses.COLOR_WHITE)

        stdscr.addstr("Hello World!", curses.color_pair(1))
        stdscr.addstr("\nHello World!", curses.color_pair(2) + curses.A_BLINK)
        stdscr.addstr("\nHello World!",
                      curses.color_pair(1) + curses.A_REVERSE)
        stdscr.getch()
    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 23
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    try:
        while True:
            c = curses.getch()
            if c == 27:
                break

            stdscr.addstr(
                10, 0, "Keycode was %s and the key was %s" %
                (format(c, '>3'), chr(c)))
            curses.move(0, 0)
    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        curses.getch()
    finally:

        curses.endwin()

    return 0
Esempio n. 24
0
 def __init__(self):
     self.stdscr = unicurses.initscr()
     self.client = Client()
     self.client.connect()
     self.receive_data_thread = threading.Thread(
         target=self.display_received_data)
     self.receive_data_thread.daemon = True
     unicurses.start_color()
     unicurses.init_pair(1, unicurses.COLOR_GREEN, unicurses.COLOR_BLACK)
     self.height, self.width = self.stdscr.getmaxyx()
     self.displayWindow = unicurses.newwin(self.height - 6, self.width, 0,
                                           0)
     self.infoWindow = unicurses.newwin(3, self.width, self.height - 6, 0)
     self.inputWindow = unicurses.newwin(3, self.width, self.height - 3, 0)
     self.inputWindow.move(1, 1)
     self.msg = ''
     self.init_display_screen()
     self.init_info_screen()
     try:
         self.receive_data_thread.start()
     except (KeyboardInterrupt, SystemExit):
         sys.exit()
Esempio n. 25
0
 def __init__(self):
     # Initialize screen
     self.stdscr = uni.initscr()
     # Hide cursor
     uni.curs_set(0)
     # Characters available one-by-one
     uni.cbreak()
     # Prevent displying user input
     uni.noecho()
     # Allow user input
     uni.keypad(self.stdscr, True)
     # Enable colors
     uni.start_color()
     # Enable mouse
     uni.mouseinterval(0)
     uni.mousemask(uni.ALL_MOUSE_EVENTS)
     # Window dimensions
     y, x = uni.getmaxyx(self.stdscr)
     # Make maxx/maxy the last row/col visible
     self.maxy = y - 1
     self.maxx = x - 1
     # Drawing order of contained widgets
     self.widgets = []
Esempio n. 26
0
import re
import requests
import struct
import sys
import threading
import time
import unicurses
import wave


os.chdir(os.path.dirname(os.path.realpath(__file__)))  # Changes working directory to the script's parent directory


# Screen config

stdscr = unicurses.initscr()  # initiates the unicurses module & returns a writable screen obj

unicurses.noecho()  # disables echoing of user input
unicurses.cbreak()  # characters are read one-by-one
unicurses.curs_set(0)  # Hide the cursor from view by the user
unicurses.start_color()  # enables color in terminal

stdscr.keypad(True)  # returns special keys like PAGE_UP, etc.
stdscr.nodelay(False)  # enables input blocking to keep CPU down

locale.setlocale(locale.LC_ALL, '')
encoding = locale.getpreferredencoding()  # get the preferred system encoding for unicode support

if sys.platform == 'win32':  # Windows: set codepage to 65001 for unicode support
    os.system('chcp 65001')
Esempio n. 27
0
from player import Player
import unicurses as uc
from math import ceil

stdscr = uc.initscr()


class Set_ships:
    def __init__(self, player):
        self.player = player

        self.on_menu = True  # Shifts the focus between menu and board, = show new ship
        self.menu_hi = 0  # Which ele is hightlighted in the menu
        self.menu_sel = -1  # Current item selected, relevant when board is active
        self.num_ships_set = 0

        self.menu = self.player.left_to_set()

        self.new_ship_x = 0
        self.new_ship_y = 0
        self.new_ship_hor = True

        self.title = f'Set ships for player: {self.player.name}'

        self.max_y, self.max_x = uc.getmaxyx(stdscr)

        uc.noecho()  # Disable typing on the screen
        uc.cbreak()  # catching characters directly without waiting for [ENTER]
        uc.curs_set(0)  # Disable blinking curser
        uc.keypad(stdscr, True)  # for catching the arrow keys
        uc.start_color()
Esempio n. 28
0
 def __init__(self):
     stdscr = uni.initscr()
     uni.start_color()
     uni.cbreak()
     uni.noecho()
     uni.keypad(stdscr, True)
Esempio n. 29
0
        self.game_stat.disable()
        self.game_field.disable()
        self.game_menu_interface.disable()

    def key_event(self, key):
        if not self.game_menu_interface.enabled and not self.game_field.enabled and not self.game_stat.enabled:
            self.main_menu.key_event(key)
        elif self.main_menu.enabled and self.game_menu_interface.blocked:
            self.main_menu.key_event(key)
        elif not self.main_menu.enabled and self.game_menu_interface.blocked:
            self.game_field.key_event(key)
        else:
            self.game_menu_interface.key_event(key)

if __name__ == "__main__":
    stdscr = initscr()
    clear()
    noecho()
    cbreak()
    curs_set(0)
    keypad(stdscr, True)
    start_color()
    use_default_colors()
    nodelay(stdscr, True)
    init_pair(1, COLOR_BLACK, COLOR_WHITE)
    init_pair(2, COLOR_WHITE, COLOR_BLUE)
    init_pair(3, COLOR_BLACK, COLOR_BLUE)
    init_pair(4, COLOR_WHITE, COLOR_CYAN)
    init_pair(5, COLOR_YELLOW, COLOR_GREEN)
    init_pair(6, COLOR_GREEN, COLOR_BLACK)
    init_pair(7, COLOR_RED, COLOR_BLACK)
Esempio n. 30
0
        self.game_field.disable()
        self.game_menu_interface.disable()

    def key_event(self, key):
        if not self.game_menu_interface.enabled and not self.game_field.enabled and not self.game_stat.enabled:
            self.main_menu.key_event(key)
        elif self.main_menu.enabled and self.game_menu_interface.blocked:
            self.main_menu.key_event(key)
        elif not self.main_menu.enabled and self.game_menu_interface.blocked:
            self.game_field.key_event(key)
        else:
            self.game_menu_interface.key_event(key)


if __name__ == "__main__":
    stdscr = initscr()
    clear()
    noecho()
    cbreak()
    curs_set(0)
    keypad(stdscr, True)
    start_color()
    use_default_colors()
    nodelay(stdscr, True)
    init_pair(1, COLOR_BLACK, COLOR_WHITE)
    init_pair(2, COLOR_WHITE, COLOR_BLUE)
    init_pair(3, COLOR_BLACK, COLOR_BLUE)
    init_pair(4, COLOR_WHITE, COLOR_CYAN)
    init_pair(5, COLOR_YELLOW, COLOR_GREEN)
    init_pair(6, COLOR_GREEN, COLOR_BLACK)
    init_pair(7, COLOR_RED, COLOR_BLACK)
Esempio n. 31
0
 def __init__(self):
     self.screen = unicurses.initscr()
     unicurses.noecho()
     unicurses.cbreak()
     unicurses.curs_set(0)
     self.screen.refresh()
        @wraps(func)
        def bar(*args, **kw):
            kw['ssl_version'] = ssl.PROTOCOL_TLSv1
            return func(*args, **kw)
        return bar
    ssl.wrap_socket = sslwrap(ssl.wrap_socket)

# Start the tool by initializing unicurses and creating a new Screen object.
# Before doing so, set the ESCDELAY environment variable to 25, in an attempt to
# mitigate the delay following the pressing of the escape key during line
# editing.
if __name__ == '__main__':
    os.environ.setdefault('ESCDELAY', '25')
    fixssl()
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try: unicurses.start_color()
        except: pass
        scr = Screen(stdscr)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    finally:
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
Esempio n. 33
0
def initCurses():
    stdscr = uc.initscr()
    uc.noecho()
    uc.curs_set(False)
    uc.keypad(stdscr, True)
    uc.start_color()
Esempio n. 34
0
import sys

import time, random
import unicurses as curses

screen = curses.initscr()
screen.nodelay(1)
screen.border()
curses.noecho()
curses.curs_set(0)
dims = screen.getmaxyx()
height, width = dims[0] - 1, dims[1] - 1
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)

row, col = 0, 0
for i in range(256):
    screen.addch(row, col, i, curses.color_pair(0))
    col += 1
    if col > 75:
        row += 1
        col = 1
    screen.refresh()
    time.sleep(0.051)
curses.endwin()
Esempio n. 35
0
        time.sleep(0.1)


message_refresh_thread = threading.Thread(target=get_messages)

err = []
sock = socket.socket()
while True:
    try:
        sock.connect((HOST, PORT))
    except WindowsError:
        print("Can't connect: " + HOST + ':' + str(PORT))
        continue
    break
sock.sendall(bytes(channel + chr(0) + chr(3) + chr(0) + args.user, "utf-8"))
stdscr = u.initscr()
u.curs_set(0)
chat_win = u.newwin(25, 90, 0, 0)
input_win = u.newwin(5, 90, 25, 0)
people_win = u.newwin(30, 30, 0, 90)
message_refresh_thread.start()
while True:
    sock = socket.socket()
    u.wclear(input_win)
    u.mvwaddstr(input_win, 1, 1, '> ')
    refresh()
    u.flushinp()
    data = u.mvwgetstr(input_win, 1, 3)
    send = True
    # if len(data.split()) > 1:
    #     if data.split()[0] == ":send":
Esempio n. 36
0
# -*- coding: utf-8 -*-
"""
Created on Wed Oct  5 16:01:09 2016

@author: Graham Cooke
"""

import unicurses

unicurses.initscr()

unicurses.newwin(10, 10)
Esempio n. 37
0
import unicurses
import todo
import main
screen = unicurses.initscr()
screen.keypad(1)
dims = screen.getmaxyx()

def menu():
    screen.nodelay(0)
    screen.clear()
    selection = -1
    option = 0
    while selection < 0:
        graphics = [0]*5
        graphics[option] = curses.A_REVERSE
        screen.addstr(0, dims[1]/2-3, "Menu")
        screen.addstr(dims[0]/2-2, dims[1]/2-2, "Sth", graphics[0])
        screen.addstr(dims[0]/2-1, dims[1]/2-6, "Instructions", graphics[1])
        screen.addstr(dims[0]/2, dims[1]/2-6, "Aby", graphics[2])
        screen.addstr(dims[0]/2+1, dims[1]/2-5, "adasf", graphics[3])
        screen.addstr(dims[0]/2+2, dims[1]/2-2, "Exit", graphics[4])
        screen.refresh()
        action = screen.getch()
        if action == curses.Key_UP:
            option = (option - 1) % 5
        elif action == curses.KEY_DOWN:
            option = (option + 1) % 5
menu()
unicurses.edwin()
Esempio n. 38
0
import sys

import time, random
import unicurses as curses 

screen = curses.initscr()
screen.nodelay(1)
screen.border()
curses.noecho()
curses.curs_set(0)
dims = screen.getmaxyx()
height,width = dims[0]-1, dims[1]-1
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)

row,col= 0,0
for i in range(256):
    screen.addch(row,col,i,curses.color_pair(0) )
    col +=1
    if col>75:
        row +=1
        col = 1
    screen.refresh()
    time.sleep(0.051)
curses.endwin()
Esempio n. 39
0
def main_loop(manga_list):
    global compc, compv

    for m in manga_list:
            req               = _parsers.ParseRequest(m)
            sout, title, path = get_listing(req._name)

            if _g.conf._usecache and _g.conf._found_in_cache:
                sout = subdir_recurse(sout, path)
            else:
                sout = sout.splitlines()
                sout = rem_subdir_recurse(sout, path)

            compv, compc, allf, compfile = walk_thru_listing(req, title, sout)

            if req._vols and req._vols[-1] == req.ALL:
                del req._vols[-1]

            if req._chps and req._chps[-1] == req.ALL:
                del req._chps[-1]

            missv = str([v for v in req._vols if v not in compv]).strip('[]')
            missc = str([c for c in req._chps if c not in compc]).strip('[]')

            if missv:
                _out._("couldn't find vol(s): " + missv)

            if missc:
                _out._("couldn't find chp(s): " + missc)

            if any((compfile, compc, compv)):
                # XXX sigh...
                # need to append MLOC when we get a cache match.
                ppfx = ''.join(['https://', loc['DOMAIN']])

                if _g.conf._found_in_cache:
                    ppfx = ''.join([ppfx, loc['MLOC']])

                try:
                    stdscr          = unicurses.initscr()
                    _g.conf._stdscr = stdscr
                    unicurses.noecho()

                    if compfile:
                        _out._('downloading complete archive... ', end='')
                        _g.conf._stdscr.erase()
                        _g.conf._stdscr.addstr(0, 0, compfile.name)
                        _g.conf._stdscr.refresh()
                        _curl.curl_to_file('/'.join([ppfx, 
                                                     _util.create_nwo_basename(
                                                        compfile.basename),
                                                     urllib
                                                       .parse
                                                       .quote(compfile.name)]),
                                           compfile.name, 'HTTP')
                    elif compv or compc:
                        _out._('downloading volume/chapters... ', end='')
                        for f,v,c in allf:
                            #_g.log.info('DL ' + f)
                            _g.conf._stdscr.erase()
                            _g.conf._stdscr.addstr(0, 0, 'title - {}'
                                                           .format(title))
                            _g.conf._stdscr.addstr(1, 0, 'current - {}'
                                                           .format(f.name))
                            _g.conf._stdscr.refresh()
                            _curl.curl_to_file('/'.join([ppfx,
                                                         _util
                                                           .create_nwo_basename(                                                             f.basename),
                                                         urllib
                                                           .parse
                                                           .quote(f.name)]),
                                               f.name, 'HTTP')
                except:
                    raise
                finally:
                    unicurses.nocbreak()
                    _g.conf._stdscr.keypad(False)
                    unicurses.echo()
                    unicurses.endwin()

                print('done', file=sys.stderr)
            else:
                _out._('could not find any requested volume/chapters.')
                return 1

    return 0
import os
import logging
import unicurses
from nex2art.menu import Safety, Main
from nex2art.core import Setup, Screen

# Start the tool by initializing unicurses and creating a new Screen object.
# Before doing so, set the ESCDELAY environment variable to 25, in an attempt to
# mitigate the delay following the pressing of the escape key during line
# editing.
if __name__ == '__main__':
    setup = Setup()
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try:
            unicurses.start_color()
        except:
            pass
        scr = Screen(stdscr)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
Esempio n. 41
0
import unicurses as curses
import time
import os
from random import randint, choice

os.environ['ESCDELAY'] = '25'
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
curses.keypad(stdscr, 1)
curses.wborder(stdscr)
curses.curs_set(0)
middley, middlex = map(lambda x: x // 2, curses.getmaxyx(
    stdscr))  # get middle coordinates depending on the size of the terminal

UP = 259  # ascii key codes
DOWN = 258
LEFT = 261
RIGHT = 260

asci = '''
   _____ _   _          _  ________ 
  / ____| \ | |   /\   | |/ /  ____|
 | (___ |  \| |  /  \  | ' /| |__   
  \___ \| . ` | / /\ \ |  < |  __|  
  ____) | |\  |/ ____ \| . \| |____ 
 |_____/|_| \_/_/    \_\_|\_\______|'''


def reset_game():
    '''
Esempio n. 42
0
            uni.mvwaddstr(menu_win, y, x, choices[i])
        y += 1
    uni.wrefresh(menu_win)

def report_choice(mouse_x, mouse_y):
    i = startx + 2
    j = starty + 3
    for choice in range(0, n_choices):
        if (mouse_y == j + choice) and (mouse_x >= i) and (mouse_x <= i + len(choices[choice])):
            if choice == n_choices - 1:
                return -1
            else:
                return choice + 1
            break

stdscr = uni.initscr()
uni.clear()
uni.noecho()
uni.cbreak()
uni.curs_set(0)
startx = int((80 - WIDTH) / 2)
starty = int((24 - HEIGHT) / 2)

menu_win = uni.newwin(HEIGHT, WIDTH, starty, startx)
uni.keypad(menu_win, True)
uni.mvaddstr(0, 0, "Click on Exit to quit (works best in a virtual console)")
uni.refresh()
print_menu(menu_win, 1)
uni.mouseinterval(0)
uni.mousemask(uni.ALL_MOUSE_EVENTS)