Esempio n. 1
0
def run():
    console.init()

    key = tcod.Key()
    mouse = tcod.Mouse()

    player = Player(int(variables.screen_width / 2),
                    int(variables.screen_height / 2))
    game_map = BoundedMap(80, 50)

    while not tcod.console_is_window_closed():
        tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS, key, mouse)
        console.update(player, game_map)

        action = input.handle_keys(key)

        move = action.get('move')
        quit_game = action.get('exit')

        if move:
            dx, dy = move
            if not game_map.is_blocked(player.x + dx, player.y + dy):
                player.move(dx, dy)

        if quit_game:
            return True

        if key.vk == tcod.KEY_ESCAPE:
            return True
def init_log(name):
    log_dir = "/var/log/ati/"
    log_file = log_dir + name + ".log"
    if not os.path.exists(log_dir):
        os.mkdir(log_dir)
    elif not os.path.isdir(log_dir):
        print "critical: unable to initialize log file, exit..."
        return False
    console.init(name, log_file)
    return True
Esempio n. 3
0
def main(stdscr, args):

    top, left = stdscr.getbegyx()  # top left coordinate of the screen
    rows, cols = stdscr.getmaxyx()  # size of screen

    console.init(stdscr)

    from console.logger import logger

    _logger = logger('main')

    try:
        from os import path
        import traceback
        from console.application import Application
        from console.ui.editor import Editor
        from console.ui.window import Window, EditorWindow, PromptWindow
        from console.enums import DEFAULT_WINDOW
        from console.config import PROMPT_HEIGHT
        from console.core.prompt_buffer import PromptBuffer
        #        from binding import load_custom_binding

        _logger.debug('terminal size %dx%d' % (rows, cols))

        #--------------------------------------------------

        book_buffer = ReaderBuffer()
        book_buffer.is_readonly = False

        booklistwindow = EditorWindow(name=BOOKLIST_WINDOW,
                                      top=top,
                                      left=left,
                                      rows=rows - PROMPT_HEIGHT,
                                      columns=cols,
                                      buf=book_buffer,
                                      wrap=True)

        #--------------------------------------------------

        login_buffer = LoginBuffer()
        login_buffer.is_readonly = False

        loginwindow = EditorWindow(name=LOGIN_WINDOW,
                                   top=top,
                                   left=left,
                                   rows=rows - PROMPT_HEIGHT,
                                   columns=cols,
                                   buf=book_buffer,
                                   wrap=True)

        #---------------------------------------------------

        edit_buffer = PromptBuffer()
        edit_buffer.is_readonly = False

        editwindow = EditorWindow(name=DEFAULT_WINDOW,
                                  top=top,
                                  left=left,
                                  rows=rows - PROMPT_HEIGHT,
                                  columns=cols,
                                  buf=edit_buffer,
                                  wrap=False)

        editor = Editor(
            rows - PROMPT_HEIGHT,  # editable area height
            cols,  # editable area width
            rows - PROMPT_HEIGHT,  # prompt row
            PROMPT_HEIGHT,  # height of prompt window(1)
            cols,
            windows=[editwindow, booklistwindow, loginwindow],  #
            initial_focused_window=BOOKLIST_WINDOW)  #BOOKLIST_WINDOW )

        registry = MergedRegistry(
            [console.default_bindings(),
             load_custom_binding()])

        app = Application(editor, registry=registry)
        app.run()

    except:
        _logger.error('application exited with exception: %r' %
                      traceback.format_exc())
        raise
    finally:
        pass
Esempio n. 4
0
File: bridge.py Progetto: ld21/nuage
        if data[0:2] == 'XX':
            for cmd in self.commands:
                if 'reset' in dir(cmd):
                    cmd.reset()

        cmd = self.commands[data[0]]
        return cmd.run(data[1:])


cp = CommandProcessor()

import processes
processes.init(cp)

import console
console.init(cp)

import mailbox
mailbox.init(cp)

import files
files.init(cp)

import sockets
sockets.init(cp)

pr = packet.PacketReader(cp)
start_time = time.time()
with cbreak():
    #while time.time() - start_time < 100:
    while True:
Esempio n. 5
0
 #from layouts import *
 from textwidgets import *
 from shapes import *
 from decorators import *
 from lines import *
 #from controls import *
 from events import *
 #from keyinput import *
 from colour import *
 
 #string = "".join([chr(c) for c in (CHAR_HLINE,CHAR_NE,CHAR_TEEE,CHAR_DVLINE,CHAR_ARROW_N,CHAR_CHECKBOX_SET)])
 string = "a string"
 
 #console.init(200,120,"Root")
 #console.init(80,48,"Root")
 console.init(80,80,"Root")
 #console.set_fullscreen(True)
 root = console.canvas()
 
 #panel = AbsoluteLayout()
 
 label1 = Label("Here is some text") >> Padding(top=5) >> Border(double_line, fg_colour=white) >> Fill(bg_colour=dark_blue)
 label2 = Label("This is a really long string of text.") >> Padding(hpad=3, vpad=2) >> Border(double_line, fg_colour=yellow) >> Fill(bg_colour=dark_red)
 label3 = Label("This text is right-aligned") >> Padding(hpad=8) >> Border(single_line, fg_colour=red) >> Fill(bg_colour=dark_amber)
 label4 = Text('The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested.\n\nSections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.', 30, nbsp='s') >> Padding(hpad=2, vpad=1) >> Border(single_line, fg_colour=red) >> Fill(bg_colour=dark_amber)
 
 #label4 = Label("This is a really long string of text.") >> Padding(hpad=3, vpad=2) >> Border(double_line, fg_colour=yellow) >> Fill(bg_colour=dark_red)
 
 label1.render(root, 30, 9)
 label2.render(root, 40, 15)
 label3.render(root, 30, 4)
