Exemplo n.º 1
0
 def __init__(self, impl):
     self.impl = impl
     #
     self.cs_grid_console_splat = Ns()
     self.cs_grid_console_kevent = Ns()
     self.cs_grid_console_mevent = Ns()
     self.cs_grid_console_closed = Ns()
Exemplo n.º 2
0
    def __init__(self):
        self.cs_wire_doc_unpack_head = Ns()
        self.cs_wire_doc_unpack_done = Ns()

        self.b_done = None
        self.buf = []
        self.n = None
Exemplo n.º 3
0
    def __init__(self):
        self.cs_recv_bulk_protocol_head = Ns()
        self.cs_recv_bulk_protocol_data = Ns()
        self.cs_recv_bulk_protocol_done = Ns()

        self.mode = None
        self.doc_len = None
        self.buf = []
        self.got = None
Exemplo n.º 4
0
 def __init__(self, spin_h, engine, cb_windows_event_quit,
              cb_windows_event_kevent, api):
     self.spin_h = spin_h
     self.engine = engine
     self.cb_windows_event_quit = cb_windows_event_quit
     self.cb_windows_event_kevent = cb_windows_event_kevent
     self.api = api
     #
     self.cs_windows_event_quit = Ns()
     self.cs_windows_event_kevent = Ns()
     self.event = c_uint64()
     self.ptr_event = c_uint64_p(self.event)
Exemplo n.º 5
0
 def __init__(self):
     self.form = FormGridConsole(self)
     #
     clib = load_clib(self)
     #
     self.api = Ns()
     self.api.set_cc_log = init_ext_fn(None, clib.set_cc_log, [CC_LOG_T])
     self.api.create_screen = init_ext_fn(None, clib.create_screen,
                                          [c_int, c_int])
     self.api.process_windows_events = init_ext_fn(
         c_int, clib.process_windows_events, [])
     self.api.get_next_event = init_ext_fn(None, clib.get_next_event,
                                           [c_uint64_p])
     self.api.set = init_ext_fn(None, clib.set,
                                [c_int, c_int, c_int, c_int])
     self.api.redraw = init_ext_fn(None, clib.redraw, [])
     self.api.close = init_ext_fn(None, clib.close, [])
Exemplo n.º 6
0
 def __init__(self, spin_h, engine):
     self.spin_h = spin_h
     self.engine = engine
     #
     self.cs_alarm_event = Ns()
     #
     self.pool_alarm_booking = pool_rail_class(RailAlarmBooking)
     self.work = []
     self.buffer = []
Exemplo n.º 7
0
 def __init__(self):
     self.cs_draw_surface_clear = Ns()
     self.cs_draw_surface_write = Ns()
     #
     self.b_started = False
Exemplo n.º 8
0
 def __init__(self):
     self.cs_game_instructs_clear = Ns()
     self.cs_game_instructs_write = Ns()
     #
     self.b_running = False
Exemplo n.º 9
0
class ImplGridConsole:
    def __init__(self):
        self.form = FormGridConsole(self)
        #
        clib = load_clib(self)
        #
        self.api = Ns()
        self.api.set_cc_log = init_ext_fn(None, clib.set_cc_log, [CC_LOG_T])
        self.api.create_screen = init_ext_fn(None, clib.create_screen,
                                             [c_int, c_int])
        self.api.process_windows_events = init_ext_fn(
            c_int, clib.process_windows_events, [])
        self.api.get_next_event = init_ext_fn(None, clib.get_next_event,
                                              [c_uint64_p])
        self.api.set = init_ext_fn(None, clib.set,
                                   [c_int, c_int, c_int, c_int])
        self.api.redraw = init_ext_fn(None, clib.redraw, [])
        self.api.close = init_ext_fn(None, clib.close, [])

    def zero(self, zero_h, cb_grid_console_splat, cb_grid_console_kevent,
             cb_grid_console_mevent, cb_grid_console_closed, engine, width,
             height):
        self.zero_h = zero_h
        self.cb_grid_console_splat = cb_grid_console_splat
        self.cb_grid_console_kevent = cb_grid_console_kevent
        self.cb_grid_console_mevent = cb_grid_console_mevent
        self.cb_grid_console_closed = cb_grid_console_closed
        self.engine = engine
        self.width = width
        self.height = height
        #
        if self.width > 200 or self.height > 100:
            # Note that width and height are by character, not by screen
            # dimension.
            log("Warning. Have seen crashes as screen dimensions become vast.")
            log('width %s %s' % (self.width, type(self.width)))
            log('height %s %s' % (self.height, type(self.height)))
        #
        self.cgrid = Cgrid(width=width, height=height)
        #
        # Emphasis: do not use named parameters for this, or the variable
        # holding the logger will get garbage-collected. You must directly
        # refer to cc_log.
        # xxx rename api to c_api
        self.api.set_cc_log(cc_log)
        #
        log('impl_grid_console w:%s h:%s' % (self.width, self.height))
        self.api.create_screen(self.width, self.height)
        self.api.process_windows_events()
        #
        self.spin_windows_events = self.engine.init_spin(
            construct=SpinWindowsEvents,
            cb_windows_event_quit=self.cb_windows_event_quit,
            cb_windows_event_kevent=self.cb_windows_event_kevent,
            api=self.api)

    def cb_windows_event_quit(self, cs_windows_event_quit):
        zero_h = cs_windows_event_quit.zero_h
        #
        raise SolentQuitException()

    def cb_windows_event_kevent(self, cs_windows_event_kevent):
        zero_h = cs_windows_event_kevent.zero_h
        k = cs_windows_event_kevent.k
        #
        # xxx we will need to do some translation here from windows-style
        # keycodes to solent style. for the moment I am just passing back the
        # raw values.
        keycode = k
        self.form.call_grid_console_kevent(zero_h=self.zero_h, keycode=keycode)

    #
    def send(self, cgrid):
        cur_dim = (self.cgrid.width, self.cgrid.height)
        new_dim = (cgrid.width, cgrid.height)
        if cur_dim != new_dim:
            self.cgrid.set_dimensions(width=cgrid.width, height=cgrid.height)
        updates = []
        o_spots = self.cgrid.spots
        n_spots = cgrid.spots
        for cgrid_idx, (o_spot, n_spot) in enumerate(zip(o_spots, n_spots)):
            if not o_spot.compare(n_spot):
                updates.append(cgrid_idx)
                o_spot.mimic(n_spot)
        log('send')
        for cgrid_idx in updates:
            spot = self.cgrid.spots[cgrid_idx]
            #
            drop = int(cgrid_idx / self.cgrid.width)
            rest = int(cgrid_idx % self.cgrid.width)
            c = ord(spot.c)
            o = 0  # xxx
            log('update %s %s %s %s' % (drop, rest, c, o))
            self.api.set(drop, rest, c, o)
        self.api.redraw()

    def close(self):
        log('close')
        return self.api.close()
Exemplo n.º 10
0
 def __init__(self):
     self.cs_line_console_connect = Ns()
     self.cs_line_console_condrop = Ns()
     self.cs_line_console_command = Ns()
Exemplo n.º 11
0
 def __init__(self):
     self.cs_menu_asks_display_to_clear = Ns()
     self.cs_menu_asks_display_to_write = Ns()
     self.cs_menu_selection = Ns()
Exemplo n.º 12
0
 def __init__(self):
     self.blst = deque()
     self.cs_bytesetter_pack = Ns()
     self.cs_bytesetter_fini = Ns()
Exemplo n.º 13
0
 def __init__(self):
     self.cs_linetalk_connect = Ns()
     self.cs_linetalk_conauth = Ns()
     self.cs_linetalk_condrop = Ns()
     self.cs_linetalk_command = Ns()