Esempio n. 6
0
      
    if data[0:2] == 'XX':
      for cmd in self.commands:
        if 'reset' in dir(cmd):
          cmd.reset()

    cmd = self.commands[data[0]]
    return cmd.run(data[1:])

cp = CommandProcessor()

import processes
processes.init(cp)

import console
console.init(cp)

import mailbox
mailbox.init(cp)

import files
files.init(cp)

import sockets
sockets.init(cp)

import sockets_udp
sockets_udp.init(cp)

pr = packet.PacketReader(cp)
start_time = time.time()
Esempio n. 7
0
            yield line
        
    def width (self):
        return max([line.width() for line in self._lines])
    
    def height (self):
        return len(self._lines)
    
    def render (self,canvas,x,y):
        anchor = Anchor(halign=self.text_align, valign="top", min_width=self.max_width)
        with CanvasState(canvas,x,y):
            self.style.apply(canvas)
            for i, line in enumerate(self._lines):
                (line >> anchor).render(canvas,0,i)
                
                
## Test Code
if __name__ == "__main__":
    import colour
    import console
    from decorators import Border
    from lines import double_line
    
    console.init(30,30,"Text Test")
    
    text = Text('The standard chunk of \n   Lorem_Ipsum_used_since_the_1500s_is_reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also repr\noduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.', 15, bg_colour=colour.darker_red, nbsp='_')
    
    (text >> Border(double_line)).render(console.canvas(), 2, 2)
    console.flush()
    console.wait_for_user()
    
Esempio n. 8
0
import utils
import console

if utils.check_for_ffmpeg() is False:
    print(
        'ffmpeg no se encuentra instalado. Esta librería es necesaria para el correcto funcionamiento.'
    )
    exit()

console.init()
def main():
    args = parse_args()
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    # effects['background'] = fx.BackGround(video_buffer, color='')
    video_buffer.add_effect("fade", fx.FadeBackGround, q=2, enabled=False)
    video_buffer.add_effect("strobe", fx.Strobe, enabled=False)
    video_buffer.add_effect("noise", fx.Noise, enabled=False)
    video_buffer.add_effect("wave", fx.Wave, enabled=True)
    video_buffer.add_effect("midi_note", fx.MidiNote, range=(300, 420), enabled=False)
    # add_effect('pointX'] = fx.PointFx(video_buffer, range=(360,420))
    # add_effect('pointY'] = fx.PointFx(video_buffer)
    # add_effect('pointZ'] = fx.PointFx(video_buffer)
    video_buffer.add_effect("scanner", fx.LarsonScanner, enabled=False, scanners=scanners(10))
    video_buffer.add_effect(
        "peak_meter",
        fx.PeakMeter,
        enabled=True,
        meters=(
            {"n1": 320, "n2": 420, "reverse": True, "color": (1, 0.5, 0)},
            {"n1": 0, "n2": 100, "reverse": False, "color": (0, 0.5, 1)},
        ),
    )
    video_buffer.add_effect("brightness", fx.Brightness, level=0.4, enabled=True)
    video_buffer.add_effect("convolution", fx.Convolution, enabled=False)

    # midi_thread = threading.Thread(target=midi.main,kwargs={'q':midi_queue})
    # midi_thread.daemon = True
    # midi_thread.start()

    loop = asyncio.get_event_loop()

    console.init(loop, video_buffer)
    websocket_server.serve(loop, video_buffer)
    serial_comms.init(loop, video_buffer)

    osc_server = OSCServer(
        loop=loop,
        maps=(
            ("/metronome", video_buffer.effects["scanner"].metronome),
            ("/metronome", video_buffer.effects["strobe"].metronome),
            ("/audio/envelope", video_buffer.effects["peak_meter"].envelope),
            ("/midi/note", video_buffer.effects["midi_note"].set),
            # ('/accxyz', functools.partial(accxyz, axis=0, point=effects['pointX'])),
            # ('/1/fader1', effects['background'].red),
            # ('/1/fader2',  effects['background'].green),
            # ('/1/fader3',  effects['background'].blue),
            ("/*", osc_logger),
        ),
        forward=(websocket_server.osc_recv,),
        server_address=(args.ip, args.port),
    )

    osc_server.serve()

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        logging.info("keyboard int")
    finally:
        loop.close()
Esempio n. 10
0
                    canvas.put_char(x,y,linestyle[cross_char])
                    
            
if __name__ == "__main__":
    
    import console
    """
    linestyle = single_line
    console.init(3,3,"Line Intersections")
    console.canvas().put_char(0,0,linestyle["nw"])
    console.canvas().put_char(1,0,linestyle["tn"])
    console.canvas().put_char(2,0,linestyle["ne"])
    console.canvas().put_char(0,1,linestyle["tw"])
    console.canvas().put_char(1,1,linestyle["x"])
    console.canvas().put_char(2,1,linestyle["te"])
    console.canvas().put_char(0,2,linestyle["sw"])
    console.canvas().put_char(1,2,linestyle["ts"])
    console.canvas().put_char(2,2,linestyle["se"])
    console.flush()
    console.wait_for_user()
    """
    
    lines = LinePainter(single_line)
    lines.add("hline", 3,3,4)
    lines.add("vline", 6,3,4)
    
    console.init(20,20,"LinePainter Test")
    console.canvas().printstr(0,0,"01234567890")
    lines.paint(console.canvas())
    console.flush()
    console.wait_for_user()